Added by jgarnett, last edited by jgarnett on May 13, 2008  (view change)

Labels

 
(None)

The following are examples of use for the CQL to Filter parser. For a full understanding of the predicate language, refer to the BNF

Related:

Filter

Filter by Comparing Values

Filter result = CQL.toFilter("ATTR1 < (1 + ((2 / 3) * 4))" );
Filter result = CQL.toFilter("ATTR1 < abs(ATTR2)" );
Filter result = CQL.toFilter("ATTR1 < 10 AND ATTR2 < 2 OR ATTR3 > 10" );

Filter using Text

Filter result = CQL.toFilter( "ATTR1 LIKE 'abc%'" );
Filter result = CQL.toFilter( "ATTR1 NOT LIKE 'abc%'" );

Filter Nulls

Filter result = CQL.toFilter( "ATTR1 IS NULL" );
Filter result = CQL.toFilter( "ATTR1 IS NOT NULL" );

Filter by Comparing Time values

Before a date.

Filter result = CQL.toFilter( "ATTR1 BEFORE 2006-11-30T01:30:00Z" );

Before a period

Filter result = CQL.toFilter( "ATTR1 BEFORE 2006-11-30T01:30:00Z/2006-12-31T01:30:00Z" );

After a date.

Filter result = CQL.toFilter( "ATTR1 AFTER 2006-11-30T01:30:00Z" );

After a period

Filter result = CQL.toFilter( "ATTR1 AFTER 2006-11-30T01:30:00Z/2006-12-31T01:30:00Z" );

Temporal predicate with dutation (ten day after 2006-11-30T01:30:00Z )

Filter result = CQL.toFilter( "ATTR1 AFTER 2006-11-30T01:30:00Z/P10D" );
Filter result = CQL.toFilter( "ATTR1 AFTER 2006-11-30T01:30:00Z/T10H" );

During predicate

Filter result = CQL.toFilter( "ATTR1 DURING 2006-11-30T01:30:00Z/2006-12-31T01:30:00Z" );

Filter based on Existence

Filter result = CQL.toFilter( "ATTR1 EXISTS" );
Filter result = CQL.toFilter( "ATTR1 DOES-NOT-EXIST" );

Filter by checking if a Value is Between

Filter result = CQL.toFilter( "ATTR1 BETWEEN 10 AND 20" );

Using Compound Attributes

Filter result = CQL.toFilter( "gmd:MD_Metadata.gmd:identificationInfo.gmd:MD_DataIdentification.gmd:abstract LIKE  'abc%'" );

Filter using Geometry Relationship

Filter result = CQL.toFilter( "CONTAINS(ATTR1, POINT(1 2))" );
Filter result = CQL.toFilter( "CROSS(ATTR1, LINESTRING(1 2, 10 15))" );
Filter result = CQL.toFilter( "INTERSECT(ATTR1, GEOMETRYCOLLECTION (POINT (10 10),POINT (30 30),LINESTRING (15 15, 20 20)) )" );
Filter result = CQL.toFilter( "BBOX(ATTR1, 10,20,30,40)" );
Filter result = CQL.toFilter( "DWITHIN(ATTR1, POINT(1 2), 10, kilometers)" );

Filter List

List filters = CQL.toFilterList("att1 > 5;INCLUDE;ogc:name = 'river'");