Geometry Cast

st_castToLineString

LineString st_castToLineString(Geometry g)

This function casts Geometry g to a LineString.

Example:

  • Query command:

    select st_astext(st_castToLineString(st_geomFromWKT(location))) from geotbl where id='5'

  • The query result is as follows:
    LINESTRING (30 10, 40 40, 20 40, 10 20, 30 10)

st_castToPoint

Point st_castToPoint(Geometry g)

This function casts Geometry g to a Point.

Example:

  • Query command:

    select st_astext(st_castToPoint(st_geomFromWKT(location))) from geotbl where id='6'

  • The query result is as follows:
    POINT (11 22)

st_castToPolygon

Polygon st_castToPolygon(Geometry g)

This function casts Geometry g to a polygon.

Example:

  • Query command:

    select st_astext(st_castToPolygon(st_geomFromWKT(location))) from geotbl where id='1'

  • The query result is as follows:
    POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))

st_byteArray

Array[Byte] st_byteArray(String s)

This function encodes strings into an array of bytes using the UTF-8 charset.

Example:

  • Query command:

    select st_byteArray(location) from geotbl where id='2'

  • The query result is as follows:
    UE9MWUdPTiAoKDYwIDEwLDcwIDYwLDgwIDAsNjAgMTApKQ==