Geometry.MultiLineStringZM (Geometry v0.2.0) View Source
A set of line-strings from type Geometry.LineStringZM
MultiLineStringMZ
implements the protocols Enumerable
and Collectable
.
Examples
iex> Enum.map(
...> MultiLineStringZM.new([
...> LineStringZM.new([
...> PointZM.new(1, 2, 3, 4),
...> PointZM.new(3, 4, 5, 6)
...> ]),
...> LineStringZM.new([
...> PointZM.new(1, 2, 3, 4),
...> PointZM.new(11, 12, 13, 14),
...> PointZM.new(13, 14, 15, 16)
...> ])
...> ]),
...> fn line_string -> length line_string end
...> )
[2, 3]
iex> Enum.into(
...> [LineStringZM.new([PointZM.new(1, 2, 3, 4), PointZM.new(5, 6, 7, 8)])],
...> MultiLineStringZM.new())
%MultiLineStringZM{
line_strings:
MapSet.new([
[[1, 2, 3, 4], [5, 6, 7, 8]]
])
}
Link to this section Summary
Functions
Returns true
if the given MultiLineStringZM
is empty.
Creates a MultiLineStringZM
from the given coordinates.
Returns an :ok
tuple with the MultiLineStringZM
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 MultiLineStringZM
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 MultiLineStringZM
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 MultiLineStringZM
contains line_string
.
Creates an empty MultiLineStringZM
.
Creates a MultiLineStringZM
from the given Geometry.MultiLineStringZM
s.
Returns the number of elements in MultiLineStringZM
.
Returns the GeoJSON term of a MultiLineStringZM
.
Converts MultiLineStringZM
to a list.
Returns the WKB representation for a MultiLineStringZM
.
Returns the WKT representation for a MultiLineStringZM
. With option :srid
an EWKT representation with the SRID is returned.
Link to this section Types
Specs
t() :: %Geometry.MultiLineStringZM{ line_strings: MapSet.t(Geometry.coordinates()) }
Link to this section Functions
Specs
Returns true
if the given MultiLineStringZM
is empty.
Examples
iex> MultiLineStringZM.empty?(MultiLineStringZM.new())
true
iex> MultiLineStringZM.empty?(
...> MultiLineStringZM.new([
...> LineStringZM.new([PointZM.new(1, 2, 3, 4), PointZM.new(3, 4, 5, 6)])
...> ])
...> )
false
Specs
from_coordinates([Geometry.coordinate()]) :: t()
Creates a MultiLineStringZM
from the given coordinates.
Examples
iex> MultiLineStringZM.from_coordinates([
...> [[-1, 1, 1, 1], [2, 2, 2, 2], [-3, 3, 3, 3]],
...> [[-10, 10, 10, 10], [-20, 20, 20, 20]]
...> ])
%MultiLineStringZM{
line_strings:
MapSet.new([
[[-1, 1, 1, 1], [2, 2, 2, 2], [-3, 3, 3, 3]],
[[-10, 10, 10, 10], [-20, 20, 20, 20]]
])
}
Specs
from_geo_json(Geometry.geo_json_term()) :: {:ok, t()} | Geometry.geo_json_error()
Returns an :ok
tuple with the MultiLineStringZM
from the given GeoJSON
term. Otherwise returns an :error
tuple.
Examples
iex> ~s(
...> {
...> "type": "MultiLineString",
...> "coordinates": [
...> [[-1, 1, 1, 1], [2, 2, 2, 2], [-3, 3, 3, 3]],
...> [[-10, 10, 10, 10], [-20, 20, 20, 20]]
...> ]
...> }
...> )
iex> |> Jason.decode!()
iex> |> MultiLineStringZM.from_geo_json()
{:ok,
%Geometry.MultiLineStringZM{
line_strings:
MapSet.new([
[[-10, 10, 10, 10], [-20, 20, 20, 20]],
[[-1, 1, 1, 1], [2, 2, 2, 2], [-3, 3, 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 MultiLineStringZM
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.PointZM.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 MultiLineStringZM
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> MultiLineStringZM.from_wkt("
...> SRID=1234;MultiLineString ZM (
...> (10 20 10 45, 20 10 35 15, 20 40 10 15),
...> (40 30 10 20, 30 30 25 30)
...> )
...> ")
{
:ok,
%MultiLineStringZM{
line_strings:
MapSet.new([
[[10, 20, 10, 45], [20, 10, 35, 15], [20, 40, 10, 15]],
[[40, 30, 10, 20], [30, 30, 25, 30]]
])
},
1234
}
iex> MultiLineStringZM.from_wkt("MultiLineString ZM EMPTY")
{:ok, %MultiLineStringZM{}}
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.LineStringZM.t()) :: boolean()
Checks if MultiLineStringZM
contains line_string
.
Examples
iex> MultiLineStringZM.member?(
...> MultiLineStringZM.new([
...> LineStringZM.new([
...> PointZM.new(11, 12, 13, 14),
...> PointZM.new(21, 22, 23, 24)
...> ]),
...> LineStringZM.new([
...> PointZM.new(31, 32, 33, 34),
...> PointZM.new(41, 42, 43, 44)
...> ])
...> ]),
...> LineStringZM.new([
...> PointZM.new(31, 32, 33, 34),
...> PointZM.new(41, 42, 43, 44)
...> ])
...> )
true
iex> MultiLineStringZM.member?(
...> MultiLineStringZM.new([
...> LineStringZM.new([
...> PointZM.new(11, 12, 13, 14),
...> PointZM.new(21, 22, 23, 24)
...> ]),
...> LineStringZM.new([
...> PointZM.new(31, 32, 33, 34),
...> PointZM.new(41, 42, 43, 44)
...> ])
...> ]),
...> LineStringZM.new([
...> PointZM.new(11, 12, 13, 14),
...> PointZM.new(41, 42, 43, 44)
...> ])
...> )
false
Specs
new() :: t()
Creates an empty MultiLineStringZM
.
Examples
iex> MultiLineStringZM.new()
%MultiLineStringZM{line_strings: MapSet.new()}
Specs
new([Geometry.LineStringZM.t()]) :: t()
Creates a MultiLineStringZM
from the given Geometry.MultiLineStringZM
s.
Examples
iex> MultiLineStringZM.new([
...> LineStringZM.new([
...> PointZM.new(1, 2, 3, 4),
...> PointZM.new(2, 3, 4, 5),
...> PointZM.new(3, 4, 5, 6)
...> ]),
...> LineStringZM.new([
...> PointZM.new(10, 20, 30, 40),
...> PointZM.new(30, 40, 50, 60)
...> ]),
...> LineStringZM.new([
...> PointZM.new(10, 20, 30, 40),
...> PointZM.new(30, 40, 50, 60)
...> ])
...> ])
%Geometry.MultiLineStringZM{
line_strings:
MapSet.new([
[[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]],
[[10, 20, 30, 40], [30, 40, 50, 60]]
])
}
iex> MultiLineStringZM.new([])
%MultiLineStringZM{line_strings: MapSet.new()}
Specs
size(t()) :: non_neg_integer()
Returns the number of elements in MultiLineStringZM
.
Examples
iex> MultiLineStringZM.size(
...> MultiLineStringZM.new([
...> LineStringZM.new([
...> PointZM.new(11, 12, 13, 14),
...> PointZM.new(21, 22, 23, 24)
...> ]),
...> LineStringZM.new([
...> PointZM.new(31, 32, 33, 34),
...> PointZM.new(41, 42, 43, 44)
...> ])
...> ])
...> )
2
Specs
to_geo_json(t()) :: Geometry.geo_json_term()
Returns the GeoJSON term of a MultiLineStringZM
.
There are no guarantees about the order of line-strings in the returned
coordinates
.
Examples
[
[[-1, 1, 1, 1], [2, 2, 2, 2], [-3, 3, 3, 3]],
[[-10, 10, 10, 10], [-20, 20, 20, 20]]
]
|> MultiLineStringZM.from_coordinates()
MultiLineStringZM.to_geo_json(
MultiLineStringZM.new([
LineStringZM.new([
PointZM.new(-1, 1, 1, 1),
PointZM.new(2, 2, 2, 2),
PointZM.new(-3, 3, 3, 3)
]),
LineStringZM.new([
PointZM.new(-10, 10, 10, 10),
PointZM.new(-20, 20, 20, 20)
])
])
)
# =>
# %{
# "type" => "MultiLineString",
# "coordinates" => [
# [[-1, 1, 1, 1], [2, 2, 2, 2], [-3, 3, 3, 3]],
# [[-10, 10, 10, 10], [-20, 20, 20, 20]]
# ]
# }
Specs
to_list(t()) :: [Geometry.PointZM.t()]
Converts MultiLineStringZM
to a list.
Specs
to_wkb(t(), opts) :: Geometry.wkb() when opts: [ endian: Geometry.endian(), srid: Geometry.srid(), mode: Geometry.mode() ]
Returns the WKB representation for a MultiLineStringZM
.
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.PointZM.to_wkb/1
function.
Specs
to_wkt(t(), opts) :: Geometry.wkt() when opts: [{:srid, Geometry.srid()}]
Returns the WKT representation for a MultiLineStringZM
. With option :srid
an EWKT representation with the SRID is returned.
There are no guarantees about the order of line-strings in the returned WKT-string.
Examples
MultiLineStringZM.to_wkt(MultiLineStringZM.new())
# => "MultiLineString ZM EMPTY"
MultiLineStringZM.to_wkt(
MultiLineStringZM.new([
LineStringZM(
[PointZM.new(7.1, 8.1, 1.1, 1), PointZM.new(9.2, 5.2, 2.2, 2)]
),
LineStringZM(
[PointZM.new(5.5, 9.2, 3.1, 1), PointZM.new(1.2, 3.2, 4.2, 2)]
)
])
)
# Returns a string without any \n or extra spaces (formatted just for readability):
# MultiLineString ZM (
# (5.5 9.2 3.1 1, 1.2 3.2 4.2 2),
# (7.1 8.1 1.1 1, 9.2 5.2 2.2 2)
# )
MultiLineStringZM.to_wkt(
MultiLineStringZM.new([
LineStringZM(
[PointZM.new(7.1, 8.1, 1.1, 1), PointZM.new(9.2, 5.2, 2.2, 2)]
),
LineStringZM(
[PointZM.new(5.5, 9.2, 3.1, 1), PointZM.new(1.2, 3.2, 4.2, 2)]
)
]),
srid: 555
)
# Returns a string without any \n or extra spaces (formatted just for readability):
# SRID=555;MultiLineString ZM (
# (5.5 9.2 3.1 1, 1.2 3.2 4.2 2),
# (7.1 8.1 1.1 1, 9.2 5.2 2.2 2)
# )