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:
@@ -351,7 +351,30 @@
|
||||
"clone() creates an OpenLayers.Geometry.LineString");
|
||||
t.ok(geometry.equals(clone), "clone has equivalent coordinates");
|
||||
}
|
||||
|
||||
function test_getGeodesicLength(t) {
|
||||
|
||||
// expected values from http://www.movable-type.co.uk/scripts/latlong-vincenty.html
|
||||
var cases = [{
|
||||
wkt: "LINESTRING(0 0, -10 45)",
|
||||
exp: 5081689.690
|
||||
}, {
|
||||
wkt: "LINESTRING(-10 45, 0 0)",
|
||||
exp: 5081689.690
|
||||
}, {
|
||||
wkt: "LINESTRING(0 0, -10 45, -20 50)",
|
||||
exp: 5081689.690 + 935018.062
|
||||
}];
|
||||
t.plan(cases.length);
|
||||
|
||||
var geom, got;
|
||||
for(var i=0; i<cases.length; ++i) {
|
||||
geom = new OpenLayers.Geometry.fromWKT(cases[i].wkt);
|
||||
got = geom.getGeodesicLength();
|
||||
t.eq(Math.round(got), Math.round(cases[i].exp), "[case " + i + "] length calculated");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user