OpenLayers. Geometry

A Geometry is a description of a geographic object.  Create an instance of this class with the OpenLayers.Geometry constructor.  This is a base class, typical geometry types are described by subclasses of this class.

Summary
OpenLayers. GeometryA Geometry is a description of a geographic object.
Properties
id{String} A unique identifier for this geometry.
parent{OpenLayers.Geometry}This is set when a Geometry is added as component of another geometry
bounds{OpenLayers.Bounds} The bounds of this geometry
Constructor
OpenLayers. GeometryCreates a geometry object.
Functions
destroyDestroy this geometry.
cloneCreate a clone of this geometry.
clearBoundsNullify this components bounds and that of its parent as well.
extendBoundsExtend the existing bounds to include the new bounds.
getBoundsGet the bounds for this Geometry.
calculateBoundsRecalculate the bounds for the geometry.
atPoint
getLengthCalculate the length of this geometry.
getAreaCalculate the area of this geometry.
toStringReturns the Well-Known Text representation of a geometry
OpenLayers. Geometry. segmentsIntersectDetermine whether two line segments intersect.

Properties

id

{String} A unique identifier for this geometry.

parent

{OpenLayers.Geometry}This is set when a Geometry is added as component of another geometry

bounds

{OpenLayers.Bounds} The bounds of this geometry

Constructor

OpenLayers. Geometry

Creates a geometry object.

Functions

destroy

destroy: function()

Destroy this geometry.

clone

clone: function()

Create a clone of this geometry.  Does not set any non-standard properties of the cloned geometry.

Returns

{OpenLayers.Geometry} An exact clone of this geometry.

clearBounds

clearBounds: function()

Nullify this components bounds and that of its parent as well.

extendBounds

extendBounds: function(newBounds)

Extend the existing bounds to include the new bounds.  If geometry’s bounds is not yet set, then set a new Bounds.

Parameters

newBounds{OpenLayers.Bounds}

getBounds

getBounds: function()

Get the bounds for this Geometry.  If bounds is not set, it is calculated again, this makes queries faster.

Returns

{OpenLayers.Bounds}

calculateBounds

calculateBounds: function()

Recalculate the bounds for the geometry.

atPoint

atPoint: function(lonlat,
toleranceLon,
toleranceLat)
NoteThis is only an approximation based on the bounds of the geometry.

Parameters

lonlat{OpenLayers.LonLat}
toleranceLon{float} Optional tolerance in Geometric Coords
toleranceLat{float} Optional tolerance in Geographic Coords

Returns

{Boolean} Whether or not the geometry is at the specified location

getLength

getLength: function()

Calculate the length of this geometry.  This method is defined in subclasses.

Returns

{Float} The length of the collection by summing its parts

getArea

getArea: function()

Calculate the area of this geometry.  This method is defined in subclasses.

Returns

{Float} The area of the collection by summing its parts

toString

toString: function()

Returns the Well-Known Text representation of a geometry

Returns

{String} Well-Known Text

OpenLayers. Geometry. segmentsIntersect

OpenLayers.Geometry.segmentsIntersect = function(seg1,
seg2,
point)

Determine whether two line segments intersect.  Optionally calculates and returns the intersection point.  This function is optimized for cases where seg1.x2 >= seg2.x1 || seg2.x2 >= seg1.x1.  In those obvious cases where there is no intersection, the function should not be called.

Parameters

seg1{Object} Object representing a segment with properties x1, y1, x2, and y2.  The start point is represented by x1 and y1.  The end point is represented by x2 and y2.  Start and end are ordered so that x1 < x2.
seg2{Object} Object representing a segment with properties x1, y1, x2, and y2.  The start point is represented by x1 and y1.  The end point is represented by x2 and y2.  Start and end are ordered so that x1 < x2.
point{Boolean} Return the intersection point.  If false, the actual intersection point will not be calculated.  If true and the segments intersect, the intersection point will be returned.  If true and the segments do not intersect, false will be returned.  If true and the segments are coincident, true will be returned.

Returns

{Boolean | OpenLayers.Geometry.Point} The two segments intersect.  If the point argument is true, the return will be the intersection point or false if none exists.  If point is true and the segments are coincident, return will be true (and the instersection is equal to the shorter segment).

Creates a geometry object.
Instances of this class represent bounding boxes.
destroy: function()
Destroy this geometry.
clone: function()
Create a clone of this geometry.
clearBounds: function()
Nullify this components bounds and that of its parent as well.
extendBounds: function(newBounds)
Extend the existing bounds to include the new bounds.
getBounds: function()
Get the bounds for this Geometry.
calculateBounds: function()
Recalculate the bounds for the geometry.
atPoint: function(lonlat,
toleranceLon,
toleranceLat)
getLength: function()
Calculate the length of this geometry.
getArea: function()
Calculate the area of this geometry.
toString: function()
Returns the Well-Known Text representation of a geometry
OpenLayers.Geometry.segmentsIntersect = function(seg1,
seg2,
point)
Determine whether two line segments intersect.
This class represents a longitude and latitude pair
Point geometry class.
Close