georust / rstar

R*-tree spatial index for the Rust ecosystem
https://docs.rs/rstar
Apache License 2.0
386 stars 67 forks source link

Unique/hashable ID for each RTreeNode #84

Open giorgostheo opened 2 years ago

giorgostheo commented 2 years ago

From what I have seen, the current RTreeNode implementation does not offer a unique (hashable, implements == correctly) key for each RTreeNode.

More specifically, I believe there are many usecases where one might need some sort of internal "access" to the node, meaning a way to add some sort of data to each one. In my case, this "data" is a tuple of values. However, since there is nothing correctly hashable in each RTreeNode, I can not find a way to create a Hashmap for ex. in order to store the data I need. The only info that is always available for each RTreeNode is the envelope, however two nodes can have the same envelope which means that this is not an appropriate key.

Adding some way to extract a (preferably hashable) unique ID for each RTreeNode would be useful in many ways, since it can allow a more "free" approach to traversal and can also allow child to parent referances instead of just parent to child.

urschrei commented 2 years ago

a way to add some sort of data to each one

Does https://docs.rs/rstar/latest/rstar/primitives/struct.GeomWithData.html work for this?

giorgostheo commented 2 years ago

No, the data needs to be added to each RTreeNode not to each individual point.

Additionally, adding EQ support to each to RTreeNode would proly be enough, even though hash would be better. I dont know if that is doable thought...