Current section

Files

Jump to
geometry lib geometry multi_line_string_z.ex
Raw

lib/geometry/multi_line_string_z.ex

defmodule Geometry.MultiLineStringZ do
# This file is auto-generated by `mix geometry.gen`.
# The ZM version of this file is used as a template.
@moduledoc """
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: [[[1, 2, 3], [5, 6, 7]]]}
"""
use Geometry.Protocols
alias Geometry.LineStringZ
alias Geometry.MultiLineStringZ
defstruct line_strings: []
@type t :: %MultiLineStringZ{line_strings: [Geometry.coordinates()]}
@doc """
Creates an empty `MultiLineStringZ`.
## Examples
iex> MultiLineStringZ.new()
%MultiLineStringZ{}
"""
@spec new :: t()
def new, do: %MultiLineStringZ{}
@doc """
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)
...> ])
...> ])
%Geometry.MultiLineStringZ{
line_strings: [
[[1, 2, 3], [2, 3, 4], [3, 4, 5]],
[[10, 20, 30], [30, 40, 50]]
]
}
iex> MultiLineStringZ.new([])
%MultiLineStringZ{}
"""
@spec new([LineStringZ.t()]) :: t()
def new([]), do: %MultiLineStringZ{}
def new(line_strings) do
%MultiLineStringZ{
line_strings: Enum.map(line_strings, fn line_string -> line_string.points end)
}
end
end