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