Geolocation Queries for Firestore
-
Mubiru Simeon commented
These already exist. You can do geolocation on documents in firestore. I know how to do it in Flutter.
-
Sean Conrad commented
Simple use case: I just want to get the N nearest places to my coordinates. (Basically, paginate a query sorted by distance.) This is not possible with geohashes (as far as I can tell).
-
Developer Account commented
This would be a great feature - we opted to use supabas in a project instead of firebase due to the GIS tooling available to SQL instances. (although things like full-text-search also add to this decision)
-
Cedvdb commented
@frank
The documented solution has the following issues:
- request more documents than necessary
- does not allow much flexibility on modelization
- requires multiple parts of the application to be aware that a collection has a geo field.I'd propose something like:
```collection.within(
radius: 1000,
center: position,
latitudeField: 'position.latitude',
longitudeField: 'position.longitude'
)
```This would allow people to not rely on a GeoPoint data type furnished by firebase and be able to rely solely on Json, which is possible currently for other data types and which brings a lot of advantages:
- no need for an additional layer to abstract firebase specifics
- is easier on code generation tools.----
Just to be clear, I advice to not have a special data type on the firestore side for geo queries, keep it json like and deprecate the current geo data type. Have a geo-hash-index opt-in index on the back-end side.
-
Melanie Hardie commented
Our company offers an Indoor Positioning system that uses the Cartesian coordinate plane and sends notifications when a user breaks a location rule, so accuracy is paramount. We current use an SQL instance solely for spatial data and these queries, but would prefer to use Firestore, which we use for all other short term data storage.
-
Please comment below, how would you see this being different from the [documented solution][1]?
[1]: https://firebase.google.com/docs/firestore/solutions/geoqueries