import type { S1ChordAngle } from '../geometry/s1/chordAngle.js'; import type { Face, FeatureIterator, JSONCollection, MValue, Projection, Properties, RGBA, S2CellId, VectorPoint, VectorPointM } from '../index.js'; import type { VectorStore, VectorStoreConstructor } from '../dataStore/index.js'; /** The kind of input required to store a point for proper indexing */ export interface PointShape { cell: S2CellId; point: VectorPointM; } /** * # Point Index * * ## Description * An index of cells with radius queries * Assumes the data is compatible with {@link https://open-s2.github.io/s2json/types/Properties.html} * * ## Usage * ```ts * import { PointIndex } from 'gis-tools-ts'; * import { FileVector } from 'gis-tools-ts/file'; * * const pointIndex = new PointIndex(); * // or used a file based store * const pointIndex = new PointIndex(FileVector); * * // insert a lon-lat * pointIndex.insertLonLat(lon, lat, data); * // insert an STPoint * pointIndex.insertFaceST(face, s, t, data); * * // after adding data build the index. NOTE: You don't have to call this, it will be called * // automatically when making a query * await pointIndex.sort(); * * // you can search a range * const points = await pointIndex.searchRange(low, high); * // or a radius * const points = await pointIndex.searchRadius(center, radius); * ``` */ export declare class PointIndex { #private; private projection; /** * @param store - the store to index. May be an in memory or disk * @param projection - the projection of the data, defaults to S2 */ constructor(store?: VectorStoreConstructor>, projection?: Projection); /** * Set the index store to a defined one. Useful for file based stores where we want to reuse data * @param store - the index store */ setStore(store: VectorStore>): void; /** * Insert a cell with the point and its corresponding data to the index * @param cell - the cell id to be indexed * @param point - the point to be indexed */ insertID(cell: S2CellId, point: VectorPointM): void; /** * Insert a point3D and its corresponding data to the index * @param point - the point to be indexed */ insert(point: VectorPointM): void; /** * Add all points from a reader. It will try to use the M-value first, but if it doesn't exist * it will use the feature properties data * @param reader - a reader containing the input data */ insertReader(reader: FeatureIterator): Promise; /** * Add a vector feature. It will try to use the M-value first, but if it doesn't exist * it will use the feature properties data * @param data - any source of data like a feature collection or features themselves */ insertFeature(data: JSONCollection): void; /** * Add a lon-lat pair to the cluster * @param ll - lon-lat vector point in degrees */ insertLonLat(ll: VectorPoint): void; /** * Insert an STPoint to the index * @param face - the face of the cell * @param s - the s coordinate * @param t - the t coordinate * @param data - the data associated with the point */ insertFaceST(face: Face, s: number, t: number, data: M): void; /** * iterate through the points * @yields {PointShape} - a PointShape */ [Symbol.asyncIterator](): AsyncGenerator>; /** Sort the index in place if unsorted */ sort(): Promise; /** * Find the starting index of a search * @param id - input id to seek the starting index of the search * @returns the starting index */ lowerBound(id: S2CellId): Promise; /** * Search for points given a range of low and high ids * @param low - the lower bound. If high is not provided, the low-high range will be created from the low * @param high - the upper bound * @param maxResults - the maximum number of results to return * @returns the points in the range */ searchRange(low: S2CellId, high?: S2CellId, maxResults?: number): Promise[]>; /** * TODO: Adjust the radius for the WM projection. Really not a massive issue thogh just adjust your calcuation for now * Search for points within a given radius of a target point * @param target - the point to search * @param radius - the search radius * @param maxResults - the maximum number of results * @returns the points within the radius */ searchRadius(target: VectorPoint, radius: S1ChordAngle, maxResults?: number): Promise[]>; } //# sourceMappingURL=pointIndex.d.ts.map