From 22550f77f0cc12e9c7e66c868e08273297014767 Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Fri, 23 May 2025 13:09:07 -0400 Subject: [PATCH 1/2] normalize CQL text support to CQL2 (#2015) --- docs/source/{cql.rst => cql2.rst} | 22 +++++++++++----------- docs/source/index.rst | 2 +- docs/source/publishing/ogcapi-features.rst | 8 ++++---- docs/source/publishing/ogcapi-records.rst | 2 +- pygeoapi/api/itemtypes.py | 4 ++-- tests/other/test_crs.py | 2 +- tests/provider/test_postgresql_provider.py | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) rename docs/source/{cql.rst => cql2.rst} (81%) diff --git a/docs/source/cql.rst b/docs/source/cql2.rst similarity index 81% rename from docs/source/cql.rst rename to docs/source/cql2.rst index 66a6d6364..74717e23d 100644 --- a/docs/source/cql.rst +++ b/docs/source/cql2.rst @@ -1,9 +1,9 @@ -.. _cql: +.. _cql2: -CQL support -=========== +CQL2 support +============ -OGC Common Query Language (`CQL2`_) is a generic language designed to provide enhanced query and subset/filtering to (primarily) feature and record data. +`OGC Common Query Language`_ (CQL2) is a generic language designed to provide enhanced query and subset/filtering to (primarily) feature and record data. Providers --------- @@ -14,7 +14,7 @@ for current provider support. Limitations ----------- -Support of CQL is limited to `Basic CQL2 `_ and thus it allows to query with the +Support is limited to `Basic CQL2 `_ and thus it allows to query with the following predicates: * comparison predicates @@ -24,9 +24,9 @@ following predicates: Formats ------- -Supported providers leverage the CQL2 dialect with the JSON encoding `CQL-JSON `_. +Supported providers leverage the CQL2 dialect with the JSON encoding `CQL JSON `_. -PostgreSQL supports both `CQL2 JSON `_ and `CQL text `_ dialects. +PostgreSQL supports both `CQL JSON `_ and `CQL Text `_ dialects. Queries ^^^^^^^ @@ -83,7 +83,7 @@ Or ] }' -The same ``BETWEEN`` query using HTTP GET request formatted as CQL text and URL encoded as below: +The same ``BETWEEN`` query using HTTP GET request formatted as CQL2 text and URL encoded as below: .. code-block:: bash @@ -103,7 +103,7 @@ An ``EQUALS`` example for a specific property: ] }' -A ``CROSSES`` example via an HTTP GET request. The CQL text is passed via the ``filter`` parameter. +A ``CROSSES`` example via an HTTP GET request. The CQL2 text is passed via the ``filter`` parameter. .. code-block:: bash @@ -122,6 +122,6 @@ The same example, but this time providing a geometry in EWKT format: curl "http://localhost:5000/collections/beni/items?filter=DWITHIN(geometry,SRID=3857;POINT(1392921%205145517),100,meters)" -Note that the CQL text has been URL encoded. This is required in curl commands but when entering in a browser, plain text can be used e.g. ``CROSSES(foo_geom, LINESTRING(28 -2, 30 -4))``. +Note that the CQL2 text has been URL encoded. This is required in curl commands but when entering in a browser, plain text can be used e.g. ``CROSSES(foo_geom, LINESTRING(28 -2, 30 -4))``. -.. _`CQL2`: https://docs.ogc.org/is/21-065r2/21-065r2.html +.. _`OGC Common Query Language`: https://docs.ogc.org/is/21-065r2/21-065r2.html diff --git a/docs/source/index.rst b/docs/source/index.rst index 4579a27b3..1430b06dc 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -45,7 +45,7 @@ reference documentation on all aspects of the project. plugins html-templating crs - cql + cql2 language development ogc-compliance diff --git a/docs/source/publishing/ogcapi-features.rst b/docs/source/publishing/ogcapi-features.rst index 8a38e0b98..19558f269 100644 --- a/docs/source/publishing/ogcapi-features.rst +++ b/docs/source/publishing/ogcapi-features.rst @@ -107,7 +107,7 @@ To publish an Elasticsearch index, the following are required in your index: The ES provider also has the support for the CQL queries as indicated in the table above. .. seealso:: - :ref:`cql` for more details on how to use Common Query Language (CQL) to filter the collection with specific queries. + :ref:`cql2` for more details on how to use Common Query Language (CQL) to filter the collection with specific queries. .. _ERDDAP Tabledap Service: @@ -284,7 +284,7 @@ These are optional and if not specified, the default from the engine will be use This provider has support for the CQL queries as indicated in the Provider table above. .. seealso:: - :ref:`cql` for more details on how to use Common Query Language (CQL) to filter the collection with specific queries. + :ref:`cql2` for more details on how to use Common Query Language (CQL) to filter the collection with specific queries. OGR @@ -424,7 +424,7 @@ To publish an OpenSearch index, the following are required in your index: The OpenSearch provider also has the support for the CQL queries as indicated in the table above. .. seealso:: - :ref:`cql` for more details on how to use Common Query Language (CQL) to filter the collection with specific queries. + :ref:`cql2` for more details on how to use Common Query Language (CQL) to filter the collection with specific queries. .. _Oracle: @@ -722,7 +722,7 @@ block contains the necessary socket connection information. This provider has support for the CQL queries as indicated in the Provider table above. .. seealso:: - :ref:`cql` for more details on how to use Common Query Language (CQL) to filter the collection with specific queries. + :ref:`cql2` for more details on how to use Common Query Language (CQL) to filter the collection with specific queries. SQLiteGPKG ^^^^^^^^^^ diff --git a/docs/source/publishing/ogcapi-records.rst b/docs/source/publishing/ogcapi-records.rst index fda95bdbd..f21533de7 100644 --- a/docs/source/publishing/ogcapi-records.rst +++ b/docs/source/publishing/ogcapi-records.rst @@ -54,7 +54,7 @@ To publish an Elasticsearch index, the following are required in your index: The ES provider also has the support for the CQL queries as indicated in the table above. .. seealso:: - :ref:`cql` for more details on how to use Common Query Language (CQL) to filter the collection with specific queries. + :ref:`cql2` for more details on how to use Common Query Language (CQL) to filter the collection with specific queries. TinyDBCatalogue ^^^^^^^^^^^^^^^ diff --git a/pygeoapi/api/itemtypes.py b/pygeoapi/api/itemtypes.py index db0a6e6fb..d11810977 100644 --- a/pygeoapi/api/itemtypes.py +++ b/pygeoapi/api/itemtypes.py @@ -43,7 +43,7 @@ from typing import Any, Tuple, Union import urllib.parse -from pygeofilter.parsers.ecql import parse as parse_ecql_text +from pygeofilter.parsers.cql2_text import parse as parse_cql2_text from pygeofilter.parsers.cql2_json import parse as parse_cql2_json from pyproj.exceptions import CRSError @@ -488,7 +488,7 @@ def get_collection_items( if cql_text is not None: try: - filter_ = parse_ecql_text(cql_text) + filter_ = parse_cql2_text(cql_text) filter_ = modify_pygeofilter( filter_, filter_crs_uri=filter_crs_uri, diff --git a/tests/other/test_crs.py b/tests/other/test_crs.py index 70ec0a46b..a13ee47e3 100644 --- a/tests/other/test_crs.py +++ b/tests/other/test_crs.py @@ -33,7 +33,7 @@ import pytest from pyproj.exceptions import CRSError import pygeofilter.ast -from pygeofilter.parsers.ecql import parse +from pygeofilter.parsers.cql2_text import parse from pygeofilter.values import Geometry from shapely.geometry import Point diff --git a/tests/provider/test_postgresql_provider.py b/tests/provider/test_postgresql_provider.py index b2e5ae0ae..03a98a9dd 100644 --- a/tests/provider/test_postgresql_provider.py +++ b/tests/provider/test_postgresql_provider.py @@ -57,7 +57,7 @@ import pyproj from shapely.geometry import shape as geojson_to_geom -from pygeofilter.parsers.ecql import parse +from pygeofilter.parsers.cql2_text import parse from pygeoapi.api import API from pygeoapi.api.itemtypes import ( @@ -396,7 +396,7 @@ def test_get_not_existing_item_raise_exception(config): 80835475, 80835478, 80835483, 80835486]), ("osm_id BETWEEN 80800000 AND 80900000 AND waterway = 'stream'", [80835470]), - ("osm_id BETWEEN 80800000 AND 80900000 AND waterway ILIKE 'sTrEam'", + ("osm_id BETWEEN 80800000 AND 80900000 AND CASEI(waterway) LIKE 'sTrEam'", [80835470]), ("osm_id BETWEEN 80800000 AND 80900000 AND waterway LIKE 's%'", [80835470]), From b48be17098c78a5d82989d74b6d37089e4204e5d Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Thu, 26 Mar 2026 19:22:05 -0400 Subject: [PATCH 2/2] test CI with pygeofilter main branch --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a9266caec..a6a0d83f9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -129,6 +129,7 @@ jobs: pip3 install -r requirements-pubsub.txt pip3 install . pip3 install GDAL==`gdal-config --version` + pip3 install https://github.com/geopython/pygeofilter/archive/main.zip - name: setup test data ⚙️ run: | python3 tests/load_es_data.py tests/data/ne_110m_populated_places_simple.geojson geonameid