【发布时间】:2011-11-08 08:38:50
【问题描述】:
我正在构建一个基于地理定位的应用程序,我想知道哪种数据类型最适合存储纬度/经度我正在使用 doubleValue,但我认为我们可以更精确,例如小数点后 10 位。
【问题讨论】:
标签: ios objective-c cocoa-touch core-location
我正在构建一个基于地理定位的应用程序,我想知道哪种数据类型最适合存储纬度/经度我正在使用 doubleValue,但我认为我们可以更精确,例如小数点后 10 位。
【问题讨论】:
标签: ios objective-c cocoa-touch core-location
不会,因为iOS 使用的纬度/经度也是双精度值。
/*
* CLLocationDegrees
*
* Discussion:
* Type used to represent a latitude or longitude coordinate in degrees under the WGS 84 reference
* frame. The degree can be positive (North and East) or negative (South and West).
*/
typedef double CLLocationDegrees;
【讨论】:
double 是 iOS 本身使用的值。 iOS 使用CLLocationDegrees 表示纬度/经度值,它是 double 的 typedef。
IMO,使用double/CLLocationDegrees 将是最佳选择。
【讨论】:
CLLocationDegrees?
CLLocationDegrees 只是 double 的 typedef。但是看到Dean 的最新评论最好使用 CLLocationDegrees
CLLocationDegress 从 double 更改为其他类型,因为 double 足以容纳经度/纬度。
iOS SDK 中已经有答案了 :)
获取look at CLLocationCoordinate2D - CoreLocation 使用它使用 CLLocationDegrees 类型存储它的纬度/经度。如果这是 CoreLocation 为您提供的准确度,那么这就是它将会得到的准确度!
【讨论】:
看CLLocationCoordinate2D的定义:
typedef struct {
CLLocationDegrees latitude;
CLLocationDegrees longitude;
}
CLLocationCoordinate2D;
然后是CLLocationDegrees的位置;
typedef double CLLocationDegrees;
我们可以看到精度是双倍的。因此,你不能做得比这更好。
【讨论】: