jesspav commented on code in PR #253: URL: https://github.com/apache/sedona-db/pull/253#discussion_r2474194931
########## rust/sedona-raster/src/builder.rs: ########## @@ -0,0 +1,1600 @@ +// 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::BinaryViewArray; +use arrow_array::{ + builder::{ + BinaryBuilder, BinaryViewBuilder, Float64Builder, ListBuilder, StringBuilder, + StringViewBuilder, StructBuilder, UInt32Builder, UInt64Builder, + }, + Array, BinaryArray, Float64Array, ListArray, StringArray, StringViewArray, StructArray, + UInt32Array, UInt64Array, +}; +use arrow_schema::{ArrowError, DataType, Field}; +use datafusion_common::error::Result; +use sedona_schema::raster::{ + band_indices, band_metadata_indices, bounding_box_indices, column, metadata_indices, + raster_indices, BandDataType, RasterSchema, StorageType, +}; + +/// Builder for constructing raster arrays with zero-copy band data writing +pub struct RasterBuilder { + main_builder: StructBuilder, +} + +/// Metadata for a raster +#[derive(Debug, Clone)] +pub struct RasterMetadata { + pub width: u64, + pub height: u64, + pub upperleft_x: f64, + pub upperleft_y: f64, + pub scale_x: f64, + pub scale_y: f64, + pub skew_x: f64, + pub skew_y: f64, +} + +/// Bounding box coordinates +#[derive(Debug, Clone)] +pub struct BoundingBox { + pub min_x: f64, + pub min_y: f64, + pub max_x: f64, + pub max_y: f64, +} Review Comment: I love the idea of unifying them - it'll make raster-geometry intersections much cleaner. Looking at the potential differences: 1. CRS handling: Raster bounding boxes are typically in EPSG:4326, while geometry bounding boxes inherit the CRS from their geometries. 2. Dimensionality: Geometries can have Z coordinates in their bounding boxes, while raster bounding boxes are typically 2D (though rasters may have elevation data, that's separate from the spatial bounds). For 1, we could consider adding a CRS to the BoundingBox to avoid bugs. Good utility functions will also help with this. For 2, we are find as we only consider z-coordinates in the bounding box intersection if both have them have it defined ([ref](https://github.com/apache/sedona-db/blob/0551583a675da1cf5cc61cb7c7a61352051f1fc6/rust/sedona-geometry/src/bounding_box.rs#L100)) I'll explore making this switch today. -- 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]
