Advertisement
Guest User

Untitled

a guest
Dec 30th, 2016
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. function gpsEtaisyys($lat1, $lon1, $lat2, $lon2) {
  2. $unit = "K";
  3. $theta = $lon1 - $lon2;
  4. $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
  5. $dist = acos($dist);
  6. $dist = rad2deg($dist);
  7. $miles = $dist * 60 * 1.1515;
  8. $unit = strtoupper($unit);
  9.  
  10. if ($unit == "K") {
  11. return ($miles * 1.609344);
  12. } else if ($unit == "N") {
  13. return ($miles * 0.8684);
  14. } else {
  15. return $miles;
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement