Adding methods for getting geodesic measures from geometries. Assuming geometries can be transformed into Geographic/WGS84, getGeodesicLength and getGeodesicArea should return reasonable 'on the ground' metrics. Use getLength and getArea for the planar metrics. r=crschmidt (closes #1819)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9248 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -231,6 +231,52 @@ OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, {
|
||||
return area;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: getGeodesicArea
|
||||
* Calculate the approximate area of the polygon were it projected onto
|
||||
* the earth.
|
||||
*
|
||||
* Parameters:
|
||||
* projection - {<OpenLayers.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 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409
|
||||
*
|
||||
* Returns:
|
||||
* {float} The approximate geodesic area of the geometry in square meters.
|
||||
*/
|
||||
getGeodesicArea: function(projection) {
|
||||
var area = 0.0;
|
||||
for(var i=0, len=this.components.length; i<len; i++) {
|
||||
area += this.components[i].getGeodesicArea(projection);
|
||||
}
|
||||
return area;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: getGeodesicLength
|
||||
* Calculate the approximate length of the geometry were it projected onto
|
||||
* the earth.
|
||||
*
|
||||
* projection - {<OpenLayers.Projection>} The spatial reference system
|
||||
* for the geometry coordinates. If not provided, Geographic/WGS84 is
|
||||
* assumed.
|
||||
*
|
||||
* Returns:
|
||||
* {Float} The appoximate geodesic length of the geometry in meters.
|
||||
*/
|
||||
getGeodesicLength: function(projection) {
|
||||
var length = 0.0;
|
||||
for(var i=0, len=this.components.length; i<len; i++) {
|
||||
length += this.components[i].getGeodesicLength(projection);
|
||||
}
|
||||
return length;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: move
|
||||
* Moves a geometry by the given displacement along positive x and y axes.
|
||||
|
||||
Reference in New Issue
Block a user