paleolimbot commented on code in PR #300:
URL: https://github.com/apache/sedona-db/pull/300#discussion_r2528051476


##########
rust/sedona-testing/src/rasters.rs:
##########
@@ -65,7 +66,317 @@ pub fn generate_test_rasters(
         builder.finish_raster()?;
     }
 
-    builder.finish()
+    Ok(builder.finish()?)
+}
+
+/// Generates a set of tiled rasters arranged in a grid
+/// - Each raster tile has specified dimensions and random pixel values
+/// - Each raster has 3 bands which can be interpreted as RGB values
+///   and the result can be visualized as a mosaic of tiles.
+/// - There are nodata values at the 4 corners of the overall mosaic.
+pub fn generate_tiled_rasters(
+    tile_size: (usize, usize),
+    number_of_tiles: (usize, usize),
+    data_type: BandDataType,
+) -> Result<StructArray> {

Review Comment:
   Sorry for missing this in the last round, but there should probably be a 
`seed` so that the data run through our tests is deterministic.



##########
rust/sedona-testing/src/rasters.rs:
##########
@@ -115,4 +426,84 @@ mod tests {
             assert_eq!(actual_pixel_values, expected_pixel_values);
         }
     }
+
+    #[test]
+    fn test_generate_tiled_rasters() {
+        let tile_size = (64, 64);
+        let number_of_tiles = (4, 4);
+        let data_type = BandDataType::UInt8;
+        let struct_array = generate_tiled_rasters(tile_size, number_of_tiles, 
data_type).unwrap();
+        let raster_array = RasterStructArray::new(&struct_array);
+        assert_eq!(raster_array.len(), 16); // 4x4 tiles
+        for i in 0..16 {
+            let raster = raster_array.get(i).unwrap();
+            let metadata = raster.metadata();
+            assert_eq!(metadata.width(), 64);
+            assert_eq!(metadata.height(), 64);
+            assert_eq!(metadata.upper_left_x(), ((i % 4) * 64) as f64);
+            assert_eq!(metadata.upper_left_y(), ((i / 4) * 64) as f64);
+            let bands = raster.bands();
+            assert_eq!(bands.len(), 3);
+            for band_index in 0..3 {
+                let band = bands.band(band_index + 1).unwrap();
+                let band_metadata = band.metadata();
+                assert_eq!(band_metadata.data_type(), BandDataType::UInt8);
+                assert_eq!(band_metadata.storage_type(), StorageType::InDb);
+                let band_data = band.data();
+                assert_eq!(band_data.len(), 64 * 64); // 4096 pixels
+            }
+        }
+    }
+
+    #[test]
+    fn test_raster_arrays_equal() {
+        let raster_array1 = generate_test_rasters(3, None).unwrap();
+        let raster_struct_array1 = RasterStructArray::new(&raster_array1);
+        // Test that identical arrays are equal
+        assert_raster_arrays_equal(&raster_struct_array1, 
&raster_struct_array1);
+    }
+
+    #[test]
+    #[should_panic]

Review Comment:
   ```suggestion
       #[should_panic = "Raster array lengths do not match"]
   ```
   
   If this works we should do it (to make sure this test doesn't panic for an 
unrelated reason). You should be able to paste whatever the panic error is here 
(I forget if the specified string has to be exact or whether it can be a 
partial match).



-- 
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]

Reply via email to