/** * GeoJSON-to-OSM conversion utilities. * * Imports GeoJSON FeatureCollections into Osm indexes, mapping geometry * types to appropriate OSM entity structures. * * @module */ import { Osm, type OsmOptions, type OsmWriter } from "@osmix/core"; import { type ProgressEvent } from "@osmix/shared/progress"; import type { FeatureCollection, LineString, MultiPolygon, Point, Polygon } from "geojson"; import type { ReadOsmDataTypes } from "./types.ts"; /** * Create an Osm index from GeoJSON data. * * Accepts various input formats (string, stream, buffer, or parsed object) * and converts features to OSM entities: * - Point → Node * - LineString → Way with nodes * - Polygon → Way (simple) or Relation (with holes) * - MultiPolygon → Relation * * Feature IDs are preserved if numeric; otherwise sequential negative IDs are assigned. * Feature properties become OSM tags. * * @param data - GeoJSON data in any supported format. * @param options - Osm index options (id, header). * @param onProgress - Progress callback for UI feedback. * @returns Populated Osm index with built indexes. * * @example * ```ts * import { fromGeoJSON } from "@osmix/geojson" * * // From file * const geojson = await Bun.file('./roads.geojson').json() * const osm = await fromGeoJSON(geojson, { id: "roads" }) * * // Query the imported data * const highways = osm.ways.search("highway") * ``` */ export declare function fromGeoJSON(data: ReadOsmDataTypes, options?: Partial, onProgress?: (progress: ProgressEvent) => void): Promise; /** * Generator that converts GeoJSON features to OSM entities. * * This is the core conversion logic, yielding progress events as features * are processed. Called by `fromGeoJSON` with progress handling. * * Geometry mapping: * - **Point**: Creates a single node with feature properties as tags. * - **LineString**: Creates nodes for each coordinate, then a way referencing them. * - **Polygon**: Creates a way for simple polygons; for polygons with holes, * creates separate ways for outer and inner rings plus a multipolygon relation. * - **MultiPolygon**: Creates a multipolygon relation with all rings as way members. * * Coordinates are normalized using `rewind` to ensure correct winding order * (outer rings counterclockwise, inner rings clockwise per OSM conventions). * * @param osm - Target Osm index to populate. * @param geojson - Parsed GeoJSON FeatureCollection. * @yields Progress events during conversion. */ export declare function startCreateOsmFromGeoJSON(osm: OsmWriter, geojson: FeatureCollection): Generator; //# sourceMappingURL=osm-from-geojson.d.ts.map