Geometry.Polygon (Geometry v1.1.0)
View SourceA polygon struct, representing a 2D polygon.
A non-empty line-string requires at least one ring with four coordinates.
Summary
Types
@type t() :: %Geometry.Polygon{rings: [Geometry.ring()], srid: Geometry.srid()}
Functions
@spec new() :: t()
Creates an empty Polygon
.
Examples
iex> Polygon.new()
%Polygon{rings: []}
@spec new([Geometry.LineString.t()], Geometry.srid()) :: t()
Creates a Polygon
from the given rings
.
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]]
],
srid: 0
}
iex> Polygon.new()
%Polygon{}