s2maps-gpu
Version:
S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.
59 lines (58 loc) • 1.85 kB
TypeScript
/** A basic vector point that allows for arbitrary data */
export interface Point<T> {
x: number;
y: number;
data: T;
}
/**
* # Point Index
*
* A kd-tree based point index
*/
export default class PointIndex<T> {
#private;
nodeSize: number;
points: Array<Point<T>>;
/** @param nodeSize - size of the kd-tree leaf node */
constructor(nodeSize?: number);
/**
* Add a point to the index.
* @param x - x coordinate
* @param y - y coordinate
* @param data - data related to point to add
*/
add(x: number, y: number, data: T): void;
/**
* Add a new point to the index
* @param point - a point to add
*/
addPoint(point: Point<T>): void;
/** Perform indexing of the added points. */
sort(): void;
/**
* Search the index for items within a given bounding box.
* @param minX - minimum x value
* @param minY - minimum y value
* @param maxX - maximum x value
* @param maxY - maximum y value
* @returns All points found within the bounding box
*/
range(minX: number, minY: number, maxX: number, maxY: number): Array<Point<T>>;
/**
* Search the index for items within a given radius.
* @param qx - query point X-coordinate
* @param qy - query point Y-coordinate
* @param r - radius
* @returns All points found within the radius of the query point
*/
radius(qx: number, qy: number, r: number): Array<Point<T>>;
/**
* Custom Floyd-Rivest selection algorithm: sort ids and coords so that
* [left..k-1] items are smaller than k-th item (on either x or y axis)
* @param k - index
* @param left - left index
* @param right - right index
* @param axis - axis (0 for x or 1 for y)
*/
select(k: number, left: number, right: number, axis: number): void;
}