filter on attributes - GeoSmartCity-CIP/gsc-client GitHub Wiki

Filter on Attributes

Usually various objects are displayed on top of a map, for example, buildings, infrastructure lines, parking sites, traffic jams, etc. These objects are retrieved from a service, typically WFS, containing huge quantum of the objects. To ensure that final map is readable, only selected objects should be displayed.

The module implements functionality enabling filtering of retrieved objects not only on object type, but also on attributes specific to the object type. For instance, the following criteria may be specified: sewage pipes of specific diameter, buildings older than a specified age, etc. Three types of criteria are supported:

  • Common Query Language (CQL), is written using text-based syntax and enables creation of simple conditions. For example
    ID = 400

  • OGC Filter Encoding, is XML-based query language, more powerful than CQL, but more difficult to read by human. Filter Encoding is standardized by OGC. An example of simple query follows
    <PropertyIsEqualTo><PropertyName>ID</PropertyName><Literal>400</Literal></PropertyIsEqualTo>

  • Feature ID (FID), is the simplest available query. It just compares given value with gml:id attribute of a feature. For example
    Building.456

Dependencies

The module depends on OpenLayers 3 library.

Example

The following example extends View/Brows Map example by CQL condition limiting displayed objects to those of ID with value equal to 400.

// Display only elements with id = 400
gscMap.filterOnAttributes('cql', 'ID = 400');

GSC client example code.

⚠️ **GitHub.com Fallback** ⚠️