我从 GPS 得到这个位置:
40.715192,-74.005795
如何判断i是否在10米半径范围内?
提前致谢
使用半正矢公式http://en.wikipedia.org/wiki/Haversine_formula http://en.wikipedia.org/wiki/Haversine_formula
伪代码:
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
将度数转换为弧度,请参见例如here http://www.krellinst.org/uces/archive/resources/trig/node10.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)