build/
build.rs

1extern crate kd_tree_rs;
2
3use kd_tree_rs::KdNode;
4use kd_tree_rs::point::Point;
5
6fn main() {
7    let points: Vec<Point<i32>> = vec![
8        Point { x: 1, y: 8 },
9        Point { x: 2, y: 2 },
10        Point { x: 3, y: 6 },
11        Point { x: 4, y: 9 },
12        Point { x: 7, y: 3 },
13        Point { x: 8, y: 8 },
14        Point { x: 9, y: 1 },
15        Point { x: 9, y: 9 },
16    ];
17
18    let node: KdNode<i32> = KdNode::build(points);
19
20    let radius: f64 = 1.5;
21    let origin: Point<i32> = Point { x: 8, y: 8 };
22    let nearest = node.nearest_neighbor(origin, radius);
23    assert_eq!(
24        nearest,
25        vec![Point { x: 8, y: 8 }, Point { x: 9, y: 9 }]
26    );
27    println!("Neighbours within 1.5 units of (1,1): {:?}", nearest);
28}