SW186000 commented on code in PR #686:
URL: https://github.com/apache/incubator-sedona/pull/686#discussion_r973687470


##########
common/src/main/java/org/apache/sedona/common/Functions.java:
##########
@@ -142,12 +143,53 @@ public static Geometry transform(Geometry geometry, 
String sourceCRS, String tar
 
     public static Geometry transform(Geometry geometry, String sourceCRS, 
String targetCRS, boolean lenient)
         throws FactoryException, TransformException {
-        CoordinateReferenceSystem sourceCRScode = CRS.decode(sourceCRS);
-        CoordinateReferenceSystem targetCRScode = CRS.decode(targetCRS);
+
+        CoordinateReferenceSystem sourceCRScode = parseCRSString(sourceCRS);
+        CoordinateReferenceSystem targetCRScode = parseCRSString(targetCRS);
         MathTransform transform = CRS.findMathTransform(sourceCRScode, 
targetCRScode, lenient);
         return JTS.transform(geometry, transform);
     }
 
+    private static CoordinateReferenceSystem parseCRSString(String CRSString) 
throws FactoryException{
+        if (checkCRSCodeFormat(CRSString) ){
+            return CRS.decode(CRSString);
+        }
+        else if (checkCRSWKTFormat(CRSString)){
+            return CRS.parseWKT(CRSString);
+        }
+        else {
+            return null;
+        }
+    }
+
+    private static boolean checkCRSCodeFormat(String CRSCode) {
+        try{
+            CRS.decode(CRSCode);
+        }
+        catch (FactoryException ex){
+            return false;
+        }
+
+        return true;
+    }
+
+    private static boolean checkCRSWKTFormat(String CRSWKT) {
+        try{
+            CRS.parseWKT(CRSWKT);
+        }
+        catch (FactoryException ex){
+            return false;
+        }
+
+        return true;
+    }
+
+    public static Geometry transform(Geometry geometry, 
CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, 
boolean lenient)
+        throws FactoryException,TransformException {
+        MathTransform transform = 
CRS.findMathTransform(sourceCRS,targetCRS,lenient);
+        return JTS.transform(geometry, transform);
+    }

Review Comment:
   Sorry for reply. 
   I forgot deleting this function.
   i will delete it.



-- 
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: dev-unsubscr...@sedona.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to