Geometry.MultiPointZ (Geometry v0.2.0) View Source
A set of points from type Geometry.PointZ
.
MultiPointZ
implements the protocols Enumerable
and Collectable
.
Examples
iex> Enum.map(
...> MultiPointZ.new([
...> PointZ.new(1, 2, 3),
...> PointZ.new(3, 4, 5)
...> ]),
...> fn [x, _y, _z] -> x end
...> )
[1, 3]
iex> Enum.into([PointZ.new(1, 2, 3)], MultiPointZ.new())
%MultiPointZ{
points:
MapSet.new([
[1, 2, 3]
])
}
Link to this section Summary
Functions
Returns true
if the given MultiPointZ
is empty.
Creates a MultiPointZ
from the given coordinates.
Returns an :ok
tuple with the MultiPointZ
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 MultiPointZ
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 MultiPointZ
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.
Checks if MulitPointZ
contains point
.
Creates an empty MultiPointZ
.
Creates a MultiPointZ
from the given Geometry.PointZ
s.
Returns the number of elements in MultiPointZ
.
Returns the GeoJSON term of a MultiPointZ
.
Converts MultiPointZ
to a list.
Returns the WKB representation for a MultiPointZ
.
Returns the WKT representation for a MultiPointZ
. With option :srid
an
EWKT representation with the SRID is returned.
Link to this section Types
Specs
t() :: %Geometry.MultiPointZ{points: MapSet.t(Geometry.coordinate())}
Link to this section Functions
Specs
Returns true
if the given MultiPointZ
is empty.
Examples
iex> MultiPointZ.empty?(MultiPointZ.new())
true
iex> MultiPointZ.empty?(
...> MultiPointZ.new(
...> [PointZ.new(1, 2, 3), PointZ.new(3, 4, 5)]
...> )
...> )
false
Specs
from_coordinates([Geometry.coordinate()]) :: t()
Creates a MultiPointZ
from the given coordinates.
Examples
iex> MultiPointZ.from_coordinates(
...> [[-1, 1, 1], [-2, 2, 2], [-3, 3, 3]]
...> )
%MultiPointZ{
points: MapSet.new([
[-1, 1, 1],
[-2, 2, 2],
[-3, 3, 3]
])
}
iex> MultiPointZ.from_coordinates(
...> [[-1, 1, 1], [-2, 2, 2], [-3, 3, 3]]
...> )
%MultiPointZ{
points: MapSet.new([
[-1, 1, 1],
[-2, 2, 2],
[-3, 3, 3]
])
}
Specs
from_geo_json(Geometry.geo_json_term()) :: {:ok, t()} | Geometry.geo_json_error()
Returns an :ok
tuple with the MultiPointZ
from the given GeoJSON term.
Otherwise returns an :error
tuple.
Examples
iex> ~s(
...> {
...> "type": "MultiPoint",
...> "coordinates": [
...> [1.1, 1.2, 1.3],
...> [20.1, 20.2, 20.3]
...> ]
...> }
...> )
iex> |> Jason.decode!()
iex> |> MultiPointZ.from_geo_json()
{:ok, %MultiPointZ{points: MapSet.new([
[1.1, 1.2, 1.3],
[20.1, 20.2, 20.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 MultiPointZ
from the given WKB string. Otherwise
returns an :error
tuple.
If the geometry contains a SRID the id is added to the tuple.
An example of a simpler geometry can be found in the description for the
Geometry.PointZ.from_wkb/2
function.
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 MultiPointZ
from the given WKT string.
Otherwise returns an :error
tuple.
If the geometry contains a SRID the id is added to the tuple.
Examples
iex> MultiPointZ.from_wkt(
...> "MultiPoint Z (-5.1 7.8 1.1, 0.1 0.2 2.2)"
...> )
{:ok, %MultiPointZ{
points: MapSet.new([
[-5.1, 7.8, 1.1],
[0.1, 0.2, 2.2]
])
}}
iex> MultiPointZ.from_wkt(
...> "SRID=7219;MultiPoint Z (-5.1 7.8 1.1, 0.1 0.2 2.2)"
...> )
{:ok, %MultiPointZ{
points: MapSet.new([
[-5.1, 7.8, 1.1],
[0.1, 0.2, 2.2]
])
}, 7219}
iex> MultiPointZ.from_wkt("MultiPoint Z EMPTY")
...> {:ok, %MultiPointZ{}}
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
member?(t(), Geometry.PointZ.t()) :: boolean()
Checks if MulitPointZ
contains point
.
Examples
iex> MultiPointZ.member?(
...> MultiPointZ.new([
...> PointZ.new(11, 12, 13),
...> PointZ.new(21, 22, 23)
...> ]),
...> PointZ.new(11, 12, 13)
...> )
true
iex> MultiPointZ.member?(
...> MultiPointZ.new([
...> PointZ.new(11, 12, 13),
...> PointZ.new(21, 22, 23)
...> ]),
...> PointZ.new(1, 2, 3)
...> )
false
Specs
new() :: t()
Creates an empty MultiPointZ
.
Examples
iex> MultiPointZ.new()
%MultiPointZ{points: MapSet.new()}
Specs
new([Geometry.PointZ.t()]) :: t()
Creates a MultiPointZ
from the given Geometry.PointZ
s.
Examples
iex> MultiPointZ.new([
...> PointZ.new(1, 2, 3),
...> PointZ.new(1, 2, 3),
...> PointZ.new(3, 4, 5)
...> ])
%MultiPointZ{points: MapSet.new([
[1, 2, 3],
[3, 4, 5]
])}
iex> MultiPointZ.new([])
%MultiPointZ{points: MapSet.new()}
Specs
size(t()) :: non_neg_integer()
Returns the number of elements in MultiPointZ
.
Examples
iex> MultiPointZ.size(
...> MultiPointZ.new([
...> PointZ.new(11, 12, 13),
...> PointZ.new(21, 22, 23)
...> ])
...> )
2
Specs
to_geo_json(t()) :: Geometry.geo_json_term()
Returns the GeoJSON term of a MultiPointZ
.
There are no guarantees about the order of points in the returned
coordinates
.
Examples
MultiPointZ.to_geo_json(
MultiPointZ.new([
PointZ.new(-1.1, -2.2, -3.3),
PointZ.new(1.1, 2.2, 3.3)
])
)
# =>
# %{
# "type" => "MultiPoint",
# "coordinates" => [
# [-1.1, -2.2, -3.3],
# [1.1, 2.2, 3.3]
# ]
# }
Specs
to_list(t()) :: [Geometry.PointZ.t()]
Converts MultiPointZ
to a list.
Examples
iex> MultiPointZ.to_list(
...> MultiPointZ.new([
...> PointZ.new(11, 12, 13),
...> PointZ.new(21, 22, 23)
...> ])
...> )
[
[11, 12, 13],
[21, 22, 23]
]
Specs
to_wkb(t(), opts) :: Geometry.wkb() when opts: [ endian: Geometry.endian(), srid: Geometry.srid(), mode: Geometry.mode() ]
Returns the WKB representation for a MultiPointZ
.
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
.
An example of a simpler geometry can be found in the description for the
Geometry.PointZ.to_wkb/1
function.
Specs
to_wkt(t(), opts) :: Geometry.wkt() when opts: [{:srid, Geometry.srid()}]
Returns the WKT representation for a MultiPointZ
. With option :srid
an
EWKT representation with the SRID is returned.
There are no guarantees about the order of points in the returned WKT-string.
Examples
MultiPointZ.to_wkt(MultiPointZ.new())
# => "MultiPoint Z EMPTY"
MultiPointZ.to_wkt(
MultiPointZ.new([
PointZ.new(7.1, 8.1, 1.1),
PointZ.new(9.2, 5.2, 2.2)
]
)
# => "MultiPoint Z (7.1 8.1 1.1, 9.2 5.2 2.2)"
MultiPointZ.to_wkt(
MultiPointZ.new([
PointZ.new(7.1, 8.1, 1.1),
PointZ.new(9.2, 5.2, 2.2)
]),
srid: 123
)
# => "SRID=123;MultiPoint Z (7.1 8.1 1.1, 9.2 5.2 2.2)"