View Source Geometry.FeatureCollection (Geometry v0.4.0)
A collection of Geometry.Featre
s.
GeometryCollectionZM
implements the protocols Enumerable
and Collectable
.
examples
Examples
iex> Enum.filter(
...> FeatureCollection.new([
...> Feature.new(
...> geometry: Point.new(11, 12),
...> properties: %{"facility" => "Hotel"}
...> ),
...> Feature.new(
...> geometry: Point.new(55, 55),
...> properties: %{"facility" => "Tower"}
...> )
...> ]),
...> fn %Feature{properties: properties} ->
...> Map.get(properties, "facility") == "Hotel"
...> end
...> )
[%Feature{geometry: %Point{coordinate: [11, 12]}, properties: %{"facility" => "Hotel"}}]
iex> Enum.into(
...> [Feature.new(geometry: Point.new(5, 1), properties: %{"area" => 51})],
...> FeatureCollection.new([
...> Feature.new(geometry: Point.new(4, 2), properties: %{"area" => 42})
...> ])
...> )
%FeatureCollection{
features: [
%Feature{geometry: %Point{coordinate: [5, 1]}, properties: %{"area" => 51}},
%Feature{geometry: %Point{coordinate: [4, 2]}, properties: %{"area" => 42}}
]
}
Link to this section Summary
Link to this section Types
@type t() :: %Geometry.FeatureCollection{features: [Geometry.Feature.t()]}
Link to this section Functions
@spec new() :: t()
Creates an empty FeatureCollection
.
examples
Examples
iex> FeatureCollection.new()
%FeatureCollection{}
@spec new([Geometry.Feature.t()]) :: t()
Creates a FeatureCollection
.
examples
Examples
iex> FeatureCollection.new([
...> Feature.new(
...> geometry: Point.new(1, 2),
...> properties: %{facility: :hotel}
...> ),
...> Feature.new(
...> geometry: Point.new(3, 4),
...> properties: %{facility: :school}
...> )
...> ])
%FeatureCollection{features: [
%Feature{
geometry: %Point{coordinate: [1, 2]},
properties: %{facility: :hotel}},
%Feature{
geometry: %Point{coordinate: [3, 4]},
properties: %{facility: :school}}
]}