Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 a "IN" operator similar to SQL in OGC Filter Encoding Standard. Combining multiple PropertyIsEqualTo operators performs really poorly.

share|improve this question

2 Answers 2

up vote 7 down vote accepted

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

share|improve this answer
    
Great! Didn't know that there is an IN operator in CQL. While trying this with "=" operator, Apache ran into "414 Request-URI Too Long". Maybe the characters saved this way make a difference. –  underdark Sep 2 '10 at 18:24
2  
switch to post instead of get. –  iant Sep 4 '10 at 14:55
    
@iant: You're right, POST instead of GET works. The performance remains poor though. –  underdark Sep 7 '10 at 16:27
    
do you have an index on the FIDs column? –  iant Sep 7 '10 at 17:11
    
@iant: I have an index on the id I'm filtering for, but not on the FIDs. –  underdark Sep 9 '10 at 21:27

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.

share|improve this answer
    
That looks like a good solution for filtering FeatureIds. Unfortunately, the ids I have to filter (results of a different party's algorithm) are not same as the FeatureIds. I updated the question. –  underdark Sep 2 '10 at 15:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.