gpt4 book ai didi

ios - 在 iOS 上从 GPS 获取时间

转载 作者:可可西里 更新时间:2023-11-01 05:43:40 24 4
gpt4 key购买 nike

我正在开发一个追踪器应用程序。该应用程序需要高精度地了解设备位置,即它使用定位服务并忽略水平精度低于 20 米的位置。 CLLocation 没有明确声明是否通过 GPS 确定。但是,如果水平精度为 20 米或更好,则可以认为它是来自 GPS 的位置。

此外,我需要知道确定位置时的时间戳。我知道 CLLocation 类中的属性 timestamp。但是,我想从 GPS 获取时间戳,而不是系统时间。

是否可以获取GPS时间?我不关心 GPS 信号不可用的情况。我只需要获取我刚刚收到的 GPS 位置(高精度位置)的 GPS 时间。

在stackoverflow的其他问题中,建议使用如下代码片段:

CLLocation* location = [[CLLocation alloc] initWithLatitude:(CLLocationDegrees) 0.0 longitude:(CLLocationDegrees) 0.0];
NSDate* now = location.timestamp;

是否可以保证 location.timestamp[NSDate date] 更与 GPS 相关?

如果关闭了自动时间设置,好像就不是这样了。如果我转到设置 -> 常规 -> 日期和时间并关闭“自动设置”,属性 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?

Is there any guarantee that location.timestamp is something more GPS-related than [NSDate date]?

它总是比较相关的,[NSDate date]是当前系统时间,而location.time是与位置记录时间相关的时间。这可以抵消例如 0.6 秒,对于开始后的第一次修复甚至更多。

要检查位置是否是当前位置,Apple 建议计算系统时间和位置时间之间的差异。

关于ios - 在 iOS 上从 GPS 获取时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31920829/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com