jesspav commented on code in PR #311:
URL: https://github.com/apache/sedona-db/pull/311#discussion_r2539733901
##########
rust/sedona-raster-functions/src/rs_geotransform.rs:
##########
@@ -0,0 +1,317 @@
+// Licensed to the Apache Software Foundatio//pub fn rs_upperleftx_udf() ->
SedonaScapub fn rs_scalex_udf() pub fn rs_scaley_udf() -pub fn rs_skewx_udf()
->pub fn rs_skewy_udf() -> SedonaScalarUDF {
+// 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 std::{sync::Arc, vec};
+
+use crate::executor::RasterExecutor;
+use arrow_array::builder::Float64Builder;
+use arrow_schema::DataType;
+use datafusion_common::error::Result;
+use datafusion_expr::{
+ scalar_doc_sections::DOC_SECTION_OTHER, ColumnarValue, Documentation,
Volatility,
+};
+use sedona_expr::scalar_udf::{SedonaScalarKernel, SedonaScalarUDF};
+use sedona_raster::traits::RasterRef;
+use sedona_schema::{datatypes::SedonaType, matchers::ArgMatcher};
+
+/// RS_UpperLeftX() scalar UDF implementation
+///
+/// Extract the raster's upper left corner's
+/// X coordinate
+pub fn rs_upperleftx_udf() -> SedonaScalarUDF {
+ SedonaScalarUDF::new(
+ "rs_upperleftx",
+ vec![Arc::new(RsGeoTransform {
+ param: GeoTransformParam::UpperLeftX,
+ })],
+ Volatility::Immutable,
+ Some(rs_upperleftx_doc()),
+ )
+}
+
+/// RS_UpperLeftY() scalar UDF implementation
+///
+/// Extract the raster's upper left corner's
+/// Y coordinate
+pub fn rs_upperlefty_udf() -> SedonaScalarUDF {
+ SedonaScalarUDF::new(
+ "rs_upperlefty",
+ vec![Arc::new(RsGeoTransform {
+ param: GeoTransformParam::UpperLeftY,
+ })],
+ Volatility::Immutable,
+ Some(rs_upperlefty_doc()),
+ )
+}
+
+/// RS_ScaleX() scalar UDF implementation
+///
+/// Extract the raster's pixel width or scale parameter
+/// in the X direction
+pub fn rs_scalex_udf() -> SedonaScalarUDF {
+ SedonaScalarUDF::new(
+ "rs_scalex",
+ vec![Arc::new(RsGeoTransform {
+ param: GeoTransformParam::ScaleX,
+ })],
+ Volatility::Immutable,
+ Some(rs_scalex_doc()),
+ )
+}
+
+/// RS_ScaleY() scalar UDF implementation
+///
+/// Extract the raster's pixel height or scale
+/// parameter in the Y direction
+pub fn rs_scaley_udf() -> SedonaScalarUDF {
+ SedonaScalarUDF::new(
+ "rs_scaley",
+ vec![Arc::new(RsGeoTransform {
+ param: GeoTransformParam::ScaleY,
+ })],
+ Volatility::Immutable,
+ Some(rs_scaley_doc()),
+ )
+}
+
+/// RS_SkewX() scalar UDF implementation
+///
+/// Extract the raster's X skew (rotation) parameter
+/// from the geotransform
+pub fn rs_skewx_udf() -> SedonaScalarUDF {
+ SedonaScalarUDF::new(
+ "rs_skewx",
+ vec![Arc::new(RsGeoTransform {
+ param: GeoTransformParam::SkewX,
+ })],
+ Volatility::Immutable,
+ Some(rs_skewx_doc()),
+ )
+}
+
+/// RS_SkewY() scalar UDF implementation
+///
+/// Extract the raster's Y skew (rotation) parameter
+/// from the geotransform.
+pub fn rs_skewy_udf() -> SedonaScalarUDF {
+ SedonaScalarUDF::new(
+ "rs_skewy",
+ vec![Arc::new(RsGeoTransform {
+ param: GeoTransformParam::SkewY,
+ })],
+ Volatility::Immutable,
+ Some(rs_skewy_doc()),
+ )
+}
+
+fn rs_upperleftx_doc() -> Documentation {
+ Documentation::builder(
+ DOC_SECTION_OTHER,
+ "Returns the X coordinate of the upper-left corner of the
raster.".to_string(),
+ "RS_UpperLeftX(raster: Raster)".to_string(),
+ )
+ .with_argument("raster", "Raster: Input raster")
+ .with_sql_example("SELECT RS_UpperLeftX(raster)".to_string())
Review Comment:
Sure! switched
--
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]