Kontinuation commented on code in PR #787: URL: https://github.com/apache/sedona-db/pull/787#discussion_r3167945578
########## rust/sedona-raster-gdal/src/utils.rs: ########## @@ -0,0 +1,167 @@ +// 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. + +//! Utility functions for loading raster data via GDAL. + +use arrow_array::StructArray; +use datafusion_common::error::Result; +use datafusion_common::exec_datafusion_err; +use sedona_gdal::dataset::Dataset; +use sedona_gdal::gdal::Gdal; +use sedona_gdal::gdal_dyn_bindgen::{GDAL_OF_RASTER, GDAL_OF_READONLY}; +use sedona_gdal::raster::types::DatasetOptions; +use sedona_gdal::spatial_ref::SpatialRef; + +use sedona_raster::builder::RasterBuilder; +use sedona_raster::traits::{BandMetadata, RasterMetadata}; +use sedona_schema::raster::{BandDataType, StorageType}; + +use crate::gdal_common::{gdal_to_band_data_type, nodata_f64_to_bytes}; + +/// Load a raster from any GDAL-openable path as an in-db raster `StructArray`. +/// +/// The `path` can be a regular file path, a `/vsimem/` memory path, +/// a `/vsicurl/` URL, or any other GDAL virtual filesystem path. +pub fn load_as_indb_raster(gdal: &Gdal, path: &str) -> Result<StructArray> { + // Open dataset from path + let dataset = gdal + .open_ex_with_options( Review Comment: I was intended to move it to a dedicated patch. I'll remove it from this patch. -- 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]
