Linear distance of two world coordinates

dist = arccos( sin(minlat) * sin(maxlat) + cos(minlat) * cos(maxlat) * cos(maxlon – minlon) ) * 6371

<?php
//coordinates of point 1
$lat1=45.12345;
$lon1=10.12345; 

//coordinates of point 2
$lat2=46.12345;
$lon2=11.12345; 

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

echo $distance;
?>

One thought on “Linear distance of two world coordinates

Leave a Reply

Your email address will not be published. Required fields are marked *