UNPKG

s2-tools

Version:

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

64 lines 1.96 kB
import type { Stringifiable } from '..'; /** The kind of input required to store a vector for proper indexing */ export interface KDKV<T = Stringifiable> { x: number; y: number; data: T; } /** Represents a vector store or an array */ export interface KDStore<T = Stringifiable> { push: (value: KDKV<T>) => void; get: (index: number) => KDKV<T>; getRange: (indexStart: number, indexEnd: number) => KDKV<T>[]; length: number; values: () => Generator<KDKV<T>>; sort: () => void; [Symbol.iterator]: () => Generator<KDKV<T>>; close: () => void; } /** A constructor for a vector store */ export type KDStoreConstructor<T = Stringifiable> = new (nodeSize: number) => KDStore<T>; /** A local KD key-value store */ export declare class KDSpatialIndex<T = Stringifiable> implements KDStore<T> { #private; private readonly nodeSize; /** * @param nodeSize - the size of each kd-tree node */ constructor(nodeSize?: number); /** @returns the length of the store */ get length(): number; /** * Push a value into the store * @param value - the value to store */ push(value: KDKV<T>): void; /** * Get a value at index * @param index - the position in the store to get the value from * @returns the value */ get(index: number): KDKV<T>; /** * Get a range of values within an index range * @param indexStart - the start index * @param indexEnd - the end index * @returns the values */ getRange(indexStart: number, indexEnd: number): KDKV<T>[]; /** * iterate through the values * @yields an iterator */ values(): Generator<KDKV<T>>; /** Sort the store in place */ sort(): void; /** * iterate through the values * @returns an iterator */ [Symbol.iterator](): Generator<KDKV<T>>; /** Closes the store */ close(): void; } //# sourceMappingURL=index.d.ts.map