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 2020/12/27 00:06:59 UTC
[incubator-sedona] branch master updated: [SEDONA-8] Add
FlipCoordinates test for RDD API (#499)
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 1a6035d [SEDONA-8] Add FlipCoordinates test for RDD API (#499)
1a6035d is described below
commit 1a6035d7a62c717f454bf3e2fbb5facd75375a7d
Author: Jia Yu <ji...@apache.org>
AuthorDate: Sat Dec 26 16:06:52 2020 -0800
[SEDONA-8] Add FlipCoordinates test for RDD API (#499)
* Update GitHub action
* Cache Maven package
* Separate maven and python test
* Add FlipCoordinate test for RDD API
* Add FlipCoordinate test for RDD API
---
.../sedona/core/spatialRDD/GeometryOpTest.java | 63 ++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/core/src/test/java/org/apache/sedona/core/spatialRDD/GeometryOpTest.java b/core/src/test/java/org/apache/sedona/core/spatialRDD/GeometryOpTest.java
new file mode 100644
index 0000000..69636b8
--- /dev/null
+++ b/core/src/test/java/org/apache/sedona/core/spatialRDD/GeometryOpTest.java
@@ -0,0 +1,63 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sedona.core.spatialRDD;
+
+import org.apache.spark.storage.StorageLevel;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.locationtech.jts.geom.Polygon;
+
+import static org.junit.Assert.assertEquals;
+
+public class GeometryOpTest extends SpatialRDDTestBase
+{
+ private static String InputLocationGeojson;
+ private static String InputLocationWkt;
+ private static String InputLocationWkb;
+ /**
+ * Once executed before all.
+ */
+ @BeforeClass
+ public static void onceExecutedBeforeAll()
+ {
+ initialize(GeometryOpTest.class.getSimpleName(), "polygon.test.properties");
+ InputLocationGeojson = "file://" + GeometryOpTest.class.getClassLoader().getResource(prop.getProperty("inputLocationGeojson")).getPath();
+ InputLocationWkt = "file://" + GeometryOpTest.class.getClassLoader().getResource(prop.getProperty("inputLocationWkt")).getPath();
+ InputLocationWkb = "file://" + GeometryOpTest.class.getClassLoader().getResource(prop.getProperty("inputLocationWkb")).getPath();
+ }
+
+ /**
+ * Tear down.
+ */
+ @AfterClass
+ public static void TearDown()
+ {
+ sc.stop();
+ }
+
+ @Test
+ public void testFlipPolygonCoordiantes()
+ {
+ PolygonRDD spatialRDD = new PolygonRDD(sc, InputLocation, splitter, true, numPartitions, StorageLevel.MEMORY_ONLY());
+ Polygon oldGeom = spatialRDD.rawSpatialRDD.take(1).get(0);
+ spatialRDD.flipCoordinates();
+ Polygon newGeom = spatialRDD.rawSpatialRDD.take(1).get(0);
+ assertEquals(oldGeom.getCoordinates().length, newGeom.getCoordinates().length);
+ for (int i =0; i < newGeom.getCoordinates().length; i++) {
+ assertEquals(newGeom.getCoordinates()[i].getX(), oldGeom.getCoordinates()[i].getY(), 0);
+ assertEquals(newGeom.getCoordinates()[i].getY(), oldGeom.getCoordinates()[i].getX(), 0);
+ }
+ }
+}