BlakeOrth commented on code in PR #8801:
URL: https://github.com/apache/arrow-rs/pull/8801#discussion_r2519218649


##########
parquet-geospatial/src/crs.rs:
##########
@@ -0,0 +1,59 @@
+use std::{collections::HashMap, sync::Arc};
+
+use arrow_schema::{Schema, SchemaBuilder};
+use serde::{Deserialize, Serialize};
+
+#[derive(Debug, Default, Serialize, Deserialize)]
+pub struct Crs {
+    crs: Option<String>,
+    crs_type: Option<String>,
+}
+
+impl Crs {
+    // TODO: make fallible
+    fn try_from_parquet_str(crs: &str, metadata: &HashMap<String, String>) -> 
Self {
+        let crs: Crs = serde_json::from_str(crs).unwrap();
+
+        let Some(crs_value) = &crs.crs else {
+            return crs;
+        };
+
+        let Some(key) = crs_value.strip_prefix("projjson:") else {
+            return crs;
+        };
+
+        let Some(proj_meta) = metadata.get(key) else {
+            return crs;
+        };
+
+        Self {
+            crs: Some(proj_meta.clone()),
+            crs_type: Some(String::from("projjson")),
+        }
+    }
+
+    pub(super) fn to_arrow_string(&self) -> String {
+        serde_json::to_string(&self).unwrap_or_default()
+    }

Review Comment:
   Pending some decisions related to my comment here: 
https://github.com/apache/arrow-rs/pull/8801#discussion_r2519206709 I get the 
sense this method may just disappear entirely. Right now it's mostly poorly 
named since we aren't really converting things to "arrow" anymore anyway.
   
   That being said, I will keep an eye out for a good place to check the 
incoming CRS value for JSON to avoid the double escaped string issues!



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