Remix.run Logo
zacwest 3 days ago

If you want to get location accuracy lower than 500m without significantly impacting battery life, you can use region monitoring. There's two paths:

1. Set up a region around the user's current location. If they exit it, note the location and set up another one around that location. This will give you around 100m accuracy, which is the minimum diameter of the monitored region.

2. Set up regions in various cardinal directions that nearly-or-just-barely overlap. If they enter one of those regions, note the location and set up another set around the current location. This can give you something closer to 50m accuracy.

For (2), this is how I did it in the Home Assistant iOS app, largely for zones that people wish to monitor which are smaller than 100m. You can find some of the annoying math here[1] (and there's tests all over for it), the logic for setting up regions here[2], and computing them here[3].

[1]: https://github.com/home-assistant/iOS/blob/master/Sources/Sh... [2]: https://github.com/home-assistant/iOS/tree/master/Sources/Ap... [3]: https://github.com/home-assistant/iOS/blob/2dfbe3c0e52a30417...