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:
- it is slow, this could be executed in a single query instead of 9
- it requires multiple part of the application to be aware of the geohash algorithm used, eg, the server and clients may be written in different languages, geofire libraries used on both sides must have the same algorithm.
- I would also like to keep my models free of Firebases concerns, so that the documents are valid json values (no GeoPoint inside the model or Timestamp).The API I'd hope for is something like:
collectionRef.within(
radius: 10000,
center: { lat: 40, lon: 50 },
latitudeFieldPath: 'position.latitude',
longitudeFieldPath: 'position.longitude',
) -
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