We received lots or requests regarding the possibility to build queries on geospatial data. This means on the one hand a way to do potentially complex queries for nodes based on any combination of the fields in a content type. The available fields should of course include geometry fields allowing for spatial operations like intersects or contains. The result set of the query should be displayed either as some kind of list or directly on a map. On the other hand spatial querying should be possible against WMS and WFS geo web services that might be included in a map within Drupal. For this an easy way to transform user input into the standardized query language CQL would be needed. The queried WMS or WFS would be reflected in the map showing only the filtered results.
The first option of complex querying on the level of nodes would be possible by integrating the PostGIS module with Views. The second option of querying WMS and WFS would be implemented by a new OpenLayers behavior. Below we'll outline a roadmap how both features should be implemented.
Add Views support to PostGIS module
The plugin system of the Views module makes it possible to add Views integration to other modules. The PostGIS module therefore should implement a Relationship plugin and a Filter plugin. The Filter plugin would make spatial filters available that can optionally be exposed to visitors. The Relationship plugin would provide the ability to build spatial relationships between entities. This would allow to do queries like “show me all features within a certain region” or “show only features within a specified distance of feature X”.
The mockup below illustrates how the configuration interface for geometry fields could look like.
The integration of PostGIS and Views is just a roadmap, the functionality is not yet available.
Filter OpenLayers WMS and WFS layer
Filtering of WMS and WFS should be enabled by implementing a new OpenLayers map behavior. The administrator should be able to activate the behavior separately for every map within the site. In the administration interface of this behavior it would be possible to define the filter criteria for every WFS or WMS layer that has been loaded in the corresponding map. The filter criteria would consist of a part according to the CQL specification and another part with a placeholder that is meant to be replaced by the user input later. The placeholder would reference the ID of a form field that has to be placed next to the map. It would be the responsibility of the developer to define the form inside a theme or as a block. This way Cartaro would include a flexible and simple solution for dynamic map WMS and WFS queries.
The first screenshot shows the planned configuration interface for the new OpenLayers map behavior that allows to define the querying options available to the user. The second screenshot shows how the same configuration would allow to query the WFS named "capitals_wfs" by the name of the capital.
We started to implement this feature for WFS already. However there is still work to be done to make it work more generally and to use it not only for WFS but also WMS.
Related Drupal.org issues:
- #1563652: Spatial Filters - geospacial queries/filters
- #1866328: Displaying geoserver filtered polygons on a WMS layer. - Displaying geoserver filtered polygons on a WMS layer
Comment | File | Size | Author |
---|---|---|---|
cartaro-views-postgis.png | 28.17 KB | friedjoff | |
cartaro-cql-filter.png | 13.39 KB | friedjoff | |
cartaro-cql-example.png | 279.67 KB | friedjoff |
Comments
Comment #1
friedjoff CreditAttribution: friedjoff commentedSee also #1942260: Spatial Aggregates in Views.
Comment #2
pinkonomy CreditAttribution: pinkonomy commentedHi,
I am also interested in this.For example,show me all nodes inside an area.
Is there a roadmap for this?Or is this already done on beta-5?
thanks!
Comment #3
ulim CreditAttribution: ulim commentedSo far we have not scheduled this feature. If you need it soon you may want to sponsor the development. In this case please contact us by e-mail.
Cheers
Uli
Comment #4
pinkonomy CreditAttribution: pinkonomy commentedOne question:How Cartaro will do the search?With the help of some reverse geocoding?Or with another way?In this case,will be quick enough for a lot of nodes?
Comment #5
augustus.kling CreditAttribution: augustus.kling commentedCartaro stores all its data in a PostgreSQL+PostGIS database. It does have a concept of geometries and optimizes the queries on the database level – so PostGIS makes the queries really quick.
Comment #6
pinkonomy CreditAttribution: pinkonomy commentedOne more question:If we want to make a query with views regarding the topic of this issue, e.g. "return me all nodes inside London area" ,I think we need the polygon data,isn't it true?Where can we find these data?
Or Cartaro uses another way to make such queries,without needing to have such polygon/data e.g. with Geocoding etc?
thanks
Comment #6.0
pinkonomy CreditAttribution: pinkonomy commentedclarified that all is just a roadmap at the moment
some formatting and re-structuring
Comment #7
robertwb CreditAttribution: robertwb commentedI have made strides in figuring out the coding hooks in Views and the setup of relationships in a table definition to allow automatic addition of spatial WHERE and JOIN conditions. The first link below shows how to accomplish it by writing a small custom module that adds spatial conditions to a specific named view:
Comment #8
mtoscano CreditAttribution: mtoscano commentedCQL filters have been added since beta5 but I can't find proper documentation on how to use them. Instruction above are more for developers that for site builders.
Any help in how to place the form field next to the map?
Thanks
Comment #9
Yo Gis CreditAttribution: Yo Gis commentedwhen I try to make filter with the CQL filter in OpenLayer Map structure interface, the WFS url don't contain CQL filter parameter...
It's a WFS layer
GeoServer CQL Filter is check
I save the map params.
What I am doing wrong ?
Best,