artemp/tickets2issues — Issue #467: Add Filter extension to WMS server
Author: artemp
Created: 2011-10-11 15:19:34+00:00
State: open
Labels: Core_Library

Proposal is to add a `CQL_FILTER` parameter to the WMS server, using the same syntax as the [http://geoserver.org/display/GEOSDOC/WMS+vendor+parameters#WMSvendorparameters-CQLFILTER GeoServer extension].

When the CQL_FILTER parameter is used, either a single filter is provided (that will be applied to all layers) or a list or filters, with the same number of filters as the layers in the WMS request.

Basically, write a parser for the [http://udig.refractions.net/confluence/display/EN/Common+Query+Language filter syntax] (as much as is supported by Mapnik's filters anyway), then when `CQL_FILTER=` is specified in a request:
* iterate through the styles & rules for each layer
* parse the cql-filter
* `AND` it with any existing filter
* draw the map as normal.

Problems:
* there's no existing way to add filters together, but the parser does it so it can't be that hard :)
* how do we handle the else-filter? Since if i specify (encoded)
{{{
CQL_FILTER=LANAME="East River"
}}}
the the else clause will match everything that's NOT in the filter, which is not the desired behaviour.
* matching the CQL syntax to Mapnik's filter behaviour

Another option would be to allow filtering at a Layer level as well as the Rule level. In that case all WMS filters would be applied to layers, which would have precedence over Rule filters. The syntax would be the same (`layer.filter=Filter(...)`, and `......`). Presumably we'd have to `AND` any WMS filters with existing layer filters as above.

Official CQL spec is part of the OGC [http://www.opengeospatial.org/standards/cat OpenGIS Catalogue Service Implementation Specification] (Section 6.2, pg 27).