SpacialIndex

SpacialIndex

2D spatial indexing for points using a KD-tree

Constructor

new SpacialIndex()

Source:
See:

Methods

add(item)

Source:

Add an item

Parameters:
Name Type Description
item Object

getInRadius(x, y, radius) → {Array}

Source:

Get all points in the radius around the coordinates

Parameters:
Name Type Description
x Number

coordinate

y Number

coordinate

radius Number

radius

Returns:

array of items in the radius

Type
Array

getInRect(minX, minY, maxX, maxY) → {Array}

Source:

Get all points in the given rectangle

Parameters:
Name Type Description
minX Number
minY Number
maxX Number
maxY Number
Returns:

array of items in the rectangle

Type
Array

getNearest(x, y, n) → {*|Array}

Source:

Get the nearest point(s) (k-nearest-neighbour)

Parameters:
Name Type Default Description
x Number

coordinate

y Number

coordinate

n Number 1

amount of items to return

Returns:

an item if n = 1, otherwise an array

Type
* | Array

import(items)

Source:

import a new array of items

Parameters:
Name Type Description
items Array

remove(item)

Source:

Remove an item

Parameters:
Name Type Description
item Object