firebase / geofire-js

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

Large radius query returns different results for small amounts either side of the meridian #227

Open tteggel opened 3 years ago

tteggel commented 3 years ago

In investigating some strange behaviour in a map rendered from geofire I noticed this following strange behaviour.

For a query with a radius equal or over 8,587,850, at the equator, moving the longitude a tiny amount to the other side of the meridian returns a different set of results. For higher/lower latitudes the critical radius is lower e.g. at 55 degrees latitude a radius of 3,342,783 passes and 3,342,784 fails. I wrote the below test case to demonstrate the problem.

I'm out of time to investigate this further as we're using a different approach but I hope this partial write-up might be useful to the team.

it('Query bounds from geohashQueryBounds must work across the meridian with big radius', () => {
    const centerLat = 0;
    const centerLong = 0.00000001;
    const radius = 8_587_850; // fails
    // const radius = 8_587_849; // passes
    const queriesEast = geohashQueryBounds([centerLat, centerLong], radius);
    const queriesWest = geohashQueryBounds([centerLat, -centerLong], radius);
    expect(queriesEast).to.have.deep.members(queriesWest);
});
ediaStudio commented 5 months ago

Hello, any solution about this issue ?