This is an automated email from the ASF dual-hosted git repository.

jiayu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-sedona.git


The following commit(s) were added to refs/heads/master by this push:
     new cd3ef7a4 [SEDONA-206] Performance regression of ST_Transform (#727)
cd3ef7a4 is described below

commit cd3ef7a4add68930f6dd139f8e3b290f5cfe2c0d
Author: Jia Yu <[email protected]>
AuthorDate: Sun Dec 11 22:00:56 2022 -0800

    [SEDONA-206] Performance regression of ST_Transform (#727)
---
 .../main/java/org/apache/sedona/common/Functions.java  | 18 +++++++++---------
 .../org/apache/sedona/sql/functionTestScala.scala      |  4 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/common/src/main/java/org/apache/sedona/common/Functions.java 
b/common/src/main/java/org/apache/sedona/common/Functions.java
index 5db853fa..af83d434 100644
--- a/common/src/main/java/org/apache/sedona/common/Functions.java
+++ b/common/src/main/java/org/apache/sedona/common/Functions.java
@@ -191,20 +191,20 @@ public class Functions {
         return JTS.transform(geometry, transform);
     }
 
-    private static CoordinateReferenceSystem parseCRSString(String CRSString) 
throws FactoryException {
+    private static CoordinateReferenceSystem parseCRSString(String CRSString)
+            throws FactoryException
+    {
         try {
-            return CRS.parseWKT(CRSString);
+            return CRS.decode(CRSString);
         }
-        catch (FactoryException ex1) {
+        catch (NoSuchAuthorityCodeException e) {
             try {
-                return CRS.decode(CRSString);
-            } catch (NoSuchAuthorityCodeException ex4) {
-                throw new NoSuchAuthorityCodeException("that Authority code 
cannot be found", CRSString, CRSString);
-            } catch (FactoryException ex6) {
-                throw new FactoryException("WKT format is illegal");
+                return CRS.parseWKT(CRSString);
+            }
+            catch (FactoryException ex) {
+                throw new FactoryException("First failed to read as a 
well-known CRS code: \n" + e.getMessage() + "\nThen failed to read as a WKT CRS 
string: \n" + ex.getMessage());
             }
         }
-
     }
 
     public static Geometry flipCoordinates(Geometry geometry) {
diff --git a/sql/src/test/scala/org/apache/sedona/sql/functionTestScala.scala 
b/sql/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
index f69a6de8..34b0581b 100644
--- a/sql/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
+++ b/sql/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
@@ -29,7 +29,7 @@ import org.locationtech.jts.geom.{Geometry, Polygon}
 import org.locationtech.jts.io.WKTWriter
 import org.locationtech.jts.linearref.LengthIndexedLine
 import org.locationtech.jts.operation.distance3d.Distance3DOp
-import org.opengis.referencing.{FactoryException, NoSuchAuthorityCodeException}
+import org.opengis.referencing.FactoryException
 import org.scalatest.{GivenWhenThen, Matchers}
 import org.xml.sax.InputSource
 
@@ -205,7 +205,7 @@ class functionTestScala extends TestBaseScala with Matchers 
with GeometrySample
         val d = org.apache.sedona.common.Functions.transform(polygeom, 
epsgString, epsgFactoryErrorString)
       }
 
-      intercept[NoSuchAuthorityCodeException]{
+      intercept[FactoryException]{
         val d2 = org.apache.sedona.common.Functions.transform(polygeom, 
epsgString, epsgNoSuchAuthorityString)
       }
 

Reply via email to