About the author

Photo of sanduhrs
sanduhrs

Geocoordinates distance

A formula to calculate the distance of geocoordinates.

<?php
$lat1
= 46.2341938036161;
$lon1 = -63.124778021257015;

$lat2 = 46.4141938036161;
$lon2 = -63.118571124705284;

$distance = (3958*3.1415926*sqrt(($lat2-$lat1)*($lat2-$lat1) + cos($lat2/57.29578)*cos($lat1/57.29578)*($lon2-$lon1)*($lon2-$lon1))/180);

print(
$distance);
?>

see [1].
Here's some theory on that subject [2].

[1] http://agaricdesign.com/note/assigning-geographical-coordinates-drupal-c...
[2] http://www.codeguru.com/Cpp/Cpp/algorithms/article.php/c5115/

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

Website powered by lovely Drupal · Microformats · XML Feed · Valid XHTML, CSS · No www.