how to check radius of 10 meter from x,y position - from GPS

℡╲_俬逩灬. 提交于 2020-01-04 05:23:23

问题


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


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/2265900/how-to-check-radius-of-10-meter-from-x-y-position-from-gps

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!