以度为单位的 GPS 坐标以计算距离

GPS coordinates in degrees to calculate distances(以度为单位的 GPS 坐标以计算距离)
本文介绍了以度为单位的 GPS 坐标以计算距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 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 坐标以计算距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type(异常:不应为错误类型创建SimpleTypeImpl)
BottomAppBar FabCradleMargin becoming less, almost flat, when BottomAppBar returns from being hidden(当BottomAppBar从隐藏状态返回时,BottomAppBar FabCradleMargin变得较少,几乎是平的)
Android IllegalArgumentException: The tag for fragment_XXX is invalid. Received: layout-sw600dp/fragment_XXX_0(Android IlLegalArgumentException:Fragment_XXX的标签无效。收到:Layout-sw600dp/Fragment_XXX_0)
iOS convert audio sample rate from 16 kHz to 8 kHz(IOS将音频采样率从16 kHz转换为8 kHz)
Enforcing an audio sampling rate in iOS(在iOS中强制音频采样率)