在iOS上从GPS获取时间

在iOS上从GPS获取时间

本文介绍了在iOS上从GPS获取时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个示踪应用程序。该应用程序需要高精度地了解设备位置,即它使用位置服务并忽略水平精度低于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 是更多的GPS相关比 [NSDate日期]



它似乎不是真的,如果自动时间设置被关闭。如果我进入设置 - >常规 - >日期&时间并关闭自动设置,属性 timestamp 包含手动设置的系统时间。至少在自动时间设置打开的情况下,GPS更具有相关性吗? 解决方案

我认为时间戳是计算出的设备并且很可能与卫星的时间戳无关。

CoreLocation在它的工作中是完全不透明的,苹果似乎不太可能允许您访问GPS卫星时间戳等原始数据...


I am working on a tracer app. The app requires to know the device location with high accuracy, i.e. it uses location services and ignores locations with horizontal accuracy worse than 20 meters. CLLocation does not declare explicitely if it was determined via GPS or not. However, if the horizontal accuracy is 20 meters or better, it can be supposed that it is a location from GPS.

Additionally, I need to know the timestamp when the location was determined. I know about the property timestamp in class CLLocation. However, I would like to get the timestamp from GPS, not the system time.

Is it possible to get the GPS time? I don't care about cases when the GPS signal is not available. I just need to get the GPS time for a GPS location (location with high accuracy) I have just received.

In other questions on stackoverflow, the following code snippet is suggested:

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

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

It seems not to be true if the automatic time setting is turned off. If I go to Settings -> General -> Date & Time and turn off "Set Automatically", the property timestamp contains the manually set system time. So is it more-GPS related at least when automatic time setting is turned on?

解决方案

I think that the timestamp is calculated device-side and is most likely not related to the satellite's timestamp.
CoreLocation is totally opaque in it's work and it sounds very unlikely from Apple to let you access raw data like GPS satellites timestamps...

这篇关于在iOS上从GPS获取时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 06:46