/** * PBF block builder utilities. * * Constructs spec-compliant OSM PBF primitive blocks from JSON entities, * handling delta encoding, string table management, and block size limits. * * @module */ import { type OsmPbfBlock, type OsmPbfBlockSettings, type OsmPbfGroup, type OsmPbfInfo, type OsmPbfStringTable } from "@osmix/pbf"; import type { OsmInfoParsed, OsmNode, OsmRelation, OsmTags, OsmWay } from "@osmix/types"; /** * Build PBF primitive blocks from JSON entities. * * Accumulates nodes, ways, and relations into a single primitive block, * handling all PBF-specific encoding: * - **String table**: Deduplicates tag keys/values and role strings. * - **Delta encoding**: Encodes IDs, coordinates, and member refs as deltas. * - **Dense nodes**: Uses compact dense node format for efficient storage. * - **Granularity**: Converts floating-point coords to integer nanodegrees. * * @example * ```ts * import { OsmPbfBlockBuilder } from "@osmix/json" * * const builder = new OsmPbfBlockBuilder() * * builder.addDenseNode({ id: 1, lon: -122.4, lat: 47.6, tags: { name: "Seattle" } }) * builder.addWay({ id: 10, refs: [1, 2, 3], tags: { highway: "primary" } }) * * if (builder.isFull()) { * const block = builder // OsmPbfBlock interface * // Serialize with osmBlockToPbfBlobBytes(block) * } * ``` */ export declare class OsmPbfBlockBuilder implements OsmPbfBlock { stringtable: OsmPbfStringTable; private stringToIndex; private encoder; primitivegroup: OsmPbfGroup[]; readonly group: OsmPbfGroup; date_granularity: number; granularity: number; lat_offset: number; lon_offset: number; private includeInfo; private maxEntitiesPerBlock; constructor(blockSettings?: OsmPbfBlockSettings & { includeInfo?: boolean; maxEntitiesPerBlock?: number; }); /** * Get the total number of entities in this block. */ totalEntities(): number; /** * Check if the block has no entities. */ isEmpty(): boolean; /** * Check if the block has reached the maximum entity limit. */ isFull(): boolean; /** * Get or create a string table index for the given string. * @param key - String to add to the table. * @returns Index of the string in the table. */ getStringtableIndex(key: string): number; /** * Convert a millisecond timestamp to integer PBF timestamp units. * Remainder milliseconds are intentionally lost at the configured granularity. */ private toPbfTimestamp; /** * Convert tags to string table indices. * @param tags - Tag key-value pairs. * @returns Object with `keys` and `vals` arrays of indices. */ addTags(tags: OsmTags): { keys: number[]; vals: number[]; }; /** * Convert parsed info to PBF info format. * @param info - Parsed entity metadata. * @returns PBF-encoded info object. */ addInfo(info: OsmInfoParsed): OsmPbfInfo; /** * Add a node using the standard (non-dense) format. * @param node - Node to add with id, lon, lat, and optional tags. */ addNode(node: OsmNode): void; /** * Add a way to the block. * @param way - Way with id, refs (node IDs), and optional tags. */ addWay(way: OsmWay): void; /** * Add a relation to the block. * @param relation - Relation with id, members, and optional tags. */ addRelation(relation: OsmRelation): void; private delta; private initializeDenseNodes; /** * Add a node using the dense node format. * * Dense nodes are more space-efficient than standard nodes, using delta * encoding for IDs and coordinates. Preferred for large node sets. * * @param node - Node with id, lon, lat, and optional tags/info. */ addDenseNode(node: OsmNode): void; } //# sourceMappingURL=osm-pbf-block-builder.d.ts.map