generic-quadtree
Description
Generic-Quadtree is a node module that implements a quadtree for storing key-value pairs where the keys are two dimensional values.
It is optimized for performing lookup of values in a specified range.
The module comes with implementations of a Point and a Box objects but will work with any objects that implement the methods on their prototypes.
For use in the browser or with node.
Installation
npm install generic-quadtree
Usage
//create bounding area of quadtreevar min = 00;var max = 100 100;var totalArea = min max;//instantiate new quadtreevar tree = totalArea;//insert itemvar position = 25 35;var item = 'value';tree;//get array of all point-value pairs contained within rangevar range = 10 10 40 40;var itemsInRange = tree; //returns [{point: position; value: item}]//get value if quadtree contains an item at pointtree; //returns 'value'//remove point from treetree; //tree is now empty//clear all internal nodes and valuestreeclear;