Pages

Wednesday 17 July 2013

Counting Features

Had a bit of fun explaining FeatureSource.getCount( Query ) on IRC.

Here is the code example:
    Query query = new Query("countries", CQL.toFilter("REGION = 3") );
    int count = featureSource.getCount( query );
    if( count == -1 ){
        count = featureSource.getFeatures( query ).size();
    }

Why the difference? The first one checks the header (or index) if such a thing exists. The second one checks the content.

Docs harmed in the making of this post:

No comments: