didEnterRegion以更大的半径调用(iOS) [英] didEnterRegion called with larger radius (iOS)

查看:123
本文介绍了didEnterRegion以更大的半径调用(iOS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望以更高的精度调用didEnterRegion,但我无法这样做。这就是我所做的:我使用了distanceFilter和desiredAccuracy的最佳值(根据Apple最精确的GPS设置)并且有一个目的地CLCircularRegion(CLRegion的子类)。

I want didEnterRegion to be called with much precision, but I wasn't able to do so. Here is what I have done: I used the best values of distanceFilter and desiredAccuracy (most precise GPS settings according to Apple) and have a destination CLCircularRegion (Subclass of CLRegion).

self.locationManager.distanceFilter = kCLLocationAccuracyBestForNavigation;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;

@property (nonatomic, strong) CLCircularRegion *Destination;
self.Destination = [[CLCircularRegion alloc] initWithCenter:CLLocationCoordinate2DMake(43.907691, -69.963158) radius:5 identifier:@"Destination"];

[self.locationManager startMonitoringForRegion:self.Destination];

问题是当我离这个目的地150米远时,didEnterRegion被调用。同样距离之外的didExitRegion被召唤。我希望在我离开5米远的地方时调用didEnter和didExit区域,而不是150米远,因为我已经指定启动了CLCircularRegion。有没有人有办法解决吗?精确度是我所需要的,150米而不是5米对我来说太不准确了。谢谢吨 -

The problem is when I am like 150m away from this destination, didEnterRegion gets called. Also around similar distance away didExitRegion gets called. I want didEnter and didExit region to be called when I am 5 m away, not 150m away, as I have specified with initiation of CLCircularRegion. Does anyone have a solution? Precision is what I need, and 150m instead of 5m is too inaccurate for me. Thanks ton -

(我用iPhone 4S测试)

(I used iPhone 4S to Test)

推荐答案

虽然理论上当前的GPS +技术设备可以达到5米的准确度,但可能是由于各种原因,Apple阻止了区域监控的准确性。

While in theory accuracies of 5m are possible with the current GPS+ technical gear, it may be that Apple prevents such accuracy for region monitoring for various reasons.

一个是他们总是希望获得良好的用户体验,并且您想要的5米精度在您通常从GPS读数获得的精度范围内。因此,当用户仍然在该区域内时,留下这样小的区域也可能是由于较低的准确度读数。 Apple通过设置发布regionEnter或regionExit通知的阈值来确实掩盖此类错误。从苹果文档

One is that they always want a good user experience and the 5m accuracy you want is within the accuracy range you will often get from the GPS readings. Thus leaving such a small region could also be on account of lower accuracy readings while the user is still within the region. Apple does cover up for such errors by setting thresholds for posting regionEnter or regionExit notifications. From Apple documentation:


在iOS模拟器或设备上测试区域监控代码时,意识到区域事件可能不会立即发生在跨越区域边界之后。为防止虚假通知,iOS在满足某些阈值条件之前不会发送区域通知。具体来说,用户的位置必须越过区域边界,离开边界最小距离,并在报告通知之前保持最小距离至少20秒。

When testing your region monitoring code in iOS Simulator or on a device, realize that region events may not happen immediately after a region boundary is crossed. To prevent spurious notifications, iOS doesn’t deliver region notifications until certain threshold conditions are met. Specifically, the user’s location must cross the region boundary, move away from the boundary by a minimum distance, and remain at that minimum distance for at least 20 seconds before the notifications are reported.

特定阈值距离由当前可用的硬件和位置技术决定。例如,如果禁用Wi-Fi,则区域监控的准确性要低得多。但是,出于测试目的,您可以假设最小距离约为200米

The specific threshold distances are determined by the hardware and the location technologies that are currently available. For example, if Wi-Fi is disabled, region monitoring is significantly less accurate. However, for testing purposes, you can assume that the minimum distance is approximately 200 meters

然而,因为您可以要求高精度读数Apple还应该考虑到这一点。替代方案可能是 - 如您所评论的那样 - 使用didUpdateLocation:并确定区域内部还是外部。这样你可以包括一个位置精度测试,只有当水平精度足够好时才接受退出/输入。

Nevertheless since you can ask for high accuracy readings Apple should also take that into account. The alternative might be - as you commented - to use didUpdateLocation: and determine if inside or outside the region. That way you could include a test for location accuracy and only accept an exit/entry when horizontal accuracy is good enough.

这篇关于didEnterRegion以更大的半径调用(iOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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