Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getAtLocation doesn't work #37

Open
ntripathy opened this issue Nov 1, 2019 · 5 comments
Open

getAtLocation doesn't work #37

ntripathy opened this issue Nov 1, 2019 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ntripathy
Copy link

ntripathy commented Nov 1, 2019

I am not getting desired result when I pass a radius other than 0. When I pass the radius as 0 then I get all the documents returned.

Here is my code snippet in. Android using Java

GeoFirestore gfs = new GeoFirestore(cr)
gfs.getAtLocation(new GeoPoint(latitude, longitude), 0, new GeoFirestore.SingleGeoQueryDataEventCallback() {
@OverRide
public void onComplete(List<? extends DocumentSnapshot> list, Exception e) {
Log.d(TAG, "Documents matched:" + list.size()); // When radius is 0 then it returns all the documents otherwise it is empty list.
}
});

@ntripathy
Copy link
Author

I think the radius is in meters and not in Kilometers. So when I give larger values then it is matching and returning desired documents.

@CaelumF
Copy link

CaelumF commented Nov 13, 2019

But the doc says it's in km? I can't see what I should when assuming km either so I reckon this should be opened and is probably a doc issue

@Supercaly
Copy link
Collaborator

I've given a rough look at the code and I think the error is that the radius is not converted from Km to m (internally it uses meters), so you're definitely right to reopen this issue and I'll mark this as a bug.

@Supercaly Supercaly reopened this Nov 14, 2019
@Supercaly Supercaly added bug Something isn't working help wanted Extra attention is needed labels Nov 14, 2019
@jonbhanson
Copy link

I have confirmed that the library does indeed use meters although the documentation states kilometers.

in GeoHashQuery.kt, the bitsForBoundingBox routine call GeoUtils.distanceToLatitudeDegrees(size) to convert the length to degrees latitude. Here is the code from that function:

fun distanceToLatitudeDegrees(distance: Double) = distance / Constants.METERS_PER_DEGREE_LATITUDE

Workaround: pass meters to the queries instead of kilometers.

@ameerhamza6733
Copy link

From initial testing i am sure it is not in KM, if you pass distance in KM then it calculates GEO hash for query upto 8 char, but if you pass distance in meters then it calculates GEO hash boundary box upto 5 char which make more sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants