Skip to content

[GH-3155] Transform query geometry into raster CRS for RS_ predicates - #3507

Open
ump45nose wants to merge 1 commit into
apache:masterfrom
ump45nose:fix/3155-raster-pred-geom-to-raster-crs
Open

ump45nose wants to merge 1 commit into
apache:masterfrom
ump45nose:fix/3155-raster-pred-geom-to-raster-crs

Conversation

@ump45nose

Copy link
Copy Markdown
Contributor

Did you read the Contributor Guide?

Is this PR related to a ticket?

Also addresses the polar false-negative repro in #3323 (same root cause: corner-only WGS84 chords).

What changes were proposed in this PR?

For cross-CRS RS_Intersects / RS_Contains / RS_Within (raster vs geometry), prefer transforming the query geometry into the raster's CRS and comparing there, instead of reprojecting both sides to WGS84.

A raster footprint is an exact straight-edged quadrilateral in its native CRS (pixel→world is affine). Reprojecting only the four corners to WGS84 under-covers curved edges — dramatically so for polar rasters (#3323). Moving the transform onto the (usually smaller) geometry keeps the footprint exact and matches SedonaDB's rs_spatial_predicates preference.

If transforming the geometry into the raster CRS fails, fall back to the previous both-to-WGS84 path (preserves antimeridian behavior). Raster–raster predicates still compare in WGS84 for the same antimeridian safety.

How was this patch tested?

mvn -pl common test -Dtest=RasterPredicatesTest

All 33 tests pass, including a new testIntersectsPolarRasterInNativeCrs covering the EPSG:3413 2000 km north-pole square repro from #3323 (POINT(45 82), POINT(180 85), POINT(0 85), POINT(90 85) → intersect/contain true; POINT(0 60) → false).

Did this PR include necessary documentation updates?

  • No, this PR does not affect any public API so no need to change the documentation.

AI assistance

Assisted by an AI coding agent (Cursor / Grok Bot) for implementation and test drafting; human review of the approach and validation against SedonaDB parity and existing antimeridian tests.

…icates

Cross-CRS RS_Intersects/Contains/Within previously reprojected both the
raster footprint and the query into WGS84. Corner-only chords under-cover
polar and other highly curved footprints (apache#3323). Prefer transforming the
geometry into the raster's native CRS (SedonaDB parity) so the footprint
stays exact; fall back to WGS84 when that transform fails. Raster-raster
predicates keep the WGS84 path for antimeridian safety.

Signed-off-by: Vincent <ump45nose@users.noreply.github.com>
@ump45nose
ump45nose requested a review from jiayuasu as a code owner October 28, 2026 15:37

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RS_ raster predicates: transform geometry into the raster CRS for cross-CRS comparison (match SedonaDB)

1 participant