b4l commented on code in PR #471:
URL: https://github.com/apache/sedona-db/pull/471#discussion_r2777765669


##########
rust/sedona-pointcloud/src/laz/options.rs:
##########
@@ -0,0 +1,150 @@
+// 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 std::{fmt::Display, str::FromStr};
+
+use datafusion_common::{
+    config::{ConfigExtension, ConfigField, Visit},
+    error::DataFusionError,
+    extensions_options,
+};
+
+/// Geometry representation
+#[derive(Clone, Copy, Default, PartialEq, Eq, Debug)]
+pub enum LasPointEncoding {
+    /// Use plain coordinates as three fields `x`, `y`, `z` with datatype 
Float64 encoding.
+    #[default]
+    Plain,
+    /// Resolves the coordinates to a fields `geometry` with WKB encoding.
+    Wkb,
+    /// Resolves the coordinates to a fields `geometry` with separated 
GeoArrow encoding.
+    Native,
+}
+
+impl Display for LasPointEncoding {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        match self {
+            LasPointEncoding::Plain => f.write_str("plain"),
+            LasPointEncoding::Wkb => f.write_str("wkb"),
+            LasPointEncoding::Native => f.write_str("nativ"),
+        }
+    }
+}
+
+impl FromStr for LasPointEncoding {
+    type Err = String;
+
+    fn from_str(s: &str) -> Result<Self, Self::Err> {
+        match s.to_lowercase().as_str() {
+            "plain" => Ok(Self::Plain),
+            "wkb" => Ok(Self::Wkb),
+            "native" => Ok(Self::Native),
+            s => Err(format!("Unable to parse from `{s}`")),
+        }
+    }
+}
+
+impl ConfigField for LasPointEncoding {
+    fn visit<V: Visit>(&self, v: &mut V, key: &str, _description: &'static 
str) {
+        v.some(
+            &format!("{key}.point_encoding"),
+            self,
+            "Specify point encoding",
+        );
+    }
+
+    fn set(&mut self, _key: &str, value: &str) -> Result<(), DataFusionError> {
+        *self = value.parse().map_err(DataFusionError::Configuration)?;
+        Ok(())
+    }
+}
+
+/// LAS extra bytes handling
+#[derive(Clone, Copy, Default, PartialEq, Eq, Debug)]
+pub enum LasExtraBytes {
+    /// Resolve to typed and named attributes
+    Typed,
+    /// Keep as binary blob
+    Blob,
+    /// Drop/ignore extrabytes
+    #[default]
+    Ignore,
+}
+
+impl Display for LasExtraBytes {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        match self {
+            LasExtraBytes::Typed => f.write_str("typed"),
+            LasExtraBytes::Blob => f.write_str("blob"),
+            LasExtraBytes::Ignore => f.write_str("ignore"),
+        }
+    }
+}
+
+impl FromStr for LasExtraBytes {
+    type Err = String;
+
+    fn from_str(s: &str) -> Result<Self, Self::Err> {
+        match s.to_lowercase().as_str() {
+            "typed" => Ok(Self::Typed),
+            "blob" => Ok(Self::Blob),
+            "ignore" => Ok(Self::Ignore),
+            s => Err(format!("Unable to parse from `{s}`")),
+        }
+    }
+}
+
+impl ConfigField for LasExtraBytes {
+    fn visit<V: Visit>(&self, v: &mut V, key: &str, _description: &'static 
str) {
+        v.some(
+            &format!("{key}.extra_bytes"),
+            self,
+            "Specify extra bytes handling",
+        );
+    }
+
+    fn set(&mut self, _key: &str, value: &str) -> Result<(), DataFusionError> {
+        *self = value.parse().map_err(DataFusionError::Configuration)?;
+        Ok(())
+    }
+}
+
+// Define a new configuration struct using the `extensions_options` macro
+extensions_options! {
+    /// The LAZ config options
+    pub struct LazTableOptions {
+        pub point_encoding: LasPointEncoding, default = 
LasPointEncoding::default()
+        pub extra_bytes: LasExtraBytes, default = LasExtraBytes::default()
+    }
+
+}
+
+impl ConfigExtension for LazTableOptions {
+    const PREFIX: &'static str = "laz";
+}

Review Comment:
   I refactored the config in 
https://github.com/apache/sedona-db/pull/471/commits/43803c3a79bd30414f8a1823330aad31527b75f3
 to reflect the potential scope of future usage.



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