/** * JSON-to-PBF conversion utilities. * * Transforms typed OSM JSON entities back into spec-compliant PBF byte streams * with proper delta encoding, string tables, and block boundaries. * * @module */ import { type OsmPbfBlock, type OsmPbfHeaderBlock } from "@osmix/pbf"; import type { OsmEntity } from "@osmix/types"; import { OsmPbfBlockBuilder } from "./osm-pbf-block-builder.ts"; /** * Convert JSON entities to a PBF byte stream. * * Accepts a header and an async generator of entities (nodes, ways, relations) * and produces a complete PBF file as a ReadableStream. Entities should be * provided in sorted order: all nodes first, then ways, then relations. * * @param header - PBF header block with required/optional features. * @param entities - Async generator yielding OsmNode, OsmWay, OsmRelation. * @returns ReadableStream of PBF bytes. * * @example * ```ts * import { osmJsonToPbf } from "@osmix/json" * * const header = { * required_features: ["OsmSchema-V0.6", "DenseNodes"], * optional_features: [], * } * * const pbfStream = osmJsonToPbf(header, entitiesGenerator) * await Bun.write('./output.pbf', pbfStream) * ``` */ export declare function osmJsonToPbf(header: OsmPbfHeaderBlock, entities: AsyncGenerator): ReadableStream>; /** * Create a ReadableStream that yields header followed by entities. * * Wraps an async generator of entities with a header block, producing a * stream suitable for piping through `OsmJsonToBlocksTransformStream`. * * @param header - PBF header block to emit first. * @param entities - Async generator yielding OSM entities. * @returns ReadableStream yielding header then entities. */ export declare function createOsmJsonReadableStream(header: OsmPbfHeaderBlock, entities: AsyncGenerator): ReadableStream; /** * TransformStream that groups JSON entities into PBF primitive blocks. * * Accepts header and JSON entities, emitting PBF blocks with proper grouping: * - Starts new blocks when entity type changes (nodes → ways → relations) * - Respects maximum entities per block limit * - Uses dense node encoding for efficient node storage * * @example * ```ts * const blocksStream = entityStream.pipeThrough(new OsmJsonToBlocksTransformStream()) * ``` */ export declare class OsmJsonToBlocksTransformStream extends TransformStream { block: OsmPbfBlockBuilder; constructor(); } /** * Convert JSON entities to PBF blocks as an async generator. * * Groups entities into blocks with proper boundaries and delta encoding. * Entities should be provided sorted: nodes first, then ways, then relations. * * @param entities - Async generator yielding OsmNode, OsmWay, OsmRelation. * @yields PBF primitive blocks ready for serialization. * * @example * ```ts * import { jsonEntitiesToBlocks, osmBlockToPbfBlobBytes } from "@osmix/json" * * for await (const block of jsonEntitiesToBlocks(entities)) { * const bytes = await osmBlockToPbfBlobBytes(block) * // Write bytes to file... * } * ``` */ export declare function jsonEntitiesToBlocks(entities: AsyncGenerator): AsyncGenerator; //# sourceMappingURL=json-to-pbf.d.ts.map