OpenLayers.Geometry.Polygon

Polygon is a collection of Geometry.LinearRings.

Inherits from

  • <OpenLayers.Geometry.Collection>
  • <OpenLayers.Geometry>
Summary
OpenLayers.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.
Functions
OpenLayers.Geometry.PolygonConstructor for a Polygon geometry.
containsPointTest if a point is inside a polygon.
splitWithSplit this geometry (the target) with the given geometry (the source).

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.

Functions

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

containsPoint

containsPoint: function(point)

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

Parameters

point{<OpenLayers.Geometry.Point>}

Returns

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

splitWith

splitWith: function(geometry,
options)

Split this geometry (the target) with the given geometry (the source). see the following URL for the algorithm: http://stackoverflow.com/questions/3623703/how-can-i-split-a-polygon-by-a-line

Parameters

geometry{<OpenLayers.Geometry>} A geometry used to split this geometry (the source).
options{Object} Properties of this object will be used to determine how the split is conducted.

Valid options

edge{Boolean} Allow splitting when only edges intersect.  Default is true.  If false, a vertex on the source must be within the tolerance distance of the intersection to be considered a split.
tolerance{Number} If a non-null value is provided, intersections within the tolerance distance of an existing vertex on the source will be assumed to occur at the vertex.

Returns

{Array} A list of geometries (of this same type as the target) that result from splitting the target with the source geometry.  The source and target geometry will remain unmodified.  If no split results, null will be returned.  If mutual is true and a split results, return will be an array of two arrays - the first will be all geometries that result from splitting the source geometry and the second will be all geometries that result from splitting the target geometry.

containsPoint: function(point)
Test if a point is inside a polygon.
splitWith: function(geometry,
options)
Split this geometry (the target) with the given geometry (the source).
Close