You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sedona.apache.org by GitBox <gi...@apache.org> on 2022/04/22 06:29:16 UTC

[GitHub] [incubator-sedona] jiayuasu commented on a diff in pull request #615: [SEDONA 115] Add ST_XMax and ST_XMin functions

jiayuasu commented on code in PR #615:
URL: https://github.com/apache/incubator-sedona/pull/615#discussion_r855803468


##########
sql/src/test/scala/org/apache/sedona/sql/functionTestScala.scala:
##########
@@ -335,6 +335,18 @@ class functionTestScala extends TestBaseScala with Matchers with GeometrySample
 
     }
 
+    it("Passed ST_XMax") {
+      var test = sparkSession.sql("SELECT ST_XMax(ST_GeomFromWKT('POLYGON ((-3 -3, 3 -3, 3 3, -3 3, -3 -3))'))")
+      assert(test.take(1)(0).get(0).asInstanceOf[Double] == 3.0)
+
+    }
+
+    it("Passed ST_XMin") {
+      var test = sparkSession.sql("SELECT ST_XMin(ST_GeomFromWKT('POLYGON ((-3 -3, 3 -3, 3 3, -3 3, -3 -3))'))")

Review Comment:
   Please use a more significant test case here. E.g., POLYGON ((-1 -11, 0 10, 1 11, 2 12, -1 -11))



##########
flink/src/test/java/org/apache/sedona/flink/FunctionTest.java:
##########
@@ -88,4 +88,22 @@ public void testAsEWKT() {
         String result = (String) first(polygonTable).getField(0);
         assertEquals("POLYGON ((-0.5 -0.5, -0.5 0.5, 0.5 0.5, 0.5 -0.5, -0.5 -0.5))", result);
     }
+
+    @Test
+    public void testXMax() {
+        Table polygonTable = createPolygonTable(1);
+        Table MaxTable = polygonTable.select(call(Functions.ST_XMax.class.getSimpleName(), $(polygonColNames[0])));
+        double result = (double) first(MaxTable).getField(0);
+        System.out.println(result);

Review Comment:
   No print to console is allowed. Please remove this line.



##########
flink/src/test/java/org/apache/sedona/flink/FunctionTest.java:
##########
@@ -88,4 +88,22 @@ public void testAsEWKT() {
         String result = (String) first(polygonTable).getField(0);
         assertEquals("POLYGON ((-0.5 -0.5, -0.5 0.5, 0.5 0.5, 0.5 -0.5, -0.5 -0.5))", result);
     }
+
+    @Test
+    public void testXMax() {
+        Table polygonTable = createPolygonTable(1);
+        Table MaxTable = polygonTable.select(call(Functions.ST_XMax.class.getSimpleName(), $(polygonColNames[0])));
+        double result = (double) first(MaxTable).getField(0);
+        System.out.println(result);
+        assertEquals(0.5, result,0);
+    }
+
+    @Test
+    public void testXMin() {
+        Table polygonTable = createPolygonTable(1);
+        Table MinTable = polygonTable.select(call(Functions.ST_XMin.class.getSimpleName(), $(polygonColNames[0])));
+        double result = (double) first(MinTable).getField(0);
+        System.out.println(result);

Review Comment:
   No print to console is allowed. Please remove this line.



##########
sql/src/test/scala/org/apache/sedona/sql/functionTestScala.scala:
##########
@@ -335,6 +335,18 @@ class functionTestScala extends TestBaseScala with Matchers with GeometrySample
 
     }
 
+    it("Passed ST_XMax") {
+      var test = sparkSession.sql("SELECT ST_XMax(ST_GeomFromWKT('POLYGON ((-3 -3, 3 -3, 3 3, -3 3, -3 -3))'))")

Review Comment:
   Please use a more significant test case here. E.g., POLYGON ((-1 -11, 0 10, 1 11, 2 12, -1 -11))



##########
docs/api/sql/Function.md:
##########
@@ -1105,4 +1105,42 @@ Result:
 +---------------------------------------------------------------+
 |LINESTRING (3 6, 2 4, 1 2, 0 0)                                |
 +---------------------------------------------------------------+
-```
\ No newline at end of file
+```
+
+## ST_XMax
+
+Introduction: Returns the maximum X coordinate of a geometry
+
+Format: `ST_XMax (A:geometry)`
+
+Since: `v1.2.1`
+
+Example:
+
+```SQL
+SELECT ST_XMax(df.geometry) AS xmax
+FROM df
+```
+
+Input: `POLYGON ((-1 1, 1 -1, -1 -1, 1 1))`

Review Comment:
   Polygon example here is not a WKT format. Use POLYGON ((-1 -11, 0 10, 1 11, 2 12, -1 -11)) instead.
   
   Please fix other places in the docs



-- 
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-unsubscribe@sedona.apache.org

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