Skip to content

Commit

Permalink
feat: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
yyy1000 committed Aug 11, 2023
1 parent 751a9d6 commit 455206f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions python/sedona/sql/st_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,22 +219,26 @@ 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
:param y: Either a number or numeric column representing the Y coordinate of a point.
: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))


Expand Down
3 changes: 3 additions & 0 deletions python/tests/sql/test_constructor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", ",").\
Expand Down

0 comments on commit 455206f

Please sign in to comment.