ios - CLLocation 接受大于或小于其最小值和最大值的经度和纬度

标签 ios cocoa-touch gps cllocation cllocationdistance

据我所知,最大值和最小值是:
纬度: [-90, 90]
经度: [-180, 180]

CLLocation 仍然接受超出这些限制的值,例如:

 [[CLLocation alloc] initWithLatitude:100.0 longitude:-200.0];

并且 CLLocation 的 distanceFromLocation: 函数仍然返回有效距离(尽管我们无法验证这一点,因为坐标超出了限制)。

为什么会这样?
我的想法如下:
1. 超出这些限制的值对应于外太空
2. 超出这些限制的值对应于其他尺寸
3. 超出这些限制的值将重新映射到 [-90, 90] 或 [-180, 180] 范围内的有效值。

最佳答案

纬度和经度是 CLLocationDegrees 的一种类型:

//From CLLocation.h
/*
 *  initWithLatitude:longitude:
 *  
 *  Discussion:
 *    Initialize with the specified latitude and longitude.
 */
- (id)initWithLatitude:(CLLocationDegrees)latitude
    longitude:(CLLocationDegrees)longitude;

如果你进一步观察,其中是一种 double 类型:

//From CLLocation.h
/*
 *  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;

what is the range of a double in Objective-C?

因此,我相信没有内置 checkin 为纬度和经度提供的值。

关于ios - CLLocation 接受大于或小于其最小值和最大值的经度和纬度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16681824/

相关文章:

ios - 如何在 iOS 中单击按钮打开带有 YouTube ID 的 YouTube 应用

ios - 本地存储数据的问题

objective-c - 将 NSMutableArray 中的所有值相加

android - 服务测试用例中setTestProviderLocation不触发onLocationChanged

android - 如何使用网络在 android 中使用 Fused Location Provider 获取位置?

ios - 选项值未正确分配给变量

c# - iOS 依赖注入(inject)框架(最佳实践)

ios - 如何删除 UITableViewCell NSIBPrototypingLayoutConstraint 并将我自己的添加到 subview ?

iphone - 本地通知声音不起作用

android - 应用程序在后台运行时无法找到位置更新