我正在开发一个跟踪器应用程序。该应用程序需要高精度地了解设备位置,即它使用位置服务并忽略水平精度低于 20 米的位置。CLLocation
没有明确声明是否通过 GPS 确定。但是,如果水平精度为 20 米或更好,则可以认为它是来自 GPS 的位置。
此外,我需要知道确定位置时的时间戳。我了解该房产timestamp
在班上CLLocation
。但是,我想从 GPS 获取时间戳,而不是系统时间。
可以获取GPS时间吗?我不关心 GPS 信号不可用的情况。我只需要获取我刚刚收到的 GPS 位置(高精度位置)的 GPS 时间。
在 stackoverflow 上的其他问题中,建议使用以下代码片段:
CLLocation* location = [[CLLocation alloc] initWithLatitude:(CLLocationDegrees) 0.0 longitude:(CLLocationDegrees) 0.0];
NSDate* now = location.timestamp;
有什么保证吗location.timestamp
与 GPS 相关的东西比[NSDate date]
?
如果关闭自动时间设置似乎就不正确了。如果我转到“设置”->“常规”->“日期和时间”并关闭“自动设置”,该属性timestamp
包含手动设置的系统时间。那么至少当自动时间设置打开时,它是否与 GPS 更相关?
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?
Yes
Is there any guarantee that location.timestamp is something more GPS-related than [NSDate date]?
它总是更相关,[NSDate date]是当前系统时间,而location.time是与位置记录时间相关的时间。对于启动后的第一次修复,这可以抵消例如 0.6 秒,甚至更多。
要检查位置是否是当前位置,Apple 建议计算系统时间和位置时间之间的差异。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)