Skip to content

Instantly share code, notes, and snippets.

@ZhandosKz
Created November 22, 2013 14:47
Show Gist options
  • Save ZhandosKz/7601034 to your computer and use it in GitHub Desktop.
Save ZhandosKz/7601034 to your computer and use it in GitHub Desktop.
<?php
function getGeo($lat, $lng, $dist, $brng)
{
$lat = deg2rad($lat);
$lng = deg2rad($lng);
$brng = deg2rad($brng);
$distRadius = $dist / 6371;
$lat2 = asin(sin($lat) * cos($distRadius) +
cos($lat) * sin($distRadius) * cos($brng) );
$lng2 = $lng + atan2(sin($brng)*sin($distRadius)*cos($lat),
cos($distRadius)-sin($lat)*sin($lat2));
return [rad2deg($lat2), rad2deg($lng2)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment