-
-
Save M-erb/7ec13e6ae02597488abe10569841b282 to your computer and use it in GitHub Desktop.
Distance between points simplified
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getDistanceFromLatLonInM(lat1, lon1, lat2, lon2) { | |
var a = | |
Math.pow(Math.sin(deg2rad(lat2 - lat1) / 2), 2) + | |
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * | |
Math.pow(Math.sin(deg2rad(lon2 - lon1) / 2), 2); | |
return 12742000 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment