jesspav commented on code in PR #268:
URL: https://github.com/apache/sedona-db/pull/268#discussion_r2491839962


##########
rust/sedona-testing/src/rasters.rs:
##########
@@ -0,0 +1,118 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+use arrow_array::StructArray;
+use arrow_schema::ArrowError;
+use sedona_raster::builder::RasterBuilder;
+use sedona_raster::traits::{BandMetadata, RasterMetadata};
+use sedona_schema::raster::{BandDataType, StorageType};
+
+/// Generate a StructArray of rasters with sequentially increasing dimensions 
and pixel values
+/// These tiny rasters are to provide fast, easy and predictable test data for 
unit tests.
+pub fn generate_test_rasters(
+    count: usize,
+    null_raster_index: Option<usize>,
+) -> Result<StructArray, ArrowError> {
+    let mut builder = RasterBuilder::new(count);
+    for i in 0..count {
+        // If a null raster index is specified and that matches the current 
index,
+        // append a null raster
+        if matches!(null_raster_index, Some(index) if index == i) {
+            builder.append_null()?;
+            continue;
+        }
+
+        let raster_metadata = RasterMetadata {
+            width: i as u64 + 1,
+            height: i as u64 + 2,
+            upperleft_x: i as f64 + 1.0,
+            upperleft_y: i as f64 + 2.0,
+            scale_x: i as f64 * 0.1,
+            scale_y: i as f64 * 0.2,
+            skew_x: i as f64 * 0.3,
+            skew_y: i as f64 * 0.4,
+        };
+        builder.start_raster(&raster_metadata, None)?;
+        builder.start_band(BandMetadata {
+            datatype: BandDataType::UInt16,
+            nodata_value: Some(vec![0u8; 2]),
+            storage_type: StorageType::InDb,
+            outdb_url: None,
+            outdb_band_id: None,
+        })?;
+
+        let pixel_count = i * (i + 1);

Review Comment:
   Thanks! I changed it to avoid zeros and then forgot to update it here.



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