Skip to content

Conversation

@Kontinuation
Copy link
Member

Summary

  • Fix RS_Envelope to return the axis-aligned bounding box (AABB) instead of the convex hull for skewed/rotated rasters, matching PostGIS ST_Envelope semantics.
  • Fix generate_test_rasters to give raster i=0 non-zero scales via i.max(1), so it has an invertible geotransform.
  • Add build_noninvertible_raster() helper to sedona-testing for tests that need a raster with zero scales/skews.
  • Update cascading test expectations in rs_envelope, rs_geotransform, and rs_rastercoordinate.

… rasters

RS_Envelope was returning the convex hull instead of the AABB. Compute
min/max X/Y across all four corners to match PostGIS ST_Envelope
semantics. Also fix generate_test_rasters to give raster i=0 non-zero
scales (i.max(1)), move build_noninvertible_raster helper to
sedona-testing, and update cascading test expectations.
@Kontinuation Kontinuation requested a review from Copilot February 10, 2026 15:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns RS_Envelope semantics with PostGIS ST_Envelope by returning an axis-aligned bounding box (AABB) for skewed/rotated rasters, and updates test raster generation/utilities to avoid accidental non-invertible geotransforms in baseline test data.

Changes:

  • Update RS_Envelope to compute an AABB from raster corner world-coordinates (instead of using the corner polygon/convex hull for skewed rasters).
  • Adjust generate_test_rasters so i=0 has non-zero scales (invertible geotransform), and introduce a dedicated build_noninvertible_raster() helper for inverse-transform error-path testing.
  • Update affected test expectations in raster coordinate, geotransform, and envelope tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
rust/sedona-testing/src/rasters.rs Makes baseline test rasters invertible for i=0 and adds a helper to intentionally produce a non-invertible geotransform.
rust/sedona-raster-functions/src/rs_rastercoordinate.rs Switches non-invertible-geotransform tests to use the new explicit helper raster.
rust/sedona-raster-functions/src/rs_geotransform.rs Updates expected ScaleX/ScaleY values after test raster scale change.
rust/sedona-raster-functions/src/rs_envelope.rs Changes envelope computation to AABB and updates tests/docs to reflect PostGIS-aligned behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +154 to +183
pub fn build_noninvertible_raster() -> StructArray {
let mut builder = RasterBuilder::new(1);
let metadata = RasterMetadata {
width: 1,
height: 1,
upperleft_x: 0.0,
upperleft_y: 0.0,
scale_x: 0.0,
scale_y: 0.0,
skew_x: 0.0,
skew_y: 0.0,
};
let crs = lnglat().unwrap().to_crs_string();
builder
.start_raster(&metadata, Some(&crs))
.expect("start raster");
builder
.start_band(BandMetadata {
datatype: BandDataType::UInt8,
nodata_value: None,
storage_type: StorageType::InDb,
outdb_url: None,
outdb_band_id: None,
})
.expect("start band");
builder.band_data_writer().append_value([0u8]);
builder.finish_band().expect("finish band");
builder.finish_raster().expect("finish raster");
builder.finish().expect("finish")
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_noninvertible_raster() uses unwrap()/expect() throughout. Even in a testing utility crate, it’s typically preferable to return Result<StructArray> and use ? so failures report the real error context (and let the calling test decide to unwrap()). This also keeps the helper consistent with other builders like generate_test_rasters().

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the other test data builders unwrap in place so I think this is OK.

@Kontinuation Kontinuation marked this pull request as ready for review February 10, 2026 15:49
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.

2 participants