La Paste
Create new paste
Pastes Archive
2024-02-22 11:55:34
copy
raw
download
function getGeoDistance($lat1, $lon1, $lat2, $lon2) { $earthRadius = 6371000; $lat1 = deg2rad($lat1); $lon1 = deg2rad($lon1); $lat2 = deg2rad($lat2); $lon2 = deg2rad($lon2); $dLat = $lat2 - $lat1; $dLon = $lon2 - $lon1; $a = sin($dLat/2) * sin($dLat/2) + cos($lat1) * cos($lat2) * sin($dLon/2) * sin($dLon/2); $c = 2 * atan2(sqrt($a), sqrt(1-$a)); $distance = $earthRadius * $c; return ($distance); }
↑