Hexagon Geospatial
MENU

Developers Knowledge Base

WebGIS enables powerful geospatial web applications and services that securely share your organization’s rich geospatial data, and provides tools to deeply examine spatial data and create value added products, on demand.
Showing results for 
Search instead for 
Do you mean 

Extensions: Charts using WFS Queries

by Technical Evangelist on ‎09-09-2015 06:39 AM - edited on ‎04-11-2017 03:44 AM by Technical Evangelist (1,153 Views)

Overview

Geospatial Portal SDK provides the facility to define and run WFS Queries. Using these WFS Queries result we can further do analysis like creating Charts which are dynamic and provide a graphical and logical presentation to the WFS Query.
The code snippet in this article uses Ext4 JS 4.1 library to draw the charts. A wide variety of HTML5 and JavaScript chart libraries are available online, and they can also be used in a similar way.

Using Ext4 JS 4.1 with GP SDK 2015

Version 2.2.1 of Ext JS is provided with Geospatial Portal SDK 2015. In order to be able to use the Ext4 JS 4.1 with the SDK, the ext-all.js JavaScript file is modified by replacing all instances of 'Ext.' to 'Ext4.'. This is done to prevent the version clash between the two versions of Ext JS libraries. The zip File:Extjs.zip (below in attachements) contains the modified library and other resources. Extract the zip to the SDK and reference the ext-all.js in the aspx page as below:

 

<script type="text/javascript" src="extjs/ext-all.js"></script>

Source Code

In the aspx page add the following div element on which the chart is rendered.

<div id="wfsCharts">
</div>

 

Also add the following style tag in the aspx page.

<style type="text/css">
     .white .x-window-body {
          background-color: white !important;
     }
</style>

 

Place the following code snippet inside a js file and reference it in the aspx page. The code snippet is written to work on the US Sample Data WFS (http://demo.hexagongeospatial.com/GWM_WFS_NonTransactional/service.svc/get). To use any other WFS sources change the code accordingly (change URL, feature name, attribute names).

Source Code

 

Note: Processing of WFS Query result takes time depending on network speed, latency and data size. For this prototype a message 'WFS Query data fetched successfully.' appears which means WFS query result has been processed and only NOW can the chart be created.

 

Snapshot

 

 

 

 

 

 

 

 

 

 

 

 

Future Scope

The above prototype is a simple example on how we can extend WFS query analysis into further analysis. A more generic and complete solution can be developed by taking care of the following points:

  • GUI to improve user experience, where the user has the option to select different WFS services registered.
  • For each WFS service selected, user can further select the Feature Class for which the analysis has to be done.
  • For the selected Feature Class, user can select the category (x) and value (y) attributes to be used for chart creation.
  • Validations can be applied. Eg: List the attributes as Category attribute (X-axis attribute) or Value attribute (Y-axis attribute).
  • Wide variety of charts (BarChart, PieChart, LineChart etc.) can be created, from the supported types in the chart library.
  • Options to print and export the charts to different formats (PDF, PNG, DOC etc..)

... and so on.

Information that could be useful for the above implementation:

  • Fetch list of feature class published in a WFS service: refer to the PortalSDK 2015 api $GP.edit.getFeatureClassIds
  • Fetch list of attributes for a WFS service feature class: refer to the PortalSDK 2015 api $GP.edit.getAttributeList
  • Fetch attribute values for a particular attribute in a WFS service feature class : refer to the PortalSDK 2015 api $GP.edit.getAttributeValues (This enhancement may also be used to get attribute values instead of running a WFS query)


Refer to Portal SDK 2015 documentation and run through the examples provided for these API's to understand how they work.

Comments
by
on ‎07-19-2018 05:12 AM

IS there any implementation yet as far as the Future Scope is concerned?

Overview