2011-11-28 52 views
3

我正在研究一个简单的应用程序,它具有以下要求:任务将在给定位置开始,并且在用户漫游一定距离后,该任务应自动结束。启动监视重要位置更改缺乏准确性

我目前正在使用CLLocationManager的startUpdatingLocation获取初始GPS位置,精度在100米以内。这工作正常。

然后我使用CLLocationManager的startMonitoringSignificantLocationChanges来确定用户是否已经走得够远。我使用这种方法,因为它在电池寿命上更好,可以在后台运行等。

现在,我遇到的问题是使用startMonitoringSignificantLocationChanges返回的位置的准确性。如果我只是让手机坐在我的桌子上等待10-20分钟,由于startMonitoringSignificantLocationChanges返回的位置准确(或缺少),它会自动结束任务。例如:

2011-11-27 20:21:44.653 MyApp[2692:707] Location manager wants 100.000000 meter accuracy 
2011-11-27 20:21:44.655 MyApp[2692:707] Location manager got 99.260482 meter accuracy 
2011-11-27 20:27:52.975 MyApp[2692:707] visit location: lat 43.619912 long -70.237781 
2011-11-27 20:27:52.977 MyApp[2692:707] current location: lat 43.619808 long -70.237561 
2011-11-27 20:27:52.981 MyApp[2692:707] moved 21.155182 meters from visit origin 
2011-11-27 20:37:53.205 MyApp[2692:707] visit location: lat 43.619912 long -70.237781 
2011-11-27 20:37:53.207 MyApp[2692:707] current location: lat 43.628081 long -70.231727 
2011-11-27 20:37:53.211 MyApp[2692:707] moved 1030.822457 meters from visit origin 

以上所有都发生在没有我移动设备一英寸的情况下。我的直觉是,启动监视重要位置更改不够准确,无法完成此要求。是这样吗?或者我可能忽略了一些东西?

任何反馈将不胜感激。我没有发布任何代码,但它都是非常基本的CLLocationManager。让我知道是否需要更多信息或代码片段。

在此先感谢!

回答

5

the CLLocationManager docs

此接口[e.g,startMonitoringSignificantLocationChanges]提供了新的事件,只有当它检测到更改设备的相关信号发射塔,从而减少频繁的更新和显著降低功耗。

因此,它是不可能的,startMonitoringSignificantLocationChanges可用于检查的准确度等级你要找的地方 - 这是罕见的,手机发射塔可以本地化你那么好。您可能需要尝试使用startMonitoringForRegion:desiredAccuracy:代替;它也在后台运行,并且会为你测试该区域的很多肮脏工作。

+0

谢谢 - 我意识到,手机塔更改触发事件与startMonitoringSignificantLocationChanges,但不是该蜂窝被用来检测位置而不是GPS。是否有文件记录GPS不能用于startMonitoringSignificantLocationChanges? –

+0

另一个小小的评论 - 如果手机信号塔的变化触发事件,为什么在手机从未移动时发生这种情况? –

+0

不明确,但我看不到任何'startMonitoringSignificantLocationChanges'会使用GPS的原因。 sMSLC的重点在于节能;自动启动GPS,并在每次改变位置时等待修复将消耗不必要的功率。关于手机不动 - 手机可以并且会自动切换塔,可能是因为信号强度的变化。 – duskwuff

相关问题