Skip to content

normalize CQL text support to CQL2 (#2015) #2018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __getattr__(cls, name):
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = {'.rst': 'restructuredtext'}

# The master toctree document.
master_doc = 'index'
Expand Down
22 changes: 11 additions & 11 deletions docs/source/cql.rst → docs/source/cql2.rst
Original file line number Diff line number Diff line change
@@ -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
---------
Expand All @@ -14,7 +14,7 @@ for current provider support.
Limitations
-----------

Support of CQL is limited to `Basic CQL2 <https://docs.ogc.org/is/21-065r2/21-065r2.html#cql2-core>`_ and thus it allows to query with the
Support is limited to `Basic CQL2 <https://docs.ogc.org/is/21-065r2/21-065r2.html#cql2-core>`_ and thus it allows to query with the
following predicates:

* comparison predicates
Expand All @@ -24,9 +24,9 @@ following predicates:
Formats
-------

Supported providers leverage the CQL2 dialect with the JSON encoding `CQL-JSON <https://docs.ogc.org/is/21-065r2/21-065r2.html#cql2-json>`_.
Supported providers leverage the CQL2 dialect with the JSON encoding `CQL JSON <https://docs.ogc.org/is/21-065r2/21-065r2.html#cql2-json>`_.

PostgreSQL supports both `CQL2 JSON <https://docs.ogc.org/is/21-065r2/21-065r2.html#cql2-json>`_ and `CQL text <https://docs.ogc.org/is/21-065r2/21-065r2.html#cql2-text>`_ dialects.
PostgreSQL supports both `CQL JSON <https://docs.ogc.org/is/21-065r2/21-065r2.html#cql2-json>`_ and `CQL Text <https://docs.ogc.org/is/21-065r2/21-065r2.html#cql2-text>`_ dialects.

Queries
^^^^^^^
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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
6 changes: 3 additions & 3 deletions docs/source/data-publishing/ogcapi-features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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:

Expand Down Expand Up @@ -359,7 +359,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:

Expand Down Expand Up @@ -612,7 +612,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
^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/source/data-publishing/ogcapi-records.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ reference documentation on all aspects of the project.
plugins
html-templating
crs
cql
cql2
language
development
ogc-compliance
Expand Down
4 changes: 2 additions & 2 deletions pygeoapi/api/itemtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from typing import Any, Tuple, Union, Optional
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

Expand Down Expand Up @@ -477,7 +477,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,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_postgresql_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import pyproj
from http import HTTPStatus

from pygeofilter.parsers.ecql import parse
from pygeofilter.parsers.cql2_text import parse

from pygeoapi.api import API
from pygeoapi.api.itemtypes import (
Expand Down Expand Up @@ -335,7 +335,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]),
Expand Down
4 changes: 2 additions & 2 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Authors: Tom Kralidis <[email protected]>
#
# Copyright (c) 2021 Tom Kralidis
# Copyright (c) 2025 Tom Kralidis
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
Expand Down Expand Up @@ -38,7 +38,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

Expand Down
Loading