struct Geo::Polygon

Overview

A Polygon is a fixed-size, immutable, stack-allocated sequence of Geo::Coord. Coordinates are in lexicographical order. Additionally, polygons form a closed loop and define a filled region.

Included Modules

Defined in:

geo/polygon.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(coords : Array(Geo::Coord), convex_hull = false) #

Instance Method Detail

def ==(other : Geo::Polygon) : Bool #

def area : RingArea::Area #

Return the approximate signed geodesic area of the polygon.


def centroid : Geo::Coord #

def contains?(coord : Geo::Coord) : Bool #

def coords : Array(Geo::Coord) #

def size : Int32 #
Description copied from module Indexable(Geo::Coord)

Returns the number of elements in this container.


def to_geojson : GeoJSON::Polygon #

def unsafe_fetch(index : Int) #
Description copied from module Indexable(Geo::Coord)

Returns the element at the given index, without doing any bounds check.

Indexable makes sure to invoke this method with index in 0...size, so converting negative indices to positive ones is not needed here.

Clients never invoke this method directly. Instead, they access elements with #[](index) and #[]?(index).

This method should only be directly invoked if you are absolutely sure the index is in bounds, to avoid a bounds check for a small boost of performance.