Open WPS Platform

ZOO.Geometry.Polygon

Polygon is a collection of ZOO.Geometry.LinearRing.

Inherits from

Functions

NAME DESCRIPTION
ZOO.Geometry.Polygon Constructor for a Polygon geometry.
getArea Calculated by subtracting the areas of the internal holes from the area of the outer hole.
containsPoint Test if a point is inside a polygon.
createRegularPolygon Create a regular polygon around a radius.
ZOO.Geometry.Polygon

Constructor for a Polygon geometry. The first ring (this.component[0]) is the outer bounds of the polygon and all subsequent rings (this.component[1-n]) are internal holes.

Parameters

components {Array(ZOO.Geometry.LinearRing)}

getArea
getArea: function()

Calculated by subtracting the areas of the internal holes from the area of the outer hole.

Returns

{float} The area of the geometry

containsPoint
containsPoint: function(point)

Test if a point is inside a polygon. Points on a polygon edge are considered inside.

Parameters

point {ZOO.Geometry.Point}

Returns

{Boolean | Number} The point is inside the polygon. Returns 1 if the point is on an edge. Returns boolean otherwise.

createRegularPolygon
ZOO.Geometry.Polygon.createRegularPolygon = function( origin,
                                                      radius,
                                                      sides,
                                                      rotation      )

Create a regular polygon around a radius. Useful for creating circles and the like.

Parameters

origin {ZOO.Geometry.Point} center of polygon.
radius {Float} distance to vertex, in map units.
sides {Integer} Number of sides. 20 approximates a circle.
rotation {Float} original angle of rotation, in degrees.