View Source Geo.WKB (Geo v3.6.0)

Converts to and from WKB and EWKB.

It supports WKB both as base-16 encoded strings or as binaries.

Examples

iex> {:ok, point} = Geo.WKB.decode("0101000000000000000000F03F000000000000F03F")
Geo.Point[coordinates: {1, 1}, srid: nil]

iex> Geo.WKT.encode!(point)
"POINT(1 1)"

iex> point = Geo.WKB.decode!("0101000020E61000009EFB613A637B4240CF2C0950D3735EC0")
Geo.Point[coordinates: {36.9639657, -121.8097725}, srid: 4326]

Summary

Functions

Takes a WKB, either as a base-16 encoded string or a binary, and returns a Geometry.

Takes a WKB, either as a base-16 encoded string or a binary, and returns a Geometry.

Takes a Geometry and returns a base-16 encoded WKB string.

Takes a Geometry and returns a base-16 encoded WKB string.

Takes a Geometry and returns WKB as iodata (a sequence of bytes).

Functions

@spec decode(binary()) :: {:ok, Geo.geometry()} | {:error, Exception.t()}

Takes a WKB, either as a base-16 encoded string or a binary, and returns a Geometry.

@spec decode!(binary()) :: Geo.geometry()

Takes a WKB, either as a base-16 encoded string or a binary, and returns a Geometry.

Link to this function

encode(geom, endian \\ :xdr)

View Source
@spec encode(binary(), Geo.endian()) :: {:ok, binary()} | {:error, Exception.t()}

Takes a Geometry and returns a base-16 encoded WKB string.

The endian decides what the byte order will be.

Link to this function

encode!(geom, endian \\ :xdr)

View Source
@spec encode!(Geo.geometry(), Geo.endian()) :: binary()

Takes a Geometry and returns a base-16 encoded WKB string.

The endian decides what the byte order will be.

Link to this function

encode_to_iodata(geom, endian \\ :xdr)

View Source
@spec encode_to_iodata(Geo.geometry(), Geo.endian()) :: iodata()

Takes a Geometry and returns WKB as iodata (a sequence of bytes).

The endian decides what the byte order will be.