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 2023/02/14 09:23:50 UTC
[sedona] branch master updated: [SEDONA-199] Update documentation for ST_NDims as it now supports M dimension. (#768)
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/sedona.git
The following commit(s) were added to refs/heads/master by this push:
new 147a377a [SEDONA-199] Update documentation for ST_NDims as it now supports M dimension. (#768)
147a377a is described below
commit 147a377ab7dafe4e45b151d8efed9203fea97a88
Author: Kristin Cowalcijk <bo...@wherobots.com>
AuthorDate: Tue Feb 14 17:23:43 2023 +0800
[SEDONA-199] Update documentation for ST_NDims as it now supports M dimension. (#768)
---
docs/api/flink/Function.md | 2 +-
docs/api/sql/Function.md | 2 +-
flink/src/test/java/org/apache/sedona/flink/FunctionTest.java | 9 +++++++++
.../test/scala/org/apache/sedona/sql/functionTestScala.scala | 10 ++++++++++
4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/docs/api/flink/Function.md b/docs/api/flink/Function.md
index a976ddd7..72dd31f6 100644
--- a/docs/api/flink/Function.md
+++ b/docs/api/flink/Function.md
@@ -536,7 +536,7 @@ FROM polygondf
## ST_NDims
-Introduction: Returns the coordinate dimension of the geometry. It supports 2 - (x,y) , 3 - (x,y,z). Currently the geometry serializer in sedona-sql does not support M dimension, 4D geometries with ZM coordinates will have their M coordinates dropped and became 3D geometries. We're working on a new geometry serializer to resolve this issue.
+Introduction: Returns the coordinate dimension of the geometry.
Format: `ST_NDims(geom: geometry)`
diff --git a/docs/api/sql/Function.md b/docs/api/sql/Function.md
index 2cc145ec..9dfeb3ad 100644
--- a/docs/api/sql/Function.md
+++ b/docs/api/sql/Function.md
@@ -897,7 +897,7 @@ Result:
```
## ST_NDims
-Introduction: Returns the coordinate dimension of the geometry. It supports 2 - (x,y) , 3 - (x,y,z). Currently the geometry serializer in sedona-sql does not support M dimension, 4D geometries with ZM coordinates will have their M coordinates dropped and became 3D geometries. We're working on a new geometry serializer to resolve this issue.
+Introduction: Returns the coordinate dimension of the geometry.
Format: `ST_NDims(geom: geometry)`
diff --git a/flink/src/test/java/org/apache/sedona/flink/FunctionTest.java b/flink/src/test/java/org/apache/sedona/flink/FunctionTest.java
index ab9c721b..4e2a0a14 100644
--- a/flink/src/test/java/org/apache/sedona/flink/FunctionTest.java
+++ b/flink/src/test/java/org/apache/sedona/flink/FunctionTest.java
@@ -432,6 +432,15 @@ public class FunctionTest extends TestBase{
int result = (int) first(polygonTable).getField(0);
assertEquals(3, result, 0);
}
+
+ @Test
+ public void testNDimsForMCoordinate() {
+ Object result = first(tableEnv.sqlQuery("SELECT ST_NDims(ST_GeomFromWKT('POINT M (1 2 3)'))")).getField(0);
+ assertEquals(result, 3);
+ result = first(tableEnv.sqlQuery("SELECT ST_NDims(ST_GeomFromWKT('POINT ZM (1 2 3 4)'))")).getField(0);
+ assertEquals(result, 4);
+ }
+
@Test
public void testXMax() {
Table polygonTable = createPolygonTable(1);
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 2fadafd1..0b3d9d42 100644
--- a/sql/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
+++ b/sql/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
@@ -481,6 +481,16 @@ class functionTestScala extends TestBaseScala with Matchers with GeometrySample
assert(test.take(1)(0).get(0).asInstanceOf[Int] == 3)
}
+ it("Passed ST_NDims with XYM point") {
+ val test = sparkSession.sql("SELECT ST_NDims(ST_GeomFromWKT('POINT M(1 2 3)'))")
+ assert(test.take(1)(0).get(0).asInstanceOf[Int] == 3)
+ }
+
+ it("Passed ST_NDims with XYZM point") {
+ val test = sparkSession.sql("SELECT ST_NDims(ST_GeomFromWKT('POINT ZM(1 2 3 4)'))")
+ assert(test.take(1)(0).get(0).asInstanceOf[Int] == 4)
+ }
+
it("Passed ST_GeometryType") {
var test = sparkSession.sql("SELECT ST_GeometryType(ST_GeomFromText('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)'))")
assert(test.take(1)(0).get(0).asInstanceOf[String].toUpperCase() == "ST_LINESTRING")