kdtree
K-dimensional tree in Rust for fast geospatial indexing
Usage
Add kdtree
to Cargo.toml
[]
= "0.5.0"
Add points to kdtree and query nearest n points with distance function
use KdTree;
use ErrorKind;
use squared_euclidean;
let a: = ;
let b: = ;
let c: = ;
let d: = ;
let dimensions = 2;
let mut kdtree = new;
kdtree.add.unwrap;
kdtree.add.unwrap;
kdtree.add.unwrap;
kdtree.add.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Benchmark
cargo bench
with 2.3 GHz Intel i5-7360U:
cargo bench
Running target/release/deps/bench-9e622e6a4ed9b92a
running 2 tests
test bench_add_to_kdtree_with_1k_3d_points ... bench: 106 ns/iter (+/- 25)
test bench_nearest_from_kdtree_with_1k_3d_points ... bench: 1,237 ns/iter (+/- 266)
test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured; 0 filtered out
Thanks Eh2406 for various fixes and perf improvements.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.