简体   繁体   English

iOS地理围栏; 这会比我现在的更准确吗?

[英]iOS Geofencing; will this be more accurate than what I have now?

I am by no means an iOS developer, and am just hacking something basic together for myself.我绝不是 iOS 开发人员,我只是为自己编写一些基本的东西。 Sorry if this is too beginner of a question.对不起,如果这是一个问题的初学者。

I'm trying to collect my own location data from my phone to my own back-end service.我正在尝试将我自己的位置数据从我的手机收集到我自己的后端服务中。 Looking around, I found a sample project to collect location info: https://github.com/chriseidhof/PostGPS/环顾四周,我发现了一个收集位置信息的示例项目: https : //github.com/chriseidhof/PostGPS/

From the looks of things, this project uses significant location update, so even though I changed my desired accuracy to 100 meters, the app will still only provide update when enough cell towers have changed.从表面上看,该项目使用了重要的位置更新,因此即使我将所需的精度更改为 100 米,该应用程序仍然只会在更改了足够多的信号塔时才提供更新。

Instead, I'm thinking of using geofencing (CLCircularRegion) by creating grids of 3x3 geofences with 500 meter radius (with maybe a 50 meter overlap between each region), and each time I exit the central region, a new set of 3x3 geofences gets generated.相反,我正在考虑通过创建半径为 500 米的 3x3 地理围栏网格(每个区域之间可能有 50 米重叠)来使用地理围栏(CLCircularRegion),并且每次我离开中心区域时,都会得到一组新的 3x3 地理围栏生成。

My questions are as follows:我的问题如下:

  1. Is this (the deleting and re-fencing part) a correct use of geofencing on iOS?这是(删除和重新围栏部分)在 iOS 上正确使用地理围栏吗?
  2. Is this going to be more accurate than what I currently have?这会比我目前拥有的更准确吗?
  3. Will this significantly negatively affect my battery life?这会显着影响我的电池寿命吗?

The problem with using geofencing is that you can't monitor more than 20 regions at a time(OS limitation).使用地理围栏的问题是您一次不能监控超过 20 个区域(操作系统限制)。 It's better to use significant location changes.最好使用显着的位置更改。 It is triggered while you're in foreground or background and the location is updated if the cell tower has changed or you have opened the app while the app was not in memory.它会在您处于前台或后台时触发,如果手机信号塔发生变化或者您在应用程序不在内存中时打开了应用程序,则位置会更新。 But this method will be triggered only in the intervals of 15 mins.但是这个方法只会在 15 分钟的时间间隔内触发。 So even if the cell tower changes rapidly, this method will be invoked only once in 15 mins.所以即使手机信号塔变化很快,这个方法也只会在 15 分钟内被调用一次。

So if you want to update the location in background keeping in mind the battery usage as well, use significant location api.因此,如果您还想在后台更新位置并记住电池使用情况,请使用重要的位置 api。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM