happydave1 commented on code in PR #1138:
URL: https://github.com/apache/iceberg-go/pull/1138#discussion_r3394253288


##########
table/arrow_utils.go:
##########
@@ -1828,3 +1848,154 @@ func positionDeleteRecordsToDataFilesDV(ctx 
context.Context, rootLocation string
                }
        }
 }
+
+func checkCRSString(rawCrs json.RawMessage) bool {
+       b := bytes.TrimSpace(rawCrs)
+
+       return len(b) > 0 && b[0] == '"'
+}
+
+func checkCRSSJSON(rawCrs json.RawMessage) bool {
+       b := bytes.TrimSpace(rawCrs)
+
+       return len(b) > 0 && b[0] == '{'
+}
+
+func geoArrowCRSToIcebergCRS(meta geoarrow.Metadata) (string, error) {
+       if len(meta.CRS) == 0 {
+               return "srid:0", nil
+       }
+
+       switch {
+       case checkCRSString(meta.CRS):
+               var crs string
+               if len(meta.CRS) > 0 {
+                       if err := json.Unmarshal(meta.CRS, &crs); err != nil {
+                               return "", fmt.Errorf("invalid geoarrow CRS 
metadata: %w", err)
+                       }
+               }
+
+               if strings.EqualFold(crs, "OGC:CRS84") || 
strings.EqualFold(crs, "EPSG:4326") {
+                       return "OGC:CRS84", nil
+               }
+
+               switch meta.CRSType {
+               case geoarrow.CRSTypeSRID:
+                       return "srid:" + crs, nil
+               case geoarrow.CRSTypePROJJSON:
+                       return "", errors.New("JSON object written to crs as 
string")

Review Comment:
   I'm a little confused about what you mean here, do you mean that we should 
remove the `geoarrow.CRSTypePROJJSON` case and just let the projjson case fall 
to default?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to