[ 
https://issues.apache.org/jira/browse/SEDONA-54?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17382918#comment-17382918
 ] 

Jia Yu commented on SEDONA-54:
------------------------------

You should use ST_FlipCoordinates before calling ST_Transform. Because in 
Sedona 1.0.0, we swapped the Lon/lat order in ST_Transform.

> ST_Transform from 4326 to 3857 throws exception
> -----------------------------------------------
>
>                 Key: SEDONA-54
>                 URL: https://issues.apache.org/jira/browse/SEDONA-54
>             Project: Apache Sedona
>          Issue Type: Bug
>    Affects Versions: 1.0.1
>            Reporter: Zhenbao.Zhai
>            Priority: Major
>
> Hi there:
> 'ST_Transform' fuction returns right result on geospark 1.3.1,but got an 
> error on sedona-viz-2.4_2.11 1.0.1-incubating
> test sql :
>     select ST_Transform(line,'epsg:4326','epsg:3857') line, name from table
> data:
>    MULTILINESTRING ((109.80679 40.67386, 109.80666 40.67389, 109.80679 
> 40.67386), (109.80679 40.67386, 109.80788 40.67371, 109.80788 40.67371, 
> 109.80788 40.67318, 109.80784 40.6728, 109.80784 40.6728, 109.80779 40.6723, 
> 109.80777 40.67216, 109.80768 40.6713, 109.80768 40.6713, 109.80769 40.67122, 
> 109.80769 40.67122, 109.80769 40.67113, 109.80769 40.67113, 109.80838 
> 40.67109, 109.80838 40.67109, 109.80974 40.67102, 109.80974 40.67102, 
> 109.81025 40.67099, 109.81025 40.67099, 109.81046 40.67099, 109.81046 
> 40.67099, 109.81065 40.67097, 109.81065 40.67097, 109.81112 40.67095, 
> 109.81112 40.67095, 109.81156 40.67093, 109.81156 40.67093, 109.81171 
> 40.67093, 109.81171 40.67093, 109.81189 40.67092, 109.81189 40.67092, 
> 109.81247 40.67088, 109.81247 40.67088, 109.81274 40.67086, 109.81274 
> 40.67086, 109.81294 40.67085, 109.81294 40.67085, 109.81421 40.67083, 
> 109.81421 40.67083, 109.81495 40.67081, 109.81495 40.67081, 109.81611 
> 40.67073, 109.81611 40.67073, 109.8163 40.67074, 109.8163 40.67074, 109.81768 
> 40.67067, 109.81768 40.67067, 109.81821 40.67066, 109.81887 40.67063, 
> 109.82053 40.67054, 109.82053 40.67054, 109.82069 40.67053, 109.82069 
> 40.67053, 109.82138 40.67049, 109.82138 40.67049, 109.82249 40.67044, 
> 109.82249 40.67044, 109.82259 40.67044, 109.82259 40.67044, 109.82267 
> 40.67044, 109.82267 40.67044, 109.82276 40.67043, 109.82276 40.67043, 
> 109.82337 40.6704, 109.82337 40.6704, 109.82395 40.67038, 109.82395 40.67038, 
> 109.82449 40.67035, 109.82449 40.67035, 109.82463 40.67034, 109.82463 
> 40.67034, 109.82512 40.67031, 109.82545 40.67031, 109.82545 40.67031, 
> 109.82624 40.67028, 109.82631 40.67028, 109.82631 40.67028, 109.82673 
> 40.67025, 109.82742 40.67022, 109.82742 40.67022, 109.82813 40.67018, 
> 109.82813 40.67018, 109.82886 40.67015, 109.82886 40.67015, 109.82957 
> 40.67011, 109.82957 40.67011, 109.83007 40.67009, 109.83007 40.67009, 
> 109.83029 40.67008, 109.83029 40.67008, 109.83062 40.67007, 109.83062 
> 40.67007, 109.8309 40.67005, 109.8309 40.67005, 109.83197 40.67, 109.83197 
> 40.67, 109.83201 40.67, 109.83201 40.67, 109.83212 40.66999, 109.83212 
> 40.66999, 109.83216 40.66999, 109.83216 40.66999, 109.8326 40.66997, 109.8326 
> 40.66997, 109.83296 40.66996, 109.83296 40.66996, 109.83385 40.66991, 
> 109.83385 40.66991, 109.83409 40.66991, 109.83409 40.66991, 109.83481 
> 40.66988, 109.83481 40.66988, 109.83519 40.66986, 109.83519 40.66986, 
> 109.83533 40.66984, 109.83533 40.66984, 109.83574 40.66982, 109.83574 
> 40.66982, 109.83733 40.66975, 109.83733 40.66975, 109.83801 40.66972, 
> 109.83801 40.66972, 109.83814 40.66971, 109.83814 40.66971, 109.83823 
> 40.66971, 109.83823 40.66971, 109.83923 40.66966, 109.83923 40.66966, 
> 109.83989 40.66963, 109.83989 40.66963, 109.84113 40.66955, 109.84113 
> 40.66955, 109.84109 40.66895, 109.84102 40.66805, 109.84097 40.66756), 
> (109.84097 40.66756, 109.84097 40.66756))
> geospark 1.31 result:
> MULTILINESTRING ((12223635.948443927 4964354.456204462, 12223621.47691012 
> 4964358.859481903, 12223635.948443927 4964354.456204462), (12223635.948443927 
> 4964354.456204462, 12223757.286688888 4964332.439846974, 12223757.286688888 
> 4964332.439846974, 12223757.286688888 4964254.649113868, 12223752.833909256 
> 4964198.875006592, 12223752.833909256 4964198.875006592, 12223747.267934717 
> 4964125.488507615, 12223745.041544901 4964104.940386518, 12223735.022790732 
> 4963978.717160566, 12223735.022790732 4963978.717160566, 12223736.135985639 
> 4963966.975547889, 12223736.135985639 4963966.975547889, 12223736.135985639 
> 4963953.766250469, 12223736.135985639 4963953.766250469, 12223812.946434285 
> 4963947.895457338, 12223812.946434285 4963947.895457338, 12223964.340941766 
> 4963937.621577834, 12223964.340941766 4963937.621577834, 12224021.11388207 
> 4963933.21848992, 12224021.11388207 4963933.21848992, 12224044.490975138 
> 4963933.21848992, 12224044.490975138 4963933.21848992, 12224065.641678385 
> 4963930.283099074, 12224065.641678385 4963930.283099074, 12224117.96183906 
> 4963927.347709115, 12224117.96183906 4963927.347709115, 12224166.942415008 
> 4963924.412320032, 12224166.942415008 4963924.412320032, 12224183.640338628 
> 4963924.412320032, 12224183.640338628 4963924.412320032, 12224203.67784697 
> 4963922.94462582, 12224203.67784697 4963922.94462582, 12224268.24315163 
> 4963917.073851177, 12224268.24315163 4963917.073851177, 12224298.299414145 
> 4963914.138465179, 12224298.299414145 4963914.138465179, 12224320.563312303 
> 4963912.670772508, 12224320.563312303 4963912.670772508, 12224461.93906561 
> 4963909.735387829, 12224461.93906561 4963909.735387829, 12224544.315488797 
> 4963906.800004032, 12224544.315488797 4963906.800004032, 12224673.446098115 
> 4963895.058477638, 12224673.446098115 4963895.058477638, 12224694.596801369 
> 4963896.526167665, 12224694.596801369 4963896.526167665, 12224848.217698663 
> 4963886.252342088, 12224848.217698663 4963886.252342088, 12224907.217028782 
> 4963884.784653601, 12224980.687892707 4963880.38158946, 12225165.478247423 
> 4963867.172408916, 12225165.478247423 4963867.172408916, 12225183.289365951 
> 4963865.704723287, 12225183.289365951 4963865.704723287, 12225260.099814598 
> 4963859.833982982, 12225260.099814598 4963859.833982982, 12225383.664449379 
> 4963852.4955625525, 12225383.664449379 4963852.4955625525, 12225394.796398457 
> 4963852.4955625525, 12225394.796398457 4963852.4955625525, 12225403.701957721 
> 4963852.4955625525, 12225403.701957721 4963852.4955625525, 12225413.720711892 
> 4963851.027879128, 12225413.720711892 4963851.027879128, 12225481.625601277 
> 4963846.624830173, 12225481.625601277 4963846.624830173, 12225546.190905936 
> 4963843.689465299, 12225546.190905936 4963843.689465299, 12225606.303430965 
> 4963839.286419647, 12225606.303430965 4963839.286419647, 12225621.888159676 
> 4963837.8187382035, 12225621.888159676 4963837.8187382035, 12225676.434710164 
> 4963833.415695188, 12225713.170142127 4963833.415695188, 12225713.170142127 
> 4963833.415695188, 12225801.112539854 4963829.0126541555, 12225808.90490421 
> 4963829.0126541555, 12225808.90490421 4963829.0126541555, 12225855.659090342 
> 4963824.609615106, 12225932.46953899 4963820.206578032, 12225932.46953899 
> 4963820.206578032, 12226011.506377453 4963814.335865024, 12226011.506377453 
> 4963814.335865024, 12226092.769605733 4963809.932832572, 12226092.769605733 
> 4963809.932832572, 12226171.806444196 4963804.062125721, 12226171.806444196 
> 4963804.062125721, 12226227.466189593 4963801.126773619, 12226227.466189593 
> 4963801.126773619, 12226251.956477566 4963799.659097895, 12226251.956477566 
> 4963799.659097895, 12226288.691909527 4963798.191422393, 12226288.691909527 
> 4963798.191422393, 12226319.86136695 4963795.256072051, 12226319.86136695 
> 4963795.256072051, 12226438.9732221 4963787.917700045, 12226438.9732221 
> 4963787.917700045, 12226443.42600173 4963787.917700045, 12226443.42600173 
> 4963787.917700045, 12226455.671145719 4963786.450026302, 12226455.671145719 
> 4963786.450026302, 12226460.123925349 4963786.450026302, 12226460.123925349 
> 4963786.450026302, 12226509.104501298 4963783.514679479, 12226509.104501298 
> 4963783.514679479, 12226549.179517984 4963782.0470064, 12226549.179517984 
> 4963782.0470064, 12226648.25386479 4963774.708644297, 12226648.25386479 
> 4963774.708644297, 12226674.970542582 4963774.708644297, 12226674.970542582 
> 4963774.708644297, 12226755.120575953 4963770.305629674, 12226755.120575953 
> 4963770.305629674, 12226797.421982454 4963767.370287694, 12226797.421982454 
> 4963767.370287694, 12226813.006711164 4963764.434946595, 12226813.006711164 
> 4963764.434946595, 12226858.64770239 4963761.499606377, 12226858.64770239 
> 4963761.499606377, 12227035.645692749 4963751.225922541, 12227035.645692749 
> 4963751.225922541, 12227111.34294649 4963746.822918485, 12227111.34294649 
> 4963746.822918485, 12227125.814480294 4963745.355250905, 12227125.814480294 
> 4963745.355250905, 12227135.833234463 4963745.355250905, 12227135.833234463 
> 4963745.355250905, 12227247.152725257 4963738.016916315, 12227247.152725257 
> 4963738.016916315, 12227320.62358918 4963733.613918202, 12227320.62358918 
> 4963733.613918202, 12227458.659757767 4963721.872599585, 12227458.659757767 
> 4963721.872599585, 12227454.206978133 4963633.813158927, 12227446.414613778 
> 4963501.725483504, 12227440.848639239 4963429.811831917), (12227440.848639239 
> 4963429.811831917, 12227440.848639239 4963429.811831917))
> sedona 1.0.1-incubating :
> Caused by: org.geotools.referencing.operation.projection.ProjectionException: 
> Latitude 109°48.4'N is too close to a pole.Caused by: 
> org.geotools.referencing.operation.projection.ProjectionException: Latitude 
> 109°48.4'N is too close to a pole. at 
> org.geotools.referencing.operation.projection.Mercator$Spherical.transformNormalized(Mercator.java:197)
>  at 
> org.geotools.referencing.operation.projection.MapProjection.transform(MapProjection.java:894)
>  at 
> org.geotools.referencing.operation.projection.MapProjection.transform(MapProjection.java:940)
>  at 
> org.geotools.referencing.operation.transform.ConcatenatedTransformDirect.transform(ConcatenatedTransformDirect.java:70)
>  at 
> org.geotools.geometry.jts.DefaultCoordinateSequenceTransformer.transform(DefaultCoordinateSequenceTransformer.java:109)
>  at 
> org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.projectCoordinateSequence(GeometryCoordinateSequenceTransformer.java:262)
>  at 
> org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transformStraightLineString(GeometryCoordinateSequenceTransformer.java:214)
>  at 
> org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transformLineString(GeometryCoordinateSequenceTransformer.java:193)
>  at 
> org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transform(GeometryCoordinateSequenceTransformer.java:145)
>  at org.geotools.geometry.jts.JTS.transform(JTS.java:437) at 
> org.apache.spark.sql.sedona_sql.expressions.ST_Transform.eval(Functions.scala:257)
>  at 
> org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection.apply(Unknown
>  Source) at 
> org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection.apply(Unknown
>  Source) at scala.collection.Iterator$$anon$11.next(Iterator.scala:410) at 
> org.apache.spark.sql.execution.SparkPlan$$anonfun$2.apply(SparkPlan.scala:256)
>  at 
> org.apache.spark.sql.execution.SparkPlan$$anonfun$2.apply(SparkPlan.scala:247)
>  at 
> org.apache.spark.rdd.RDD$$anonfun$mapPartitionsInternal$1$$anonfun$apply$24.apply(RDD.scala:836)
>  at 
> org.apache.spark.rdd.RDD$$anonfun$mapPartitionsInternal$1$$anonfun$apply$24.apply(RDD.scala:836)
>  at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:52) 
> at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:324) at 
> org.apache.spark.rdd.RDD.iterator(RDD.scala:288) at 
> org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:52) at 
> org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:324) at 
> org.apache.spark.rdd.RDD.iterator(RDD.scala:288) at 
> org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90) at 
> org.apache.spark.scheduler.Task.run(Task.scala:123) at 
> org.apache.spark.executor.Executor$TaskRunner$$anonfun$10.apply(Executor.scala:408)
>  at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1360) at 
> org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:414) at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>  at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>  at java.lang.Thread.run(Thread.java:748)
>  
> code 
> :{color:#FF0000}org/apache/spark/sql/sedona_sql/expressions/Functions.scala{color}
>  line 248 and line 249
> val sourceCRScode = CRS.decode("...") change to
> val sourceCRScode = CRS.decode("...",{color:#FF0000}true{color})   may fix 
> this
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to