paleolimbot commented on code in PR #1056:
URL: https://github.com/apache/sedona-db/pull/1056#discussion_r3603460102
##########
rust/sedona-raster-functions/src/rs_example.rs:
##########
@@ -116,23 +114,19 @@ mod tests {
let arg_types = vec![];
let result = kernel.invoke_batch(&arg_types, &args).unwrap();
- if let ColumnarValue::Scalar(ScalarValue::Struct(arc_struct)) = result
{
- let raster_array =
RasterStructArray::try_new(arc_struct.as_ref()).unwrap();
-
- assert_eq!(raster_array.len(), 1);
- let raster = raster_array.get(0).unwrap();
- let metadata = raster.metadata();
- assert_eq!(metadata.width(), 64);
- assert_eq!(metadata.height(), 32);
-
- let bands = raster.bands();
- let band = bands.band(1).unwrap();
- let band_metadata = band.metadata();
- assert_eq!(band_metadata.data_type().unwrap(),
BandDataType::UInt8);
- assert_eq!(band_metadata.nodata_value(), Some(&[127u8][..]));
- assert_eq!(band_metadata.storage_type().unwrap(),
StorageType::InDb);
- } else {
+ let ColumnarValue::Scalar(scalar) = result else {
panic!("Expected scalar struct result");
+ };
+
+ // RS_Example builds a 64x32, 3-band UInt8 raster with origin
+ // (43.08, 79.07), scale 2, skew 1, nodata 127. Every pixel of band N
+ // is N except the top-left corner, which is set to the nodata value.
+ let mut expected = RasterSpec::d2(64, 32).transform([43.08, 2.0, 1.0,
79.07, 1.0, 2.0]);
Review Comment:
Can this use the bbox setter or is this transform value significant?
##########
rust/sedona-raster-functions/src/rs_setsrid.rs:
##########
@@ -395,9 +395,33 @@ mod tests {
use sedona_raster::traits::RasterRef;
use sedona_schema::crs::deserialize_crs;
use sedona_schema::datatypes::RASTER;
+ use sedona_testing::raster_spec::{assert_rasters_equal, RasterSpec};
use sedona_testing::rasters::generate_test_rasters;
use sedona_testing::testers::ScalarUdfTester;
+ /// The non-null raster that [`generate_test_rasters`] produces at index
+ /// `i`, expressed as a declarative spec: the same per-index geotransform
+ /// arithmetic and sequential UInt16 pixels with nodata 0. Used as the
+ /// expected side after an RS_SetSRID/RS_SetCRS, which only swaps the CRS
+ /// and preserves everything else — so callers append `.crs(...)` with the
+ /// CRS they expect.
+ fn generated_raster_spec(i: usize) -> RasterSpec {
Review Comment:
We have some other raster example generators (maybe in sedona-testing
somewhere)...is this generator unique to set_srid or can/should it be reused?
##########
rust/sedona-raster-functions/src/rs_setsrid.rs:
##########
@@ -395,9 +395,33 @@ mod tests {
use sedona_raster::traits::RasterRef;
use sedona_schema::crs::deserialize_crs;
use sedona_schema::datatypes::RASTER;
+ use sedona_testing::raster_spec::{assert_rasters_equal, RasterSpec};
use sedona_testing::rasters::generate_test_rasters;
use sedona_testing::testers::ScalarUdfTester;
+ /// The non-null raster that [`generate_test_rasters`] produces at index
+ /// `i`, expressed as a declarative spec: the same per-index geotransform
+ /// arithmetic and sequential UInt16 pixels with nodata 0. Used as the
+ /// expected side after an RS_SetSRID/RS_SetCRS, which only swaps the CRS
+ /// and preserves everything else — so callers append `.crs(...)` with the
+ /// CRS they expect.
+ fn generated_raster_spec(i: usize) -> RasterSpec {
+ let width = i as i64 + 1;
+ let height = i as i64 + 2;
+ let pixels: Vec<u16> = (0..(width * height) as u16).collect();
+ RasterSpec::d2(width, height)
+ .transform([
+ i as f64 + 1.0,
+ i.max(1) as f64 * 0.1,
+ i as f64 * 0.03,
+ i as f64 + 2.0,
+ i as f64 * 0.04,
+ i.max(1) as f64 * -0.2,
+ ])
Review Comment:
Can this now use the bbox setter?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]