A Linear Ring is a special LineString which is closed. It closes itself automatically on every addPoint/removePoint by adding a copy of the first point as the last point.
Also, as it is the first in the line family to close itself, a getArea() function is defined to calculate the enclosed area of the linearRing
OpenLayers. | A Linear Ring is a special LineString which is closed. |
Properties | |
componentTypes | {Array(String)} An array of class names representing the types of components that the collection can include. |
Constructor | |
OpenLayers. | Linear rings are constructed with an array of points. |
Functions | |
addComponent | Adds a point to geometry components. |
removeComponent | Removes a point from geometry components. |
move | Moves a geometry by the given displacement along positive x and y axes. |
rotate | Rotate a geometry around some origin |
resize | Resize a geometry relative to some origin. |
transform | Reproject the components geometry from source to dest. |
getCentroid | {OpenLayers.Geometry.Point} The centroid of the collection |
getArea | |
getGeodesicArea | Calculate the approximate area of the polygon were it projected onto the earth. |
containsPoint | Test if a point is inside a linear ring. |
intersects | Determine if the input geometry intersects this one. |
getVertices | Return a list of all points in this geometry. |
Linear rings are constructed with an array of points. This array can represent a closed or open ring. If the ring is open (the last point does not equal the first point), the constructor will close the ring. If the ring is already closed (the last point does equal the first point), it will be left closed.
points | {Array(OpenLayers.Geometry.Point)} points |
addComponent: function( point, index )
Adds a point to geometry components. If the point is to be added to the end of the components array and it is the same as the last point already in that array, the duplicate point is not added. This has the effect of closing the ring if it is not already closed, and doing the right thing if it is already closed. This behavior can be overridden by calling the method with a non-null index as the second argument.
point | {OpenLayers.Geometry.Point} |
index | {Integer} Index into the array to insert the component |
{Boolean} Was the Point successfully added?
removeComponent: function( point )
Removes a point from geometry components.
point | {OpenLayers.Geometry.Point} |
rotate: function( angle, origin )
Rotate a geometry around some origin
angle | {Float} Rotation angle in degrees (measured counterclockwise from the positive x-axis) |
origin | {OpenLayers.Geometry.Point} Center point for the rotation |
resize: function( scale, origin, ratio )
Resize a geometry relative to some origin. Use this method to apply a uniform scaling to a geometry.
scale | {Float} Factor by which to scale the geometry. A scale of 2 doubles the size of the geometry in each dimension (lines, for example, will be twice as long, and polygons will have four times the area). |
origin | {OpenLayers.Geometry.Point} Point of origin for resizing |
ratio | {Float} Optional x:y ratio for resizing. Default ratio is 1. |
{OpenLayers.Geometry} | The current geometry. |
transform: function( source, dest )
Reproject the components geometry from source to dest.
source | {OpenLayers.Projection} |
dest | {OpenLayers.Projection} |
getGeodesicArea: function( projection )
Calculate the approximate area of the polygon were it projected onto the earth. Note that this area will be positive if ring is oriented clockwise, otherwise it will be negative.
projection | {OpenLayers.Projection} The spatial reference system for the geometry coordinates. If not provided, Geographic/WGS84 is assumed. |
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 http://trs-new.jpl.nasa.gov
{float} The approximate signed geodesic area of the polygon in square meters.
containsPoint: function( point )
Test if a point is inside a linear ring. For the case where a point is coincident with a linear ring edge, returns 1. Otherwise, returns boolean.
point | {OpenLayers.Geometry.Point} |
{Boolean | Number} The point is inside the linear ring. Returns 1 if the point is coincident with an edge. Returns boolean otherwise.
intersects: function( geometry )
Determine if the input geometry intersects this one.
geometry | {OpenLayers.Geometry} Any type of geometry. |
{Boolean} The input geometry intersects this one.
getVertices: function( nodes )
Return a list of all points in this geometry.
nodes | {Boolean} For lines, only return vertices that are endpoints. If false, for lines, only vertices that are not endpoints will be returned. If not provided, all vertices will be returned. |
{Array} A list of all vertices in the geometry.
Adds a point to geometry components.
addComponent: function( point, index )
Removes a point from geometry components.
removeComponent: function( point )
Moves a geometry by the given displacement along positive x and y axes.
move: function( x, y )
Rotate a geometry around some origin
rotate: function( angle, origin )
Resize a geometry relative to some origin.
resize: function( scale, origin, ratio )
Reproject the components geometry from source to dest.
transform: function( source, dest )
{OpenLayers.Geometry.Point} The centroid of the collection
getCentroid: function()
getArea: function()
Calculate the approximate area of the polygon were it projected onto the earth.
getGeodesicArea: function( projection )
Test if a point is inside a linear ring.
containsPoint: function( point )
Determine if the input geometry intersects this one.
intersects: function( geometry )
Return a list of all points in this geometry.
getVertices: function( nodes )