geofire-js icon indicating copy to clipboard operation
geofire-js copied to clipboard

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

Open tteggel opened this issue 4 years ago • 1 comments

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);
});

tteggel avatar Jun 22 '21 15:06 tteggel

Hello, any solution about this issue ?

ediaStudio avatar Apr 01 '24 05:04 ediaStudio