Hi all,

I'm using the measurement tool in an application that uses google maps as
base.
My problem is that the measurement tool calculate the planar distance
(instead geodesic)...

I tried to use the Util.distVincenty and it works (very good) only if my map
projection is 4326.

Snippet:

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];
        dist += OpenLayers.Util.distVincenty(
            {lon: first.x, lat: first.y},
            {lon: second.x, lat: second.y}
        );
    }
    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_misure');
    var out = "";
    if(order == 1) {
        
        if (map.getProjection()== "EPSG:4326") {
                out += "Distanza: " + calcVincenty(geometry).toFixed(3)+ " " + 
units;
                
        } else {
                out += "Distanza: " + measure.toFixed(3)+ " " + units;
        }
    } else {
        if (map.getProjection() == "EPSG:4326") {
                out += "Area: " +
(OpenLayers.Util.approxPolyAreaOnSphere(geometry)/1000000.0).toFixed(3)+ " "
+ units + "q";
        } else {
                out += "Area: " + measure.toFixed(3) + " " + units + "q";
        }
    }
                element.innerHTML = out;
}


If I apply the calcVincenty function to the 900913 projection I get enormous
distance errors...
Is there a way to measure geodesic distances (and areas) also for 900913
projected maps?

Thx in advance, alessio
-- 
View this message in context: 
http://n2.nabble.com/distances-in-spherical-mercator-tp2503670p2503670.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users

Reply via email to