import type { BBox } from '../index.js'; /** Function describing how to access the minX, minY, maxX, and maxY properties */ export type BoxIndexAccessor = (item: T) => BBox; /** * # BoxIndex * * ## Description * An Index for points and rectangles * * A really fast static spatial index for 2D points and rectangles in JavaScript. * Uses either a fast simple Hilbert curve algorithm or a more complex Hilbert curve (S2) algorithm. * * This is a partial port/typescript port of the [flatbush](https://github.com/mourner/flatbush) * codebase. * * ## Usage * ```ts * import { BoxIndex } from 'gis-tools-ts'; * import type { BoxIndexAccessor } from 'gis-tools-ts'; * * interface Item { minX: number; minY: number; maxX: number; maxY: number } * * // define how to access the minX, minY, maxX, and maxY properties * const accessor: BoxIndexAccessor = (item: Item) => [item.minX, item.minY, item.maxX, item.maxY]; * // create the index * const flatbush = new BoxIndex(items, accessor); * * // make a bounding box query * const found = index.search(minX, minY, maxX, maxY); * * // make a k-nearest-neighbors query * const neighborIds = index.neighbors(x, y, 5); * ``` * * ## Links * - */ export declare class BoxIndex { #private; private readonly items; private readonly accessor; minX: number; minY: number; maxX: number; maxY: number; /** * Create a BoxIndex index that will hold a given number of items. * @param items - The items to index. * @param accessor - A function for accessing the minX, minY, maxX, and maxY properties of the items. * @param [nodeSize] Size of the tree node (16 by default). */ constructor(items: T[], accessor: BoxIndexAccessor, nodeSize?: number); /** * Search the index by a bounding box. * @param minX - The minimum x coordinate of the query point. * @param minY - The minimum y coordinate of the query point. * @param maxX - The maximum x coordinate of the query point. * @param maxY - The maximum y coordinate of the query point. * @param [filterFn] An optional function that is called on every found item; if supplied, only items for which this function returns true will be included in the results array. * @returns An array of indices of items intersecting or touching the given bounding box. */ search(minX: number, minY: number, maxX: number, maxY: number, filterFn?: (item: T) => boolean): T[]; /** * Search items in order of distance from the given point. * @param x - The x coordinate of the query point. * @param y - The y coordinate of the query point. * @param [maxResults] - The maximum number of results to return. * @param [maxDistance] - The maximum distance to search. * @param [filterFn] An optional function for filtering the results. * @returns An array of indices of items found. */ neighbors(x: number, y: number, maxResults?: number, maxDistance?: number, filterFn?: (item: T) => boolean): T[]; } //# sourceMappingURL=boxIndex.d.ts.map