cql2-json: {"bbox": ...} literals scramble axes through values.Envelope field order
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
Research direction
Start in parsers/cql2_json/parser.py at the BBox construction on lines 78-79, then compare its field ordering with the cql2-text parser and the SQLAlchemy backend's envelope handler. Verify the example New York bbox through parse_bbox; done means GeoJSON [minx, miny, maxx, maxy] becomes Envelope(minx, maxx, miny, maxy) without axis scrambling.
Written by the indexing model from the issue text.
Description
parsers/cql2_json/parser.py builds a BBox literal with values.Envelope(*node["bbox"]):
https://github.com/geopython/pygeofilter/blob/master/pygeofilter/parsers/cql2_json/parser.py#L78-L79
A GeoJSON-order bbox [minx, miny, maxx, maxy] therefore lands in Envelope(x1, x2, y1, y2) as x1=minx, x2=miny, y1=maxx, y2=maxy.
Since #147, the convention used by the cql2-text parser and the SQLAlchemy backend is x1=minx, x2=maxx, y1=miny, y2=maxy (the backend's envelope handler passes [x1, y1, x2, y2] to parse_bbox, and #147's test expects Envelope(-180, 180, -90, 90) for the global box). Through that convention the JSON construction mixes longitudes and latitudes.
Concrete effect via the SQLAlchemy backend: for {"bbox": [-74.1, 40.5, -73.9, 41.0]} (a ~20 km box over New York) the backend's envelope handler hands [x1, y1, x2, y2] = [-74.1, -73.9, 40.5, 41.0] to parse_bbox, which renders a polygon spanning x from -74.1 to 40.5 and y from -73.9 to 41.0 (roughly 114 by 115 degrees), so S_INTERSECTS silently matches a large part of the hemisphere rather than erroring.
Expected: Envelope(minx, maxx, miny, maxy), i.e. values.Envelope(b[0], b[2], b[1], b[3]).
Found while wiring pygeofilter 0.4.0 into an OGC API Features Part 3 endpoint; we currently rewrite {"bbox": ...} nodes to explicit GeoJSON Polygons before parsing to avoid the scramble.
- Dominant language
- Python
- Stars
- 90
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from geopython/pygeofilter
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
geopython/pygeofilter#165 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
geopython/pygeofilter#164 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
geopython/pygeofilter#162 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
geopython/pygeofilter#144 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 72/100
geopython/pygeofilter#160 ·
All issues in geopython/pygeofilter
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100