Skip to content

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

@tteggel

Description

@tteggel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions