apache / apache/sedona-db

RS_Within turns antimeridian- and pole-wrapping footprints inside out when reprojecting into the geometry's CRS

Open
#1,240 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
503
Forks
61
Avg merge
2d 4h
Merged PRs (30d)
90

Description

`RS_Within` reprojects the raster's (densified) footprint into the geometry's CRS and evaluates the predicate in that flat plane. When the footprint wraps a projection singularity, its interior maps to the *edges* of the target plane and the reprojected ring turns inside out — no amount of edge densification fixes the topology — so SedonaDB answers false for rasters that are truly within the geometry:

**Antimeridian**: an EPSG:3413 square centred on the longitude-180 direction (bbox `(-1330942, 730942, -730942, 1330942)`, corner longitudes ±163.8 and ±180) is truly within the two-lobe region `MULTIPOLYGON(((160 70, 180 70, 180 84, 160 84, ...)), ((-180 70, -160 70, ...)))` — every footprint point lies in a lobe. `RS_Within` returns **false**: the densified footprint's longitudes jump across ±180, and the resulting flat polygon is not within either lobe. (Sedona Spark transforms the geometry into the raster's CRS instead and answers true here.)

**Pole**: the ±1e6 EPSG:3413 pole square is truly within `POLYGON((-180 75, 180 75, 180 90, -180 90, -180 75))` (the latitude-75 cap contains it — footprint latitudes stay above 77). `RS_Within` returns **false**; the pole in the footprint's interior maps to the degenerate latitude-90 edge. (Sedona Spark throws on this one — its corner-only reprojection is apache/sedona#3323 — so on this shape *both* engines fail, in different ways.)

Surfaced by `integration/spark-parity`, where these are xfail-cataloged with truth anchors. A footprint that crosses ±180 or contains the pole in the geometry's CRS needs either evaluation in the raster's CRS (transform the geometry instead, as the intersects path effectively achieves) or split/clamped handling of the seam.

Contributor guide

Open the contributing guide

Research direction

Start by locating the RS_Within implementation and reviewing the integration/spark-parity xfail cases with their truth anchors. Compare its footprint reprojection with the intersects path, then determine how antimeridian and pole-wrapping footprints should be handled. Done means the antimeridian and pole examples return the expected containment results without breaking ordinary cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.