firebase / geofire-js

GeoFire for JavaScript - Realtime location queries with Firebase
MIT License
1.44k stars 345 forks source link

Geofire Minimum radius? #193

Closed sandeshnaroju closed 3 years ago

sandeshnaroju commented 4 years ago

What is the minimum radius? In my use case, I want a it to detect under 2 meters.

mjpoulsen commented 4 years ago

If I understand the code and geohash encoding correctly, you should be able to detect under 2 meters.

The utils.ts file defines GEOHASH_PRECISION = 10 https://github.com/firebase/geofire-js/blob/master/src/utils.ts#L4

and according to https://www.movable-type.co.uk/scripts/geohash.html, 10 characters means a geohash will cover an area of less than 1.19m (width) x 0.596m (height).

So, as long as your documents have a geohash of 10 characters, you should be able to detect under 2 meters but greater than ~0.6m.

puf commented 3 years ago

That's indeed also my experience @mjpoulsen : geofire-js is (or more accurately: the geohash values it uses) accurate to around 1 meter in my tests.