ALKMaps.Geometry.Polygon

Polygon is a collection of Geometry.LinearRings.

Inherits from

Summary
ALKMaps.Geometry.PolygonPolygon is a collection of Geometry.LinearRings.
Properties
componentTypes{Array(String)} An array of class names representing the types of components that the collection can include.
Constructor
ALKMaps.Geometry.PolygonConstructor for a Polygon geometry.
Functions
getAreaCalculated by subtracting the areas of the internal holes from the area of the outer hole.
getGeodesicAreaCalculate the approximate area of the polygon were it projected onto the earth.
containsPointTest if a point is inside a polygon.
intersectsDetermine if the input geometry intersects this one.
distanceToCalculate the closest distance between two geometries (on the x-y plane).
createRegularPolygonCreate a regular polygon around a radius.
createGeodesicPolygonCreate a regular polygon around a radius.

Properties

componentTypes

{Array(String)} An array of class names representing the types of components that the collection can include.  A null value means the component types are not restricted.

Constructor

ALKMaps.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(ALKMaps.Geometry.LinearRing)}

Functions

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

getGeodesicArea

getGeodesicArea: function(projection)

Calculate the approximate area of the polygon were it projected onto the earth.

Parameters

projection{ALKMaps.Projection} The spatial reference system for the geometry coordinates.  If not provided, Geographic/WGS84 is assumed.

Reference

Robert.  G. Chamberlain and William H.  Duquette, “Some Algorithms for Polygons on a Sphere”, JPL Publication 07-03, Jet Propulsion Laboratory, Pasadena, CA, June 2007 https://trs-new.jpl.nasa.gov/dspace/handle/2014/40409

Returns

{float} The approximate geodesic area of the polygon in square meters.

containsPoint

containsPoint: function(point)

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

Parameters

point{ALKMaps.Geometry.Point}

Returns

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

intersects

intersects: function(geometry)

Determine if the input geometry intersects this one.

Parameters

geometry{ALKMaps.Geometry} Any type of geometry.

Returns

{Boolean} The input geometry intersects this one.

distanceTo

distanceTo: function(geometry,
options)

Calculate the closest distance between two geometries (on the x-y plane).

Parameters

geometry{ALKMaps.Geometry} The target geometry.
options{Object} Optional properties for configuring the distance calculation.

Valid options

details{Boolean} Return details from the distance calculation.  Default is false.
edge{Boolean} Calculate the distance from this geometry to the nearest edge of the target geometry.  Default is true.  If true, calling distanceTo from a geometry that is wholly contained within the target will result in a non-zero distance.  If false, whenever geometries intersect, calling distanceTo will return 0.  If false, details cannot be returned.

Returns

{Number | Object} The distance between this geometry and the target.  If details is true, the return will be an object with distance, x0, y0, x1, and y1 properties.  The x0 and y0 properties represent the coordinates of the closest point on this geometry.  The x1 and y1 properties represent the coordinates of the closest point on the target geometry.

createRegularPolygon

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

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

Parameters

origin{ALKMaps.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.

createGeodesicPolygon

ALKMaps.Geometry.Polygon.createGeodesicPolygon = function(origin,
radius,
sides,
rotation,
projection)

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

Parameters

origin{ALKMaps.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.
projection{ALKMaps.Projection} the map’s projection
getArea: function()
Calculated by subtracting the areas of the internal holes from the area of the outer hole.
getGeodesicArea: function(projection)
Calculate the approximate area of the polygon were it projected onto the earth.
containsPoint: function(point)
Test if a point is inside a polygon.
intersects: function(geometry)
Determine if the input geometry intersects this one.
distanceTo: function(geometry,
options)
Calculate the closest distance between two geometries (on the x-y plane).
ALKMaps.Geometry.Polygon.createRegularPolygon = function(origin,
radius,
sides,
rotation)
Create a regular polygon around a radius.
ALKMaps.Geometry.Polygon.createGeodesicPolygon = function(origin,
radius,
sides,
rotation,
projection)
Create a regular polygon around a radius.
A Collection is exactly what it sounds like: A collection of different Geometries.
A Geometry is a description of a geographic object.
A Linear Ring is a special LineString which is closed.
Methods for coordinate transforms between coordinate systems.
Point geometry class.
Close