[OpenLayers-Users] Measuring tool

Tim Schaub tschaub at openplans.org
Sun Mar 23 18:10:52 EDT 2008


Hey-

Christopher Schmidt wrote:
> On Wed, Mar 19, 2008 at 08:44:42AM +0100, Gérald Quintana wrote:
>> Hi,
>>
>> Once I saw an example of Control to measure the length of a path
>> (rubber), but I can't find it anymore. Where is it?
>>
>> I managed to do my own using the DrawFeature control and the
>> Curve.getLength() method but I miss the conversion factor to get the
>> distance in meters or kilometers, how can I do it?

Note that it is not as simple as saying you want to measure distance in 
meters.  You have to specify whether you want to measure planar 
distances in the same projection as your data (this is what 
line.getLength() * unitConversion will get you) or whether you want to 
measure geodesic distances (shortest path on a spheroid).

The distVincenty function that Chris mentions below is *not* about 
converting units of the planar measurement.  It is about measuring 
geodesic distances.

If you want to measure the perimeter of Africa or you're planning a trip 
from NYC to London and you want to know how much fuel you'll need, by 
all means use geodesic distances.  If you're measuring distances around 
the block or to the grocery store, you'll find that planar distances in 
your projected system work well.

Tim

> 
> No measurement tool in OpenLayers has ever done this. Hoever, the
> OpenLayers.Util.distVincenty function might help you.
> 
> Regards,




More information about the Users mailing list