Skip to content

Distance(...)

Alex-Kent edited this page Mar 30, 2019 · 4 revisions

$meters = $index->Distance( \%point_1, \%point_2 );
$meters = $index->Distance( \@point_1, \@point_2 );
$meters = $index->Distance( \%point_1, \@point_2 );
$meters = $index->Distance( \@point_1, \%point_2 );
Returns the distance in meters between two points

The haversine function is used to compute the distance. As this assumes a spherical body the distances returned may show errors. Using the default options, these errors are up to 0.056% (north - south) or 1.12% (east - west).
Such errors typically start becoming significant at distances over 20 km.


%point_1 or @point_1, %point_2 or @point_2
The points to measure the distance between

These can be either hashes containing at a minimum a lat and a lon value (both in degrees) or arrays giving each point. See the POINTS section for details.