我正在开发一个追踪应用程序。该应用程序要求以高精度知道设备位置,即使用定位服务而忽略水平精度低于20米的位置。如果CLLocation
是通过全球定位系统确定的,那么它不会明确声明。然而,如果水平精度是20米或更高,它可以被认为是一个位置的GPS。
此外,当确定位置时,我需要知道时间戳。我知道timestamp
在CLLocation
类中的属性。然而,我想从全球定位系统获得时间戳,而不是系统时间。
有可能得到GPS时间吗?我不关心GPS信号不存在的情况。我只需要获得GPS定位的时间(高精度的位置),我刚刚收到。
在关于堆栈溢出的其他问题中,建议使用以下代码片段:
CLLocation* location = [[CLLocation alloc] initWithLatitude:(CLLocationDegrees) 0.0 longitude:(CLLocationDegrees) 0.0];
NSDate* now = location.timestamp;
有什么可以保证location.timestamp
比[NSDate date]
更有GPS关系吗?
如果关闭自动时间设置,则似乎不正确。如果我转到Settings -> General -> Date & time并关闭"Set自动“,则属性timestamp
包含手动设置的系统时间。那么,至少在打开自动时间设置时,这与GPS更相关吗?
发布于 2015-08-10 13:54:20
我认为时间戳是计算出的设备端,很可能与卫星的时间戳无关。
CoreLocation在它的工作中是完全不透明的,从苹果看来,它不太可能让你访问原始数据,比如GPS卫星时间戳.
发布于 2015-08-10 14:04:48
However, I would like to get the timestamp from GPS, not the system time.
您无法获得GPS芯片提供的时间戳。
如果用户人为地设置了错误的时间,ios也会在其位置使用此偏移量。
I just need to get the GPS time for a GPS location (location with high accuracy) I have just received.
如果设备设置为自动设置系统时间,则应计算gps定位时间。
So is it more-GPS related at least when automatic time setting is turned on?
是
Is there any guarantee that location.timestamp is something more GPS-related than [NSDate date]?
它总是更相关的,NSDate日期是当前的系统时间,而location.time是与位置记录时间相关的时间。这可以被0.6s抵消,甚至在开始后的第一次修复时更多。
为了检查该位置是否当前,Apple建议计算系统时间和位置时间之间的差异。
https://stackoverflow.com/questions/31920829
复制相似问题