问题描述
在iPhone上,我以十进制度得到用户的位置,例如:纬度39.470920,经度= -0.373192;这就是A点。我需要创建一个带有另一个GPS坐标的线,也是十进制度,点B。然后,计算线之间的距离(垂直) A到B和另一个点C。
问题是我与度数值混淆。我想把结果以米计。需要什么转换?如何计算这个样子的最终公式如何?
为什么不使用 s distanceFromLocation:
方法?它会告诉你接收者和另一个CLLocation之间的精确距离。
CLLocation * locationA = [[CLLocation alloc] initWithLatitude:12.123456经度: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];
这样很简单。
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.
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?
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];
It's as easy as that.
这篇关于GPS坐标以度数计算距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!