import type { OsmPbfBlock, OsmPbfDenseNodes } from "@osmix/pbf"; import type { ContentHasher } from "@osmix/shared/content-hasher"; import type { GeoBbox2D, OsmNode, OsmTags } from "@osmix/types"; import { Entities, type EntitiesTransferables } from "./entities.ts"; import { type IdOrIndex } from "./ids.ts"; import type StringTable from "./stringtable.ts"; import { type BufferType } from "./typed-arrays.ts"; export interface NodesTransferables extends EntitiesTransferables { lons: T; lats: T; bbox: GeoBbox2D; /** Optional - can be rebuilt via buildSpatialIndex() */ spatialIndex?: T; } export interface AddNodeOptions { filter?: (node: OsmNode) => boolean; } export declare class Nodes extends Entities { /** * Coordinates are stored as integer microdegrees (Int32Array). * Use OSM_COORD_SCALE (1e7) to convert between degrees and microdegrees. */ private lons; private lats; private bbox; private spatialIndex; private spatialIndexBuilt; /** * Create a new Nodes index. */ constructor(stringTable: StringTable, transferables?: NodesTransferables); /** * Add a single node to the index. */ addNode(node: OsmNode): number; /** * Add dense nodes from a PBF block. */ addDenseNodes(dense: OsmPbfDenseNodes, block: OsmPbfBlock, blockStringIndexMap: Uint32Array, filter?: (node: OsmNode) => boolean): number; /** * Compact the internal arrays to free up memory. */ buildEntityIndex(): void; /** * Build the spatial index for nodes. * Spatial index stores degrees (Float64Array) for geokdbush compatibility. */ buildSpatialIndex(): void; /** * Check if the spatial index has been built. */ hasSpatialIndex(): boolean; /** * Get the bounding box of all nodes. */ getBbox(): GeoBbox2D; /** * Get the bounding box of a specific node. */ getEntityBbox(i: IdOrIndex): GeoBbox2D; /** * Get the longitude and latitude of a specific node. * ID lookups return `null` when the node is not present; index lookups remain strict. */ getNodeLonLat(i: { index: number; }): [number, number]; getNodeLonLat(i: { id: number; }): [number, number] | null; /** * Get the full node entity. */ getFullEntity(index: number, id: number, tags?: OsmTags): OsmNode; /** * Find node indexes within a bounding box. */ findIndexesWithinBbox(bbox: GeoBbox2D): number[]; /** * Find node indexes within a radius of a point. * Uses geokdbush for proper great-circle distance calculations. * @param lon - Longitude in degrees. * @param lat - Latitude in degrees. * @param radiusKm - Radius in kilometers. * @returns Array of node indexes within the radius. */ findIndexesWithinRadius(lon: number, lat: number, radiusKm: number): number[]; /** * Get nodes within a bounding box. * @param bbox - The bounding box to search within. * @param include - A function to filter nodes. If provided, only nodes for which the function returns true will be included. * @returns An object containing the IDs and positions of the nodes within the bounding box. */ withinBbox(bbox: GeoBbox2D, include?: (i: number) => boolean): { ids: Float64Array; positions: Float64Array; }; /** * Get transferable objects for passing to another thread. * Only includes spatialIndex if it has been built. */ transferables(): NodesTransferables; /** * Get the approximate memory requirements for a given number of nodes in bytes. */ static getBytesRequired(count: number): number; /** * Update a ContentHasher with node-specific data (coordinates). */ updateHash(hasher: ContentHasher): ContentHasher; } //# sourceMappingURL=nodes.d.ts.map