Geometry.PointZM (Geometry v0.2.0) View Source

A point struct, representing a 3D point with a measurement.

Link to this section Summary

Functions

Returns true if the given PointZM is empty.

Creates a PointZM from the given coordinate.

Returns an :ok tuple with the PointZM from the given GeoJSON term. Otherwise returns an :error tuple.

The same as from_geo_json/1, but raises a Geometry.Error exception if it fails.

Returns an :ok tuple with the PointZM from the given WKB string. Otherwise returns an :error tuple.

The same as from_wkb/2, but raises a Geometry.Error exception if it fails.

Returns an :ok tuple with the PointZM from the given WKT string. Otherwise returns an :error tuple.

The same as from_wkt/1, but raises a Geometry.Error exception if it fails.

Creates an empty PointZM.

Creates a PointZM from the given coordinate.

Creates a PointZM from the given x, y, z, and m.

Returns the GeoJSON term of a PointZM.

Returns the WKB representation for a PointZM.

Returns the WKT representation for a PointZM. With option :srid an EWKT representation with the SRID is returned.

Link to this section Types

Specs

t() :: %Geometry.PointZM{coordinate: Geometry.coordinate() | nil}

Link to this section Functions

Specs

empty?(t()) :: boolean()

Returns true if the given PointZM is empty.

Examples

iex> PointZM.empty?(PointZM.new())
true

iex> PointZM.empty?(PointZM.new(1, 2, 3, 4))
false
Link to this function

from_coordinates(coordinate)

View Source

Specs

from_coordinates(Geometry.coordinate() | [nil, ...]) :: t()

Creates a PointZM from the given coordinate.

Examples

iex> PointZM.from_coordinates([[-1, 1, 1, 1]])
%PointZM{coordinate: [-1, 1, 1, 1]}

Specs

from_geo_json(Geometry.geo_json_term()) ::
  {:ok, t()} | Geometry.geo_json_error()

Returns an :ok tuple with the PointZM from the given GeoJSON term. Otherwise returns an :error tuple.

Examples

iex> ~s({"type": "Point", "coordinates": [1.1, 2.2, 3.3, 4.4]})
iex> |> Jason.decode!()
iex> |> PointZM.from_geo_json()
{:ok, %PointZM{coordinate: [1.1, 2.2, 3.3, 4.4]}}

Specs

from_geo_json!(Geometry.geo_json_term()) :: t()

The same as from_geo_json/1, but raises a Geometry.Error exception if it fails.

Link to this function

from_wkb(wkb, mode \\ :binary)

View Source

Specs

from_wkb(Geometry.wkb(), Geometry.mode()) ::
  {:ok, t()} | {:ok, t(), Geometry.srid()} | Geometry.wkb_error()

Returns an :ok tuple with the PointZM from the given WKB string. Otherwise returns an :error tuple.

If the geometry contains a SRID the id is added to the tuple.

The optional second argument determines if a :hex-string or a :binary input is expected. The default is :binary.

Examples

iex> PointZM.from_wkb(
...>   "00C00000017FF80000000000007FF80000000000007FF80000000000007FF8000000000000",
...>   :hex
...> )
{:ok, %PointZM{coordinate: nil}}

iex> PointZM.from_wkb(
...>   "00C00000013FF199999999999A400199999999999A400A666666666666401199999999999A",
...>   :hex
...> )
{:ok, %PointZM{coordinate: [1.1, 2.2, 3.3, 4.4]}}

iex> PointZM.from_wkb(
...>   "01010000C09A9999999999F13F9A999999999901406666666666660A409A99999999991140",
...>   :hex
...> )
{:ok, %PointZM{coordinate: [1.1, 2.2, 3.3, 4.4]}}

iex> PointZM.from_wkb(
...>   "00E0000001000012673FF199999999999A400199999999999A400A666666666666401199999999999A",
...>   :hex
...> )
{:ok, %PointZM{coordinate: [1.1, 2.2, 3.3, 4.4]}, 4711}
Link to this function

from_wkb!(wkb, mode \\ :binary)

View Source

Specs

from_wkb!(Geometry.wkb(), Geometry.mode()) :: t() | {t(), Geometry.srid()}

The same as from_wkb/2, but raises a Geometry.Error exception if it fails.

Specs

from_wkt(Geometry.wkt()) ::
  {:ok, t()} | {:ok, t(), Geometry.srid()} | Geometry.wkt_error()

Returns an :ok tuple with the PointZM from the given WKT string. Otherwise returns an :error tuple.

If the geometry contains an SRID the id is added to the tuple.

Examples

iex> PointZM.from_wkt("Point ZM (-5.1 7.8 9.9 12)")
{:ok, %PointZM{coordinate: [-5.1, 7.8, 9.9, 12]}}

iex> PointZM.from_wkt("SRID=7219;Point ZM (-5.1 7.8 9.9 12)")
{:ok, %PointZM{coordinate: [-5.1, 7.8, 9.9, 12]}, 7219}

iex> PointZM.from_wkt("Point ZM EMPTY")
{:ok, %PointZM{}}

Specs

from_wkt!(Geometry.wkt()) :: t() | {t(), Geometry.srid()}

The same as from_wkt/1, but raises a Geometry.Error exception if it fails.

Specs

new() :: t()

Creates an empty PointZM.

Examples

iex> PointZM.new()
%PointZM{coordinate: nil}

Specs

new(Geometry.coordinate()) :: t()

Creates a PointZM from the given coordinate.

Examples

iex> PointZM.new([1.5, -2.1, 3, 4])
%PointZM{coordinate: [1.5, -2.1, 3, 4]}

Specs

new(number(), number(), number(), number()) :: t()

Creates a PointZM from the given x, y, z, and m.

Examples

iex> PointZM.new(-1.1, 2.2, 3, 4)
%PointZM{coordinate: [-1.1, 2.2, 3, 4]}

Specs

to_geo_json(t()) :: Geometry.geo_json_term()

Returns the GeoJSON term of a PointZM.

Examples

iex> PointZM.to_geo_json(PointZM.new(1, 2, 3, 4))
%{"type" => "Point", "coordinates" => [1, 2, 3, 4]}
Link to this function

to_wkb(point_zm, opts \\ [])

View Source

Specs

to_wkb(t(), opts) :: Geometry.wkb()
when opts: [
       endian: Geometry.endian(),
       srid: Geometry.srid(),
       mode: Geometry.mode()
     ]

Returns the WKB representation for a PointZM.

With option :srid an EWKB representation with the SRID is returned.

The option :endian indicates whether :xdr big endian or :ndr little endian is returned. The default is :xdr.

The :mode determines whether a hex-string or binary is returned. The default is :binary.

Examples

iex> PointZM.to_wkb(PointZM.new(), mode: :hex)
"00C00000017FF80000000000007FF80000000000007FF80000000000007FF8000000000000"

iex> PointZM.to_wkb(PointZM.new(), endian: :ndr, mode: :hex)
"01010000C0000000000000F87F000000000000F87F000000000000F87F000000000000F87F"

iex> PointZM.to_wkb(PointZM.new(1.1, 2.2, 3.3, 4.4), endian: :xdr, mode: :hex)
"00C00000013FF199999999999A400199999999999A400A666666666666401199999999999A"

iex> PointZM.to_wkb(PointZM.new(1.1, 2.2, 3.3, 4.4), endian: :ndr, mode: :hex)
"01010000C09A9999999999F13F9A999999999901406666666666660A409A99999999991140"

iex> PointZM.to_wkb(PointZM.new(1.1, 2.2, 3.3, 4.4), srid: 4711, endian: :xdr, mode: :hex)
"00E0000001000012673FF199999999999A400199999999999A400A666666666666401199999999999A"
Link to this function

to_wkt(point_zm, opts \\ [])

View Source

Specs

to_wkt(t(), opts) :: Geometry.wkt() when opts: [{:srid, Geometry.srid()}]

Returns the WKT representation for a PointZM. With option :srid an EWKT representation with the SRID is returned.

Examples

iex> PointZM.to_wkt(PointZM.new())
"Point ZM EMPTY"

iex> PointZM.to_wkt(PointZM.new(1.1, 2.2, 3.3, 4.4))
"Point ZM (1.1 2.2 3.3 4.4)"

iex> PointZM.to_wkt(PointZM.new(1.1, 2.2, 3.3, 4.4), srid: 4711)
"SRID=4711;Point ZM (1.1 2.2 3.3 4.4)"