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

Not finding points. Always returning empty arry. #4

Closed
atomless opened this issue Sep 24, 2013 · 9 comments
Closed

Not finding points. Always returning empty arry. #4

atomless opened this issue Sep 24, 2013 · 9 comments

Comments

@atomless
Copy link

Hi,

I've added a geoJSON layer to a leafletjs map by passing this json file ( http://labs.jamestindall.info/rhumb_lines/tracks.json )
to the L.geoJson method and this successfully generates the desired polylines.

However, when I then pass a L.LatLng to leaflet-knn like so :

var knn_index = leafletKnn(geoJSON_layer);
var nearest = knn_index.nearest( latlng, 5, 10 );

nearest is always an empty array no matter how high I set the max_distance threshold. Any ideas what might be going wrong here?

@tmcw
Copy link
Contributor

tmcw commented Sep 24, 2013

Can't really tell without context - can you link to an online example?

@atomless
Copy link
Author

Sure, here's the quick test/demo : http://labs.jamestindall.info/rhumb_lines/ and the js file is at : http://labs.jamestindall.info/rhumb_lines/js/main-using-leaflet.js (see function findClosestTrackPoint at line 83)

@tmcw
Copy link
Contributor

tmcw commented Sep 25, 2013

Hmm, this code has the bit using leaflet-knn disabled/commented out in initialization, and unused anywhere else.

@atomless
Copy link
Author

Sorry to have taken up your time Tom, I was on a deadline and had to drop leaflet-knn in favour of using the leaflet.geometryutil plugin.

@tmcw tmcw reopened this Sep 26, 2013
@tmcw
Copy link
Contributor

tmcw commented Sep 26, 2013

Reopening to find the core issue.

@tmcw
Copy link
Contributor

tmcw commented Sep 26, 2013

Ah, initialization flow was likely wrong. Closing; this was in the app.

@tmcw tmcw closed this as completed Sep 26, 2013
@atomless
Copy link
Author

Interesting. What had I done wrong?

@tmcw
Copy link
Contributor

tmcw commented Sep 26, 2013

The example was using polylines; this library deals in markers only.

@atomless
Copy link
Author

Thanks again for taking a look Tom. Though that really needs to be stated more clearly in the documentation. I followed the example and passed in GeoJSON. There should be very little difference whether the GeoJSON features are drawn as points/markers or as lines or polygons the method of calculating the nearest neighbour should be the same.

tmcw added a commit that referenced this issue Sep 27, 2013
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

2 participants