@saehrimnir/druidjs / spatial_tree
Function: spatial_tree()
ts
function spatial_tree<T>(elements: T[], parameters: {
metric: Metric;
seed: number;
}):
| KDTree<T>
| BallTree<T>;Defined in: knn/spatial_tree.js:30
Picks the fastest spatial index that is still correct for the given metric.
Returns a KDTree for metrics it can prune soundly, and a BallTree — which only relies on the triangle inequality and therefore works for any metric — otherwise.
Type Parameters
| Type Parameter | Description |
|---|---|
T extends number[] | Float64Array<ArrayBufferLike> |
Parameters
| Parameter | Type | Description |
|---|---|---|
elements | T[] | Elements to index. |
parameters | { metric: Metric; seed: number; } | Metric and seed for the tree. |
parameters.metric | Metric | - |
parameters.seed | number | - |
Returns
The constructed index.