-
Notifications
You must be signed in to change notification settings - Fork 122
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
NearestNeighbors not returning correct point #29
Comments
For me, the following code prints {[88.492724 22.55827]}:
Could you post the Bounds() function and your user struct definitions? |
// user struct // Bounds rectangle with rtree // rtree storage I think issue with my "tol" value |
I think you're right. Your points differ by less than your tol = 0.01 (i.e. 88.490, 88.492 and 88.495 would all look like the same value), so the library probably can't distinguish between them properly. Try using 0.001 or 0.0001 and see if you get the correct result. |
yes getting correct result. Thank you. Please tell me what is "tol" ? |
tol (for "tolerance") is the width of the rectangle that is formed from your point -- the library doesn't actually store points because the algorithms involved only use rectangles, and so we have to create small rectangles out of the points before inserting them into the tree (see https://github.com/dhconnelly/rtreego/blob/master/geom.go#L300). I'm not sure why tol = 0.001 works but tol = 0.0001 doesn't. That seems strange. I'd have to debug this in a lot more detail (especially as I can't reproduce the issue), but for now I'd say to just use the tol value that is producing the correct results for you. |
Yes.. |
Hi,
Thanks for this awesome lib.
I am facing an issue :
I have following points:
keysBody := []byte(
[{"id": "1","name": "A","location": [88.495873,22.551802]},{"id": "2","name": "B","location": [88.490197,22.552743]},{"id": "3","name": "C","location": [88.492724,22.558270]}]
).................
type Storage struct {
Users map[string][]*user
geoIndex *rtreego.Rtree
nearestNeighbors int
}
.............
geoIndex.Insert(user)
............
lat := 22.562454
lon := 88.494374
...
geoIndex.NearestNeighbors(
20, rtreego.Point{lat, lon},
)
It always return : {"id": "2","name": "B","location": [88.490197,22.552743]} while id 3 (name c) is nearest
am I doing wrong or something ?
The text was updated successfully, but these errors were encountered: