CQL for WMSserver

Developer
Jan 17, 2012 at 3:59 PM
Edited Jan 17, 2012 at 4:01 PM

Today, I implemented a first version of CQL for the WMSserver. CQL is a filtering method which makes it possible to render only the features which pass the filter. You can filter on all the attribute information in a Shapefile. For more information on CQL, see this webpage of Geoserver, which has the same: http://docs.geoserver.org/stable/en/user/tutorials/cql/cql_tutorial.html and http://docs.geoserver.org/latest/en/user/googleearth/features/filters.html

It's a first version and it's therefore limited to:

-Shapefiles which are drawn via a FeatureDataTable, because the Shapefile already had a filtering method included. Filtering methods in other data providers will have to be created if you want to use the CQL filter on data coming from other sources.

-A real CQL filter. The featureid=<feature> is not implemented, if you want to select on an ID being not FID, then you can use IN

-Simple filters and no mathematical operations.

The AND, OR and NOT do work, so you can filter on multiple columns/attributes in the shapefile. Please separate evertything well by a (encoded) space, because the filter will be split on spaces.

Examples:

&CQL_FILTER=site_id%20BETWEEN%2037165%20AND%2037169
Selects all features with a site_id between 37165 and 37169 (37166,37167,37168)

&CQL_FILTER=site_id%20BETWEEN%2037165%20AND%2037169%20OR%20site_name%20==%20Lochem 
Selects all features with a site_id between 37165 and 37169 (37166,37167,37168) or where the site_name equals Lochem

&CQL_FILTER=site_id%20BETWEEN%2037165%20AND%2037169%20NOT%20site_name%20==%20Aalten
 Selects all features with a site_id between 37165 and 37169 (37166,37167,37168), but removes the features with site_name  equals Aalten

 

Developer
Jan 17, 2012 at 8:42 PM

Nice addition :)

>Filtering methods in other data providers will have to be created

> if you want to use the CQL filter on data coming from other sources.

I think that can be cool to have a "CQL2SQL" translator, in order to apply generated SQL to "DefinitionQuery" (if I remember well) property in database providers

Developer
Jan 18, 2012 at 3:50 PM

A new update!

I made a new abstract class for all providers which support filtering based on a FeatureDataRow. I moved the FilterDelegate from ShapeFile to the new abstract class and ShapeFile now implements this new abstract class, so nothing changed to the ShapeFile object. The GeometryFeatureProvider implements this abstract class as well and therefore also supports the CQL filter.

The WMSServer now filters on the response on GetFeatureInfo as well. This works on the result from the ExecuteIntersectionQuery, so it does work on layers which implement the ICanQueryLayer.