spaceindex
spaceindex is a tool for building r-trees.
- API Documentation
- Cargo package: spaceindex
Installation
Add this to your Cargo.toml
:
[]
= "0.3"
Basic Usage
To create a new RTree
, use:
use RTree;
// Creates a 2-dimensional RTree
let mut rtree : = new;
// This region is the rectangle whose lower-left corner is at (0,0) and whose upper-right corner is at (2, 2)
rtree.insert.expect;
// This region goes from (1, 0) to (3, 3).
rtree.insert.expect;
// Both rectangles contain the point (1, 1)
assert_eq!;
// No rectangle should contain the point (-1, 0)
assert!;
Python module
Also included is pyspaceindex
, a Python module exposing a simple interface
for working with two dimensional RTree's.
Build instructions
To build pyspaceindex
:
- Install the excellent maturin package from pypi.
- Navigate to the
pyspaceindex
directory in this repository, then runmaturin build
to build a copy of the wheel. To install the module in your current virtualenv instead, runmaturin develop
instead.
Example usage
# Make an RTree instance
=
# A region is described by a tuple (min_x, min_y, max_x, max_y).
# A tree can contain data, as well.
# Query the tree for whether it contains a point
assert ==
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.