Skip to content

Commit f728f44

Browse files
Merge pull request #251 from developmentseed/fix/bbox-filter-non-epsg4326
fix: bbox filter for non-epsg4326 geometries
2 parents 47e1f09 + 97a7e66 commit f728f44

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

CHANGES.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Note: Minor version `0.X.0` update might break the API, It's recommended to pin
88

99
## [unreleased]
1010

11+
## [1.3.1] - 2026-02-26
12+
13+
* fix: bbox filter when collection's geometry is not in EPSG:4326 CRS
14+
1115
## [1.3.0] - 2025-11-17
1216

1317
* switch to official python docker image from `bitnami`
@@ -425,7 +429,8 @@ Note: Minor version `0.X.0` update might break the API, It's recommended to pin
425429

426430
- Initial release
427431

428-
[unreleased]: https://github.com/developmentseed/tipg/compare/1.3.0...HEAD
432+
[unreleased]: https://github.com/developmentseed/tipg/compare/1.3.1...HEAD
433+
[1.3.1]: https://github.com/developmentseed/tipg/compare/1.3.0...1.3.1
429434
[1.3.0]: https://github.com/developmentseed/tipg/compare/1.2.1...1.3.0
430435
[1.2.1]: https://github.com/developmentseed/tipg/compare/1.2.0...1.2.1
431436
[1.2.0]: https://github.com/developmentseed/tipg/compare/1.1.2...1.2.0

tests/routes/test_items.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,20 @@ def test_items_geo_filter_cql2(app):
390390
Items.model_validate(body)
391391

392392

393-
def test_items_geo_filter_cql2_non_4326_crs(app):
393+
def test_items_geo_filte_non_4326_crs(app):
394394
"""Test CQL2 non 4326 geo filter."""
395395
response = app.get(
396-
"/collections/public.minnesota/items?filter-lang=cql2-text&filter=S_INTERSECTS(geom, POLYGON((-95.5389899 47.5578719,-95.5018943 46.4902864,-94.1637708 46.4891952,-94.1277889 47.5804373,-95.5389899 47.5578719)))"
396+
"/collections/public.minnesota/items?filter-lang=cql2-text&filter=S_INTERSECTS(geom, POLYGON((-95.5389899 46.4902864, -94.1637708 46.4902864, -94.1637708 47.5804373, -95.5389899 47.5804373, -95.5389899 46.4902864)))"
397+
)
398+
399+
assert response.status_code == 200
400+
body = response.json()
401+
assert len(body["features"]) == 2
402+
assert body["numberMatched"] == 2
403+
Items.model_validate(body)
404+
405+
response = app.get(
406+
"/collections/public.minnesota/items?bbox=-95.5389899,46.4902864,-94.1637708,47.5804373"
397407
)
398408

399409
assert response.status_code == 200

tipg/collections.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,12 @@ def _where( # noqa: C901
570570
wheres.append(
571571
logic.Func(
572572
"ST_Intersects",
573-
logic.S(bbox_to_wkt(bbox)),
574573
logic.V(geometry_column.name),
574+
logic.Func(
575+
"ST_Transform",
576+
logic.S(bbox_to_wkt(bbox)),
577+
logic.Func("ST_SRID", logic.V(geometry_column.name)),
578+
),
575579
)
576580
)
577581

0 commit comments

Comments
 (0)