import { PointIndex, Tile } from '../index.js'; import type { Face, JSONCollection, MValue, Projection, Properties, S2CellId, VectorPoint, VectorPointM } from '../geometry/index.js'; import type { FeatureIterator, PointShape } from '../index.js'; import type { VectorStore, VectorStoreConstructor } from '../dataStore/vector/index.js'; /** The kind of input required to store a point for proper indexing */ export type ClusterStore = VectorStoreConstructor>>; /** Options for point clustering */ export interface ClusterOptions { /** type of store to use. Defaults to an in memory store */ store?: ClusterStore; /** projection to use */ projection?: Projection; /** Name of the layer to build when requesting a tile */ layerName?: string; /** min zoom to generate clusters on */ minzoom?: number; /** max zoom level to cluster the points on */ maxzoom?: number; /** cluster radius in pixels relative to a 512x512 pixel tile */ radius?: number; } /** A cluster is a storage device to maintain groups of information in a cluster */ export interface Cluster extends Properties { data: M; visited: boolean; value: number; } /** Compare two data items, return true to merge data */ export type ClusterDataComparitor = (a: M, b: M) => boolean; /** * # Point Cluster * * ## Description * A cluster store to index points at each zoom level * * ## Usage * ```ts * import { PointCluster } from 'gis-tools-ts'; * const pointCluster = new PointCluster(); * * // add a lon-lat * pointCluster.insertLonLat(lon, lat, data); * // add an STPoint * pointCluster.insertFaceST(face, s, t, data); * * // after adding data build the clusters * await pointCluster.buildClusters(); * * // get the clusters for a tile * const tile = await pointCluster.getTile(id); * // or get the raw cluster data * const clusters = await pointCluster.getCellData(id); * ``` */ export declare class PointCluster { #private; projection: Projection; layerName: string; minzoom: number; maxzoom: number; radius: number; gridSize: number; indexes: Map>>; avgAngleSpan: import("../index.js").LengthMetric; /** * @param data - if provided, the data to index * @param options - cluster options on how to build the cluster * @param maxzoomStore - the store to use for the maxzoom index */ constructor(data?: JSONCollection, options?: ClusterOptions, maxzoomStore?: VectorStore>>); /** * Add a point to the maxzoom index. The point is a Point3D * @param point - the point to add */ 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; /** * Build the clusters when done adding points * @param cmp_ - custom compare function */ buildClusters(cmp_?: ClusterDataComparitor): Promise; /** * @param id - the cell id * @returns - the data within the range of the tile id */ getCellData(id: S2CellId): Promise>[]>; /** * @param id - the id of the vector tile * @returns - the vector tile */ getTile(id: S2CellId): Promise, { value: number; }, M>>; } //# sourceMappingURL=pointCluster.d.ts.map