View Source Geometry.Polygon (Geometry v0.4.0)

A polygon struct, representing a 2D polygon.

A none empty line-string requires at least one ring with four points.

Link to this section Summary

Functions

Creates an empty Polygon.

Creates a Polygon from the given rings.

Link to this section Types

@type t() :: %Geometry.Polygon{rings: [Geometry.coordinates()]}

Link to this section Functions

@spec new() :: t()

Creates an empty Polygon.

examples

Examples

iex> Polygon.new()
%Polygon{rings: []}
@spec new([Geometry.LineString.t()]) :: t()

Creates a Polygon from the given rings.

examples

Examples

iex> Polygon.new([
...>   LineString.new([
...>     Point.new(35, 10),
...>     Point.new(45, 45),
...>     Point.new(10, 20),
...>     Point.new(35, 10)
...>   ]),
...>   LineString.new([
...>     Point.new(20, 30),
...>     Point.new(35, 35),
...>     Point.new(30, 20),
...>     Point.new(20, 30)
...>   ])
...> ])
%Polygon{
  rings: [
    [[35, 10], [45, 45], [10, 20], [35, 10]],
    [[20, 30], [35, 35], [30, 20], [20, 30]]
  ]
}

iex> Polygon.new()
%Polygon{}