Conversions

SQL/MM Lua
ST.GeomFromWKT() wkt.decode()
ST.AsWKT() wkt.encode() Geometry.wkt()
ST.GeomFromWKB() wkb.decode()
ST.AsWKB() wkb.encode() Geometry.wkb()
ST.GeomFromHEXWKB() wkb.decode_hex()
ST.AsHEXWKB() wkb.encode_hex() Geometry.hexwkb() Geometry.hex()
ST.AsTable() Geometry.table()
wkt.decode(wkt, srid)
Parameters:
  • wkt (string) – Well-Known Text
  • srid (uint) – Spatial Reference System Identifier
Returns:

a new geometry

Return type:

Geometry

Constructs Geometry from Well-Known Text (WKT).

tarantool> gis.wkt.decode('POINT (37.17284 55.74495)', 4326)
---
- POINT (37.17284 55.74495)
...
ST.GeomFromWKT(wkt, srid)
ST.GeomFromText(wkt, srid)

These function are PostGIS-compatible aliases for wkt.decode().

wkt.encode(geometry)
Parameters:geometry (Geometry) – geometry
Returns:Well-Known Text
Return type:string

Return the Well-Known Text (WKT) representation of the geometry. These function lose SRID information.

WKT format does not maintain precision so please use WKB to prevent floating truncation.

tarantool> point = gis.Point({37.17284, 55.74495}, 4326)
---
...

tarantool> point:wkt()
---
- POINT (37.17284 55.74495)
...

tarantool> tostring(point)
---
- POINT (37.17284 55.74495)
...
Geometry.wkt()

An alias for wkt.encode().

ST.AsWKT(geometry)
ST.AsText(geometry)

These function are PostGIS-compatible aliases for wkt.encode().

wkb.decode(wkb, srid)
Parameters:
  • wkt (string) – Well-Known Binary
  • srid (uint) – Spatial Reference System Identifier
Returns:

a new geometry

Return type:

Geometry

Constructs Geometry from Well-Known Binary (WKB).

tarantool> wkb = "\x01\x01\x00\x00\x00\x67\xB8\x01\x9F\x1F\x96\x42\x40\xDE\x93\x87\x85\x5A\xDF\x4B\x40"
---
...

tarantool> gis.wkb.decode(wkb, 4326)
---
- POINT (37.17284 55.74495)
...
ST.GeomFromWKB(wkb, srid)
ST.GeomFromText(wkb, srid)

These function are PostGIS-compatible aliases for wkb.decode().

wkb.decode_hex(hexwkb, srid)
Parameters:
  • hexwkb (string) – Well-Known Binary as HEX
  • srid (uint) – Spatial Reference System Identifier
Returns:

a new geometry

Return type:

Geometry

Constructs Geometry from Well-Known Binary (WKB) encoded as HEX.

tarantool> hexwkb = "010100000067B8019F1F964240DE9387855ADF4B40"
---
...

tarantool> gis.wkb.decode_hex(hexwkb, 4326)
---
- POINT (37.17284 55.74495)
...
ST.GeomFromHEXWKB(hexwkb, srid)

This function is an alias for wkb.decode_hex().

wkb.encode(geometry)
Parameters:geometry (Geometry) – geometry
Returns:Well-Known Binary
Return type:string

Return the Well-Known Binary (WKB) representation of the geometry. These function lose SRID information.

tarantool> point:wkb()
---
- !!binary AQEAAABnuAGfH5ZCQN6Th4Va30tA
...

tarantool> point:hexwkb()
---
- 010100000067B8019F1F964240DE9387855ADF4B40
...
wkb.encode_hex(geometry)
Parameters:geometry (Geometry) – geometry
Returns:Well-Known Binary (WKB) encoded as HEX
Return type:string

Return the Well-Known Binary (WKB) representation of the geometry encoded as HEX string.

These function lose SRID information.

tarantool> point:hexwkb()
---
- 010100000067B8019F1F964240DE9387855ADF4B40
...
Geometry.wkb()

An alias for wkb.encode().

Geometry.hexwkb()
Geometry.hex()

Aliases for wkb.encode_hex().

ST.AsWKB(geometry)
ST.AsBinary(geometry)

These function are PostGIS-compatible aliases for wkb.encode().

ST.AsHEXWKB(geometry)

This function is an alias for wkb.encode_hex().

Geometry.table()
Geometry.totable()
Returns:Lua Table suitable for constructor
Return type:table

Returns table, srid suitable for a constructor of appropriate type.

tarantool> gis.Point({37.17284, 55.74495}, 4326):totable()
---
- [37.17284, 55.74495]
- 4326
...

tarantool> gis.LineString({{37.279357, 55.849493}, {37.275152, 55.865005}}, 4326):totable()
---
- [[37.279357, 55.849493], [37.275152, 55.865005]]
- 4326
...

tarantool> gis.Point(gis.Point({37.17284, 55.74495}, 4326):totable())
---
- POINT (37.17284 55.74495)
...
ST.AsTable(geometry)

This function is an alias for Geometry.table().