You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by ji...@apache.org on 2022/06/30 18:43:16 UTC
[incubator-sedona] branch ST_Transform updated: Fix the wrong order. The correct order now is long/lat
This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch ST_Transform
in repository https://gitbox.apache.org/repos/asf/incubator-sedona.git
The following commit(s) were added to refs/heads/ST_Transform by this push:
new 555100b9 Fix the wrong order. The correct order now is long/lat
555100b9 is described below
commit 555100b9c6fb9e928b56bdebcfccfc3d4c816c00
Author: Jia Yu <ji...@apache.org>
AuthorDate: Thu Jun 30 11:43:08 2022 -0700
Fix the wrong order. The correct order now is long/lat
---
.../apache/sedona/core/spatialRDD/CircleRDD.java | 2 +-
.../sedona/core/spatialRDD/LineStringRDD.java | 54 +++++++++++-----------
.../apache/sedona/core/spatialRDD/PointRDD.java | 54 +++++++++++-----------
.../apache/sedona/core/spatialRDD/PolygonRDD.java | 54 +++++++++++-----------
.../sedona/core/spatialRDD/RectangleRDD.java | 54 +++++++++++-----------
.../apache/sedona/core/spatialRDD/SpatialRDD.java | 11 +++--
.../sql/sedona_sql/expressions/Functions.scala | 16 +++----
.../org/apache/sedona/sql/functionTestScala.scala | 22 ++++-----
8 files changed, 131 insertions(+), 136 deletions(-)
diff --git a/core/src/main/java/org/apache/sedona/core/spatialRDD/CircleRDD.java b/core/src/main/java/org/apache/sedona/core/spatialRDD/CircleRDD.java
index 959f2f7a..82f8f951 100644
--- a/core/src/main/java/org/apache/sedona/core/spatialRDD/CircleRDD.java
+++ b/core/src/main/java/org/apache/sedona/core/spatialRDD/CircleRDD.java
@@ -56,7 +56,7 @@ public class CircleRDD
public CircleRDD(JavaRDD<Circle> circleRDD, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.rawSpatialRDD = circleRDD;
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
}
/**
diff --git a/core/src/main/java/org/apache/sedona/core/spatialRDD/LineStringRDD.java b/core/src/main/java/org/apache/sedona/core/spatialRDD/LineStringRDD.java
index 25bc7b1e..5748ccb5 100644
--- a/core/src/main/java/org/apache/sedona/core/spatialRDD/LineStringRDD.java
+++ b/core/src/main/java/org/apache/sedona/core/spatialRDD/LineStringRDD.java
@@ -57,12 +57,12 @@ public class LineStringRDD
*
* @param rawSpatialRDD the raw spatial RDD
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public LineStringRDD(JavaRDD<LineString> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCode)
+ public LineStringRDD(JavaRDD<LineString> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.rawSpatialRDD = rawSpatialRDD;
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
}
/**
@@ -167,14 +167,14 @@ public class LineStringRDD
*
* @param rawSpatialRDD the raw spatial RDD
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
* @param datasetBoundary the dataset boundary
* @param approximateTotalCount the approximate total count
*/
- public LineStringRDD(JavaRDD<LineString> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCode, Envelope datasetBoundary, Integer approximateTotalCount)
+ public LineStringRDD(JavaRDD<LineString> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCRSCode, Envelope datasetBoundary, Integer approximateTotalCount)
{
this.rawSpatialRDD = rawSpatialRDD;
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.boundaryEnvelope = datasetBoundary;
this.approximateTotalCount = approximateTotalCount;
}
@@ -398,12 +398,12 @@ public class LineStringRDD
* @param rawSpatialRDD the raw spatial RDD
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public LineStringRDD(JavaRDD<LineString> rawSpatialRDD, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ public LineStringRDD(JavaRDD<LineString> rawSpatialRDD, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.rawSpatialRDD = rawSpatialRDD;
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.analyze(newLevel);
}
@@ -419,10 +419,10 @@ public class LineStringRDD
* @param partitions the partitions
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public LineStringRDD(JavaSparkContext sparkContext, String InputLocation, Integer startOffset, Integer endOffset,
- FileDataSplitter splitter, boolean carryInputData, Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ FileDataSplitter splitter, boolean carryInputData, Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
JavaRDD rawTextRDD = partitions != null ? sparkContext.textFile(InputLocation, partitions) : sparkContext.textFile(InputLocation);
if (startOffset != null && endOffset != null) {
@@ -431,7 +431,7 @@ public class LineStringRDD
else {
this.setRawSpatialRDD(rawTextRDD.mapPartitions(new LineStringFormatMapper(splitter, carryInputData)));
}
- if (sourceEpsgCRSCode != null && targetEpsgCode != null) { this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);}
+ if (sourceEpsgCRSCode != null && targetEpsgCRSCode != null) { this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);}
if (newLevel != null) { this.analyze(newLevel);}
if (splitter.equals(FileDataSplitter.GEOJSON)) { this.fieldNames = FormatMapper.readGeoJsonPropertyNames(rawTextRDD.take(1).get(0).toString()); }
}
@@ -447,12 +447,12 @@ public class LineStringRDD
* @param carryInputData the carry input data
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public LineStringRDD(JavaSparkContext sparkContext, String InputLocation, Integer startOffset, Integer endOffset,
- FileDataSplitter splitter, boolean carryInputData, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ FileDataSplitter splitter, boolean carryInputData, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
- this(sparkContext, InputLocation, startOffset, endOffset, splitter, carryInputData, null, newLevel, sourceEpsgCRSCode, targetEpsgCode);
+ this(sparkContext, InputLocation, startOffset, endOffset, splitter, carryInputData, null, newLevel, sourceEpsgCRSCode, targetEpsgCRSCode);
}
/**
@@ -465,11 +465,11 @@ public class LineStringRDD
* @param partitions the partitions
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public LineStringRDD(JavaSparkContext sparkContext, String InputLocation, FileDataSplitter splitter, boolean carryInputData, Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ public LineStringRDD(JavaSparkContext sparkContext, String InputLocation, FileDataSplitter splitter, boolean carryInputData, Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
- this(sparkContext, InputLocation, null, null, splitter, carryInputData, partitions, newLevel, sourceEpsgCRSCode, targetEpsgCode);
+ this(sparkContext, InputLocation, null, null, splitter, carryInputData, partitions, newLevel, sourceEpsgCRSCode, targetEpsgCRSCode);
}
/**
@@ -481,12 +481,12 @@ public class LineStringRDD
* @param carryInputData the carry input data
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public LineStringRDD(JavaSparkContext sparkContext, String InputLocation,
- FileDataSplitter splitter, boolean carryInputData, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ FileDataSplitter splitter, boolean carryInputData, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
- this(sparkContext, InputLocation, null, null, splitter, carryInputData, null, newLevel, sourceEpsgCRSCode, targetEpsgCode);
+ this(sparkContext, InputLocation, null, null, splitter, carryInputData, null, newLevel, sourceEpsgCRSCode, targetEpsgCRSCode);
}
/**
@@ -498,12 +498,12 @@ public class LineStringRDD
* @param userSuppliedMapper the user supplied mapper
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public LineStringRDD(JavaSparkContext sparkContext, String InputLocation, Integer partitions, FlatMapFunction userSuppliedMapper, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ public LineStringRDD(JavaSparkContext sparkContext, String InputLocation, Integer partitions, FlatMapFunction userSuppliedMapper, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.setRawSpatialRDD(sparkContext.textFile(InputLocation, partitions).mapPartitions(userSuppliedMapper));
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.analyze(newLevel);
}
@@ -515,12 +515,12 @@ public class LineStringRDD
* @param userSuppliedMapper the user supplied mapper
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public LineStringRDD(JavaSparkContext sparkContext, String InputLocation, FlatMapFunction userSuppliedMapper, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ public LineStringRDD(JavaSparkContext sparkContext, String InputLocation, FlatMapFunction userSuppliedMapper, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.setRawSpatialRDD(sparkContext.textFile(InputLocation).mapPartitions(userSuppliedMapper));
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.analyze(newLevel);
}
}
diff --git a/core/src/main/java/org/apache/sedona/core/spatialRDD/PointRDD.java b/core/src/main/java/org/apache/sedona/core/spatialRDD/PointRDD.java
index c4409b59..555f1b35 100644
--- a/core/src/main/java/org/apache/sedona/core/spatialRDD/PointRDD.java
+++ b/core/src/main/java/org/apache/sedona/core/spatialRDD/PointRDD.java
@@ -59,12 +59,12 @@ public class PointRDD
*
* @param rawSpatialRDD the raw spatial RDD
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public PointRDD(JavaRDD<Point> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCode)
+ public PointRDD(JavaRDD<Point> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.rawSpatialRDD = rawSpatialRDD;
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
}
/**
@@ -167,14 +167,14 @@ public class PointRDD
*
* @param rawSpatialRDD the raw spatial RDD
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
* @param datasetBoundary the dataset boundary
* @param approximateTotalCount the approximate total count
*/
- public PointRDD(JavaRDD<Point> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCode, Envelope datasetBoundary, Integer approximateTotalCount)
+ public PointRDD(JavaRDD<Point> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCRSCode, Envelope datasetBoundary, Integer approximateTotalCount)
{
this.rawSpatialRDD = rawSpatialRDD;
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.boundaryEnvelope = datasetBoundary;
this.approximateTotalCount = approximateTotalCount;
}
@@ -391,12 +391,12 @@ public class PointRDD
* @param rawSpatialRDD the raw spatial RDD
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public PointRDD(JavaRDD<Point> rawSpatialRDD, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ public PointRDD(JavaRDD<Point> rawSpatialRDD, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.rawSpatialRDD = rawSpatialRDD;
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.analyze(newLevel);
}
@@ -411,15 +411,15 @@ public class PointRDD
* @param partitions the partitions
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public PointRDD(JavaSparkContext sparkContext, String InputLocation, Integer Offset, FileDataSplitter splitter,
- boolean carryInputData, Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ boolean carryInputData, Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
JavaRDD rawTextRDD = partitions != null ? sparkContext.textFile(InputLocation, partitions) : sparkContext.textFile(InputLocation);
if (Offset != null) {this.setRawSpatialRDD(rawTextRDD.mapPartitions(new PointFormatMapper(Offset, splitter, carryInputData)));}
else {this.setRawSpatialRDD(rawTextRDD.mapPartitions(new PointFormatMapper(splitter, carryInputData)));}
- if (sourceEpsgCRSCode != null && targetEpsgCode != null) { this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);}
+ if (sourceEpsgCRSCode != null && targetEpsgCRSCode != null) { this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);}
if (newLevel != null) { this.analyze(newLevel);}
if (splitter.equals(FileDataSplitter.GEOJSON)) { this.fieldNames = FormatMapper.readGeoJsonPropertyNames(rawTextRDD.take(1).get(0).toString()); }
}
@@ -434,12 +434,12 @@ public class PointRDD
* @param carryInputData the carry input data
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public PointRDD(JavaSparkContext sparkContext, String InputLocation, Integer Offset, FileDataSplitter splitter,
- boolean carryInputData, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ boolean carryInputData, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
- this(sparkContext, InputLocation, Offset, splitter, carryInputData, null, newLevel, sourceEpsgCRSCode, targetEpsgCode);
+ this(sparkContext, InputLocation, Offset, splitter, carryInputData, null, newLevel, sourceEpsgCRSCode, targetEpsgCRSCode);
}
/**
@@ -452,12 +452,12 @@ public class PointRDD
* @param partitions the partitions
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public PointRDD(JavaSparkContext sparkContext, String InputLocation, FileDataSplitter splitter, boolean carryInputData,
- Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
- this(sparkContext, InputLocation, null, splitter, carryInputData, partitions, newLevel, sourceEpsgCRSCode, targetEpsgCode);
+ this(sparkContext, InputLocation, null, splitter, carryInputData, partitions, newLevel, sourceEpsgCRSCode, targetEpsgCRSCode);
}
/**
@@ -469,12 +469,12 @@ public class PointRDD
* @param carryInputData the carry input data
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public PointRDD(JavaSparkContext sparkContext, String InputLocation, FileDataSplitter splitter, boolean carryInputData,
- StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
- this(sparkContext, InputLocation, null, splitter, carryInputData, null, newLevel, sourceEpsgCRSCode, targetEpsgCode);
+ this(sparkContext, InputLocation, null, splitter, carryInputData, null, newLevel, sourceEpsgCRSCode, targetEpsgCRSCode);
}
/**
@@ -486,12 +486,12 @@ public class PointRDD
* @param userSuppliedMapper the user supplied mapper
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public PointRDD(JavaSparkContext sparkContext, String InputLocation, Integer partitions, FlatMapFunction userSuppliedMapper,
- StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
- this(sparkContext, InputLocation, null, null, false, partitions, newLevel, sourceEpsgCRSCode, targetEpsgCode);
+ this(sparkContext, InputLocation, null, null, false, partitions, newLevel, sourceEpsgCRSCode, targetEpsgCRSCode);
}
/**
@@ -502,10 +502,10 @@ public class PointRDD
* @param userSuppliedMapper the user supplied mapper
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public PointRDD(JavaSparkContext sparkContext, String InputLocation, FlatMapFunction userSuppliedMapper, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ public PointRDD(JavaSparkContext sparkContext, String InputLocation, FlatMapFunction userSuppliedMapper, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
- this(sparkContext, InputLocation, null, null, false, null, newLevel, sourceEpsgCRSCode, targetEpsgCode);
+ this(sparkContext, InputLocation, null, null, false, null, newLevel, sourceEpsgCRSCode, targetEpsgCRSCode);
}
}
diff --git a/core/src/main/java/org/apache/sedona/core/spatialRDD/PolygonRDD.java b/core/src/main/java/org/apache/sedona/core/spatialRDD/PolygonRDD.java
index 1df75635..1c284560 100644
--- a/core/src/main/java/org/apache/sedona/core/spatialRDD/PolygonRDD.java
+++ b/core/src/main/java/org/apache/sedona/core/spatialRDD/PolygonRDD.java
@@ -67,12 +67,12 @@ public class PolygonRDD
*
* @param rawSpatialRDD the raw spatial RDD
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public PolygonRDD(JavaRDD<Polygon> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCode)
+ public PolygonRDD(JavaRDD<Polygon> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.rawSpatialRDD = rawSpatialRDD;
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
}
/**
@@ -177,14 +177,14 @@ public class PolygonRDD
*
* @param rawSpatialRDD the raw spatial RDD
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
* @param datasetBoundary the dataset boundary
* @param approximateTotalCount the approximate total count
*/
- public PolygonRDD(JavaRDD<Polygon> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCode, Envelope datasetBoundary, Integer approximateTotalCount)
+ public PolygonRDD(JavaRDD<Polygon> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCRSCode, Envelope datasetBoundary, Integer approximateTotalCount)
{
this.rawSpatialRDD = rawSpatialRDD;
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.boundaryEnvelope = datasetBoundary;
this.approximateTotalCount = approximateTotalCount;
}
@@ -401,12 +401,12 @@ public class PolygonRDD
* @param rawSpatialRDD the raw spatial RDD
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public PolygonRDD(JavaRDD<Polygon> rawSpatialRDD, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ public PolygonRDD(JavaRDD<Polygon> rawSpatialRDD, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.rawSpatialRDD = rawSpatialRDD;
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.analyze(newLevel);
}
@@ -422,10 +422,10 @@ public class PolygonRDD
* @param partitions the partitions
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public PolygonRDD(JavaSparkContext sparkContext, String InputLocation, Integer startOffset, Integer endOffset,
- FileDataSplitter splitter, boolean carryInputData, Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ FileDataSplitter splitter, boolean carryInputData, Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
JavaRDD rawTextRDD = partitions != null ? sparkContext.textFile(InputLocation, partitions) : sparkContext.textFile(InputLocation);
if (startOffset != null && endOffset != null) {
@@ -434,7 +434,7 @@ public class PolygonRDD
else {
this.setRawSpatialRDD(rawTextRDD.mapPartitions(new PolygonFormatMapper(splitter, carryInputData)));
}
- if (sourceEpsgCRSCode != null && targetEpsgCode != null) { this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);}
+ if (sourceEpsgCRSCode != null && targetEpsgCRSCode != null) { this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);}
if (newLevel != null) { this.analyze(newLevel);}
if (splitter.equals(FileDataSplitter.GEOJSON)) { this.fieldNames = FormatMapper.readGeoJsonPropertyNames(rawTextRDD.take(1).get(0).toString()); }
}
@@ -450,12 +450,12 @@ public class PolygonRDD
* @param carryInputData the carry input data
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public PolygonRDD(JavaSparkContext sparkContext, String InputLocation, Integer startOffset, Integer endOffset,
- FileDataSplitter splitter, boolean carryInputData, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ FileDataSplitter splitter, boolean carryInputData, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
- this(sparkContext, InputLocation, startOffset, endOffset, splitter, carryInputData, null, newLevel, sourceEpsgCRSCode, targetEpsgCode);
+ this(sparkContext, InputLocation, startOffset, endOffset, splitter, carryInputData, null, newLevel, sourceEpsgCRSCode, targetEpsgCRSCode);
}
/**
@@ -468,12 +468,12 @@ public class PolygonRDD
* @param partitions the partitions
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public PolygonRDD(JavaSparkContext sparkContext, String InputLocation,
- FileDataSplitter splitter, boolean carryInputData, Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ FileDataSplitter splitter, boolean carryInputData, Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
- this(sparkContext, InputLocation, null, null, splitter, carryInputData, partitions, newLevel, sourceEpsgCRSCode, targetEpsgCode);
+ this(sparkContext, InputLocation, null, null, splitter, carryInputData, partitions, newLevel, sourceEpsgCRSCode, targetEpsgCRSCode);
}
/**
@@ -485,12 +485,12 @@ public class PolygonRDD
* @param carryInputData the carry input data
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public PolygonRDD(JavaSparkContext sparkContext, String InputLocation,
- FileDataSplitter splitter, boolean carryInputData, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ FileDataSplitter splitter, boolean carryInputData, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
- this(sparkContext, InputLocation, null, null, splitter, carryInputData, null, newLevel, sourceEpsgCRSCode, targetEpsgCode);
+ this(sparkContext, InputLocation, null, null, splitter, carryInputData, null, newLevel, sourceEpsgCRSCode, targetEpsgCRSCode);
}
/**
@@ -502,12 +502,12 @@ public class PolygonRDD
* @param userSuppliedMapper the user supplied mapper
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public PolygonRDD(JavaSparkContext sparkContext, String InputLocation, Integer partitions, FlatMapFunction userSuppliedMapper, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ public PolygonRDD(JavaSparkContext sparkContext, String InputLocation, Integer partitions, FlatMapFunction userSuppliedMapper, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.setRawSpatialRDD(sparkContext.textFile(InputLocation, partitions).mapPartitions(userSuppliedMapper));
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.analyze(newLevel);
}
@@ -519,12 +519,12 @@ public class PolygonRDD
* @param userSuppliedMapper the user supplied mapper
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public PolygonRDD(JavaSparkContext sparkContext, String InputLocation, FlatMapFunction userSuppliedMapper, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ public PolygonRDD(JavaSparkContext sparkContext, String InputLocation, FlatMapFunction userSuppliedMapper, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.setRawSpatialRDD(sparkContext.textFile(InputLocation).mapPartitions(userSuppliedMapper));
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.analyze(newLevel);
}
diff --git a/core/src/main/java/org/apache/sedona/core/spatialRDD/RectangleRDD.java b/core/src/main/java/org/apache/sedona/core/spatialRDD/RectangleRDD.java
index 6b03ff4c..0fe2e537 100644
--- a/core/src/main/java/org/apache/sedona/core/spatialRDD/RectangleRDD.java
+++ b/core/src/main/java/org/apache/sedona/core/spatialRDD/RectangleRDD.java
@@ -57,12 +57,12 @@ public class RectangleRDD
*
* @param rawSpatialRDD the raw spatial RDD
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public RectangleRDD(JavaRDD<Polygon> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCode)
+ public RectangleRDD(JavaRDD<Polygon> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.rawSpatialRDD = rawSpatialRDD;
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
}
/**
@@ -165,14 +165,14 @@ public class RectangleRDD
*
* @param rawSpatialRDD the raw spatial RDD
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
* @param datasetBoundary the dataset boundary
* @param approximateTotalCount the approximate total count
*/
- public RectangleRDD(JavaRDD<Polygon> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCode, Envelope datasetBoundary, Integer approximateTotalCount)
+ public RectangleRDD(JavaRDD<Polygon> rawSpatialRDD, String sourceEpsgCRSCode, String targetEpsgCRSCode, Envelope datasetBoundary, Integer approximateTotalCount)
{
this.rawSpatialRDD = rawSpatialRDD;
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.boundaryEnvelope = datasetBoundary;
this.approximateTotalCount = approximateTotalCount;
}
@@ -397,12 +397,12 @@ public class RectangleRDD
* @param rawSpatialRDD the raw spatial RDD
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public RectangleRDD(JavaRDD<Polygon> rawSpatialRDD, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ public RectangleRDD(JavaRDD<Polygon> rawSpatialRDD, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.rawSpatialRDD = rawSpatialRDD;
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.analyze(newLevel);
}
@@ -417,13 +417,13 @@ public class RectangleRDD
* @param partitions the partitions
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public RectangleRDD(JavaSparkContext sparkContext, String InputLocation, Integer Offset,
- FileDataSplitter splitter, boolean carryInputData, Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ FileDataSplitter splitter, boolean carryInputData, Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.setRawSpatialRDD(sparkContext.textFile(InputLocation, partitions).mapPartitions(new RectangleFormatMapper(splitter, carryInputData)));
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.analyze(newLevel);
}
@@ -437,13 +437,13 @@ public class RectangleRDD
* @param carryInputData the carry input data
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public RectangleRDD(JavaSparkContext sparkContext, String InputLocation, Integer Offset,
- FileDataSplitter splitter, boolean carryInputData, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ FileDataSplitter splitter, boolean carryInputData, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.setRawSpatialRDD(sparkContext.textFile(InputLocation).mapPartitions(new RectangleFormatMapper(Offset, splitter, carryInputData)));
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.analyze(newLevel);
}
@@ -457,13 +457,13 @@ public class RectangleRDD
* @param partitions the partitions
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public RectangleRDD(JavaSparkContext sparkContext, String InputLocation,
- FileDataSplitter splitter, boolean carryInputData, Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ FileDataSplitter splitter, boolean carryInputData, Integer partitions, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.setRawSpatialRDD(sparkContext.textFile(InputLocation, partitions).mapPartitions(new RectangleFormatMapper(splitter, carryInputData)));
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.analyze(newLevel);
}
@@ -476,13 +476,13 @@ public class RectangleRDD
* @param carryInputData the carry input data
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
public RectangleRDD(JavaSparkContext sparkContext, String InputLocation,
- FileDataSplitter splitter, boolean carryInputData, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ FileDataSplitter splitter, boolean carryInputData, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.setRawSpatialRDD(sparkContext.textFile(InputLocation).mapPartitions(new RectangleFormatMapper(splitter, carryInputData)));
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.analyze(newLevel);
}
@@ -495,12 +495,12 @@ public class RectangleRDD
* @param userSuppliedMapper the user supplied mapper
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public RectangleRDD(JavaSparkContext sparkContext, String InputLocation, Integer partitions, FlatMapFunction userSuppliedMapper, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ public RectangleRDD(JavaSparkContext sparkContext, String InputLocation, Integer partitions, FlatMapFunction userSuppliedMapper, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.setRawSpatialRDD(sparkContext.textFile(InputLocation, partitions).mapPartitions(userSuppliedMapper));
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.analyze(newLevel);
}
@@ -512,12 +512,12 @@ public class RectangleRDD
* @param userSuppliedMapper the user supplied mapper
* @param newLevel the new level
* @param sourceEpsgCRSCode the source epsg CRS code
- * @param targetEpsgCode the target epsg code
+ * @param targetEpsgCRSCode the target epsg code
*/
- public RectangleRDD(JavaSparkContext sparkContext, String InputLocation, FlatMapFunction userSuppliedMapper, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCode)
+ public RectangleRDD(JavaSparkContext sparkContext, String InputLocation, FlatMapFunction userSuppliedMapper, StorageLevel newLevel, String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
this.setRawSpatialRDD(sparkContext.textFile(InputLocation).mapPartitions(userSuppliedMapper));
- this.CRSTransform(sourceEpsgCRSCode, targetEpsgCode);
+ this.CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false, false);
this.analyze(newLevel);
}
}
diff --git a/core/src/main/java/org/apache/sedona/core/spatialRDD/SpatialRDD.java b/core/src/main/java/org/apache/sedona/core/spatialRDD/SpatialRDD.java
index 0044e3b9..ad3ce9dd 100644
--- a/core/src/main/java/org/apache/sedona/core/spatialRDD/SpatialRDD.java
+++ b/core/src/main/java/org/apache/sedona/core/spatialRDD/SpatialRDD.java
@@ -145,16 +145,17 @@ public class SpatialRDD<T extends Geometry>
*
* @param sourceEpsgCRSCode the source epsg CRS code
* @param targetEpsgCRSCode the target epsg CRS code
+ * @param longitudeFirst set to true if input coordinates are in long/lat order
* @param lenient consider the difference of the geodetic datum between the two coordinate systems,
* if {@code true}, never throw an exception "Bursa-Wolf Parameters Required", but not
* recommended for careful analysis work
* @return true, if successful
*/
- public boolean CRSTransform(String sourceEpsgCRSCode, String targetEpsgCRSCode, boolean lenient)
+ public boolean CRSTransform(String sourceEpsgCRSCode, String targetEpsgCRSCode, boolean longitudeFirst, boolean lenient)
{
try {
- CoordinateReferenceSystem sourceCRS = CRS.decode(sourceEpsgCRSCode);
- CoordinateReferenceSystem targetCRS = CRS.decode(targetEpsgCRSCode);
+ CoordinateReferenceSystem sourceCRS = CRS.decode(sourceEpsgCRSCode, longitudeFirst);
+ CoordinateReferenceSystem targetCRS = CRS.decode(targetEpsgCRSCode, longitudeFirst);
final MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, lenient);
this.CRStransformation = true;
this.sourceEpsgCode = sourceEpsgCRSCode;
@@ -178,7 +179,7 @@ public class SpatialRDD<T extends Geometry>
}
/**
- * CRS transform.
+ * CRS transform. The input is in long/lat order.
*
* @param sourceEpsgCRSCode the source epsg CRS code
* @param targetEpsgCRSCode the target epsg CRS code
@@ -186,7 +187,7 @@ public class SpatialRDD<T extends Geometry>
*/
public boolean CRSTransform(String sourceEpsgCRSCode, String targetEpsgCRSCode)
{
- return CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, false);
+ return CRSTransform(sourceEpsgCRSCode, targetEpsgCRSCode, true, false);
}
public boolean spatialPartitioning(GridType gridType)
diff --git a/sql/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Functions.scala b/sql/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Functions.scala
index 738e8001..4cfe0444 100644
--- a/sql/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Functions.scala
+++ b/sql/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Functions.scala
@@ -23,21 +23,21 @@ import org.apache.sedona.core.utils.GeomUtils
import org.apache.sedona.sql.utils.GeometrySerializer
import org.apache.spark.internal.Logging
import org.apache.spark.sql.catalyst.InternalRow
-import org.apache.spark.sql.catalyst.expressions.codegen.{CodegenContext, CodegenFallback, ExprCode}
-import org.apache.spark.sql.catalyst.expressions.{BoundReference, Expression, Generator}
+import org.apache.spark.sql.catalyst.expressions.codegen.CodegenFallback
+import org.apache.spark.sql.catalyst.expressions.{Expression, Generator}
import org.apache.spark.sql.catalyst.util.{ArrayData, GenericArrayData}
import org.apache.spark.sql.sedona_sql.UDT.GeometryUDT
import org.apache.spark.sql.sedona_sql.expressions.collect.Collect
-import org.apache.spark.sql.sedona_sql.expressions.geohash.{GeoHashDecoder, GeometryGeoHashEncoder, InvalidGeoHashException}
+import org.apache.spark.sql.sedona_sql.expressions.geohash.GeometryGeoHashEncoder
import org.apache.spark.sql.sedona_sql.expressions.implicits._
import org.apache.spark.sql.sedona_sql.expressions.subdivide.GeometrySubDivider
-import org.apache.spark.sql.types.{ArrayType, _}
+import org.apache.spark.sql.types._
import org.apache.spark.unsafe.types.UTF8String
import org.geotools.geometry.jts.JTS
import org.geotools.referencing.CRS
import org.locationtech.jts.algorithm.MinimumBoundingCircle
import org.locationtech.jts.geom.util.GeometryFixer
-import org.locationtech.jts.geom.{PrecisionModel, _}
+import org.locationtech.jts.geom._
import org.locationtech.jts.io.{ByteOrderValues, WKBWriter, WKTWriter}
import org.locationtech.jts.linearref.LengthIndexedLine
import org.locationtech.jts.operation.IsSimpleOp
@@ -49,8 +49,6 @@ import org.locationtech.jts.precision.GeometryPrecisionReducer
import org.locationtech.jts.simplify.TopologyPreservingSimplifier
import org.opengis.referencing.operation.MathTransform
import org.wololo.jts2geojson.GeoJSONWriter
-import org.locationtech.jts.geom.Geometry
-import org.locationtech.jts.geom.Coordinate
import java.nio.ByteOrder
import scala.util.{Failure, Success, Try}
@@ -324,8 +322,8 @@ case class ST_Transform(inputExpressions: Seq[Expression])
(originalGeometry, sourceCRS, targetCRS) match {
case (originalGeometry: Geometry, sourceCRS: String, targetCRS: String) =>
- val sourceCRScode = CRS.decode(sourceCRS)
- val targetCRScode = CRS.decode(targetCRS)
+ val sourceCRScode = CRS.decode(sourceCRS,true)
+ val targetCRScode = CRS.decode(targetCRS, true)
var transform: MathTransform = null
if (inputExpressions.length == 4) {
transform = CRS.findMathTransform(sourceCRScode, targetCRScode, inputExpressions(3).eval(input).asInstanceOf[Boolean])
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 75c68eac..3199b046 100644
--- a/sql/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
+++ b/sql/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
@@ -22,9 +22,7 @@ package org.apache.sedona.sql
import org.apache.commons.codec.binary.Hex
import org.apache.sedona.sql.implicits._
import org.apache.spark.sql.functions._
-import org.apache.spark.sql.sedona_sql.expressions.ST_MakeValid
import org.apache.spark.sql.{DataFrame, Row}
-import org.geotools.geometry.jts.WKTReader2
import org.locationtech.jts.algorithm.MinimumBoundingCircle
import org.locationtech.jts.geom.{Geometry, Polygon}
import org.locationtech.jts.io.WKTWriter
@@ -122,19 +120,17 @@ class functionTestScala extends TestBaseScala with Matchers with GeometrySample
}
it("Passed ST_Transform") {
- var polygonWktDf = sparkSession.read.format("csv").option("delimiter", "\t").option("header", "false").load(mixedWktGeometryInputLocation)
- polygonWktDf.createOrReplaceTempView("polygontable")
- var polygonDf = sparkSession.sql("select ST_GeomFromWKT(polygontable._c0) as countyshape from polygontable")
- polygonDf.createOrReplaceTempView("polygondf")
- val polygon = "POLYGON ((110.54671 55.818002, 110.54671 55.143743, 110.940494 55.143743, 110.940494 55.818002, 110.54671 55.818002))"
- val forceXYExpect = "POLYGON ((471596.69167460164 6185916.951191288, 471107.5623640998 6110880.974228167, 496207.109151055 6110788.804712435, 496271.31937046186 6185825.60569904, 471596.69167460164 6185916.951191288))"
+ // Longitude first, latitude later
+ val geom1BeforeCRS = "POINT (-0.063 51.5)"
+ val geom1AfterCRSexpect = "POINT (-7013.127919976235 6710219.083220741)"
- sparkSession.createDataset(Seq(polygon))
- .withColumn("geom", expr("ST_GeomFromWKT(value)"))
- .createOrReplaceTempView("df")
+ val geom1AfterCRSactual = sparkSession.sql(s"""select ST_Transform(ST_geomFromWKT('$geom1BeforeCRS'),'EPSG:4326', 'EPSG:3857', false)""").rdd.map(row => row.getAs[Geometry](0).toString).collect()(0)
+ assert(geom1AfterCRSactual == geom1AfterCRSexpect)
- val forceXYResult = sparkSession.sql(s"""select ST_Transform(ST_FlipCoordinates(ST_geomFromWKT('$polygon')),'EPSG:4326', 'EPSG:32649', false)""").rdd.map(row => row.getAs[Geometry](0).toString).collect()(0)
- assert(forceXYResult == forceXYExpect)
+ val geom2BeforeCRS = "POINT (-176.058774 51.137904)"
+ val geom2AfterCRSexpect = "POINT (-19598773.07136803 6645723.691240616)"
+ val geom2AfterCRSactual = sparkSession.sql(s"""select ST_Transform(ST_geomFromWKT('$geom2BeforeCRS'),'EPSG:4326', 'EPSG:3857', false)""").rdd.map(row => row.getAs[Geometry](0).toString).collect()(0)
+ assert(geom2AfterCRSactual == geom2AfterCRSexpect)
}
it("Passed ST_Intersection - intersects but not contains") {