
forEachInRectangle(x, y, w, h, action)

Apply the callback to each object that interacts with the rectangle.
Parameters:
Name 
Type 
Description 
x 
Number

the x coordinate of the rectangle 
y 
Number

the y coordinate of the rectangle 
w 
Number

the width of the rectangle 
h 
Number

the height of the rectangle 
action 
function

called for each element interacting with the retangle 

insert(object, x, y, w, h)

Add an object to the RTree.
Parameters:
Name 
Type 
Description 
object 
Object

element to add 
x 
Number

the x coordinate of the rectangle 
y 
Number

the y coordinate of the rectangle 
w 
Number

the width of the rectangle 
h 
Number

the height of the rectangle 

mapInRectangle(x, y, w, h, map) → {Array}

Apply the map function to each object that interacts with the retangle and add it to the result.
Parameters:
Name 
Type 
Description 
x 
Number

the x coordinate of the rectangle 
y 
Number

the y coordinate of the rectangle 
w 
Number

the width of the rectangle 
h 
Number

the height of the rectangle 
map 
function

called for each element, returns a mapped object/value. 
Returns:
collection with all mapped values.

Type

Array

nearestNeighbours(x, y, k) → {Array}

Return the k nearest objects from the tree.
Parameters:
Name 
Type 
Default 
Description 
x 
Number


x coordinate of search position 
y 
Number


y coordinate of search position 
k 
Number

1

how many 
Returns:
the results. This may be less than k if the size of the tree is smaller than k.

Type

Array

reduceInRectangle(object, x, y, w, h, fold, initial) → {Object}

Fold collection into single value.
Parameters:
Name 
Type 
Argument 
Description 
object 
Object


element to add 
x 
Number


the x coordinate of the rectangle 
y 
Number


the y coordinate of the rectangle 
w 
Number


the width of the rectangle 
h 
Number


the height of the rectangle 
fold 
function


a reduce function, taking two arguments, the accumulator and an object interacting with the search retangle. 
initial 
Object

<optional>

initial accumulator 
Returns:
accumulated value

Type

Object

remove(object, x, y, w, h)

Remove the object from the RTree
Parameters:
Name 
Type 
Description 
object 
Object

the object to remove 
x 
Number

corresponding x of the object 
y 
Number

corresponding y of the object 
w 
Number

corresponding w of the object 
h 
Number

corresponding h of the object 

search(x, y, w, h) → {Array}

Search the RTree.
Parameters:
Name 
Type 
Description 
x 
Number

the x coordinate of the rectangle 
y 
Number

the y coordinate of the rectangle 
w 
Number

the width of the rectangle 
h 
Number

the height of the rectangle* @returns {Array} objects interaction with the search retangle 
Returns:
the object which interact with the search rectangle

Type

Array

size() → {Number}

Gets the number of object in the tree.
Returns:
the number of elements in the tree.

Type

Number