Class: GeoKdTree<T>
A spatial tree which is keyed on points on Earth's surface and allows searching for elements based on the great- circle distances from their keys to a query point.
Type parameters
Name |
---|
T |
Constructors
constructor
• new GeoKdTree<T
>(keyFunc
): GeoKdTree
<T
>
Constructor.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
keyFunc | (element : T , out : Float64Array ) => Float64Array | A function which generates keys from elements. Keys are cartesian representations of points on Earth's surface. |
Returns
GeoKdTree
<T
>
Throws
Error if the dimension count is less than 2.
Defined in
src/sdk/utils/datastructures/GeoKdTree.ts:46
Methods
clear
▸ clear(): void
Removes all elements from this tree.
Returns
void
Defined in
src/sdk/utils/datastructures/GeoKdTree.ts:235
insert
▸ insert(element
): void
Inserts an element into this tree. This operation will trigger a rebalancing if, after the insertion, the length of this tree's longest branch is more than twice the length of the shortest branch.
Parameters
Name | Type | Description |
---|---|---|
element | T | The element to insert. |
Returns
void
Defined in
src/sdk/utils/datastructures/GeoKdTree.ts:183
insertAll
▸ insertAll(elements
): void
Inserts a batch of elements into this tree. This tree will be rebalanced after the elements are inserted.
Parameters
Name | Type | Description |
---|---|---|
elements | Iterable <T > | An iterable of the elements to insert. |
Returns
void
Defined in
src/sdk/utils/datastructures/GeoKdTree.ts:191
rebuild
▸ rebuild(): void
Rebuilds and balances this tree.
Returns
void
Defined in
src/sdk/utils/datastructures/GeoKdTree.ts:228
remove
▸ remove(element
): boolean
Removes an element from this tree. This tree will be rebalanced after the element is removed.
Parameters
Name | Type | Description |
---|---|---|
element | T | The element to remove. |
Returns
boolean
Whether the element was removed.
Defined in
src/sdk/utils/datastructures/GeoKdTree.ts:200
removeAll
▸ removeAll(elements
): boolean
Removes a batch of elements from this tree. This tree will be rebalanced after the elements are removed.
Parameters
Name | Type | Description |
---|---|---|
elements | Iterable <T > | An iterable of the elements to remove. |
Returns
boolean
Whether at least one element was removed.
Defined in
src/sdk/utils/datastructures/GeoKdTree.ts:209
removeAndInsert
▸ removeAndInsert(toRemove
, toInsert
): void
Removes elements from this tree, then inserts elements into this tree as a single operation. The tree will be rebalanced at the end of the operation.
Using this method is more efficient than calling removeAll()
and insertAll()
separately.
Parameters
Name | Type | Description |
---|---|---|
toRemove | Iterable <T > | An iterable of the elements to remove. |
toInsert | Iterable <T > | An iterable of the elements to insert. |
Returns
void
Defined in
src/sdk/utils/datastructures/GeoKdTree.ts:221
search
▸ search(lat
, lon
, radius
, visitor
): void
Searches this tree for elements located near a query point and visits each of them with a function.
Parameters
Name | Type | Description |
---|---|---|
lat | number | The latitude of the query point, in degrees. |
lon | number | The longitude of the query point, in degrees. |
radius | number | The radius around the query point to search, in great-arc radians. |
visitor | GeoKdTreeSearchVisitor <T > | A visitor function. This function will be called once per element found within the search radius. If the visitor returns true , then the search will continue; if the visitor returns false , the search will immediately halt. |
Returns
void
Defined in
src/sdk/utils/datastructures/GeoKdTree.ts:58
▸ search(center
, radius
, visitor
): void
Searches this tree for elements located near a query point and visits each of them with a function.
Parameters
Name | Type | Description |
---|---|---|
center | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | LatLonInterface | The query point. |
radius | number | The radius around the query point to search, in great-arc radians. |
visitor | GeoKdTreeSearchVisitor <T > | A visitor function. This function will be called once per element found within the search radius. If the visitor returns true , then the search will continue; if the visitor returns false , the search will immediately halt. |
Returns
void
Defined in
src/sdk/utils/datastructures/GeoKdTree.ts:67
▸ search(lat
, lon
, radius
, maxResultCount
, out
, filter?
): T
[]
Searches this tree for elements located near a query point and returns them in order of increasing distance from the query key.
Parameters
Name | Type | Description |
---|---|---|
lat | number | The latitude of the query point, in degrees. |
lon | number | The longitude of the query point, in degrees. |
radius | number | The radius around the query point to search, in great-arc radians. |
maxResultCount | number | The maximum number of search results to return. |
out | T [] | An array in which to store the search results. |
filter? | GeoKdTreeSearchFilter <T > | A function to filter the search results. |
Returns
T
[]
An array containing the search results, in order of increasing distance from the query key.
Defined in
src/sdk/utils/datastructures/GeoKdTree.ts:79
▸ search(center
, radius
, maxResultCount
, out
, filter?
): T
[]
Searches this tree for elements located near a query point and returns them in order of increasing distance from the query key.
Parameters
Name | Type | Description |
---|---|---|
center | Readonly <Omit <Float64Array , "set" | "sort" | "copyWithin" >> | LatLonInterface | The query point. |
radius | number | The radius around the query point to search, in great-arc radians. |
maxResultCount | number | The maximum number of search results to return. |
out | T [] | An array in which to store the search results. |
filter? | GeoKdTreeSearchFilter <T > | A function to filter the search results. |
Returns
T
[]
An array containing the search results, in order of increasing distance from the query key.
Defined in
src/sdk/utils/datastructures/GeoKdTree.ts:90