How to calculate distance between two lat longs?

Hi Friends ,

Now I am going to share one more important topic how to get distance between two lat long. There is a formula that I am using to calculate the distance between two places on basis of their lat long. This formula is called Haversine Formula, that is given below:-

 SQRT(POW(69.1 * ($lat2 – $lat1)), 2) + POW(69.1 * ($long1 – $long2) * COS($lat1 / 57.3), 2)

In this formula you can use this example also to test the formula.

<?
$lat1=”30.720182″;
$long1=”76.748121″;
$lat2=”30.726389″;
$long2=”76.768307″;

echo $distance = SQRT(POW(69.1 * ($lat2 – $lat1)), 2) + POW(69.1 * ($long1 – $long2) * COS($lat1 / 57.3), 2);

?>

 

 

Keep Smiling 🙂

Share This Post

Recent Articles

Leave a Reply

*

© 2019 Networkocean. All rights reserved. Site Admin · Entries RSS · Comments RSS
Powered by WordPress · Designed by Theme Junkie