tidwall / tile38

Real-time Geospatial and Geofencing
https://tile38.com
MIT License
9.09k stars 569 forks source link

Geofencing using overlapping ratios? #191

Open joashc opened 7 years ago

joashc commented 7 years ago

First off, thanks for developing Tile38! We've been using it in production to track hundreds of location updates per second, and it's performant, stable, and generally hassle-free.

As outlined here, the Android geofencing feature will only fire an entrance event when about 80% of the area of the location circle (with radius defined by the location accuracy) overlaps with the geofence circle.

This means that if the accuracy of the location is really low (i.e. the location circle is really large) it won't fire the geofence event even if the center of the location circle intersects the geofence.

Would something like this be possible with Tile38? I know we can choose from WITHIN or INTERSECTS, but I'm not sure if there's a way to easily check if two areas overlap by a certain amount.

tidwall commented 7 years ago

Hi Joash, I'm happy to hear that Tile38 is working well for you organization.

There's nothing specifically like what you described built into Tile38, but it may be possible to simulate that feature by using circles (instead of points) for the moving location objects and two static geofence circles instead of one.

The size of the location circle could represents the GPS accuracy. The circle would need to be generated by you and sent to Tile38 as a GeoJSON polygon, but it's basically a series of points that go around the center point. Here's the basic logic for generating.

Then both geofence circles would be in the same position with one circle being 20% larger than the second.

The larger geofence only watches for exit and inside events (inside is equivalent to Androids dwell event). The smaller geofence watches for enter and inside.

You would need to ignore all larger circle events until the enter event fires.