Publication Date: 2020-07-08
Approval Date: 2020-06-26
Submission Date: 2020-05-05
Reference number of this document: OGC 19-084
Reference URL for this document: http://www.opengis.net/doc/PER/vtp2-D002
Category: OGC Public Engineering Report
Editor: Andrea Aime
Title: OGC Vector Tiles Pilot 2: Vector Tiles Filtering Language Engineering Report
COPYRIGHT
Copyright © 2020 Open Geospatial Consortium. To obtain additional rights of use, visit http://www.opengeospatial.org/
WARNING
This document is not an OGC Standard. This document is an OGC Public Engineering Report created as a deliverable in an OGC Interoperability Initiative and is not an official position of the OGC membership. It is distributed for review and comment. It is subject to change without notice and may not be referred to as an OGC Standard. Further, any OGC Public Engineering Report should not be referenced as required or mandatory technology in procurements. However, the discussions in this document could very well lead to the definition of an OGC Standard.
LICENSE AGREEMENT
Permission is hereby granted by the Open Geospatial Consortium, ("Licensor"), free of charge and subject to the terms set forth below, to any person obtaining a copy of this Intellectual Property and any associated documentation, to deal in the Intellectual Property without restriction (except as set forth below), including without limitation the rights to implement, use, copy, modify, merge, publish, distribute, and/or sublicense copies of the Intellectual Property, and to permit persons to whom the Intellectual Property is furnished to do so, provided that all copyright notices on the intellectual property are retained intact and that each person to whom the Intellectual Property is furnished agrees to the terms of this Agreement.
If you modify the Intellectual Property, all copies of the modified Intellectual Property must include, in addition to the above copyright notice, a notice that the Intellectual Property includes modifications that have not been approved or adopted by LICENSOR.
THIS LICENSE IS A COPYRIGHT LICENSE ONLY, AND DOES NOT CONVEY ANY RIGHTS UNDER ANY PATENTS THAT MAY BE IN FORCE ANYWHERE IN THE WORLD. THE INTELLECTUAL PROPERTY IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE DO NOT WARRANT THAT THE FUNCTIONS CONTAINED IN THE INTELLECTUAL PROPERTY WILL MEET YOUR REQUIREMENTS OR THAT THE OPERATION OF THE INTELLECTUAL PROPERTY WILL BE UNINTERRUPTED OR ERROR FREE. ANY USE OF THE INTELLECTUAL PROPERTY SHALL BE MADE ENTIRELY AT THE USER’S OWN RISK. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ANY CONTRIBUTOR OF INTELLECTUAL PROPERTY RIGHTS TO THE INTELLECTUAL PROPERTY BE LIABLE FOR ANY CLAIM, OR ANY DIRECT, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM ANY ALLEGED INFRINGEMENT OR ANY LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR UNDER ANY OTHER LEGAL THEORY, ARISING OUT OF OR IN CONNECTION WITH THE IMPLEMENTATION, USE, COMMERCIALIZATION OR PERFORMANCE OF THIS INTELLECTUAL PROPERTY.
This license is effective until terminated. You may terminate it at any time by destroying the Intellectual Property together with all copies in any form. The license will also terminate if you fail to comply with any term or condition of this Agreement. Except as provided in the following sentence, no such termination of this license shall require the termination of any third party end-user sublicense to the Intellectual Property which is in force as of the date of notice of such termination. In addition, should the Intellectual Property, or the operation of the Intellectual Property, infringe, or in LICENSOR’s sole opinion be likely to infringe, any patent, copyright, trademark or other right of a third party, you agree that LICENSOR, in its sole discretion, may terminate this license without any compensation or liability to you, your licensees or any other party. You agree upon termination of any kind to destroy or cause to be destroyed the Intellectual Property together with all copies in any form, whether held by you or by any third party.
Except as contained in this notice, the name of LICENSOR or of any other holder of a copyright in all or part of the Intellectual Property shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Intellectual Property without prior written authorization of LICENSOR or such copyright holder. LICENSOR is and shall at all times be the sole entity that may authorize you or any third party to use certification marks, trademarks or other special designations to indicate compliance with any LICENSOR standards or specifications.
This Agreement is governed by the laws of the Commonwealth of Massachusetts. The application to this Agreement of the United Nations Convention on Contracts for the International Sale of Goods is hereby expressly excluded. In the event any provision of this Agreement shall be deemed unenforceable, void or invalid, such provision shall be modified so as to make it valid and enforceable, and as so modified the entire Agreement shall remain in full force and effect. No decision, action or inaction by LICENSOR shall be construed to be a waiver of any rights or remedies available to it.
None of the Intellectual Property or underlying information or technology may be downloaded or otherwise exported or reexported in violation of U.S. export laws and regulations. In addition, you are responsible for complying with any local laws in your jurisdiction which may impact your right to import, export or use the Intellectual Property, and you represent that you have complied with any regulations or registration procedures required by applicable law to make this license enforceable.
- 1. Subject
- 2. Executive Summary
- 3. References
- 4. Terms and definitions
- 5. Overview
- 6. Introduction
- 7. Previous work
- 8. Filter Conceptual Model and VTP2 testing considerations
- 9. Filtering Tiles
- 10. Filtering GeoPackages with Vector Tiles
- 11. Implementations
- 11.1. GeoSolutions D100 OGC API - Features
- 11.2. Terranodo D100 OGC API - Tiles
- 11.3. interactive instruments D101 Features, Tiles and Styles API
- 11.4. GeoSolutions D102 OGC API - Tiles
- 11.5. Ecere D103 Features & OGC API - Tiles
- 11.5.1. Examples of filtering expressions used with the OGC API - Features
- 11.5.2. Use of filtering for vector tiles
- 11.5.3. Multi-layer and scale-based filtering (OGC API - Tiles)
- 11.5.4. POST requests to the OGC API - Tiles
- 11.5.5. Filtering driven by styles
- 11.5.6. Retrieving attributes separately from geometry
- 11.5.7. CMSS Expressions Syntax
- 11.6. Ecere D105 Client
- 11.7. Ecere D107 GeoPackage producer & client
- 11.8. Skymantics D104 Client
- 11.9. GeoSolutions D104 Client
- 12. Results and findings
- Appendix A: CQL BNF
- Appendix B: Queryables
- Appendix C: Filter capabilities
- Appendix D: Revision History
- Appendix E: Bibliography
1. Subject
The OGC Vector Tiles Pilot 2: Vector Tiles Filtering Language Engineering Report (ER) defines a filter language for vector data delivered as tiles (also known as vector tiles). The language applies to vector tiles served through implementations of the OGC API – Features standard and the draft OGC API - Tiles specification, but can be generally applied on all services supporting filtering by attributes.
The ER further includes an assessment of filter languages, styles and online/offline symbol sharing for GeoPackages, OGC API - Features and OGC API - Tiles implementations for accuracy and completeness in applications that render vector tiles at local to regional scales.
1.1. Target Scenario
The main benefits for transitioning from raster tiles to vector tiles has been the possibility of flexible map styling and the reduction of storage space required for maps, the latter allowing for maps being stored on devices with lower storage capacity as well as requiring lower bandwidth communications for transmission. In some cases, maps represented with vector tiles can be 20 to 30 times smaller than the same maps represented by raster tiles. This reduction enables the possibility of storing large sets of maps (i.e.,tile sets) into secure and lightweight removable media devices.
As described in Figure 1, a tile set repository (such as GeoPackage, Static Cache, or Compact Cache V2) is being used by a humanitarian relief convoy in the middle of the desert and with limited to no connectivity, supported by a group of interconnected systems working and communicating with each other. The repositories are generated at Command Post Computing Environments (CPCE) and comprise tile sets, styles, maps and routes served by National-level Services and Enterprise-level Services, which communicate with each other throughout OGC API Styles, API Tiles, API Images and API Routes.
The intention of working with vector tile sets is to transition from classic raster maps into using up-to-date and small-sized vector maps which allow for different styles to be applied as needed. An end user would easily transition from a Day Tpographic styling during daytime operations, to Night Topographic during night time, or even a hybrid satellite imagery/vector overlay styling.
Tile content filtering, as described in this ER, allows preparing a tile set specifically targeted to the mission, focusing on pertinent information, further reducing the final size of the package being downloaded on the mobile units, as well as limiting potential confusion.
2. Executive Summary
Consistent application of filters on data is important, whether an application is connected to a network or not. This is more so in environments with Denied, Degraded, Intermittent or Limited (DDIL) connectivity. This engineering report presents work conducted by the OGC Vector Tiles Pilot Phase 2 (VTP2) project with respect to filter languages.
VTP2 sought to deliver a consistent, interoperable online/offline architecture consisting of feature and tile servers, and GeoPackage-producing components that could publish, display and query vector tiles. One of the objectives of the VTP2 pilot was to develop a filtering language for vector tiles, and implement and exercise the filtering language on clients and servers.
The purpose of this Engineering Report and associated component implementations is to study the filtering and production of tiled feature data (also known as vector tiles) and GeoPackages, with particular attention to the following filtering features based on spatial and temporal aspects, as well as alphanumeric
The APIs applied in the pilot are from the emerging suite of OGC API standards. The first of the OGC API standards to be approved by the Technical Committee is the OGC API - Features standard. The pilot also explored the draft OGC API - Tiles and OGC API - Styles specifications.
The report also focuses on the opportunity for client-side versus server-side filtering, coupled with the possibility of caching, overall performance and user experience.
Feature and tile servers deployed in VTP2 implemented the OGC API - Features standard, and the draft OGC API - Tiles and OGC API - Styles specifications. Whereas the feature and tile servers allowed the pilot to explore online support for vector tiles, GeoPackage allowed the pilot to explore offline support.
The key findings of the pilot, with regard to a vector tiles filter language, are:
-
Both server-side and client-side filtering are important. Server-side filtering reduces payload size and can simplify the client-side development. The client-side helps to keep tiles static, and thus cacheable, while adding interactivity.
-
In the context of vector tiles some pre-defined server-side filters are important, to include pertinent information depending on the zoom level, and to keep the vector tile size in control.
-
The filtering language can contain operators that are not needed for specific applications, and difficulties of implementing a text-based parsers may limit its implementations.
The pilot made the following recommendations, with regard to a vector tiles filter language:
-
A way to advertise support for a subset of filtering operators and expressions should be developed and included in filtering extensions.
-
JSON based filtering languages should be explored to lower the implementation cost and provide a suitable option for clients offering Graphical User Interfaces (GUIs) to build filters.
-
Complex filtering and multi-layer filtering should be investigated, and methods to support them implemented.
-
While filtering can reduce the number of returned items, it’s also necessary to develop support for limiting the returned attributes. A querying extension should both advertise which attributes can be removed, and provide ways to limit them in requests.
-
Support for complex, eventually multi-layer filtering should be explored, allowing to perform queries that are too large to fit the limits of a URL, as well as to avoid providing the same query into all tile requests.
2.1. Document contributor contact points
All questions regarding this document should be directed to the editor or the contributors:
Contacts
Name | Organization | Role |
---|---|---|
Andrea Aime |
GeoSolutions |
Editor |
Stefano Bovio |
GeoSolutions |
Contributor |
Clemens Portele |
interactive instruments |
Contributor |
Jeff Yutzler |
Image Matters |
Contributor |
Jerome Jacovella-St-Louis |
Ecere |
Contributor |
Jeffrey Johnson |
Terranodo |
Contributor |
Sergio Taleisnik |
Skymantics |
Contributor |
Jeff Harrison |
AGC |
Contributor |
2.2. Foreword
Attention is drawn to the possibility that some of the elements of this document may be the subject of patent rights. The Open Geospatial Consortium shall not be held responsible for identifying any or all such patent rights.
Recipients of this document are requested to submit, with their comments, notification of any relevant patent claims or other intellectual property rights of which they may be aware that might be infringed by any implementation of the standard set forth in this document, and to provide supporting documentation.
3. References
The following normative documents are referenced in this document.
-
OGC: OGC 09-026r2, OGC® Filter Encoding 2.0 Encoding Standard – With Corrigendum
-
OGC: OGC 12-168r6, OGC® Catalogue Services 3.0 - General Model
-
OGC: OGC 12-176r7, OGC® Catalogue Services 3.0 Specification - HTTP Protocol Binding
-
OGC: OGC 07-057r7, OpenGIS® Web Map Tile Service Implementation Standard
-
OGC: OGC 19-014r1, Core Tiling Conceptual and Logical Models for 2D Euclidean Space, Draft
4. Terms and definitions
For the purposes of this report, the definitions specified in Clause 4 of the OWS Common Implementation Standard OGC 06-121r9 shall apply. In addition, the following terms and definitions apply.
- ● tile
-
geometric shape with known properties that may or may not be the result of a tiling (tessellation) process. A tile consists of a single connected "piece" without "holes" or "lines" (topological disc). (from OGC 19-014r1).
Note
|
In the ER, the definition for “tile is further constrained as a tessellated representation of geographicdata, often part of a set of such elements, covering a spatially contiguous extent which can be uniquely defined by a pair of indices for the column and row along with an identifier for the tile matrix (adapted from OGC 07-057r7) |
- ● GeoPackage
-
an open, standards-based, platform-independent, portable, self-describing, compact format for transferring geospatial information [geopackage]
- ● dataset
-
collection of data, published or curated by a single agent, and available for access or download in one or more formats [OGC 17-069r3]
- ● collection
-
a set of features from a dataset [OGC 17-069r3]
5. Overview
The introduction provides a quick introduction to the VTP2 objectives.
The previous work section provides a summary of previous work related to tiling and filtering.
The Filter Conceptual Model and VTP2 testing considerations provides an overview of the filtering expressions and operators, a more in depth analysis of CQL.
The Tiles filtering section provides a list of filters used in the VTP2 tests and implementations, and the protocol extensions required to advertise queryables and submit filters.
The GeoPackaage filtering section details application of filters against GeoPackages, and support structures that can be used to speed up tile contents filtering.
The implementations section covers each VTP2 server and client deliverable involved in filtering tiles. Each component is described in detail, along with implementation difficulties and unique features.
The results and findings section summarizes the issues found in the development of VTP2 components, findings, as well as future work items.
Annex A contains the full Baukus Naur Form (BNF) of the CQL text encoding.
Annex B contains a copy of they Queryables specification from the Testbed 15 Styles Engineering report..
Annex C provides a sample filter capabilities document developed during the STAC and OGC API - Features and Catalogues Sprint.
6. Introduction
The goal of the Vector Tiles Pilot Phase 2 filtering activity, as described in this Engineering Report (ER) and associated component implementations, was to study the filtering and production of tiled feature data (also known as vector tiles) and GeoPackages, with particular attention to the following:
-
Filtering tiles based on the tile matrix set, range of zoom levels, bounding box and tile matrix set limits per level.
-
Removing layers and attributes that are not desired to be on the client-side.
-
Filtering features based on spatial, temporal, as well as alphanumeric aspects.
The ER also focuses on the opportunity for client-side versus server-side filtering, coupled with the possibility of caching, thereby enhancing overall performance and user experience.
7. Previous work
This section discusses previous work related to filtering, among existing OGC specifications, Testbeds and other activities, evaluating its usefulness in the context of filtering vector tiles.
7.1. Filter Encoding
The OpenGIS Filter Encoding 2.0 Encoding Standard (FE) describes an Extensible Markup Language (XML) and Key-Value Pair (KVP) encoding of a system neutral syntax for expressing projections, selection and sorting clauses collectively called a query expression.
The FE Standard includes both a conceptual filtering model as well as one encoding in Extensible Markup Language (XML). The FE language supports:
-
Literals and value references (attributes)
-
Expressions, as basic math, and functions
-
Comparison operators for alphanumeric expressions
-
Spatial operators for location-based expressions
-
Temporal operators for time-based expressions
-
Logical operators allowing the combination of all the above
-
Value references. In particular, value references can use a a subset of XPath, allowing sophisticated access to objects in a nested structure. This makes FE a natural fit for application schemas based on complex features.
The FE detailed conceptual model is distributed across the entire specification document. This ER contains a simple overview diagram of FE in the conceptual model chapter in this ER.
The FE XML encoding is best suited for use in XML documents sent in HTTP POST requests. Usage in GET requests, as a query parameter, is also possible, but limited in application by the verboseness of the language, the URL encoding obfuscating most of its structure, and the practical length limits of a URL.
7.2. Catalog Services
The HTTP binding of the Catalog Services standard (OGC 12-168r6), also referred to as the Catalogue Services for the Web (CSW) standard (OGC 12-176r7), supports multiple query languages by means of a CONSTRAINTLANGUAGE
parameter in GetRecords
requests.
The Catalog Services Standard supports the usage of OGC Filter Encoding, but also defines the Common Query Language (CQL). CQL is a text based query language with "a syntax similar to the SQL Where Clause", extended to support both temporal and spatial filters.
CSW advertises CQL as the primary means to filter records. Below is an example used against the AnyText
property, which in CSW allows for full text searches:
http://host/catalogServer/csw? service=CSW& version=2.0.2& request=GetRecords& resultType=results& outputSchema=http%3A%2F%2Fwww.isotc211.org%2F2005%2Fgmd& NAMESPACE=xmlns(gmd=http%3A%2F%2Fwww.isotc211.org%2F2005%2Fgmd)& typeNames=gmd:MD_Metadata& CONSTRAINTLANGUAGE=CQL_TEXT CONSTRAINT=AnyText%20=%20'air%20temperature'& CONSTRAINT_LANGUAGE_VERSION=1.1.0& elementSetName=full
-
The Baukus Naur Form (BNF) is not structurally valid
-
The CQL imposes limitations on comparisons that are not present in OGC Filter, e.g., while
attribute = literal
is valid,attribute1 > attribute2
is not. -
The standard lacks CQL examples. The same is true of most CSW implementations. On the other hand, OGC Filter examples can be found in abundance, suggesting a less than widespread implementation of CQL.
-
While geometries can be expressed in Well-Known Text (WKT), there is no support for defining their Coordinate Reference System CRS.
The implementation of OGC Catalog Services has also pioneered two concepts that are now relevant to OGC API - Features, queryables and returnables.
Queryable properties are "field-like objects" that can be used to build filters, and "may differ from the response data elements".
In other words, queryables are property names, but do not necessarily match the names of the returned properties, and may not appear in the data schema at all (if any schema is present).
One example of a queryable without a direct match with returned data is AnyText
, which is defined as a "target for full-text search of character data types in a catalogue".
Another interesting example is "Abstract". This is a property that can be found among the results, but
whose name may vary depending on the record format. For example, in Dublin Core records "Abstract" is named
description
, while in ISO records "Abstract" matches the nested property /gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataI
dentification/gmd:abstract
.
On the other hand Returnable properties
are property names found in the response. Some of them have a match with a corresponding queryable (e.g., title
), while others do not. If this is the case, those properties cannot be used in filters (e.g, publisher
, contributor
).
7.3. CQL adoption and extension in open source software
The GeoServer open source project was the first reference implementation of the OGC Web Feature Service (WFS) standard.
Users of the WFS standard reported difficulties in using the OGC Filter Encoding standard for filtering. This was partly due to the complexity of the language, and partly due to limits in its usage within HTTP GET requests, in particular:
-
The verboseness of the format limited the ability to fit filters in the practical maximum length of a URL.
-
URL encoding of the XML elements both reduced URL legibility and aggravated the verboseness issues, with many characters represented as a 3 chars escape code.
This limited the ability to share data references as simple links.
The GeoServer project adopted, in 2007, a CQL_FILTER
query parameter for both WFS GetFeature and Web Map Service (WMS) GetMap:
-
In WFS GetFeature, the parameter serves as an alternative to
FILTER
(which uses a different OGC FE XML encoding according to the WFS version in use). -
In WMS GetMap, the parameter filters the map contents, allowing dynamic selection and filtering, from the client, without requiring to setup again the whole map style (see also the
SLD
andSLD_BODY
parameters in OGC 05-078r4).
The following examples show a WFS 1.1 GetFeature request, returning features where the LAND_KM
property value is between 100000 and 150000. The first uses FE XML, while the second encodes the filter in CQL instead:
http://host/wfs?request=GetFeature&version=1.1.0&typeName=topp:states&FILTER=%3CFilter%20xmlns=%22http://www.opengis.net/ogc%22%3E%3CPropertyIsBetween%3E%3CPropertyName%3Etopp:LAND_KM%3C/PropertyName%3E%3CLowerBoundary%3E%3CLiteral%3E100000%3C/Literal%3E%3C/LowerBoundary%3E%3CUpperBoundary%3E%3CLiteral%3E150000%3C/Literal%3E%3C/UpperBoundary%3E%3C/PropertyIsBetween%3E%3C/Filter%3E
http://wfs?request=GetFeature&version=1.1.0&typeName=topp:states&CQL_FILTER=LAND_KM%20BETWEEN%20100000%20AND%20150000
Eventually some limitations of the first CQL version became apparent, so in 2010 Extended CQL (ECQL) was created by the GeoTools and GeoServer communities, to bring the language closer to the OGC Filter capabilities. In particular, ECQL supports, in addition to CQL:
-
Free-form comparison expressions in terms of
expression OP expression
. -
FeatureId filters.
The CQL_FILTER
parameter has supported both CQL and ECQL syntaxes since then.
A remaining significant limitation of (E)CQL, in GeoServer, is that it can only be used in a GET request, and has no support in XML POST requests.
7.4. OGC Testbed 14
Participants in the Testbed 14 Complex Features Handling thread performed an extensive analysis of filtering languages [1]. Of particular interest is the ER chapter on API building blocks for queries.
That chapter contains an analysis of filtering languages following different approaches:
Notable observations from that work include:
-
Due to being encoded in XML, OGC Filter Encoding is not considered a natural fit for JSON-first services (though it remains a good option for implementations returning GML based application schemas).
-
Falcor is best suited for JSON only services, and needs to be extended to support spatial support capabilities.
-
GraphQL needs extensions to its spatial capabilities. GraphQL also depends on the presence of a schema, which is not mandatory in OGC API - Features. Like CQL, GraphQL does not support multi-valued properties.
CQL has been considered suitable for usage in future extensions of the OGC API - Features but, due to its numerous limitations, but not without further work.
For CQL, the notion of a queryable was first used in combination with a data retrieving service.
As with CSW, a queryable is a property that can be queried, but it is not necessarily tied to the schema of the dataset. A queryable could indeed be a visible property
of the data. A queryable could also be referring to a nested element via a simple name, or referring to a
summary property, such as AnyText
, without the property actually being present in the result.
The concept was further explored in OGC Testbed 15, where a dedicated OGC API - Features extension was proposed.
7.5. OGC Testbed 15
Participants in the OGC Testbed 15 Open Portrayal thread investigated and prototyped a new Application Programming Interface (API) for styles publishing, discovery and editing. Results of this activity are documented in the OGC Testbed-15: Styles API Engineering Report.
When a client edits styles, knowing which attributes can
be used for collection filtering is important. This was handled by the queryables OGC API - Features extension draft.
Queryables are normally a subset of all possible attributes, and in general, may not even show up
among the results of a items
query. The returned attributes are referred to as "presentables" or "returnables", instead.
Quoting the Testbed 15 ER, each collection exposes a list of Queryable objects, each characterized by:
-
id
(required) - the property name for use in expressions. -
type
(required) - the data type of the property, one ofstring
,uri
,enum
,number
,integer
,date
,dateTime
,boolean
. -
description
(optional) - a description of the property. -
required
(optional) - indicator whether the property is always present in features. -
mediaTypes
(optional) - in general, the representation of the queryables is meant to be independent of the feature encoding. However, this is not always the case. For example, length restrictions or namespace prefixes may result in different property identifiers for the same property. To support this, the definition of a queryable may be restricted to one or more feature encodings (media types). -
pattern
(optional, only for "string" and "uri") - a regular expression to validate the values of the property. -
values
(required, only for "enum") - an array of valid values of the property. -
range
(optional, only for "number", "integer", "date" and "dateTime") - the range of valid values expressed as an array with two items. Open ranges can be expressed using null for the minimum or maximum value.
As they provide a list of property names the filter can use, queryables are a natural fit for a filtering extension.
7.6. STAC and OGC API Sprint, OGC API Filtering extension
In November 2019 OGC organized the STAC and OGC API - Features and Catalogues Sprint. The sprint hosted numerous groups, one of them focused on experimenting a possible "OGC API - Features - Part 3: Common Query Language" extension.
The CQL language was considered first in conceptual terms, with a definition of the operators and expressions that could be used in an encoding. Then, three possible encodings were prototyped:
-
A text-based language, derived from the original CQL. The language is similar to the GeoServer Extended CQL, in particular, it removes some of the original CQL limitations, allowing comparisons between expressions.
-
A JSON-based hierarchical objects language, meant to be a port to JSON of the OGC Filter Encoding XML encoding.
-
A JSON-based nested array language, that would read like a prefix notation, reminiscent of Mapbox Styles Expressions.
The following table compares the various approaches:
Text | Hierarchical JSON | Array based JSON | |
---|---|---|---|
User |
Trivial to write by hand and understand |
Easier to handle for those familiar with OGC filter |
Reads "backwards", easier to handle for those familiar with Mapbox Styles Expressions |
Developer |
Requires writing a text based parser based on the BNF |
JSON reads directly into a parse-tree like structure (based on nested objects) |
JSON reads directly into a parse-tree like structure (based on nested arrays) |
The following shows an example of filtering based on properties of a satellite image, and spatial location, in the three encodings:
Language | Example |
---|---|
Text |
beamMode='ScanSAR Narrow' AND swathDirection='ascending' AND polarization='HH+VV+HV+VH' AND intersects(geometry,POLYGON((-77.117938 38.936860,-77.040604 39.995648,-76.910536 38.892912,-77.039359 38.791753,-77.047906 38.841462,-77.034183 38.840655,-77.033142 38.857490))) |
Hierarchical json |
|
Array based JSON |
|
In addition to working with the filtering language, the sprint considered the cost of filter language implementation, from the filtering operators point of view. The CQL model contains a rich set of comparison, spatial, temporal and logic operators. Implementing the full set can be both expensive, and depending on the application, perhaps un-necessary.
Based on the OGC Filter Encoding 2.0 specification, and the OGC APIs, two options were considered:
-
Conformance classes for filters, identifying them in groups.
-
Fine grained filter capabilities documents, listing the specific subset chosen by a server
The conformance classes approach allows a compact representation of the supported filters.
This is at the expense of fine grain tuning the supported operator set.
Classes can be naturally derived from the existing operator subdivision, that is, logical, comparison, spatial, and temporal.
However, in practical applications, subsets of operators tend to go across classes.
For example, a minimal subset covering basic filtering needs could include all comparisons and logical operators, along with bbox
and during
basic spatial and temporal filtering. The uncommon and advanced operators
can be found within the spatial and temporal categories, but the common ones are found
in all categories.
On the other hand, the capabilities document allows for a tailored operator selection but at the expense of listing all supported operators. Annex C contains an example of a full queryables document, as prototyped in GeoServer during the code sprint.
Combining the best aspects of the two approaches above is also possible: declaring a conformance class when all operators in it are supported, and explicitly enumerating the ones for incomplete classes.
8. Filter Conceptual Model and VTP2 testing considerations
8.1. Conceptual model
The following diagram provides a draft of the filter conceptual model, the elements and their relationship to the other significant elements, available when using a filter in a service or GeoPackage implementation.
In particular, an implementation of the model refers to:
-
A hierarchy of filter types and expression concepts, that can be used to compose a filter.
-
A filter language, an encoding, typically textual, that expresses the filter.
-
A collection or tile set, which is the target of the filtering.
The collection in turn exposes a set of queryables, property names and types that can be used to build a filter, and to verify its formal correctness.
The filter refers to the common building blocks. In summary:
-
Expressions, be they property references, literals, functions and arithmetic combinations thereof.
-
Filters, in particular, spatial ones, temporal, simple comparisons and logic combinations thereof.
Refer to 09-026r2, OGC® Filter Encoding 2.0 Encoding Standard – With Corrigendum for a detailed definition of each expression and filter.
8.2. The CQL language
The OGC API - Features Standards Working Group (SWG) is currently exploring a filtering extension and are evaluating a number of possible encodings. Two encodings are currently being considered for use in the filtering extension:
-
An extended version of the OGC Catalogue Common Query Language (CQL).
-
A JSON encoding of the filter conceptual model, based either on a hierarchical structure, similar to the OGC Filter XML encoding, or an array based structure, similar to the Mapbox GL filter expressions.
The JSON encoding is recognized to be most useful to express filters in a larger JSON document, while the CQL based syntax is considered more useful for direct human entry and usage in URLs.
Within the limits of VTP2, the CQL language was chosen for prototyping purposes, as CQL is currently better defined, and better supports the target usage within tile resource URLS.
The CQL language is a text-based language that reads like a SQL 'Where' clause expression, as it is regarded as easy to read and to enter directly, without support by a user interface. On the other hand, due to the text nature, CQL is more complex to handle software-wise, as a full parser needs to be written to handle it. By comparison, the two JSON structures mentioned above, can be parsed using a JSON parser, and would construct an object structure that is similar to a parse tree, ready for use and evaluation.
Usage of CQL outside of the confines of Catalog Services has been pioneered by GeoServer community. GeoServer is an open source project which began using an extended version of the CQL language in both the WFS and WMS protocols:
-
In WFS, CQL can be used as an alternative to the XML filter encoding in GetFeature requests.
-
In WMS, CQL can be used as a way to further filter map contents, in addition to the filtering already performed by the Styled Layer Descriptor (SLD) styles.
In both cases the user can add a &CQL_FILTER=<filter expression>
query parameter in the request, and get back filtered results.
Compared to the Catalog CQL, the proposed filtering extension of OGC API - Features provided some improvements:
-
Some of the original restrictions have been lifted, making this approach as expressive as OGC FE, and similar to the version adopted by GeoServer. For example, the original CQL did not allow comparing two properties, but only a property with a literal.
-
The BNF was updated to correctly validate, and can now be parsed by a machine.
A copy of the current BNF version can be found in Annex A.
The following table shows a few examples of text CQL filters:
Filter meaning | CQL encoding |
---|---|
Floors greater than 5 |
floors>5 |
Owner name contains 'Jones' |
owner LIKE '% Jones %' |
More than 5 floors and a swimming pool |
floors>5 AND swimming_pool=true |
A swimming pool and (more than five floors or material is brick) |
swimming_pool=true AND (floors > 5 OR material LIKE 'brick%' OR material LIKE '%brick')` |
Updated between 7:30am June 10, 2017 and 10:30am June 11, 2017 |
updated DURING 2017-06-10T07:30:00 2017-06-11T10:30:00 |
Geometry that intersects with geometry |
INTERSECTS(geometry,POLYGON\((-10.0 -10.0,10.0 -10.0,10.0 10.0,-10.0 -10.0))) |
Some considerations:
-
The filter is normally human readable and quite similar to SQL.
-
Geometries are expressed in the Well Known Text (WKT) syntax.
-
Time literals are expressed in ISO format.
9. Filtering Tiles
This ER Section focuses on filtering tile contents and explains the final decisions and recommended API changes needed to generate outputs that match the VTP2 objectives.
9.1. Vector Tiles Pilot 2 testing operator subset
The VTP2 implementations exercised the following subset of operators:
The selection of the operators has been driven by the following principles:
-
The set is simple enough to be implemented within the time frame of VTP2.
-
The set is representative of the overall model filtering abilities.
9.2. Queryables
The list of valid properties, and their type, must be available for clients to build filters.
As indicated in Chapter 6, the Testbed 15 Styles’s Engineering Report extended the OGC API - Features with a concept of Queryables, a resource enumerating all attributes available for filtering.
The VTP2 participants used the same extension to advertise collection queryables, both in the OGC API - Features, and in the OGC API - Tiles (for those implementing a stand-alone Tile API, as opposed to a tiles building block in the Features API).
9.3. Single and multi-layer tile filtering
The VTP2 participants considered two filtering cases:
-
Filtering a tile from a single collection
-
Filtering a multi-layer collection
The first use case, filtering a single layer tile, is well-supported by the existing work, in particular, the OGC API - Features CQL extension, as well as the Queryables extension, with the following workflow:
-
The client inspects the queryables
-
The client helps the user to build a filter reducing the features returned in tiles
-
A request for tiles with the
filter
andfilter-lang
parameters is sent to the OGC API - Features tiles extension, or to the stand-alone OGC API - Tiles, retrieving tiles with reduced content.
The second use case presents some extra complexities, in particular:
-
Discovery of queryables for all the layers included in the tile must be possible.
-
Providing multiple filters, one per collection, to the server must be possible.
Regarding queryables discovery, the issue is easily solved in an OGC API - Features providing
multi-layer tiles at the root level /tiles
resource. In this case, the client can
list the collections to be retrieved, and thus, lookup the queryables on a collection by collection basis.
A stand-alone Tiles API poses a challenge, as collections are opaque and can contain
anything, including having a single collection delivering directly multi-layer tiles (see the
GeoSolutions implementation in this regard).
The queryables document, as a flat list of attributes, is insufficient for this case, and should
be turned into a list of named layers, each having their own queryables.
The second issue, providing multiple filters, does not have a solution in the existing CQL language.
GeoServer Extended CQL supports a notion of "filter list", used to provide multiple filters in WMS GetMap requests.
The grammar uses the semicolon to separate filters, as the comma is already used in the IN
operator.
SequenceOfSearchConditions> ::=
<search condition>
| <SequenceOfSearchConditions> ; <search condition>
Another possibility would be to repeat the "filter" and "filter-lang" parameters, one instance per filtered collection, in the URL.
Regardless of the solution adopted, most base maps use a large number of layers, for example, an openstreemap.org like map typically uses over 20 layers. Trying to filter on this would require placing over 20 filters in the request, quickly exhausting the practical length of a URL.
For these reasons, with the exception of the Ecere Tiles API, the VTP2 participants limited filtering to single layer collections, while filtering multi-layer collections with CQL is left as future exercise.
Ecere implemented support for compact multi-layer filtering expressions based on the selectors and expressions syntax from the Cascading Map Style Sheets (CMSS) styling language (see Section 11.5).
10. Filtering GeoPackages with Vector Tiles
GeoPackage is built on the SQLite relational database. As a relational database, filtering of feature data is easily done through conventional SQL querying. However, when the feature data is stored in vector tiles, filtering is more complicated. Both formats used in VTP2 tiles (MVT and GeoJSON) embed attribute information in the vector tiles. Keeping the attributes embedded in the vector tiles undermines the capabilities of a GeoPackage-based architecture for the following reasons:
-
Since features may span multiple tiles, having the attribute information duplicated across each tile containing a particular feature is redundant.
-
Queries against the embedded attributes are not possible without opening a number of candidate tiles individually, an inefficient process.
-
There is no obvious way to identify the candidate tiles to open, beyond knowledge of the area of interest of a particular query.
In response to these concerns, the participants proposed some alternatives for managing attributes. Due to resource constraints, these approaches were only tested in a limited fashion.
10.1. Attributes in Attributes Tables
Through the Vector Tiles Attributes Extension (see the Summary ER), a GeoPackage may contain an attributes table for each vector tiles layer. Using this approach provides two benefits:
-
Features can be filtered via their attributes using conventional SQL queries.
-
The attributes for a feature can be removed from the vector tiles, so that they are only stored in the GeoPackage once.
Depending on the underlying architecture of the vector tiles server, this approach may impose significant additional processing during GeoPackage creation. In some architectures, the vector tiles are created in advance. In naive GeoPackage creation (ignoring filtering considerations), those vector tiles can simply be copied directly into the GeoPackage. However, in this scenario the vector tiles would have to be modified to remove the attributes. This would significantly increase the processing time required to produce the GeoPackage. An architecture where vector tiles are produced on-the-fly would not be subject to this performance impact.
10.2. Spatial Filtering
The approach described in the previous section provides significant benefits for scenarios where features need to be filtered by their attributes and spatial extents. However, it is not possible or practical to isolate which tiles to open to find the geometries for the features that satisfy a particular query.
An R-tree spatial index, storing the overall extent of whole (untiled) features, can be used in conjunction with the attributes table to handle arbitrarily large geospatial extents. Such an index can speed up queries by focusing on the features present in a specific area, only performing more costly attributes comparison for those features within the bounding box of a query. That same stored extent can also be used to easily identify where specific features are located, e.g. to center the view on a particular feature, potentially after having identified that feature by an attributes-based query.
The GeoPackage Related Tables Extension can be used to establish a many-to-many mapping between features and the tiles containing those features. Once this is done, the query can be performed to identify a result set (based on feature IDs) and the mapping table can be queried to identify the tile or tiles that contain the geometries for those features. In some scenarios, this will improve the performance of filtering operations.
The following examples are practical queries performed on a GeoPackage produced by Ecere of the Daraa / OpenStreetMap Topographic DataStore for the pilot, with vector data tiled according to the World Mercator WGS84 Tile Matrix Set, and using the Attributes Table extension, the Tiles/Features Mapping Table extension, as well as a 32-bit integer R-tree spatial index (storing the extent of features as decimal degrees multiplied by a factor of 107, maintaining the same precision as OpenStreetMap).
Querying features and attributes
In this first example query, the client does not care about either the detailed geometry or the tiles of the features but does care about features within a specific geographic region. The client wishes to list the GeoPackage feature IDs, as well as the values for four of the attribute fields (UFI, F_CODE, FCSUBTYPE and ZI005_FNA) matching the following conditions:
-
Features from the Daraa transportation lines (roads) layer
-
Whose name
ZI005_FNA
is not No Information -
Which are at least partially located within a geographic bounding box whose lower-left and upper-right corners are respectively (32.6083233°N, 32.6083233°E) and (32.6097047°N, 36.0987994°E).
An inner join is used between the attributes table and the R-tree spatial index, whose id fields correspond.
select attributes_TransportationGroundCrv.id, UFI, F_CODE, FCSUBTYPE, ZI005_FNA
from attributes_TransportationGroundCrv
inner join rtree_attributes_TransportationGroundCrv_vector_tiles
on attributes_TransportationGroundCrv.id = rtree_attributes_TransportationGroundCrv_vector_tiles.id
where ZI005_FNA != 'No Information' and
maxLat > 326083233 and maxLon > 360899582 and
minLat < 326097047 and minLon < 360987994;
Output (list of features):
id |
UFI |
F_CODE |
FCSUBTYPE |
ZI005_FNA |
1442 |
36d6beb3-0a35-4ec3-a2f6-6b526ea1f659 |
AP030 |
100152 |
شارع الأردن |
3178 |
204af963-3d18-402d-8cfe-ff4195e992c7 |
AP030 |
100152 |
شارع الزيدي |
Identifying tiles containing certain features
In this second example query, the client wishes to preserve the above conditions (only roads with name information, within that same bounding box), but rather than retrieving the attributes values, all the tiles (specifically of zoom level 16, in this case) containing those features should be listed.
Because this GeoPackage includes a Tiles / Features Mapping table, that table can be joined with both the Attributes table (through its related_id
) as well as with the Tiles table (through its base_id
).
Note that the tiles returned by this query cover the entirety of the unclipped features which happen to intersect the bounding box of interest — not only the tiles which themselves intersect the bounding box.
select distinct tiles_Daraa2.id, zoom_level, tile_row, tile_column
from mapping_table_TransportationGroundCrv
inner join tiles_Daraa2
on mapping_table_TransportationGroundCrv.base_id = tiles_Daraa2.id
inner join attributes_TransportationGroundCrv
on mapping_table_TransportationGroundCrv.related_id = attributes_TransportationGroundCrv.id
inner join rtree_attributes_TransportationGroundCrv_vector_tiles
on attributes_TransportationGroundCrv.id = rtree_attributes_TransportationGroundCrv_vector_tiles.id
where ZI005_FNA != 'No Information'
and maxLat > 326083233 and maxLon > 360899582
and minLat < 326097047 and minLon < 360987994
and zoom_level = 16;
Output (list of tiles):
id |
zoom_level |
tile_row |
tile_column |
7962 |
16 |
26518 |
39339 |
8059 |
16 |
26519 |
39338 |
8060 |
16 |
26519 |
39339 |
8161 |
16 |
26520 |
39337 |
8162 |
16 |
26520 |
39338 |
8163 |
16 |
26520 |
39339 |
Identifying tiles without a mapping table
Even without a Tiles / Features Mapping table, a client could still easily determine a list of tiles from the extent of the feature(s) as stored in the R-tree spatial index. For a large feature, often only the tiles in view are of interest, in which case the client could also calculate the intersection of the feature’s extent with the view’s extent to identify those tiles. It could then proceed to enumerate the full list (complete box) of tiles within that extent, in a similar way to how the limits of a tile matrix are calculated for a dataset’s extent. The advantage of the Mapping table is to altogether skip tiles in which the features of interest may not be present at all, therefore avoiding to decode tiles not containing these. This would most likely only benefit large features spread non-uniformly across a vast geospatial extent, and come at the cost of additional storage, which should be taken into consideration. The benefit would also not apply to scenarios where all tiles within a geographic area of interest should be decoded anyways (e.g. the simple visualization use case).
In this third example query, it is assumed that a Tiles / Features Mapping table is not available, and therefore the output of the query is an extent which will be programmatically converted to tile coordinates.
select min(minLat), min(minLon), max(maxLat), max(maxLon)
from attributes_TransportationGroundCrv
inner join rtree_attributes_TransportationGroundCrv_vector_tiles
on attributes_TransportationGroundCrv.id = rtree_attributes_TransportationGroundCrv_vector_tiles.id
where ZI005_FNA != 'No Information'
and maxLat > 326083233 and maxLon > 360899582
and minLat < 326097047 and minLon < 360987994;
Output (extent of the unclipped features):
min(minLat) |
min(minLon) |
max(maxLat) |
max(maxLon) |
326079262 |
360884617 |
326191309 |
361000583 |
The extent returned in this case is larger and fully contains the extent of interest in the request. Converting the geographic extent to WorldMercatorWGS84Quad level 16 tile coordinates gives (26518, 39337)-(26520, 39339).
Here is the full list of tiles using those bounding tile coordinates, assuming the whole unclipped features are desired:
select id, zoom_level, tile_row, tile_column
from tiles_Daraa2
where zoom_level = 16
and tile_row >= 26518 and tile_row <= 26520
and tile_column >= 39337 and tile_row <= 39339;
Output (list of tiles):
id |
zoom_level |
tile_row |
tile_column |
7960 |
16 |
26518 |
39337 |
7961 |
16 |
26518 |
39338 |
7962 |
16 |
26518 |
39339 |
8058 |
16 |
26519 |
39337 |
8059 |
16 |
26519 |
39338 |
8060 |
16 |
26519 |
39339 |
8161 |
16 |
26520 |
39337 |
8162 |
16 |
26520 |
39338 |
8163 |
16 |
26520 |
39339 |
It can be seen that the Mapping table request in this scenario would save the client from decoding 3 out of 9 tiles (33%), which might be significant.
If the client is instead interested in the clipped portion rather than the unclipped features (i.e. only the tiles which themselves intersect the bounding box of interest), then the intersection of the returned extent with the requested extent should be used. This might have justified avoiding the query altogether and directly converting the area of interest to a list of tiles, depending on the circumstances. Converting this intersected extent (which here is the same as the original requested bounding box) to WorldMercatorWGS84Quad level 16 tile coordinates gives (26520, 39337)-(26520, 39339).
The full list of tiles for the portion of the features of interest intersecting the area of interest is:
select id, zoom_level, tile_row, tile_column
from tiles_Daraa2
where zoom_level = 16
and tile_row >= 26520 and tile_row <= 26520
and tile_column >= 39337 and tile_row <= 39339;
Output (list of tiles):
id |
zoom_level |
tile_row |
tile_column |
8161 |
16 |
26520 |
39337 |
8162 |
16 |
26520 |
39338 |
8163 |
16 |
26520 |
39339 |
In this case, only 3 tiles are needed, and a query using the Mapping table does not eliminate any tile from the full box of tiles covered by the extent, since all tiles of the bounding box contain those features (no saving).
11. Implementations
Each component provides filtering abilities, available both on the client and server side. This chapter includes salient implementation notes, descriptions and demonstrations, as well as relevant feedback from each deliverable.
11.1. GeoSolutions D100 OGC API - Features
GeoSolutions worked on extending their implementation of the OGC API - Features standard to match the requirements of the VTP2 initiative. Specifically, the following changes were implemented to support filtering and tiles:
-
Exposed GeoServer (E)CQL filtering capabilities as an implementation of the current OGC API Features CQL extension draft, along with queryables support.
-
Implemented the draft OGC API - Tiles building blocks as part of the OGC API - Features, and added filtering support in the same way as the OGC API - Features extensions.
The CQL filtering support has been added directly into the "gs-ogcapi-features" GeoServer plugin, while the tiles building block has been implemented as new plugin, "gs-ogciapi-tiled-features", which can be added on top of the base "gs-ogcapi-features" one.
When the Tiled Features plugin is added, the landing page of the service reports the tile matrix set endpoint, as well as advertising tiling resources in the API definition. The following figures show the GeoServer OGC API - Features landing page and API, both extended with new elements from the OGC API - Tile building blocks.
Tiles are provided in any vector format supported by the internal machinery. During VTP2 that meant MVT, GeoJSON and TopoJSON, new formats can be added as desired through a plug-in programming interface.
Queryables support has been added in all collections. The following is an excerpt
from the queryables of the syria_vtp:building_s
collection (only a few attributes are shown to keep
the example short):
{
"queryables": [
{
"id": "AOO",
"type": "number"
},
{
"id": "ARA",
"type": "number"
},
{
"id": "BEN",
"type": "string"
},
{
"id": "CAA",
"type": "integer"
},
{
"id": "CCN",
"type": "string"
},
{
"id": "geom",
"type": "geometry"
}
],
"links": [
{
"href": "http://vtp2.geo-solutions.it/geoserver/ogc/features/collections/vtp%3ATransportationGroundCrv?f=application%2Fx-yaml",
"rel": "alternate",
"type": "application/x-yaml",
"title": "This document as application/x-yaml"
},
{
"href": "http://vtp2.geo-solutions.it/geoserver/ogc/features/collections/vtp%3ATransportationGroundCrv?f=application%2Fjson",
"rel": "self",
"type": "application/json",
"title": "This document"
},
{
"href": "http://vtp2.geo-solutions.it/geoserver/ogc/features/collections/vtp%3ATransportationGroundCrv?f=text%2Fhtml",
"rel": "alternate",
"type": "text/html",
"title": "This document as text/html"
}
]
}
Support for the filter
and filter-lang
query parameters has been added both to the items
and the tiles
resources.
An example of a filtered items
request follows:
The same example above, reformatted and URL decoded for readability, can be split into:
-
https://vtp2.geo-solutions.it/geoserver/ogc/features
(service base) -
collections/vtp:TransportationGroundCrv/items?
(items access) -
f=application/vnd.mapbox-vector-tile
(requests to return Mapbox Vector Tile format) -
filter=("RIN_ROI" = '3') AND (BBOX(geom,36.140,32.595,36.142,32.658))
(the filter) -
filter-lang=cql-text
(filter language is CQL)
An example of a single collection filtered tiles
request follows:
The same example above, reformatted and URL decoded for readability, can be split into:
-
https://vtp2.geo-solutions.it/geoserver/ogc/features
(service base) -
collections/vtp:TransportationGroundCrv/tiles/WebMercatorQuad/14/6618/9833?
(tile access) -
f=application/vnd.mapbox-vector-tile
(requests to return mapbox vector tiles) -
filter=("RIN_ROI" = '3')
(the filter) -
filter-lang=cql-text
(filter language is CQL)
Regarding caching, it is worth noting that a layer needs to have a caching configuration in order to expose tiled access, as tiling is internally managed by GeoWebCache. It is however not required to make filtered tiles cacheable, if not enabled, then the filtered tiles are computed on-the-fly. If enabled, internal GeoWebCache is going to treat the filter as a "CQL_FITLER" query parameter, to make caches reusable across services. Mapbox vector tiles are indeed already provided as part of the WMTS and WMS services.
In particular, MVT tiles construction is driven by styles, using filters and scale dependencies to decide which features to include at a given zoom level. As a general rule, anything that needs styles to be generated is treated as a WMS output format, and is then exposed into WMTS via GeoWebCache tiling and caching engine.
Various filtering visual examples are available in the GeoSolutions D104 client section.
11.2. Terranodo D100 OGC API - Tiles
The open source tegola software implemented the OGC API - Features CQL extension draft, along with collection level queryables support.
11.2.1. CQL
CQL was implemented in tegola with the following functionality:
-
CQL filters supported via the
filter=
parameter. -
CQL text support was added. CQL JSON was planned for a future implementation.
11.2.2. Sample Requests
Spatial Predicates example requests, CQL filter first, followed by a full URL-encoded API request:
INTERSECTS(geometry,POLYGON((36.0710334777832 32.59845703812064, 36.13574981689453 32.59845703812064, 36.13574981689453 32.633592568907005, 36.0710334777832 32.633592568907005, 36.0710334777832 32.59845703812064)))`
WITHIN(geometry,POLYGON((36.0710334777832 32.59845703812064, 36.13574981689453 32.59845703812064, 36.13574981689453 32.633592568907005, 36.0710334777832 32.633592568907005, 36.0710334777832 32.59845703812064)))
DISJOINT(geometry,POLYGON((34.73876953125 34.53823752729575, 37.825927734375 31.835565983656224, 38.72680664062501 34.06631196472105, 34.73876953125 34.53823752729575)))
Non spatial predicates examples, CQL filter first, followed by a full URL-encoded API request:
class=’landuse’
class like '%land%T'
Temporal predicates examples:
BEFORE 2020-03-03`
AFTER 2016-03-03
Logical Operators examples:
INTERSECTS(geometry,POLYGON((35.9 32.7,36 32.7,36 32.8,35.9 32.8,35.9 32.7))) AND class='swamp'
INTERSECTS(geometry,POLYGON((35.9 32.7,36 32.7,36 32.8,35.9 32.8,35.9 32.7))) OR class='swamp'
11.2.3. Queryables
The following resource encodes queryables as a JSON document:
{
"queryables": [
{
"id": "wkb_geometry",
"type": "geometry"
},
{
"id": "event_id_no_cnty",
"type": "string"
},
{
"id": "event_date",
"type": "date"
},
{
"id": "sub_event_type",
"type": "string"
},
{
"id": "actor2",
"type": "string"
},
{
"id": "ogc_fid",
"type": ""
},
{
"id": "data_id",
"type": "string"
},
{
"id": "event_type",
"type": "string"
},
{
"id": "region",
"type": "string"
},
{
"id": "notes",
"type": "string"
},
{
"id": "interaction",
"type": "string"
},
{
"id": "source",
"type": "string"
},
{
"id": "admin3",
"type": "string"
},
{
"id": "location",
"type": "string"
},
{
"id": "event_id_cnty",
"type": "string"
},
{
"id": "actor1",
"type": "string"
},
{
"id": "country",
"type": "string"
},
{
"id": "admin1",
"type": "string"
},
{
"id": "admin2",
"type": "string"
}
]
}
11.3. interactive instruments D101 Features, Tiles and Styles API
11.3.1. The starting point
At the beginning of the OGC Vector Tiles Pilot Phase 2 initiative, the open-source tool ldproxy implemented the following capabilities that were the basis for the work in the pilot:
-
OGC API - Features - Part 1: Core: The following conformance classes were used in the pilot: Core, HTML, GeoJSON, OpenAPI 3.0. ldproxy was the first OGC Reference Implementation for the standard.
-
OGC API - Features - Part 2: Coordinate Reference Systems by Reference: The latest draft (the public review started during the pilot).
-
OGC API - Tiles: The following conformance classes of the latest draft were used in the pilot: Core, Tile Matrix Set, Tiles from more than one collection. Mapbox Vector Tiles and GeoJSON tiles were supported.
-
OGC API - Styles: The following conformance classes of the latest draft were used in the pilot: Core, Resources, HTML, Mapbox Styles, Style Info, Queryables.
-
A query parameter "properties" on all tile and feature resources to return only the selected properties in the response.
For the demonstration server, a test dataset with data from OpenStreetMap from the region of Daraa, Syria, converted to the Topographic Data Store (TDS) schema of NGA was used.
The following screenshots of the HTML view of the API resources illustrate the starting point for the work in the pilot. The HTML view is a rendering of the JSON content that was also available for each resource.
For filtering, knowledge about the available properties for use in filter predicates is important. These were published as a separate resource for each collection, in the following screenshot for the Transportation (Ground) features with a line string geometry.
To illustrate the data, here is a screenshot of a road feature:
The following code snippet is the same feature in GeoJSON (coordinates have been truncated):
{
"type":"Feature",
"links":[
{
"href":"https://services.interactive-instruments.de/t15/daraa/collections/TransportationGroundCrv/items/34?f=json",
"rel":"self",
"type":"application/geo+json",
"title":"This document"
},
{
"href":"https://services.interactive-instruments.de/t15/daraa/collections/TransportationGroundCrv/items/34?f=html",
"rel":"alternate",
"type":"text/html",
"title":"This document as HTML"
},
{
"href":"https://services.interactive-instruments.de/t15/daraa/collections/TransportationGroundCrv?f=json",
"rel":"collection",
"type":"application/json",
"title":"The collection the feature belongs to"
}
],
"id":"34",
"geometry":{
"type":"MultiLineString",
"coordinates":[ ... ]
},
"properties":{
"F_CODE":"AP030",
"ZI001_SDV":"2014-09-13T18:57:11Z",
"ZI005_FNA":"No Information",
"RTY":2,
"RIN_ROI":3,
"UFI":"86c0f5fe-4abd-4e0e-970a-feaf7e0ab314",
"FCSUBTYPE":100152,
"ZI006_MEM":"No Information",
"ZI001_SDP":"No Information",
"ZI016_WTC":1,
"RIN_RTN":"No Information",
"RLE":-999999,
"LOC":-999999
}
}
All features were also available as vector tiles, both for each individual collection and a single multi-layer tile set. The screenshot below shows the vector tiles of the Transportation (Ground) features in an OpenLayers map.
11.3.2. Support for filters
Support for CQL filters was implemented in ldproxy and support for the query parameters filter
and filter-lang
was added to the following resources:
-
/collections/{collectionId}/items
- to filter the features resources -
/collections/{collectionId}/tiles
- to filter the features in the vector tiles of a collection -
/tiles
- to filter the features in the multi-collection vector tiles
Both representations of CQL expressions were supported (cql-text
for text, cql-json
for hierarchical JSON).
Most of the CQL grammar was implemented, with a few limitations:
-
only the temporal operators specified in Filtering Tiles;
-
no existence operators, since their semantics is not well-defined (see Chapter 12);
-
no arithmetic expressions (add, subtract, multiply, divide).
Some examples for filters:
Fetch the agricultural area that contains a point |
|
CQL: |
|
Features: |
Fetch all other agricultural areas (not containing the point) |
|
CQL: |
|
Features: |
Fetch the agricultural areas in a polygon/bbox |
|
CQL: |
|
Features: |
|
Tile: |
Fetch all the other agricultural areas |
|
CQL: |
|
Tile: |
Fetch the major roads in the eastern part of the city that were updated since 2013; only return selected attributes |
|
CQL: |
|
Features: |
|
Tile: |
Fetch the local roads in the eastern part of the city that were updated during 2011 or 2012; only return selected attributes |
|
CQL: |
|
Features: |
|
Tile: |
Fetch the ground transportation features last updated on 12/31/2011 at 11:45:18 UTC |
|
CQL: |
|
Features: |
In a filter on a multi-layer vector tile ldproxy applied the filter on each collection. This implied that the list of collections in the tile has to be restricted to a small set with shared queryables. Otherwise an error was returned since the predicate could not be evaluated for all layers/collections. This is discussed in more detail in Chapter 12.
Fetch a multi-layer tile with Transportation (Ground) curves and Agricultural surfaces updated since 06/05/2012 |
|
CQL: |
|
Tile: |
All the examples above used CQL in the Text variant. The following is a JSON example:
Fetch all Transportation (Ground) curves and Agricultural surfaces updated since 06/05/2012 |
|
CQL: |
|
Features: |
The API was also tested with the GeoSolutions client, where various filters were applied on the vector tiles of the Transportation (Ground) curves. The following are two screenshots of sample filters: