How to filter big datasets in Geoserver WMS?

by underdark   Last Updated January 14, 2018 00:22 AM

Is there a good way to filter datasets with approx 50,000 features in Geoserver? I'd have to select between 100 and 200 features based on ids. These ids are different from the FeatureIds. Couldn't find an "IN" operator similar to SQL in OGC Filter Encoding Standard. Combining multiple PropertyIsEqualTo operators performs really poorly.



Answers 2


You could pass a list of feature id's in the following manner:

GET:

http://<hostname>/wfs?service=WFS&version=1.1.0&request=GetFeature&typename=foo&featureid=id_1,id_2,id_3

POST:

<?xml version="1.0" encoding="UTF-8"?>
<wfs:GetFeature version="1.1.0" outputFormat="text/xml; subtype=gml/3.1.1" service="WFS" resultType="results" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <wfs:Query typeName="foo">
        <wfs:PropertyName>String</wfs:PropertyName>
        <ogc:Filter>
            <ogc:FeatureId fid="id_1"/>
            <ogc:FeatureId fid="id_2"/>
            <ogc:FeatureId fid="id_3"/>
        </ogc:Filter>
    </wfs:Query>
</wfs:GetFeature>

The POST option is obviously more verbose, but less than looping PropertyIsEqualTo constructs.

tomkralidis
tomkralidis
September 02, 2010 13:27 PM

Ah. In that case, you could use GeoServer's WMS CQL filter support, i.e.:

http://<hostname>/wms?service=WMS&version=1.1.1&request=GetMap&....&cql_filter=IN ('id_1','id_2','id_3')

More information is available at http://geoserver.org/display/GEOSDOC/WMS+vendor+parameters

tomkralidis
tomkralidis
September 02, 2010 17:47 PM

Related Questions



Filter function based on attribute. Leaflet

Updated July 01, 2018 14:22 PM