Created
January 5, 2016 10:00
-
-
Save unitycoder/571496c9d40555445f9c to your computer and use it in GitHub Desktop.
Calculate distance between LAT LON values
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
// calculate distance between two LAT LON values | |
// Note: In this formula, the latitudes and longitudes are expressed in radians. 6371 is radius of the earth in km | |
// SOURCE: codinggame.com | |
var earthRadius = 6371; | |
var x = (lonB-lonA)*Math.cos((latA+latB)/2); | |
var y = (latB-latA); | |
var d = Math.sqrt(x*x+y*y)*earthRadius; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment