tags:

views:

162

answers:

2

hi

i have this position from GPS:

40.715192,-74.005795

how to check if i in the range of 10 meter radius ?

thank's in advance

+5  A: 

Use Haversine formula http://en.wikipedia.org/wiki/Haversine_formula

Pseudocode:

R = 6371; // corrected earth radius, km
dLat = degToRad(lat2-lat1);
dLon = degToRad(lon2-lon1); 
a = sin(dLat/2) * sin(dLat/2) +
        cos(degToRad(lat1)) * cos(degToRad(lat2)) * 
        sin(dLon/2) * sin(dLon/2); 
c = 2 * atan2(sqrt(a), sqrt(1-a)); 
distance = R * c;

degToRad converts degress to radians, see e.g. here

Marek
A: 

I was looking for something similar and found this: http://megocode3.wordpress.com/2008/02/05/haversine-formula-in-c/

Cornflex