startMonitoringSignificantLocationChanges缺乏准确性

时间:2011-11-28 01:48:38

标签: objective-c ios core-location

我正在开发一个具有以下要求的简单应用程序:任务将在给定位置启动,在用户离开一定距离后,任务应自动结束。

我目前正在使用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

以上所有事情都发生在我没有将设备移动一英寸的情况下。我的预感是startMonitoringSignificantLocationChanges不够准确,无法完成这个要求。是这样的吗?或者我可能会忽视某些事情?

任何反馈都将不胜感激。我没有发布任何代码,但它都是非常基本的CLLocationManager东西。如果需要更多信息或代码片段,请告诉我。

提前致谢!

1 个答案:

答案 0 :(得分:5)

来自the CLLocationManager docs

  

此接口[例如,startMonitoringSignificantLocationChanges ]仅在检测到设备关联的信号塔更改时才会发送新事件,从而减少更新频率并显着降低功耗。

因此,startMonitoringSignificantLocationChanges不太可能用于检查您正在寻找的准确度级别的位置 - 细胞塔很少能够很好地定位您。您可以尝试使用startMonitoringForRegion:desiredAccuracy:代替;它也可以在后台运行,并且会为你做很多肮脏的测试。