iPhone CLLocationManager每0.5秒更新一次 [英] iPhone CLLocationManager updates every 0.5 seconds

查看:165
本文介绍了iPhone CLLocationManager每0.5秒更新一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于从GPS进行大量计算的应用程序,我需要每0.5秒获得纬度/经度和速度,以便非常准确并避免延迟。

For an app that does lots of calculation from the GPS, I need to get the latitude/longitude and speed every 0.5 second to be very accurate and avoid delay.

我正在使用:


  • [locationManager setDesiredAccuracy:kCLLocationAccuracyBestForNavigation];

  • - locationManager:didUpdateToLocation:fromLocation:将值存储在3个变量中的函数: newLatitude newLongitude newSpeed

  • 一个 NSTimer 每0.5秒调用一次函数的对象。

  • [locationManager setDesiredAccuracy:kCLLocationAccuracyBestForNavigation];
  • - locationManager:didUpdateToLocation:fromLocation: function to store the value in 3 variables: newLatitude, newLongitude and newSpeed
  • An NSTimer object that call a function every 0.5 second.

请参阅下面Excel生成的代表纬度值的图表在18秒内:

See below a graph generated by Excel representing the latitude values during 18 seconds:

我们可以清楚地看到我们每秒都有位置更新,而不是每隔0.5秒就有所需。我在办公室里做样品,所以我的速度在0到65英里/小时之间。因此,当我驾驶50MPH时,我应该每隔0.5秒从iPhone获得不同的lat / lon /速度值吗?

We can clearly see that we have location updates every second, and not every 0.5 second as wished. I do samples driving around my office, so my speeds vary between 0 and 65 MPH. So when I am driving 50MPH, I should get different values for lat/lon/speed from the iPhone every 0.5s right?

请告诉我如何获得这些位置如果您对 CLLocationManager 对象的准确性有任何了解,则每0.5秒更新一次。

Please tell me how I can get those location updates every 0.5s if you know anything about the accuracy with the CLLocationManager object.

谢谢!

推荐答案

您无法告诉位置管理员您希望更新的频率,但只有在选择为您提供更新时才会响应。获取更新的时间不能指望,这取决于寻找WiFi信号和GPS信号的难易程度。

You can't tell the location manager how often you want updates, but only respond when it chooses to give you updates. The timing of getting updates can't be counted on, it depends on the ease of finding WiFi signals and GPS signals.

这篇关于iPhone CLLocationManager每0.5秒更新一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆