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


##########
spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/geography/Constructors.scala:
##########
@@ -37,11 +37,25 @@ private[apache] case class ST_GeogFromWKT(inputExpressions: 
Seq[Expression])
   }
 }
 
+/**
+ * Return a Geography from a EWKT string
+ *
+ * @param inputExpressions
+ *   This function takes a geography string. The string format must be EWKT. / 
string.

Review Comment:
   The comment has a malformed ending '/ string.' which appears to be a 
copy-paste artifact and should be removed for clarity.
   ```suggestion
    *   This function takes a geography string. The string format must be EWKT.
   ```



##########
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");

Review Comment:
   The error message 'Invalid EWKT string' is not specific enough. It should 
indicate that the SRID declaration is missing a semicolon separator, e.g., 
'Invalid EWKT format: missing semicolon after SRID declaration'.
   ```suggestion
           throw new ParseException("Invalid EWKT format: missing semicolon 
after SRID declaration");
   ```



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