Created
September 15, 2015 14:02
-
-
Save danielhusar/f4872e4c8570a8731d86 to your computer and use it in GitHub Desktop.
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
var data = require('./data/users.json'); | |
function distance(lat1, lon1, lat2, lon2) { | |
var radlat1 = Math.PI * lat1/180; | |
var radlat2 = Math.PI * lat2/180; | |
var radlon1 = Math.PI * lon1/180; | |
var radlon2 = Math.PI * lon2/180; | |
var theta = lon1 - lon2; | |
var radtheta = Math.PI * theta/180; | |
var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta); | |
dist = Math.acos(dist); | |
dist = dist * 180/Math.PI; | |
return dist * 60 * 1.3368159616; | |
} | |
data.forEach(function (item) { | |
if (distance(53.3381985, -6.2592576, item.latitude, item.longitude) <= 100) { | |
console.log(item.user_id); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment