Skip to content

Commit 9736027

Browse files
authored
Switch pygeofilter to cql2 (#242)
* switch pygeofilter to cql2 * update changelog
1 parent 42cea5d commit 9736027

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- disable transaction and bulk_transactions extensions by default **breaking change**
99
- update `stac-fastapi-*` version requirements to `>=5.2,<6.0`
1010
- add pgstac health-check in `/_mgmt/health`
11+
- switch from using pygeofilter to cql2
1112

1213
## [5.0.2] - 2025-04-07
1314

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"asyncpg",
1616
"buildpg",
1717
"brotli_asgi",
18-
"pygeofilter>=0.2",
18+
"cql2>=0.3.6",
1919
"pypgstac>=0.8,<0.10",
2020
]
2121

stac_fastapi/pgstac/core.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
import orjson
1010
from asyncpg.exceptions import InvalidDatetimeFormatError
1111
from buildpg import render
12+
from cql2 import Expr
1213
from fastapi import HTTPException, Request
1314
from pydantic import ValidationError
14-
from pygeofilter.backends.cql2_json import to_cql2
15-
from pygeofilter.parsers.cql2_text import parse as parse_cql2_text
1615
from pypgstac.hydration import hydrate
1716
from stac_fastapi.api.models import JSONResponse
1817
from stac_fastapi.types.core import AsyncBaseCoreClient, Relations
@@ -556,11 +555,12 @@ def _clean_search_args( # noqa: C901
556555
"""Clean up search arguments to match format expected by pgstac"""
557556
if filter_query:
558557
if filter_lang == "cql2-text":
559-
filter_query = to_cql2(parse_cql2_text(filter_query))
560-
filter_lang = "cql2-json"
561-
562-
base_args["filter"] = orjson.loads(filter_query)
563-
base_args["filter_lang"] = filter_lang
558+
e = Expr(filter_query)
559+
base_args["filter"] = e.to_json()
560+
base_args["filter_lang"] = "cql2-json"
561+
else:
562+
base_args["filter"] = orjson.loads(filter_query)
563+
base_args["filter_lang"] = filter_lang
564564

565565
if datetime:
566566
base_args["datetime"] = datetime

0 commit comments

Comments
 (0)