Geometry.GeometryCollectionM (Geometry v0.2.0) View Source
A collection set of 2D geometries with a measurement.
GeometryCollectionM
implements the protocols Enumerable
and Collectable
.
Examples
iex> Enum.map(
...> GeometryCollectionM.new([
...> PointM.new(11, 12, 14),
...> LineStringM.new([
...> PointM.new(21, 22, 24),
...> PointM.new(31, 32, 34)
...> ])
...> ]),
...> fn
...> %PointM{} -> :point
...> %LineStringM{} -> :line_string
...> end
...> ) |> Enum.sort()
[:line_string, :point]
iex> Enum.into([PointM.new(1, 2, 4)], GeometryCollectionM.new())
%GeometryCollectionM{
geometries: MapSet.new([%PointM{coordinate: [1, 2, 4]}])
}
Link to this section Summary
Functions
Returns true
if the given GeometryCollectionM
is empty.
Returns an :ok
tuple with the GeometryCollectionM
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 GeometryCollectionM
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 GeometryCollectionM
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 GeometryCollectionM
contains geometry
.
Creates an empty GeometryCollectionM
.
Creates an empty GeometryCollectionM
.
Returns the number of elements in GeometryCollectionM
.
Returns the GeoJSON term of a GeometryCollectionM
.
Converts GeometryCollectionM
to a list.
Returns the WKB representation for a GeometryCollectionM
.
Returns the WKT representation for a GeometryCollectionM
. With option
:srid
an EWKT representation with the SRID is returned.
Link to this section Types
Specs
t() :: %Geometry.GeometryCollectionM{geometries: MapSet.t(Geometry.t())}
Link to this section Functions
Specs
Returns true
if the given GeometryCollectionM
is empty.
Examples
iex> GeometryCollectionM.empty?(GeometryCollectionM.new())
true
iex> GeometryCollectionM.empty?(GeometryCollectionM.new([PointM.new(1, 2, 4)]))
false
Specs
from_geo_json(Geometry.geo_json_term()) :: {:ok, t()} | Geometry.geo_json_error()
Returns an :ok
tuple with the GeometryCollectionM
from the given GeoJSON
term. Otherwise returns an :error
tuple.
Examples
iex> ~s({
...> "type": "GeometryCollection",
...> "geometries": [
...> {"type": "Point", "coordinates": [1.1, 2.2, 4.4]}
...> ]
...> })
iex> |> Jason.decode!()
iex> |> GeometryCollectionM.from_geo_json()
{
:ok,
%GeometryCollectionM{
geometries: MapSet.new([%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()} | {:ok, t(), Geometry.srid()} | Geometry.wkb_error()
Returns an :ok
tuple with the GeometryCollectionM
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.PointM.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 GeometryCollectionM
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> GeometryCollectionM.from_wkt(
...> "GeometryCollection M (Point M (1.1 2.2 4.4))")
{
:ok,
%GeometryCollectionM{
geometries: MapSet.new([%PointM{coordinate: [1.1, 2.2, 4.4]}])
}
}
iex> GeometryCollectionM.from_wkt(
...> "SRID=123;GeometryCollection M (Point M (1.1 2.2 4.4))")
{
:ok,
%GeometryCollectionM{
geometries: MapSet.new([%PointM{coordinate: [1.1, 2.2, 4.4]}])
},
123
}
iex> GeometryCollectionM.from_wkt("GeometryCollection M EMPTY")
{:ok, %GeometryCollectionM{}}
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.t()) :: boolean()
Checks if GeometryCollectionM
contains geometry
.
Examples
iex> GeometryCollectionM.member?(
...> GeometryCollectionM.new([
...> PointM.new(11, 12, 14),
...> LineStringM.new([
...> PointM.new(21, 22, 24),
...> PointM.new(31, 32, 34)
...> ])
...> ]),
...> PointM.new(11, 12, 14)
...> )
true
iex> GeometryCollectionM.member?(
...> GeometryCollectionM.new([
...> PointM.new(11, 12, 14),
...> LineStringM.new([
...> PointM.new(21, 22, 24),
...> PointM.new(31, 32, 34)
...> ])
...> ]),
...> PointM.new(1, 2, 4)
...> )
false
Specs
new() :: t()
Creates an empty GeometryCollectionM
.
Examples
iex> GeometryCollectionM.new()
%GeometryCollectionM{geometries: MapSet.new()}
Specs
new([Geometry.t()]) :: t()
Creates an empty GeometryCollectionM
.
Examples
iex> GeometryCollectionM.new([
...> PointM.new(1, 2, 4),
...> LineStringM.new([PointM.new(1, 1, 1), PointM.new(2, 2, 2)])
...> ])
%GeometryCollectionM{geometries: MapSet.new([
%PointM{coordinate: [1, 2, 4]},
%LineStringM{points: [[1, 1, 1], [2, 2, 2]]}
])}
Specs
size(t()) :: non_neg_integer()
Returns the number of elements in GeometryCollectionM
.
Examples
iex> GeometryCollectionM.size(
...> GeometryCollectionM.new([
...> PointM.new(11, 12, 14),
...> LineStringM.new([
...> PointM.new(21, 22, 24),
...> PointM.new(31, 32, 34)
...> ])
...> ])
...> )
2
Specs
to_geo_json(t()) :: Geometry.geo_json_term()
Returns the GeoJSON term of a GeometryCollectionM
.
Examples
iex> GeometryCollectionM.to_geo_json(
...> GeometryCollectionM.new([PointM.new(1.1, 2.2, 4.4)]))
%{
"type" => "GeometryCollection",
"geometries" => [
%{
"type" => "Point",
"coordinates" => [1.1, 2.2, 4.4]
}
]
}
Specs
to_list(t()) :: [Geometry.t()]
Converts GeometryCollectionM
to a list.
Examples
iex> GeometryCollectionM.to_list(
...> GeometryCollectionM.new([
...> PointM.new(11, 12, 14)
...> ])
...> )
[%PointM{coordinate: [11, 12, 14]}]
Specs
to_wkb(t(), opts) :: Geometry.wkb() when opts: [endian: Geometry.endian(), srid: Geometry.srid()]
Returns the WKB representation for a GeometryCollectionM
.
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 :ndr
.
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.PointM.to_wkb/1
function.
Specs
to_wkt(t(), opts) :: Geometry.wkt() when opts: [{:srid, Geometry.srid()}]
Returns the WKT representation for a GeometryCollectionM
. With option
:srid
an EWKT representation with the SRID is returned.
Examples
iex> GeometryCollectionM.to_wkt(GeometryCollectionM.new())
"GeometryCollection M EMPTY"
iex> GeometryCollectionM.to_wkt(
...> GeometryCollectionM.new([
...> PointM.new(1.1, 1.2, 1.4),
...> PointM.new(2.1, 2.2, 2.4)
...> ])
...> )
"GeometryCollection M (Point M (1.1 1.2 1.4), Point M (2.1 2.2 2.4))"
iex> GeometryCollectionM.to_wkt(
...> GeometryCollectionM.new([PointM.new(1.1, 2.2, 4.4)]),
...> srid: 4711)
"SRID=4711;GeometryCollection M (Point M (1.1 2.2 4.4))"