Ios CLLocation接受大于或小于其最小值和最大值的经度和纬度
据我所知,最大值和最小值为:Ios CLLocation接受大于或小于其最小值和最大值的经度和纬度,ios,cocoa-touch,gps,cllocation,cllocationdistance,Ios,Cocoa Touch,Gps,Cllocation,Cllocationdistance,据我所知,最大值和最小值为: 纬度:[-9090] 经度:[-180180] CLLocation仍接受超出这些限制的值,例如: [[CLLocation alloc] initWithLatitude:100.0 longitude:-200.0]; CLLocation的distanceFromLocation:函数仍然返回有效的距离(尽管我们无法验证这一点,因为坐标超出了限制) 为什么会这样? 我的想法如下: 1.超出这些限制的值对应于外层空间 2.超出这些限制的值对应于其他尺寸 3.
纬度:[-9090]
经度:[-180180] CLLocation仍接受超出这些限制的值,例如:
[[CLLocation alloc] initWithLatitude:100.0 longitude:-200.0];
CLLocation的distanceFromLocation:
函数仍然返回有效的距离(尽管我们无法验证这一点,因为坐标超出了限制)
为什么会这样?我的想法如下:
1.超出这些限制的值对应于外层空间
2.超出这些限制的值对应于其他尺寸
3.超出这些限制的值将重新映射到[-90,90]或[-180,180]范围内的有效值。纬度和经度是一种位置度:
//From CLLocation.h
/*
* initWithLatitude:longitude:
*
* Discussion:
* Initialize with the specified latitude and longitude.
*/
- (id)initWithLatitude:(CLLocationDegrees)latitude
longitude:(CLLocationDegrees)longitude;
其中,如果您进一步观察,则是一种双精度:
//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;
因此,我认为没有为纬度和经度提供的值的内置检入。任何以度为单位测量的角度都是360度的模,因此经度380在数学上与经度20相同。关于纬度,如果你想一想在[-90,90]范围外移动的角度,图片在球体上的样子,那么你会看到纬度是180模。所以我认为你的第三个选择是正确的答案 我知道CLLocationDegrees是double类型,但我很好奇为什么苹果没有将CLLocation的创建限制在已知有效范围[-90,90]和[-180,180]内的纬度和经度。