06-Other Filters

This documentation is no longer maintained. Please see the new GeoServer documentation at http://docs.geoserver.org

Overview

Though not a specific Google Earth feature, GeoServer has a powerful capability to limit the data returned based on a query passed in by the user. The KML Reflector will pass through any 'FILTER' or 'CQL_FILTER" parameter to GeoServer to constrain the response. Filters are basically a translation of a SQL 'WHERE' statement in to web form, and allow the full power of SQL, though limited to a single table. This allows users to do logical filters, like AND and OR, to make very complex queries, leveraging numerical and string comparisons, geometric operations (bbox, touches, intersects, disjoint), LIKE statements, nulls, and more.

OGC Filters

There is an open standard put out by the Open Geospatial Consortium called 'Filter Encoding' GeoServer implements the full spec, so read it for the full language with examples.

There simplest filter is very easy to include. It is called the 'featureid' filter, and it lets you grab a single feature by saying its ID:

[http://localhost:8080/geoserver/wms/kml_reflect?layers=topp:states&featureid=states.5]

This request will take you to the state of Maryland. The featureIDs of your data are most easily found by doing WFS requests and examining the resulting GML. KML output will also include the featureIDs if there is not a template that overrides it.

Using filters in a URL can be very unwieldy, as one needs to include full XML inside the URL:

http:/localhost:8080/geoserver/wms/kml_reflect?layers=topp:states&FILTER=%3CFilter%3E%3CPropertyIsBetween%3E%3C
PropertyName%3Etopp:LAND_KM%3C/PropertyName%3E%3CLowerBoundary%3E%3CLiteral%3E100000%3C/Literal%3E%3C/LowerBoundary
%3E%3CUpperBoundary%3E%3CLiteral%3E150000%3C/Literal%3E%3C/UpperBoundary%3E%3C/PropertyIsBetween%3E%3C/Filter%3E

This is ugly. Instead there is Common Query Language (CQL), which allows one to specify the same long statement more succinctly.

[http://localhost:8080/geoserver/wms/kml?layers=topp:states&CQL_FILTER=LAND_KM+BETWEEN+100000+AND+150000]

This query will return all the states in the US with areas between 100,000 and 150,000 sq. km.

See the CQL tutorial for an introduction to CQL queries.

Added by Chris Holmes, last edited by Mike Pumphrey on Dec 05, 2008  (view change)
View Attachments (1) Info