2

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

Gold
  • 60,526
  • 100
  • 215
  • 315

2 Answers2

5

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
  • 10,307
  • 8
  • 70
  • 106
1

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

Cornflex
  • 11
  • 3