View Source Geometry.GeometryCollection (Geometry v0.4.0)

A collection set of 2D geometries.

GeometryCollection implements the protocols Enumerable and Collectable.

examples

Examples

iex> Enum.map(
...>   GeometryCollection.new([
...>     Point.new(11, 12),
...>     LineString.new([
...>       Point.new(21, 22),
...>       Point.new(31, 32)
...>     ])
...>   ]),
...>   fn
...>     %Point{} -> :point
...>     %LineString{} -> :line_string
...>   end
...> ) |> Enum.sort()
[:line_string, :point]

iex> Enum.into([Point.new(1, 2)], GeometryCollection.new())
%GeometryCollection{geometries: [%Point{coordinate: [1, 2]}]}

Link to this section Summary

Functions

Creates an empty GeometryCollection.

Creates an empty GeometryCollection.

Link to this section Types

@type t() :: %Geometry.GeometryCollection{geometries: []}

Link to this section Functions

@spec new() :: t()

Creates an empty GeometryCollection.

examples

Examples

iex> GeometryCollection.new()
%GeometryCollection{geometries: []}
@spec new([Geometry.t()]) :: t()

Creates an empty GeometryCollection.

examples

Examples

iex> GeometryCollection.new([
...>   Point.new(1, 2),
...>   LineString.new([Point.new(1, 1), Point.new(2, 2)])
...> ])
%GeometryCollection{geometries: [
  %Point{coordinate: [1, 2]},
  %LineString{points: [[1, 1], [2, 2]]}
]}