firebase / geofire-java

GeoFire for Java - Realtime location queries with Firebase
MIT License
670 stars 271 forks source link

Max radius for queryAtLocation() #72

Closed m6s closed 6 years ago

m6s commented 7 years ago

Through trial and error I've found that the max radius for which query results are returned is about 8587km. For bigger radiuses, onKeyEntered() is never called. Is that a bug? If not, how would I go about querying locations that are further apart? I'm using GeoFire 2.1.1 on Android.

    @Test
    public void queryAtLocation() throws InterruptedException {
        double radius = 8589; // Fails
//        double radius = 8587.8; //Passes
        CountDownLatch latch = new CountDownLatch(1);
        final boolean[] entered = {false};
        geoFire.queryAtLocation(new GeoLocation(0, 0), radius)
                .addGeoQueryEventListener(new GeoQueryEventListener() {
                    @Override
                    public void onKeyEntered(String key, GeoLocation location) {
                        entered[0] = true;
                    }

                    @Override
                    public void onKeyExited(String key) {
                    }

                    @Override
                    public void onKeyMoved(String key, GeoLocation location) {
                    }

                    @Override
                    public void onGeoQueryReady() {
                        latch.countDown();
                    }

                    @Override
                    public void onGeoQueryError(DatabaseError error) {
                    }
                });
        latch.await();
        Assert.assertTrue(entered[0]);
    }
braulio94 commented 7 years ago

Facing the same issue.

vanniktech commented 6 years ago

Let's go and throw an error when the passed radius is too big too handle?

samtstern commented 6 years ago

@vanniktech that's a great idea, or at least a sternly-worded Log message.

vanniktech commented 6 years ago

Another possible solution is to max it internally and state in the javadoc that we'll not go higher than 8589.

Which one should we go for?

samtstern commented 6 years ago

@vanniktech I think that's least harmful, and we can still do big warnings in the log whenever we get a bigger radius.

vanniktech commented 6 years ago

I'll do this tomorrow then.

ahaverty commented 6 years ago

This sounds like a different bug if 8589km is working for a few people, but just incase the cause is linked and ye haven't seen this on the objective-c project: https://github.com/firebase/geofire-objc/issues/64

samtstern commented 6 years ago

This issue was fixed and released in v2.2.0.