Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

SpatialSelectorQueryForm Plugin

Lorenzo Pini edited this page Oct 9, 2015 · 9 revisions

Needed Files

In order to use the SpatialSelectorQueryForm plugin in MapStore you need to be sure that the files below are included in the buildjs.cfg file:

  • openlayers-ext/lib/OpenLayers/Control/SetBox.js
  • openlayers/lib/OpenLayers/Handler/RegularPolygon.js
  • gxp/src/script/widgets/form/BBOXFieldset.js
  • gxp/src/script/widgets/FilterBuilder.js
  • gxp/src/script/plugins/QueryForm.js
  • gxp/src/script/plugins/spatialselector/SpatialSelectorMethod.js
  • gxp/src/script/plugins/spatialselector/BBOXSpatialSelectorMethod.js
  • gxp/src/script/plugins/spatialselector/BufferSpatialSelectorMethod.js
  • gxp/src/script/plugins/spatialselector/PolygonSpatialSelectorMethod.js
  • gxp/src/script/plugins/spatialselector/CircleSpatialSelectorMethod.js
  • gxp/src/script/plugins/spatialselector/GeocoderSpatialSelectorMethod.js
  • gxp/src/script/plugins/spatialselector/SpatialSelector.js
  • gxp/src/script/plugins/SpatialSelectorQueryForm.js

NOTE: In the default configuration this is already done.

IMPORTANT!!! The plugin requires the use of WMS version 1.1.1.

##Plugin Description

The Spatial Selector Query Form plugin allows performing queries on feature layers. Using this plugin you can create alphanumeric queries on feature attributes and/or spatial query on a specific region of ​​interest.

You can also perform spatial queries by the available selector methods:

  • BBOXSpatialSelectorMethod: gxp_spatial_bbox_selector
  • BufferSpatialSelectorMethod: gxp_spatial_buffer_selector
  • CircleSpatialSelectorMethod: gxp_spatial_circle_selector
  • GeocoderSpatialSelectorMethod: gxp_spatial_geocoding_selector
  • PolygonSpatialSelectorMethod: gxp_spatial_polygon_selector

NOTE: If you haven't any ROI selected, the query will use the current extension of the map.

##Configuration Example

Besides the plugin configuration, the following script import must be uncommented in the composer.html file:

<!-- Externals OpenLayers libraries --> 
<script type="text/javascript" src="script/OpenLayersExt.js"></script>

Then you have to specify a valid plugin configuration, such as:

        ...
	"customPanels":[
        ...
        {
            "xtype": "panel",
            "title": "FeatureGrid",      
            "border": false,
            "id": "south",
            "region": "south",
            "layout": "fit",
            "height": 330,
            "collapsed": false,
            "collapsible": true,
            "header": true
        },
		{
            "xtype": "panel",
            "title": "Query Panel",         
            "border": false,
            "id": "east",
            "width": 400,
            "height": 500,
            "region": "east",
            "layout": "fit",
            "collapsed": false,
            "collapsible": true,
            "header": true
        }
        ...
    ],	
    ...
	"customTools":[
               ...
               {
                    "ptype": "gxp_featuremanager",
                    "id": "featuremanager"
		}, {
                    "ptype": "gxp_featuregrid",
                    "featureManager": "featuremanager",
                    "outputConfig": {
                        "id": "featuregrid",
                        "title": "Features"
                    },
                    "outputTarget": "south",
                    "showExportCSV": true
		}, {
		  "ptype": "gxp_spatialqueryform",
		  "featureManager": "featuremanager",
		  "featureGridContainer": "south",
		  "outputTarget": "east",
		  "showSelectionSummary": true,
		  "actions": null,
		  "id": "bboxquery",
                  "filterLayer": true,
		  "outputConfig":{
			  "outputSRS": "EPSG:900913"
		  },
		  "spatialSelectorsConfig":{
		        "bbox":{
		            "xtype": "gxp_spatial_bbox_selector"
		        },
		        "buffer":{
		            "xtype": "gxp_spatial_buffer_selector"
		        },
		        "circle":{
		            "xtype": "gxp_spatial_circle_selector",
		            "zoomToCurrentExtent": true
		        },
		        "polygon":{
		            "xtype": "gxp_spatial_polygon_selector"
		        }
		  },
                  "validators": {
                     ...
                  }
	    }
            ...
	]
        ...
  • ptype: ptype of the plugin
  • featureManager: The id of the :class:gxp.plugins.FeatureManager to use with this tool
  • outputTarget: plugin identifier
  • actions: By default, this tool creates a "Query" action to trigger the output of this tool's form. Set to null if you want to include the form permanently in your layout.
  • id: plugin identifier
  • filterLayer: boolean, show the "Filter Map" button to filter the selected layer on the map

You can see complete configuration examples:

Selection methods

You can add different selection methods to perform the queries. The configuration of this methods have common and specific parameters.

Common (SpatialSelectorMethod)

This options are available for all selection methods:

  • name: Name to show on the combo box of the spatial selected.
  • label:Label to show on the combo box of the spatial selected.
  • zoomToCurrentExtent: Flag to zoom the current map to the selected geometry when you select one. Default is false.
  • defaultStyle: Style for features drawn
  • selectStyle: Style for selected features drawn
  • temporaryStyle: Style for features drawn in this state
  • showSelectionSummary: Whether we want to show or not the selection summary as a pop-up on the map. Default it's true

BBOXSpatialSelectorMethod

  • ptype: gxp_spatial_bbox_selector

This selector draws a rectangle and use it as bounding box for the query.

  • ptype: gxp_spatial_buffer_selector

Configuration

  • spatialFilterOptions: Default CRS limits if not selection has been made. Must be compliant with the map CRS.

BufferSpatialSelectorMethod

  • ptype: gxp_spatial_buffer_selector

With this selector you can select a location in the map (clicking on it or by coordinates) and a radious to perform the query in the buffer generated.

Configuration

  • bufferOptions: Map with Buffer spatial selector options: minValue, maxValue, decimalPrecision, distanceUnits`.
  • geodesic: Use geodesic on the buffer fieldset

CircleSpatialSelectorMethod

  • ptype: gxp_spatial_circle_selector

You can draw a circle for the spatial selection.

Configuration

No specific configuration.

PolygonSpatialSelectorMethod

  • ptype: gxp_spatial_polygon_selector

You can draw a polygon for the spatial selection.

Configuration

No specific configuration.

GeocoderSpatialSelectorMethod

This selector show a WFS combobox to search features in the configured layer. If you want to select more than one record, you must add a WPS manager (see example with WPS)

  • ptype: gxp_spatial_geocoding_selector

Configuration

  • labelStyle: Style for the label on selected features
  • wfsBaseURL: WFS Base URL
  • geocoderTypeName: Type name to perform the query
  • geocoderTypeTpl: Tpl for the Geocoder combo items
  • geocoderTypeRecordModel: Record model for the geocoder combo
  • geocoderTypeSortBy: If you want to order the WFS query, put here the order. If you won't, put a null inside
  • geocoderTypeQueriableAttributes: Fetaure properties array to perform the query
  • geocoderTypeDisplayField: Feature type property to select as name on the grid.
  • geocoderTypePageSize: Page size for the WFS search combo
  • wpsUnionProcessID: ID of the WPS Union Process. Default is JTS:union
  • wpsManagerID: Id of the WPS Manager to be used for the union. If it's null, or the tool is not found, it will disable the multiple selection
  • multipleSelection: Append a grid and allow multiple WFS record selections. It needs a WPS manager configured.

Interaction with FeatureManager

For an optimal usage of the plugin together with the FeatureManager (gxp_featuremanager) we suggest to configure paging type to WFS for this one, using the configuration option "pagingType" : 1.

Widgets by field type

From 1.6 release, the widgets used to enter values in the Query by attributes section, are specific for the field data type. For example, numeric fields only allow entering a number, while date fields allows using a calendar to choose a date. This new behaviour is automatic, and no configuration is needed to enable it.

Validation

From 1.6 release, optional validation can be configured for fields specific features and fields. Currently only regular expression based validators are supported for text fields. To configure them, use the validators section, like in the following example:

        ...
	       {
		  "ptype": "gxp_spatialqueryform",
		  ...
                  "validators": {
                        "myfeature": {
                           "email": {
                              "type": "regex",
                              "value": "^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+$",
                              "invalidText": "Insert a correct email in the format [email protected]"
                           }                
                        }
                  }
	       }
            

Autocomplete for filter values

From 1.7 release, optional autocomplete functionality has been added for string fields of features served by a Geoserver instance with the gs:PagedUnique WPS process installed (currently only available on master nightly builds).

To configure autocomplete, use the autoComplete section, like in the following example:

        ...
	       {
		  "ptype": "gxp_spatialqueryform",
		  ...
                  "autoComplete": {
                        "sources": ["default"],
                        "url": "http://localhost:8080/geoserver/wps",
                        "pageSize": 10
                   },
	       }
            
  • sources: array of sources backed by a Geoserver with the gs:PagedUnique WPS process
  • url: WPS Base URL
  • pageSize: pageSize for the autocomplete combo
Clone this wiki locally