Geometry.PointM (Geometry v0.3.0) View Source
A point struct, representing a 2D point with a measurement.
Link to this section Summary
Functions
Returns true
if the given PointM
is empty.
Creates a PointM
from the given coordinate.
Returns an :ok
tuple with the PointM
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 PointM
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 PointM
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 PointM
.
Creates a PointM
from the given coordinate
.
Creates a PointM
from the given x
, y
, and m
.
Returns the GeoJSON term of a PointM
.
Returns the WKB representation for a PointM
.
Returns the WKT representation for a PointM
. With option :srid
an EWKT
representation with the SRID is returned.
Link to this section Types
Specs
t() :: %Geometry.PointM{coordinate: Geometry.coordinate() | nil}
Link to this section Functions
Specs
Returns true
if the given PointM
is empty.
Examples
iex> PointM.empty?(PointM.new())
true
iex> PointM.empty?(PointM.new(1, 2, 4))
false
Specs
from_coordinates(Geometry.coordinate() | [nil, ...]) :: t()
Creates a PointM
from the given coordinate.
Examples
iex> PointM.from_coordinates([[-1, 1, 1]])
%PointM{coordinate: [-1, 1, 1]}
Specs
from_geo_json(Geometry.geo_json_term()) :: {:ok, t()} | Geometry.geo_json_error()
Returns an :ok
tuple with the PointM
from the given GeoJSON term.
Otherwise returns an :error
tuple.
Examples
iex> ~s({"type": "Point", "coordinates": [1.1, 2.2, 4.4]})
iex> |> Jason.decode!()
iex> |> PointM.from_geo_json()
{:ok, %PointM{coordinate: [1.1, 2.2, 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.
Specs
from_wkb(Geometry.wkb(), Geometry.mode()) :: {:ok, t() | {t(), Geometry.srid()}} | Geometry.wkb_error()
Returns an :ok
tuple with the PointM
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> PointM.from_wkb(
...> "00400000017FF80000000000007FF80000000000007FF8000000000000",
...> :hex
...> )
{:ok, %PointM{coordinate: nil}}
iex> PointM.from_wkb(
...> "00400000013FF199999999999A400199999999999A401199999999999A",
...> :hex
...> )
{:ok, %PointM{coordinate: [1.1, 2.2, 4.4]}}
iex> PointM.from_wkb(
...> "01010000409A9999999999F13F9A999999999901409A99999999991140",
...> :hex
...> )
{:ok, %PointM{coordinate: [1.1, 2.2, 4.4]}}
iex> PointM.from_wkb(
...> "0060000001000012673FF199999999999A400199999999999A401199999999999A",
...> :hex
...> )
{:ok, {%PointM{coordinate: [1.1, 2.2, 4.4]}, 4711}}
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()} | {t(), Geometry.srid()} | Geometry.wkt_error()
Returns an :ok
tuple with the PointM
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> PointM.from_wkt("Point M (-5.1 7.8 12)")
{:ok, %PointM{coordinate: [-5.1, 7.8, 12]}}
iex> PointM.from_wkt("SRID=7219;Point M (-5.1 7.8 12)")
{:ok, {%PointM{coordinate: [-5.1, 7.8, 12]}, 7219}}
iex> PointM.from_wkt("Point M EMPTY")
{:ok, %PointM{}}
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 PointM
.
Examples
iex> PointM.new()
%PointM{coordinate: nil}
Specs
new(Geometry.coordinate()) :: t()
Creates a PointM
from the given coordinate
.
Examples
iex> PointM.new([1.5, -2.1, 4])
%PointM{coordinate: [1.5, -2.1, 4]}
Specs
Creates a PointM
from the given x
, y
, and m
.
Examples
iex> PointM.new(-1.1, 2.2, 4)
%PointM{coordinate: [-1.1, 2.2, 4]}
Specs
to_geo_json(t()) :: Geometry.geo_json_term()
Returns the GeoJSON term of a PointM
.
Examples
iex> PointM.to_geo_json(PointM.new(1, 2, 4))
%{"type" => "Point", "coordinates" => [1, 2, 4]}
Specs
to_wkb(t(), opts) :: Geometry.wkb() when opts: [ endian: Geometry.endian(), srid: Geometry.srid(), mode: Geometry.mode() ]
Returns the WKB representation for a PointM
.
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> PointM.to_wkb(PointM.new(), mode: :hex)
"00400000017FF80000000000007FF80000000000007FF8000000000000"
iex> PointM.to_wkb(PointM.new(), endian: :ndr, mode: :hex)
"0101000040000000000000F87F000000000000F87F000000000000F87F"
iex> PointM.to_wkb(PointM.new(1.1, 2.2, 4.4), endian: :xdr, mode: :hex)
"00400000013FF199999999999A400199999999999A401199999999999A"
iex> PointM.to_wkb(PointM.new(1.1, 2.2, 4.4), endian: :ndr, mode: :hex)
"01010000409A9999999999F13F9A999999999901409A99999999991140"
iex> PointM.to_wkb(PointM.new(1.1, 2.2, 4.4), srid: 4711, endian: :xdr, mode: :hex)
"0060000001000012673FF199999999999A400199999999999A401199999999999A"
Specs
to_wkt(t(), opts) :: Geometry.wkt() when opts: [{:srid, Geometry.srid()}]
Returns the WKT representation for a PointM
. With option :srid
an EWKT
representation with the SRID is returned.
Examples
iex> PointM.to_wkt(PointM.new())
"Point M EMPTY"
iex> PointM.to_wkt(PointM.new(1.1, 2.2, 4.4))
"Point M (1.1 2.2 4.4)"
iex> PointM.to_wkt(PointM.new(1.1, 2.2, 4.4), srid: 4711)
"SRID=4711;Point M (1.1 2.2 4.4)"