StaticAABB2DIndex
Summary
Fast static spatial index data structure for 2D axis aligned bounding boxes utilizing hilbert curve spatial ordering. This is a rust port of the excellent flatbush javascript library.
Quick Links
Quick Code Example
use *;
// create builder for index containing 4 axis aligned bounding boxes
// index also supports integers and custom types that implement the IndexableNum trait
let mut builder: = new;
// add bounding boxes to the index
// add takes in (min_x, min_y, max_x, max_y) of the bounding box
builder.add;
builder.add;
builder.add;
builder.add;
// note build may return an error if the number of added boxes does not equal the static size
// given at the time the builder was created or the type used fails to cast to/from a u16
let index: = builder.build.unwrap;
// query the created index (min_x, min_y, max_x, max_y)
let query_results = index.query;
// query_results holds the index positions of the boxes that overlap with the box given
// (positions are according to the order boxes were added the index builder)
assert_eq!;
// the query may also be done with a visiting function that can stop the query early
let mut visited_results: = Vec new;
let mut visitor = ;
index.visit_query;
assert_eq!;