@allmaps/render
Version:
Render functions for WebGL and image buffers
29 lines (27 loc) • 766 B
TypeScript
import { default as RBush } from 'rbush';
import { Bbox, Point, Polygon } from '@allmaps/types';
type RTreeItem = {
minX: number;
minY: number;
maxX: number;
maxY: number;
id: string;
};
/**
* 2D spatial index for polygons
*/
export declare class RTree {
rbush: RBush<RTreeItem>;
polygonsById: Map<string, Polygon>;
bboxesById: Map<string, Bbox>;
itemsById: Map<string, RTreeItem>;
addItem(id: string, polygon: Polygon): void;
removeItem(id: string): void;
clear(): void;
private search;
getBbox(id: string): Bbox | undefined;
getPolygon(id: string): Polygon | undefined;
searchFromBbox(bbox: Bbox): string[];
searchFromPoint(point: Point, filterInsidePolygon?: boolean): string[];
}
export {};