G2A Many GEOs
SHARE
TWEET

geo distance

krot Apr 10th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function distance($lat1, $lon1, $lat2, $lon2, $unit) {
  2.       $theta = $lon1 - $lon2;
  3.       $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
  4.       $dist = acos($dist);
  5.       $dist = rad2deg($dist);
  6.       $miles = $dist * 60 * 1.1515;
  7.       $unit = strtoupper($unit);
  8.  
  9.       if ($unit == "K") {
  10.         return ($miles * 1.609344);
  11.       } else if ($unit == "N") {
  12.           return ($miles * 0.8684);
  13.         } else {
  14.             return $miles;
  15.           }
  16.     }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top