MichaelSolati / geofirestore-js

Location-based querying and filtering using Firebase Firestore.
https://geofirestore.com
MIT License
505 stars 58 forks source link

Results only returned from one side of the Prime Meridian #132

Closed palkerecsenyi closed 5 years ago

palkerecsenyi commented 5 years ago

I have a places collection containing some places (inserted by GeoFirestore), all of which are to the East of the Prime Meridian.

If I run the following query (setting the centre point to be to the East of the Prime Meridian), all of the places are returned:

geofirestore.collection('places')
    .near({
        center: new firebase.firestore.GeoPoint(12.345, 0.1),
        radius: 100000
    })
    .get()

However, when I run the following query (setting the centre point to be to the West of the Prime Meridian), no places are returned, even though they are all within the radius:

geofirestore.collection('places')
    .near({
        center: new firebase.firestore.GeoPoint(12.345, -0.1),
        radius: 100000
    })
    .get()

I haven't tried doing this with latitude (North/South of the equator), but a similar issue perhaps might exist for latitude too.

willbattel commented 5 years ago

Likely due to fundamental limitations of geohashing. https://en.wikipedia.org/wiki/Geohash#Limitations_when_used_for_deciding_proximity

This library would need to do queries on both sides of the 180 degree meridian.

palkerecsenyi commented 5 years ago

That makes sense @willbattel. Could this be implemented into GeoFirestore so that (maybe by adding an additional option to .near) it queries both sides of the meridian automatically?

hindsricardo commented 5 years ago

Was this resolved? This kind of makes the library unusable

MichaelSolati commented 5 years ago

@hindsricardo There won't be a fix for this as it is a fundamental limitations of geohashing, and there is no neat way to implement a fix for this. (Unless someone wants to propose and implement a fix)