在 iPhone 上,我以十进制度数获取用户的位置,例如:纬度 39.470920 和经度 = -0.373192;这就是A点.
On the iPhone, I get the user's location in decimal degrees, for example: latitude 39.470920 and longitude = -0.373192; That's point A.
我需要用另一个 GPS 坐标创建一条线,也以十进制度为单位,点 B.然后,计算从 A 到 B 的线与另一个点 C 之间的距离(垂直).
I need to create a line with another GPS coordinate, also in decimal degrees, point B. Then, calculate the distance (perpendicular) between the line from A to B and another point C.
问题是我对度数的值感到困惑.我想要以米为单位的结果.需要什么转换?计算这个的最终公式会是什么样子?
The problem is I get confused with the values in degrees. I would like to have the result in meters. What's the conversion needed? How will the final formula to compute this look like?
你为什么不用CLLocation 的 distanceFromLocation:
方法?它会告诉您接收器与另一个 CLLocation 之间的精确距离.
Why don't you use CLLocations distanceFromLocation:
method? It will tell you the precise distance between the receiver and another CLLocation.
CLLocation *locationA = [[CLLocation alloc] initWithLatitude:12.123456 longitude:12.123456];
CLLocation *locationB = [[CLLocation alloc] initWithLatitude:21.654321 longitude:21.654321];
CLLocationDistance distanceInMeters = [locationA distanceFromLocation:locationB];
// CLLocation is aka double
[locationA release];
[locationB release];
就这么简单.
这篇关于以度为单位的 GPS 坐标以计算距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!