kdtree
K-dimensional tree in Rust for fast geospatial indexing
Usage
Add kdtree
to Cargo.toml
[]
= "~0.3.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 Core i7:
cargo bench
Running target/release/bench-a26a346635ebfc8f
running 2 tests
test bench_add_to_kdtree_with_1k_3d_points ... bench: 116 ns/iter (+/- 24)
test bench_nearest_from_kdtree_with_1k_3d_points ... bench: 2,661 ns/iter (+/- 1,769)
test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured
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.