使用iOS地理围栏跟踪多个(20+)位置 [英] Tracking multiple (20+) locations with iOS geofencing

查看:667
本文介绍了使用iOS地理围栏跟踪多个(20+)位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS应用程序使用地理围栏来通知用户有关预定义的附近位置的信息。允许应用程序错过某个位置(用户没有收到有关附近位置的通知),但是希望保持较低的丢失率。

An iOS application uses the geofencing for notifying the user about predefined nearby locations. The application is allowed to miss some location (the user is not getting a notification about a nearby location), but it is desirable to keep the missing rate low.

单向实施这将是开始与 startMonitoringSignificantLocationChanges ,并且每个位置改变事件被触发时监测显著的变化位置,内寻找位置,让说,500个半径报告的位置。

One way to implement this would be to start monitoring for significant change locations with startMonitoringSignificantLocationChanges and each time the "location change" event is fired, look for locations within, let say, 500m radius of the reported location.

令我担心的是,每次发生重大位置变化时都要求对附近区域执行查询,这会影响电池。

What worries me is the requirement to perform the query for the nearby regions each time the significant location change occurs and it impact on the battery.

另一种方法是使用 startMonitoringForRegion 注册位置,但Apple已对此进行了(合理的)限制。同时跟踪的区域数量为20,我们有超过20个位置。因此需要对跟踪区域进行某种动态更新,但我仍然不确定最佳方法是什么。

The other way to do it would be to register the locations with startMonitoringForRegion but Apple has put a (reasonable) limitation on the number of simultaneously tracked regions which is 20 and we have significantly more than 20 locations. So some sort of dynamic updating of the tracked regions is required but I am still unsure what is the best way to do it.

关于如何做到这一点的任何想法它可以保持较低的电池消耗,但也具有低位置的丢失率?

Any ideas on how can it be done so that it keeps the battery consumption low but also has the low missing rate for locations?

推荐答案

由于没有太多的活动问题我将描述我们目前是如何解决这个问题的。

Since there was not much activity on the question I will describe how we are currently solving this problem.

我们将新区域的重新加载与重要的位置变更(SLC)事件联系在一起。当SLC发生时,我们检查应该地理围栏的20个相邻区域。为了找到20个最接近的区域,我们只是根据以下公式逼近纬度和经度的1'':

We tied the reloading of the new regions to significant location change (SLC) events. When an SLC takes place, we check for 20 neighbouring regions that should be "geofenced". To find the 20 closest regions we are simply approximating 1'' of the latitude and longitude according to the following formulae:


纬度:1度= 110.54 km

Latitude: 1 deg = 110.54 km

经度:1度= 111.320 * cos(纬度)km

Longitude: 1 deg = 111.320 * cos(latitude) km

并检查设备当前位置的边界平方,以查看受监控区域的中心(请参阅:使用lat / lon + km距离的简单计算?

and just check the bounding square of the current position of the device for the centers of the monitored regions (see: Simple calculations for working with lat/lon + km distance?)

所以,例如,如果(10N,10E)是我们从边界正方形开始的设备的当前位置,顶点位于(10-1',10-1'),(X-10',10 + 1'),(10 + 1') ,10 + 1'),(10 + 1',10-1')(在纬度(10N,10E),一个纬度/经度分钟接近1,85 km)。

So, for example, if (10N,10E) is the current location of the device we start with the bounding square with vertices at (10-1',10-1'), (X-10',10+1'), (10+1',10+1'), (10+1',10-1') (at latitude (10N,10E) one latitude/longitude minute approximates 1,85 km).

如果有20个(或差不多20个) - 我们将它们注册为地理围栏并等待下一个SC L.如果更少/更多,只需增加/减小边界矩形的大小并重复搜索。

If there are 20 (or almost 20) - we register them for the geofencing and wait for the next SCL. If less/more, just increase/decrease the size of the bounding rectangle and repeat the search.

您可以调整此搜索算法以获得更好的性能,但描述的是这里已经完成了这项工作。

You can tweak this search algorithm for a better performance, but the one described here will already do the job.

这篇关于使用iOS地理围栏跟踪多个(20+)位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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