Skip to content

Commit

Permalink
chore: format python code
Browse files Browse the repository at this point in the history
  • Loading branch information
furqaankhan committed Sep 23, 2024
1 parent 0296ea0 commit 48afff5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
11 changes: 9 additions & 2 deletions python/sedona/sql/st_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,9 +1209,15 @@ def ST_Polygonize(geometry: ColumnOrName) -> Column:
"""
return _call_st_function("ST_Polygonize", (geometry))


@validate_argument_types
def ST_Project(geom: ColumnOrName, distance: Union[ColumnOrName, float], azimuth: Union[ColumnOrName, float], lenient: Optional[Union[ColumnOrName, bool]] = None) -> Column:
""" Calculates a new point location given a starting point, distance, and direction (azimuth).
def ST_Project(
geom: ColumnOrName,
distance: Union[ColumnOrName, float],
azimuth: Union[ColumnOrName, float],
lenient: Optional[Union[ColumnOrName, bool]] = None,
) -> Column:
"""Calculates a new point location given a starting point, distance, and direction (azimuth).
@param geom:
@param distance:
Expand All @@ -1224,6 +1230,7 @@ def ST_Project(geom: ColumnOrName, distance: Union[ColumnOrName, float], azimuth
args = (geom, distance, azimuth)
return _call_st_function("ST_Project", args)


@validate_argument_types
def ST_MakePolygon(
line_string: ColumnOrName, holes: Optional[ColumnOrName] = None
Expand Down
16 changes: 14 additions & 2 deletions python/tests/sql/test_dataframe_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,20 @@
"ST_Normalize(geom)",
"GEOMETRYCOLLECTION (POLYGON ((0 2, 1 3, 2 4, 2 3, 2 2, 1 2, 0 2)), POLYGON ((2 2, 2 3, 2 4, 3 3, 4 2, 3 2, 2 2)))",
),
(stf.ST_Project, ("point", 10.0, radians(10)), "point_geom", "", "POINT (1.7364817766693021 10.848077530122081)"),
(stf.ST_Project, ("geom", 10.0, radians(10), True), "triangle_geom", "", "POINT EMPTY"),
(
stf.ST_Project,
("point", 10.0, radians(10)),
"point_geom",
"",
"POINT (1.7364817766693021 10.848077530122081)",
),
(
stf.ST_Project,
("geom", 10.0, radians(10), True),
"triangle_geom",
"",
"POINT EMPTY",
),
(
stf.ST_MakePolygon,
("geom",),
Expand Down
11 changes: 7 additions & 4 deletions python/tests/sql/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1735,16 +1735,19 @@ def test_st_polygonize(self):
for actual, expected in result:
assert actual == expected


def test_st_project(self):
baseDf = self.spark.sql("SELECT ST_GeomFromWKT('POINT(0 0)') as point")
actual = baseDf.selectExpr("ST_Project(point, 10, radians(45))").first()[0].wkt
expected = "POINT (7.0710678118654755 7.071067811865475)"
assert expected == actual

actual = self.spark\
.sql("SELECT ST_Project(ST_MakeEnvelope(0, 1, 2, 0), 10, radians(50), true)")\
.first()[0].wkt
actual = (
self.spark.sql(
"SELECT ST_Project(ST_MakeEnvelope(0, 1, 2, 0), 10, radians(50), true)"
)
.first()[0]
.wkt
)

expected = "POINT EMPTY"
assert expected == actual
Expand Down

0 comments on commit 48afff5

Please sign in to comment.