startMonitoringSignificantLocationChanges缺乏准确性 [英] startMonitoringSignificantLocationChanges Lack of Accuracy

查看:83
本文介绍了startMonitoringSignificantLocationChanges缺乏准确性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm working on a simple app that has the following requirement: a task will be started at a given location and, after the user wanders a certain distance away, the task should be automatically ended.

我目前正在使用CLLocationManager的startUpdatingLocation来将初始GPS位置精确到100米以内。

I'm currently using CLLocationManager's startUpdatingLocation to get the initial GPS location to within 100 meters accuracy. This works fine.

然后我使用CLLocationManager的startMonitoringSignificantLocationChanges来确定用户是否已经走了足够远。我使用此方法是因为它可以延长电池寿命,可以在后台运行,等等。

Then I use CLLocationManager's startMonitoringSignificantLocationChanges to determine if the user has wandered far enough away. I use this method as it's better on battery life, can run in the background, etc.

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

Now, the issue I am having is with the accuracy of the location returned when using startMonitoringSignificantLocationChanges. If I just let my phone sit on my desk, and wait 10-20 minutes, it will automatically end the task because of the accuracy (or lack thereof) of the position returned from startMonitoringSignificantLocationChanges. For instance:

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不够准确,无法满足此要求。是这样吗还是我可能忽略了某些东西?

The above all occurred without me moving the device an inch. My hunch is that startMonitoringSignificantLocationChanges is not accurate enough to accomplish this requirement. Is that the case? Or am I maybe overlooking something?

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

Any feedback would be appreciated. I didn't post any code but it's all pretty basic CLLocationManager stuff. Let me know if there's more information or code snippets needed.

谢谢!

推荐答案

来自 CLLocationManager 文档


此接口[例如,startMonitoringSignificantLocationChanges ]仅在检测到设备相关联的基站信号塔发生变化时才发送新事件,从而导致更新频率降低并显着降低了功耗。

This interface [e.g, startMonitoringSignificantLocationChanges] delivers new events only when it detects changes to the device’s associated cell towers, resulting in less frequent updates and significantly lower power usage.

因此, startMonitoringSignificantLocationChanges 不太可能用于以您想要的精度级别检查位置-信号塔很难定位你那么好。您可能想尝试使用 startMonitoringForRegion:desiredAccuracy:代替;它也可以在后台运行,并且会为您完成对该区域的点击测试的许多繁琐工作。

As such, it's unlikely that startMonitoringSignificantLocationChanges can be used to check for locations at the level of accuracy you're looking for -- it's rare that a cell tower can localize you that well. You may want to try using startMonitoringForRegion:desiredAccuracy: instead; it also works in the background, and will do a lot of the dirty work of hit-testing the region for you.

这篇关于startMonitoringSignificantLocationChanges缺乏准确性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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