georust / rstar

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

RTree panics when running locate_within_distance on an empty tree #161

Closed gold-silver-copper closed 7 months ago

gold-silver-copper commented 7 months ago

I am creating an application in which a loop runs. During this loop a new rtree is created, and potentially something is inserted, then I run locate_within_distance on the resulting tree. The issue is that if nothing gets inserted at all, the rtree remains empty, then running locate_within_distance() panics. Here is some code to reproduce the panic

fn main() {

    let mut empty_tree : RTree<[i64;3]> = RTree::new();

    let all = empty_tree.locate_within_distance([0,0,0], 10);
}
gold-silver-copper commented 6 months ago

just want to say thank you for fixing it !!!!!