Hilbert Packed R-Tree in Typescript
This is an implementation of a Hilbert Packed R-Tree without any external dependencies. R-Trees are a special data structure for indexing spatial data. To improve the performance of query operations on the data structure, the R-Tree may be packed using the space filling Hilbert Curve.
Install
npm install hilbert-rtree
Usage
const options = { maxChildrenPerNode: 4 };
const tree = new RTree(
options
);
const records = [
{
x: 0, y: 0, width: 10, height: 10, data: "This can be any data type"
},
{ x: 30, y: 30, data: "Data may also be stored as a point rather than a rectangle" },
];
tree.batchInsert(records);
const boundingRectangle = {
x: 0, y: 0, width: 5, height: 5
};
const result = tree.search(boundingRectangle);
console.log(result);