[OpenLayers-Dev] measurement
ibrahim saricicek
ibrahimsaricicek at gmail.com
Mon Oct 19 07:04:12 EDT 2009
Hi all,
I'm using spherical and cartesian measurements,
Why i'm getting so different results?
Code;
function calcVincenty(geometry)
{
var dist = 0;
for (var i = 1; i < geometry.components.length; i++) {
var first = geometry.components[i-1];
var second = geometry.components[i];
first_ll =
OpenLayers.Layer.SphericalMercator.inverseMercator(first.x, first.y);
second_ll =
OpenLayers.Layer.SphericalMercator.inverseMercator(second.x, second.y);
dist += OpenLayers.Util.distVincenty(
{lon: first_ll.lon, lat: first_ll.lat},
{lon: second_ll.lon, lat: second_ll.lat}
);
}
return dist;
}
function handleMeasurements(event)
{
var geometry = event.geometry;
var units = event.units;
var order = event.order;
var measure = event.measure;
var element = document.getElementById('output');
var out = "";
if(order == 1) {
out += cartesian + " : " + measure.toFixed(3) + " " + units;
out += "<br />" + spherical + " : " +
calcVincenty(geometry).toFixed(3) + " km ";
}
else
{
out += area + " : " + measure.toFixed(3) + " " + units +
"<sup>2</" + "sup>";
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20091019/da24dfea/attachment.html
More information about the Dev
mailing list