/** * PBF block parser utilities. * * Parses raw OSM PBF primitive blocks into typed JSON entities with decoded * string tables, resolved coordinates, and expanded delta encoding. * * @module */ import type { OsmPbfBlock, OsmPbfDenseNodes, OsmPbfGroup, OsmPbfInfo, OsmPbfNode, OsmPbfRelation, OsmPbfStringTable, OsmPbfWay } from "@osmix/pbf"; import type { OsmInfoParsed, OsmNode, OsmRelation, OsmWay } from "@osmix/types"; /** * Options for controlling entity parsing behavior. */ export interface ParseOptions { /** Whether to decode tags from string table (default: true). */ parseTags?: boolean; /** Whether to include entity metadata like version, timestamp (default: false). */ includeInfo?: boolean; } /** * Parse a PBF primitive block into JSON entities. * * Handles all PBF-specific decoding: * - **String table**: Resolves tag keys/values and role strings. * - **Delta encoding**: Expands IDs, coordinates, and member refs. * - **Dense nodes**: Parses compact dense node format. * - **Granularity**: Converts integer nanodegrees to floating-point coords. * * Implements `OsmPbfBlock` interface and is iterable over entity groups. * * @example * ```ts * import { OsmPbfBlockParser } from "@osmix/json" * * const parser = new OsmPbfBlockParser(primitiveBlock) * * // Iterate over groups * for (const group of parser.primitivegroup) { * if (group.dense) { * for (const node of parser.parseDenseNodes(group.dense)) { * console.log(node.id, node.lon, node.lat) * } * } * } * * // Or use the iterator interface * for (const entities of parser) { * console.log(entities.length, "entities in group") * } * ``` */ export declare class OsmPbfBlockParser implements OsmPbfBlock { stringtable: OsmPbfStringTable; primitivegroup: OsmPbfGroup[]; private parsedStringTable; date_granularity: number; granularity: number; lat_offset: number; lon_offset: number; parseOptions: ParseOptions; constructor(block: OsmPbfBlock, options?: ParseOptions); /** * Make this class iterable. Iterates over the primitive groups and yields their parsed entities. */ [Symbol.iterator](): Generator; /** * Convert PBF info to parsed format with resolved user string. * @param info - Raw PBF info object. * @returns Parsed info with timestamp in milliseconds and user string. */ fillInfo(info: OsmPbfInfo): OsmInfoParsed; private getString; /** * Resolve tag indices to key-value pairs. * @param keys - Array of string table indices for keys. * @param vals - Array of string table indices for values. * @returns Object mapping tag keys to values. */ getTags(keys: number[], vals: number[]): any; /** * Parse a standard (non-dense) node. * @param n - Raw PBF node structure. * @param options - Parsing options. * @returns Parsed node with coordinates in degrees. */ parseNode(n: OsmPbfNode, { parseTags, includeInfo }?: ParseOptions): OsmNode; /** * Parse a way with expanded node refs. * @param w - Raw PBF way structure with delta-encoded refs. * @param options - Parsing options. * @returns Parsed way with absolute node IDs. */ parseWay(w: OsmPbfWay, { parseTags, includeInfo }?: ParseOptions): OsmWay; /** * Parse a relation with expanded member refs. * @param r - Raw PBF relation structure with delta-encoded member IDs. * @param options - Parsing options. * @returns Parsed relation with typed members and roles. */ parseRelation(r: OsmPbfRelation, { parseTags, includeInfo }?: ParseOptions): OsmRelation; /** * Parse dense nodes into an array of node objects. * * Dense nodes use delta encoding for IDs, coordinates, and info fields. * Tags are stored as a flat array with 0-delimiters between nodes. * * @param dense - Dense nodes structure from the primitive group. * @param options - Parsing options. * @returns Array of parsed nodes with absolute coordinates. */ parseDenseNodes(dense: OsmPbfDenseNodes, { parseTags, includeInfo }?: ParseOptions): OsmNode[]; } //# sourceMappingURL=osm-pbf-block-parser.d.ts.map