-
-
Save adammendoza/a30fa9cfe5f09c706ce23508798b0b3a to your computer and use it in GitHub Desktop.
Distance between points simplified
This file contains hidden or 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