The filter module provides utilities for parsing and encoding filters.
- class geoscript.filter.Filter(obj)¶
A predicate or constraint used to match or filter Feature objects.
obj is the CQL str representation of the filter.
>>> f = Filter("name = 'foobar'") >>> f [ name = foobar ]obj may also be specified as XML.
>>> f = Filter('<Filter><PropertyIsEqualTo><PropertyName>name</PropertyName><Literal>foobar</Literal></PropertyIsEqualTo></Filter>') >>> f [ name = foobar ]
- evaluate(f)¶
Evaluates the filter against a Feature.
f is the geoscript.feature.Feature to evaluate against.
>>> from geoscript.feature import Feature >>> feature = Feature({'name': 'foobar'}) >>> f = Filter("name = 'foobar'") >>> f.evaluate(feature) True
- cql¶
The CQL representation of the filter.
- xml(pretty=True, version=1.0)¶
Returns the OGC XML representation of the filter.
pretty controls if the resulting xml is “pretty printed” or not.
version specifies the version of of the OGC filter encoding specification to use for encoding. The default is 1.0. Other possibilites include 1.1.
>>> f = Filter("name = 'foobar'") >>> xml = f.xml(False) >>> from xml.dom import minidom >>> d = minidom.parseString(xml) >>> str(d.documentElement.tagName) 'ogc:Filter'