Language selection

Search


Filter Encoding

Overview      

The internationally developed Filter Encoding Standard provides XML and KVP encoding of a system-neutral syntax for expressing projection, selection and sorting clauses, collectively called a query (or filter) expression. Filter Encoding can handle both spatial and non-spatial aspects of a query, and will restrict the records that are returned in response to the query.

This joint OGC/ISO standard was designed to work with the Web Feature Service (WFS), but can be used by a broad range of services that require the ability to express predicates in XML. A predicate in XML is analogous to an if/then statement: if the predicate is TRUE, then the object will be selected; if the predicate is FALSE, it will be excluded, giving developers a means to sort/filter objects returned in response to a query.

Many web-based services require the ability to support XML-based filtering capabilities. This standard defines such a Filter Encoding mechanism that can be used by web services to select a subset of object instances. These include Web Feature Service (WFS), Web Coverage Service (WCS), and Styled Layer Descriptor (SLD). For example, a Web Feature Service (WFS) may use Filter Encoding in a GetFeature operation to specify query constraints.

Additional Information

Standard       

OpenGIS® Filter Encoding 2.0 Encoding Standard*

Related Information

Web Feature Service (WFS)

Web Coverage Service (WCS)

Styled Layer Descriptor (SLD)

Web Map Service (WMS)

Catalog Services for the Web (CSW)

Gazetteer Service

Notes

Filter Encoding is an international standard that was developed jointly by the Open Geospatial Consortium (OGC) and the International Organization of Standards ISO/TC 211, and published as ISO 19143, Geographic Information – Filter Encoding*.

Additional Information: Filter Encoding

Filter Encoding to Obtain Query Subsets

Conformance

 

While the OpenGIS® Filter Encoding Standard (FES) was originally part of the Web Feature Service (WFS), it was decided that the contents of this specification should be put into their own document. Filter Encoding can be used by a broad range of services that require the ability to express predicates in XML, including Web Feature Service (WFS), Web Map Service (WMS)Web Coverage Service (WCS), Gazetteer Service, and Web Registries (Catalog Services for the Web (CSW)).

This discussion provides a high-level description of the international Filter Encoding Standard. However, any developer who wishes to implement Filter Encoding should consult the OpenGIS® Filter Encoding Standard (FES) for technical details.

Filter Encoding to Obtain Query Subsets

A fundamental operation performed on a set of data or resources is that of querying, in order to obtain a subset of data instances which contain certain desired information that satisfies the query. This International Standard defines both XML and KVP encodings for query and filter expressions.

Query/Filter Expressions

The jointly developed OGC and ISO International Standard is considered system-neutral. Using the numerous XML tools available today, XML-encoded projection, selection and sorting clauses can be easily validated, parsed and then transformed into whatever target query language is required to retrieve or modify resources stored in a web-accessible repository. These components, collectively called a query expression, are modular and intended to be used together or individually by other standards which reference the OGC/ISO standard.

A query expression is an action that performs a search over some set of resources and returns a subset of those resources. A query expression is designed to constrain the property values of an object type for the purpose of identifying a subset of object instances to be operated upon in some manner. An abstract query expression can be used to assign a user-defined identifier to a query expression for the purpose of error handling or correlating the response from within a series of queries. Another fundamental type of query expression is an ad hoc query expression, which is ad hoc in the sense that the query is not known before the time it is being executed as, for example, a stored query would be. An ad hoc query expression is a query expression that contains the names of one or more resource types to query, an optional projection clause enumerating the properties of the resource to present in the response, an optional selection clause that constraints the properties of those resources types in order to define a result set, and an optional sorting clause specifying the order in which the result set is presented.

The Filter Encoding Standard defines an XML or KVP encoding for query expressions. As an example, a subset of features might be identified, to render them in a particular color or to convert them into a user-specified format. 

Each data instance in the source set is evaluated using the query expression. The predicates in the overall query expression always evaluate to true or false. If the expression evaluates to TRUE, the data instance satisfies the expression and is marked as being included in the results set. If the overall query expression evaluates to FALSE, the data instance is excluded from the results set. Thus, the net effect of evaluating a query expression is a set of data or resource identifiers which satisfy the predicates in the expression.

Any service that requires the ability to query objects from a web-accessible repository can make use of the XML encodings of a query expression described in the International Standard. For example an XML-encoded query composed of projection, selection and sorting clauses can be transformed into a SQL “SELECT … FROM … WHERE … ORDER BY …” statement to fetch data stored in a SQL-based relational database. Similarly, the same XML-encoded query expression can just as easily be transformed into an XQuery expression to retrieve data from an XML document repository.

XML and KVP Encoding of Predicates

The International Standard defines XML-encoding for the following predicates:

  1. A standard set of logical predicates: and, or and not;
  2. A standard set of comparison predicates: equal to, not equal to, less than, less than or equal to, greater than, greater than or equal to, like, is null and between;
  3. A standard set of spatial predicates: equal, disjoint, touches, within, overlaps, crosses, intersects, contains, within a specified distance, beyond a specified distance and BBOX;
  4. A standard set of temporal predicates: after, before, begins, begun by, contains, during, ends, equals, meets, met by, overlaps and overlapped by; and
  5. A predicate to test whether the identifier of an object matches a specified value.

Several of the parameters in the KVP-encoding of predicates consist of lists of values, and possibly lists of lists of values. For more detailed information, refer to the OGC® Filter Encoding Standard.

Projection Clause

A projection clause encodes a list of optional resource properties that should be available in the query response. For XML-encoded requests, specifications which implement the projection clause of an ad hoc query expression define a concrete element derived from fes:AbstractAdhocProjectionClause.  For KVP-encoded requests, the PROPERTYNAME keyword is used to encode the projection clause. Property names must be valid XML element or attribute names, and may be qualified with a namespace prefix as well.

Simple properties may be referenced using their names. However, since objects can also include complex or aggregate non-geometric properties, a mechanism for referencing these types of properties is supported by filter encoding. A subset of Xpath expressions is used for this purpose, to support abbreviated relative location paths. Filter encoding is not required to support the full Xpath language, to keep the implementation entry cost as low as possible. For details on required XPath compliance, refer to the OGC® Filter Encoding Standard.

Filter / Selection Clause

A filter clause, or selection clause, describes an encoding of one or more predicates which are typically used in query operations to specify how data instances in a source data set should be filtered to produce a results set. The following selection types can be used:

  • Comparison operators: evaluate the mathematical comparison between two arguments. If the arguments satisfy the comparison then the expression evaluates to true. Otherwise the expression evaluates to false.
  • Spatial operators: determine whether geometric arguments satisfy the stated spatial relationship. The operator evaluates to true if the spatial relationship is satisfied. Otherwise, the operator evaluates to false.
  • Temporal operators: determine whether time arguments satisfy the stated temporal relationship. The operator evaluates to true if the temporal relationship is satisfied. Otherwise, the operator evaluates to false.
  • Logical operators: combine one or more conditional expressions. The logical operator AND evaluates to true if all the combined expressions evaluate to true. The operator OR operator evaluates to true is any of the combined expressions evaluate to true. The NOT operator reverses the logical value of an expression.
  • Object identifiers: represent a unique identifier for an instance of a resource within the context of the web service that is serving the resource.

A web service that supports filter encoding should publish the filter capabilities it supports in its capabilities metadata document. Filter capabilities are divided into five categories:

  • ID capabilities: a generic element for referencing resources by ID. However, web services may define their own elements for resource identifications. The resource identifiers section of the filter capabilities document allows such implementations to declare the name or names of the elements being used as resource identifiers.
  • Scalar capabilities: used by a service to advertise which logical, comparison and arithmetic operators the service supports. If the element is not specified, a client must assume that the service does not support any logical or comparison operators and does not implement any additional functions.
  • Spatial capabilities: used by a service to advertise which spatial operators and geometric operands the service supports. If the element is not specified, a client must assume that the service does not support any spatial operators.
  • Temporal capabilities: used by a service to advertise which temporal operators and temporal operands the service supports. If the element is not specified a client must assume that the service does not support any temporal operators.
  • Ability to test the schemaof a resource for the existence or absence of a named property.

A web service is expected to advertise any additional operators added to the filter syntax in the extended capabilities section of its filter capabilities metadata document.

Sorting Clause

The term sorting clause is an optional part of a service-specific query, included in the normative set of filter schema files. This element is used to specify property names whose values will be used to order or sequence the set of resources that satisfy the filter expression, prior to being presented. It acts as an entry point to invoke the sorting mechanism of the filter expression processor. The International Standard does not specify a sorting mechanism; the only requirement is that the sort sequence must be consistent, given the same data set and sort request, between consecutive invocations of the sort.

Conformance

Few usage scenarios require full implementation of the International Standard to work. Therefore, service providers may want to specify requirements for only the subset(s) needed to fulfill their service needs. Or system developers may want to document which subset of the International Standard it is that they have implemented and conform to. These named conformance classes help in specifying such subsets, based on the operations andbehaviourthat a Filter Encoding service may claim to implement, as shown in Table 1 below. 

Conformance Class Operation or Behaviour
Query Service that references the International Standard materializes a concrete query element that is substitutable forFES: AbstractQueryElement
Ad hoc Query Service that references the International Standard materializes a concrete query element that is substitutable forFES: AbstractAdhocQueryElement and materializes a concrete selection clause element that is substitutable for FES: AbstractSelectionClause and materializes a concrete projection clause element that is substitutable for FES: AbstractProjectionClause and materializes a concrete sorting clause element that is substitutable for FES: AbstractSortingClause
Functions Implements functions that are in addition to the operators defined in the International Standard. 
Resource Identification Implements the ResourceId operator with the rid parameter to allow predicates to be written that allow a specific resource to be queried. 
Minimum Standard Filter Implements the comparison operators: PropertyIsEqualTo, PropertyIsNotEqualTo, PropertyIsLessThan, PropertyIsGreaterThan, PropertyIsLessThanOrEqualTo, PropertyIsGreaterThanOrEqualTo. Implements the logical operators. Does not implement any additional functions. 
Standard Filter Implements all the comparison and logical operators and may implement one or more additional functions. 
Minimum Spatial Filter Implements only the BBOX spatial operator. 
Spatial Filter Implements the BBOX spatial operator and one or more other spatial operators. 
Minimum Temporal Filter Implements only the During temporal operator. 
Temporal Filter Implements the During temporal operator and one or more other temporal operators. 
Version navigation Implements ResourceId operator with the parameters that allow versions of resources to be queried ( version, startTime, endTime). 
Sorting Implements sorting of the resources in a response. 
Extended Operators Implements additional operators not defined in the International Standard. 
Minimum XPath Implements the minimum required set of XPath capabilities. 
Schema Element Function Implements the schema-element(s) XPath function. 

Table 1 — Filter Encoding Conformance Classes

Other standards that apply the International Filter Encoding Standard must specify what constitutes a “minimum” filter by declaring the minimum set of conformance classes from Table 1 that must be implemented. 


*      © ISO – All rights reserved

Page details

Report a problem on this page
Please select all that apply:

Thank you for your help!

You will not receive a reply. For enquiries, contact us.

Date modified: