Kontinuation commented on code in PR #2262:
URL: https://github.com/apache/sedona/pull/2262#discussion_r2271765190


##########
common/src/main/java/org/apache/sedona/common/geography/Constructors.java:
##########
@@ -41,6 +41,35 @@ public static Geography geogFromWKT(String wkt, int srid) 
throws ParseException
     return geog;
   }
 
+  public static Geography geogFromEWKT(String ewkt) throws ParseException {
+    if (ewkt == null) {
+      return null;
+    }
+    int SRID = 0;
+    String wkt = ewkt;
+
+    int index = ewkt.indexOf("SRID=");
+    if (index != -1) {
+      int semicolonIndex = ewkt.indexOf(';', index);
+      if (semicolonIndex != -1) {
+        SRID = Integer.parseInt(ewkt.substring(index + 5, semicolonIndex));
+        wkt = ewkt.substring(semicolonIndex + 1);
+      } else {
+        throw new ParseException("Invalid EWKT string");
+      }
+    }
+    try {
+      return geogFromWKT(wkt, SRID);
+    } catch (ParseException e) {
+      String msg = e.getMessage();
+      // Normalize JUST the common JTS phrasing
+      if (msg != null && msg.startsWith("Unknown geometry type:")) {
+        msg = msg.replaceFirst("geometry", "geography");
+      }

Review Comment:
   Is it cleaner to emit exception messages containing "geography" instead of 
"geometry" in S2Geography/WKTReader.java in the first place, so that we don't 
need to do this find and replace here?



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