从 iOS 上的 GPS 获取时间
Getting time from GPS on iOS
我正在开发一个追踪器应用程序。该应用程序需要高精度地了解设备位置,即它使用定位服务并忽略水平精度低于 20 米的位置。 CLLocation
未明确声明是否通过 GPS 确定。但是,如果水平精度为20米或更好,则可以认为它是来自GPS的位置。
此外,我需要知道确定位置时的时间戳。我知道 class CLLocation
中的 属性 timestamp
。但是,我想从 GPS 获取时间戳,而不是系统时间。
是否可以获取GPS时间?我不关心 GPS 信号不可用的情况。我只需要获取我刚刚收到的 GPS 位置(高精度位置)的 GPS 时间。
在Whosebug的其他问题中,建议使用以下代码片段:
CLLocation* location = [[CLLocation alloc] initWithLatitude:(CLLocationDegrees) 0.0 longitude:(CLLocationDegrees) 0.0];
NSDate* now = location.timestamp;
是否可以保证 location.timestamp
比 [NSDate date]
更与 GPS 相关?
如果关闭了自动时间设置,好像不太对。如果我转到设置 -> 常规 -> 日期和时间并关闭 "Set Automatically",属性 timestamp
包含手动设置的系统时间。那么至少在开启自动时间设置的情况下是不是更与GPS相关?
我认为时间戳是在设备端计算的,很可能与卫星的时间戳无关。
CoreLocation 在其工作中是完全不透明的,Apple 似乎不太可能让您访问 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日期]是当前系统时间,而location.time是与位置记录时间相关的时间。这可以抵消例如 0.6 秒,或者对于开始后的第一次修复甚至更多。
要检查位置是否是当前位置,Apple 建议计算系统时间和位置时间之间的差异。
我正在开发一个追踪器应用程序。该应用程序需要高精度地了解设备位置,即它使用定位服务并忽略水平精度低于 20 米的位置。 CLLocation
未明确声明是否通过 GPS 确定。但是,如果水平精度为20米或更好,则可以认为它是来自GPS的位置。
此外,我需要知道确定位置时的时间戳。我知道 class CLLocation
中的 属性 timestamp
。但是,我想从 GPS 获取时间戳,而不是系统时间。
是否可以获取GPS时间?我不关心 GPS 信号不可用的情况。我只需要获取我刚刚收到的 GPS 位置(高精度位置)的 GPS 时间。
在Whosebug的其他问题中,建议使用以下代码片段:
CLLocation* location = [[CLLocation alloc] initWithLatitude:(CLLocationDegrees) 0.0 longitude:(CLLocationDegrees) 0.0];
NSDate* now = location.timestamp;
是否可以保证 location.timestamp
比 [NSDate date]
更与 GPS 相关?
如果关闭了自动时间设置,好像不太对。如果我转到设置 -> 常规 -> 日期和时间并关闭 "Set Automatically",属性 timestamp
包含手动设置的系统时间。那么至少在开启自动时间设置的情况下是不是更与GPS相关?
我认为时间戳是在设备端计算的,很可能与卫星的时间戳无关。
CoreLocation 在其工作中是完全不透明的,Apple 似乎不太可能让您访问 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日期]是当前系统时间,而location.time是与位置记录时间相关的时间。这可以抵消例如 0.6 秒,或者对于开始后的第一次修复甚至更多。
要检查位置是否是当前位置,Apple 建议计算系统时间和位置时间之间的差异。