Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions python/sedona/spark/sql/st_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,123 @@ def ST_GeogFromWKT(
return _call_constructor_function("ST_GeogFromWKT", args)


@validate_argument_types
def ST_GeogFromText(
wkt: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate a geography column from a Well-Known Text (WKT) string column.
This is an alias of ST_GeogFromWKT.

:param wkt: WKT string column to generate from.
:type wkt: ColumnOrName
:return: Geography column representing the WKT string.
:rtype: Column
"""
args = (wkt) if srid is None else (wkt, srid)

return _call_constructor_function("ST_GeogFromText", args)


@validate_argument_types
def ST_GeogFromWKB(
wkb: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate a geography column from a Well-Known Binary (WKB) binary column.

:param wkb: WKB binary column to generate from.
:type wkb: ColumnOrName
:return: Geography column representing the WKB binary.
:rtype: Column
"""
args = (wkb) if srid is None else (wkb, srid)

return _call_constructor_function("ST_GeogFromWKB", args)


@validate_argument_types
def ST_GeogFromEWKB(wkb: ColumnOrName) -> Column:
"""Generate a geography column from an OGC Extended Well-Known Binary (EWKB) binary column.

:param wkb: EWKB binary column to generate from.
:type wkb: ColumnOrName
:return: Geography column representing the EWKB binary.
:rtype: Column
"""
return _call_constructor_function("ST_GeogFromEWKB", wkb)


@validate_argument_types
def ST_GeogFromEWKT(ewkt: ColumnOrName) -> Column:
"""Generate a geography column from an OGC Extended Well-Known Text (EWKT) string column.

:param ewkt: EWKT string column to generate from.
:type ewkt: ColumnOrName
:return: Geography column representing the EWKT string.
:rtype: Column
"""
return _call_constructor_function("ST_GeogFromEWKT", ewkt)


@validate_argument_types
def ST_GeogFromGeoHash(
geohash: ColumnOrName, precision: Optional[Union[ColumnOrName, int]] = None
) -> Column:
"""Generate a geography column from a geohash column at a specified precision.

:param geohash: Geohash string column to generate from.
:type geohash: ColumnOrName
:param precision: Geohash precision to use, either an integer or an integer column.
:type precision: Union[ColumnOrName, int]
:return: Geography column representing the supplied geohash and precision level.
:rtype: Column
"""
args = (geohash) if precision is None else (geohash, precision)

return _call_constructor_function("ST_GeogFromGeoHash", args)


@validate_argument_types
def ST_GeogCollFromText(
wkt: ColumnOrName, srid: Optional[ColumnOrNameOrNumber] = None
) -> Column:
"""Generate a GeometryCollection geography from a GeometryCollection WKT representation.

:param wkt: GeometryCollection WKT string column to generate from.
:type wkt: ColumnOrName
:param srid: SRID for the geography.
:type srid: ColumnOrNameOrNumber
:return: GeometryCollection geography generated from the wkt column.
:rtype: Column
"""
args = (wkt) if srid is None else (wkt, srid)

return _call_constructor_function("ST_GeogCollFromText", args)


@validate_argument_types
def ST_GeogToGeometry(geog: ColumnOrName) -> Column:
"""Convert a geography column into a geometry column.

:param geog: Geography column to convert.
:type geog: ColumnOrName
:return: Geometry column representing the geography.
:rtype: Column
"""
return _call_constructor_function("ST_GeogToGeometry", geog)


@validate_argument_types
def ST_GeomToGeography(geom: ColumnOrName) -> Column:
"""Convert a geometry column into a geography column.

:param geom: Geometry column to convert.
:type geom: ColumnOrName
:return: Geography column representing the geometry.
:rtype: Column
"""
return _call_constructor_function("ST_GeomToGeography", geom)


@validate_argument_types
def ST_GeomFromEWKT(ewkt: ColumnOrName) -> Column:
"""Generate a geometry column from a OGC Extended Well-Known Text (WKT) string column.
Expand Down
Loading
Loading