Kontinuation commented on code in PR #591:
URL: https://github.com/apache/sedona-db/pull/591#discussion_r2816689752


##########
rust/sedona-functions/src/sd_format.rs:
##########
@@ -356,6 +359,73 @@ fn list_view_value_to_formatted_value<OffsetSize: 
OffsetSizeTrait>(
     ))
 }
 
+fn raster_value_to_formatted_value(
+    columnar_value: &ColumnarValue,
+    maybe_width_hint: Option<usize>,
+) -> Result<ColumnarValue> {
+    match columnar_value {
+        ColumnarValue::Array(array) => {
+            let struct_array = array.as_struct();
+            let raster_array = RasterStructArray::new(struct_array);
+            let min_output_size = match maybe_width_hint {
+                Some(width_hint) => raster_array.len() * width_hint,
+                None => raster_array.len() * 48,
+            };
+            let mut builder =
+                StringBuilder::with_capacity(raster_array.len(), 
min_output_size.max(1));
+
+            for i in 0..raster_array.len() {
+                if raster_array.is_null(i) {
+                    builder.append_null();
+                    continue;
+                }
+
+                let raster = raster_array.get(i)?;
+                let metadata = raster.metadata();
+                let bands = raster.bands();
+
+                let has_outdb_band = bands.iter().any(|band| {
+                    matches!(band.metadata().storage_type(), 
Ok(StorageType::OutDbRef))
+                });
+
+                let mut limited_output =
+                    LimitedSizeOutput::new(&mut builder, 
maybe_width_hint.unwrap_or(usize::MAX));
+                let _ = write!(
+                    limited_output,
+                    "Raster[w={}, h={}, ul=({:.6}, {:.6}), scale=({:.6}, 
{:.6}), skew=({:.6}, {:.6}), bands={}, outdb={}]",
+                    metadata.width(),
+                    metadata.height(),
+                    metadata.upper_left_x(),
+                    metadata.upper_left_y(),
+                    metadata.scale_x(),
+                    metadata.scale_y(),
+                    metadata.skew_x(),
+                    metadata.skew_y(),
+                    bands.len(),
+                    has_outdb_band
+                );

Review Comment:
   OK. I believe that this format requires the CRS to be abbreviated when it is 
possible. I'll submit the patch for refactoring the CRS abbreviation cache for 
ST_SetCRS before implementing this raster display format.



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