sdd / kiddo

Kiddo
Apache License 2.0
87 stars 14 forks source link

Get coordinates at index? #176

Closed contagon closed 4 weeks ago

contagon commented 2 months ago

Apologies if this is the wrong place for this; couldn't find anywhere else to ask a question.

Is there anyway to get coordinates from a KdTree index? IE in NearestNeighbour there is a distance and an index field - is there anyway to query KdTree to get the coordinate at this index? Preferably, nearest_one would even return it. I perused the documentation, but couldn't find anything.

I imagine the coordinates are being stored internally, so it seems like it'd be redundant to have to keep an external copy of all the coordinates just for indexing. Correct me if I'm wrong though.

sdd commented 4 weeks ago

There isn't a way to do this. The suggested use case is to keep a Vec of your co-ords alongside the KdTree if you need to do this. Whilst the co-ords are kept internally, they are not in any kind of suitable datastructure where it is possible to quickly find the co-ords by index, since this is exactly what a Vec is for.