paleolimbot commented on code in PR #591:
URL: https://github.com/apache/sedona-db/pull/591#discussion_r2807574357
##########
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:
At least for rasters that are not rotated or skewed, what I would really
like to know are the bounds and CRS. Can this output be more like:
```
[WxH/nbands] @ [xmin ymin xmax ymax] / crs <outdb>
```
That may be a little more compact. Even for skewed data the 2D bounds are
probably more useful output for human reading.
(Drawing from the last time I had to decide this:
https://paleolimbot.github.io/wk/reference/grd.html )
##########
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 {
Review Comment:
The logic for displaying individual raster items should probably live in
sedona-raster
--
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]