Skip to content

Instantly share code, notes, and snippets.

@henryrossiter
Last active May 5, 2020 15:10
Show Gist options
  • Save henryrossiter/8000d83458514b6909613abf58ef71f7 to your computer and use it in GitHub Desktop.
Save henryrossiter/8000d83458514b6909613abf58ef71f7 to your computer and use it in GitHub Desktop.
function pythagoreanDistanceBetweenPoints(lat1, lon1, lat2, lon2) {
const R = 6371e3;
const x = (lon2-lon1) * Math.cos((lat1+lat2)/2);
const y = (lat2-lat1);
const d = Math.sqrt(x*x + y*y) * R;
return d;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment