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