Although the OGC WMS standards don’t support specifying a filter in requests, the LuciadFusion WMS service does support it by means of a custom filter parameter. Using this parameter, WMS clients can include an OGC filter in GetMap and GetFeatureInfo requests to apply to the vector data used in the requested WMS layer. The supported OGC filter versions are 1.1.0 and 2.0.

If you define a filter parameter, you must specify a value for each requested layer using the following encoding:

filter=(FilterForLayer1)(FilterForLayer2)…​

Add each filter between parentheses. If you don’t want to specify a filter for one of the layers, you can use an empty () value.

This image shows the result of a GetMap request for a global imagery and US cities vector layer without filtering:

WMSNoFilter
Figure 1. Result of a GetMap request for a global imagery and US cities vector layer without filtering.

By relying on the filter parameter, you can filter the US cities data and decide what cities you see in the resulting map. Such a filter can include conditions for spatial, temporal, and regular properties. For more information about OGC filter support in LuciadFusion, see The OGC filter model.

For example, if you want to include cities with a population larger than 2.000.000 only, you must define an OGC filter that expresses this condition using a property in the data. Through a GetFeatureInfo request, you know that the US cities data includes the total number of people living in a city in the TOT_POP attribute:

Program: Result of a GetFeatureInfo request on a US city.
{
  "type": "FeatureCollection",
  "crs": {
    "type": "name",
    "properties": {
      "name": "urn:ogc:def:crs:EPSG::4326"
    }
  },
  "features": [
    {
      "type": "Feature",
      "id": "cities.SHP_11",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -76.610616,
          39.3008
        ]
      },
      "layerName": "cities",
      "properties": {
        "CITY": "Baltimore",
        "STATE": "MD",
        "TOT_HU": 303706,
        "TOT_POP": 736014
      }
    }
  ]
}

The resulting filter looks like this:

Program: OGC filter for the US cities
<fes:Filter xmlns:fes="http://www.opengis.net/fes/2.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.opengis.net/fes/2.0 http://schemas.opengis.net/filter/2.0/filter.xsd">
  <fes:PropertyIsGreaterThanOrEqualTo>
    <fes:ValueReference>TOT_POP</fes:ValueReference>
    <fes:Literal>2000000</fes:Literal>
  </fes:PropertyIsGreaterThanOrEqualTo>
</fes:Filter>

Next, you use this filter in the filter parameter of the GetMap request. Because there are two layers in the request, you must specify two filter values: an empty value, indicating that there is no filter for the imagery layer, and the defined OGC filter for the US cities layer.

The resulting GetMap request shows this result:

WMSWithFilter
Figure 2. Result of a GetMap request for a global imagery and US cities vector layer with filtering.