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

Clarification on Radius #131

Open
tapizquent opened this issue Jan 6, 2021 · 5 comments
Open

Clarification on Radius #131

tapizquent opened this issue Jan 6, 2021 · 5 comments
Assignees

Comments

@tapizquent
Copy link

While testing the .within method, I realized that the radius property does not seem to be in Km as stated in the example project.

I base this statement because I have a document in my database of the following structure:

locations : {
    my_location_id : {
        name : locationName,
        position : {
            geohash: djn6c055s,
            geopoint: {
                latitude: 26.628408,
                longitude: -81.874084
            }
        }
    }
}

As can be seen, the LatLng is (26.628408, -81.874084)

When calling the method:

I am using:

final center = geoflutterfire.point(latitude: 26.628420, longitude: -81.804004);

geoflutterfire
        .collection(collectionRef: collection)
        .within(
            center: center,
            radius: 50,
            field: 'position',
            strictMode: true)

If you use a tool such as https://www.nhc.noaa.gov/gccalc.shtml, you can see that the there is approximately only 7km between these points, but even with radius 50, GeoFlutterFire returns 0 items.

Increasing the radius to 200 does return the correct item.

Thus, I am led to believe that the radius is indeed not in km.

I would like to get some more details on this and correct the documentation if that is the case.

@Beautylivery
Copy link

i get completely weird results ... with 3 data points all in an area of 3 km i can not really filter for the ones in a 1km range only to 2 points .... i even get the far away point of 3 km but missing one close point of <1km i am let to believe that the within function also have troubles here.

@awaik
Copy link
Collaborator

awaik commented Apr 4, 2021

Will check it next week. Thank you!

@awaik awaik self-assigned this Apr 4, 2021
@kamaleshbasu
Copy link

kamaleshbasu commented Apr 21, 2021

The plugin makes use of GeoHashes. The problem with GeoHash based queries can be summarised as:

Geohashing guarantees that the longer a shared prefix between two geohashes is, the spatially closer they are together. The reverse of this is not guaranteed, as two points can be very close but have a short or no shared prefix.

There is a possibility that the problem is due to boundary issues between two edge case geohashes.
https://en.wikipedia.org/wiki/Geohash

@jack84156
Copy link

jack84156 commented Feb 28, 2022

same here . in my case it always return item 0 if distance was less than 100 . so i when i increase radius to 500 so it returns results ,even though after hard tested i realized the problem was from .within method and not only radius because i am sure this plugin uses native geo hash wrapping to flutter , i am use the same geo hash native in my java app , and there no issues into it and it can have a very accurate vision with distance , i hope this package solve it's issues

@jlopezrod
Copy link

same here. I've used the next code:

print('${list.length} close'); list.forEach((element) { final point = GeoFirePoint(actualLatLng.latitude, actualLatLng.longitude); print( 'Distance from ${element.name}: ${point.distance(lat: element.latitude, lng: element.longitude)} kms'); });

it show me: 14.069 kms when my radius 'within' was 10.

.within(center: center, radius: 10, field: 'localization')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants