This is an automated email from the ASF dual-hosted git repository.

jiayu pushed a commit to branch geojson-m
in repository https://gitbox.apache.org/repos/asf/sedona.git

commit 7e2e240006cdf46651446ea64781218f5e97daaf
Author: Jia Yu <[email protected]>
AuthorDate: Sat Aug 16 14:56:13 2025 -0700

    Add a Scala test
---
 .../org/apache/sedona/sql/functionTestScala.scala  | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git 
a/spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala 
b/spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
index 75a6911dee..44d4c42211 100644
--- a/spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
+++ b/spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
@@ -858,6 +858,32 @@ class functionTestScala
       assert(geojsonDf.first().getString(0) === expectedGeoJson)
     }
 
+    it("Passed ST_AsGeoJSON with XYZM coordinates") {
+      // Define a GeoJSON point with Z and M coordinates
+      val geoJSONPoint = """
+    {
+      "type": "Point",
+      "coordinates": [1.0, 2.0, 3.0, 4.0]
+    }
+  """
+
+      // Convert GeoJSON to geometry
+      val geomDf = sparkSession.sql(s"SELECT 
ST_GeomFromGeoJSON('$geoJSONPoint') as geom")
+      geomDf.createOrReplaceTempView("geomTable")
+
+      // Verify WKT representation includes ZM
+      val wktResult = sparkSession.sql("SELECT ST_AsText(geom) FROM geomTable")
+      val wktExpected = "POINT ZM (1 2 3 4)"
+      assertEquals(wktExpected, 
wktResult.take(1)(0).get(0).asInstanceOf[String])
+
+      // Convert back to GeoJSON
+      val geoJSONResult = sparkSession.sql("SELECT ST_AsGeoJSON(geom) FROM 
geomTable")
+      val expected = "{\"type\":\"Point\",\"coordinates\":[1.0,2.0,3.0]}"
+      assertEquals(expected, 
geoJSONResult.take(1)(0).get(0).asInstanceOf[String])
+
+      // Note that the M coordinate is dropped in GeoJSON output as GeoJSON 
spec doesn't support M values
+    }
+
     it("Passed ST_AsBinary") {
       val df = sparkSession.sql("SELECT ST_AsBinary(ST_GeomFromWKT('POINT (1 
1)'))")
       val s = "0101000000000000000000f03f000000000000f03f"

Reply via email to