diff --git a/common/src/test/java/org/apache/sedona/common/ConstructorsTest.java b/common/src/test/java/org/apache/sedona/common/ConstructorsTest.java index 29d769b0cd..7d621f7c5a 100644 --- a/common/src/test/java/org/apache/sedona/common/ConstructorsTest.java +++ b/common/src/test/java/org/apache/sedona/common/ConstructorsTest.java @@ -132,7 +132,7 @@ public void point4DZM() { assertTrue(point instanceof Point); assertTrue(GeomUtils.isMeasuredGeometry(point)); assertEquals(0, point.getSRID()); - assertEquals("POINT Z(1 2 3)", Functions.asWKT(point)); + assertEquals("POINT ZM(1 2 3 4)", Functions.asWKT(point)); } @Test diff --git a/python/sedona/sql/st_constructors.py b/python/sedona/sql/st_constructors.py index 4fb6b805f3..395676bb3e 100644 --- a/python/sedona/sql/st_constructors.py +++ b/python/sedona/sql/st_constructors.py @@ -219,9 +219,9 @@ def ST_PointFromText(coords: ColumnOrName, delimiter: ColumnOrName) -> Column: return _call_constructor_function("ST_PointFromText", (coords, delimiter)) @validate_argument_types -def ST_MakePoint(x: ColumnOrNameOrNumber, y: ColumnOrNameOrNumber, z: Optional[ColumnOrNameOrNumber] = None) -> Column: - """Generate a 2D or a 3D Z Point geometry. If z is None then a 2D point is generated. - This function doesn't support M coordinates for creating a 4D ZM Point. +def ST_MakePoint(x: ColumnOrNameOrNumber, y: ColumnOrNameOrNumber, z: Optional[ColumnOrNameOrNumber] = None, m: Optional[ColumnOrNameOrNumber] = None) -> Column: + """Generate a 2D, 3D Z or 4D ZM Point geometry. If z is None then a 2D point is generated. + This function doesn't support M coordinates for creating a 4D ZM Point in Dataframe API. :param x: Either a number or numeric column representing the X coordinate of a point. :type x: ColumnOrNameOrNumber @@ -229,12 +229,16 @@ def ST_MakePoint(x: ColumnOrNameOrNumber, y: ColumnOrNameOrNumber, z: Optional[C :type y: ColumnOrNameOrNumber :param z: Either a number or numeric column representing the Z coordinate of a point, if None then a 2D point is generated, defaults to None :type z: ColumnOrNameOrNumber + :param m: Either a number or numeric column representing the M coordinate of a point, if None then a point without M coordinate is generated, defaults to None + :type m: ColumnOrNameOrNumber :return: Point geometry column generated from the coordinate values. :rtype: Column """ args = (x, y) if z is not None: args = args + (z,) + if m is not None: + args = args + (m,) return _call_constructor_function("ST_MakePoint", (args)) diff --git a/python/tests/sql/test_constructor_test.py b/python/tests/sql/test_constructor_test.py index c3c17b3301..8e40ab8b10 100644 --- a/python/tests/sql/test_constructor_test.py +++ b/python/tests/sql/test_constructor_test.py @@ -51,6 +51,9 @@ def test_st_makepoint(self): point_df = self.spark.sql("SELECT ST_AsText(ST_MakePoint(1.2345, 2.3456, 3.4567))") assert point_df.take(1)[0][0] == "POINT Z(1.2345 2.3456 3.4567)" + point_df = self.spark.sql("SELECT ST_AsText(ST_MakePoint(1.2345, 2.3456, 3.4567, 4))") + assert point_df.take(1)[0][0] == "POINT ZM(1.2345 2.3456 3.4567 4)" + def test_st_point_from_text(self): point_csv_df = self.spark.read.format("csv").\ option("delimiter", ",").\