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