firebase / geofire-js

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

Query base on GeoJsonLayer polygon #207

Closed ArcherEmiya05 closed 3 years ago

ArcherEmiya05 commented 3 years ago

How does GeoFire perform queries is it circular or rectangular in shape? Also is it possible to do query based on GeoJsonLayer polygon in Google Map where queries will be limited only inside of that polygon (city boundary). Thanks.

ziyaddin commented 3 years ago

GeoFire searches for items within some radius, so it should be circular.

ArcherEmiya05 commented 3 years ago

GeoFire searches for items within some radius, so it should be circular.

Yes since radius and diameter words are both use when talking about circle, but I just got confused when I read some thread that says rectangular so I wanted to correct myself if I am wrong of thinking that queries is in circular shape.

https://stackoverflow.com/a/42215681 https://github.com/firebase/geofire-js/issues/46#issuecomment-61043194

puf commented 3 years ago

GeoFire uses geohashes to implement its functionality, and by their nature those allow querying in roughly rectangular areas. To implement the point+radius queries, GeoFire post-processes the keys it gets from the database to discard the ones outside of the requested radius.

The library has no support for any other shapes at the moment.