Skip to main content

Module osm

Module osm 

Source
Expand description

OSM PBF reader with two-pass processing.

Max node ID (scan_max_node_id): sizes the node store, so a small regional extract does not allocate a 97 GB store. A PBF whose header declares Sort.Type_then_ID (Geofabrik extracts and the planet file) is answered from its last node blob, found by a binary search over blob headers; any other PBF gets a full parallel scan.

Pass 1 (pass1_nodes_and_relations): Single parallel scan that simultaneously collects every node coordinate into a dense NodeStore AND preprocesses boundary/route relations into a way→relation lookup. The node store is sized to fit the actual max node ID found during pre-scan.

Pass 2: Process ways and relations into InputFeatures. Ways are reconstructed from node coordinates in the store. The pipeline uses parallel blob processing (BlobReader::par_bridge) for maximum throughput.

Structs§

CollectedRelation
Relation info collected during preprocessing.
NodeCollectionStats
Result of pass 1: statistics about nodes collected.
Pass1Result
Result of pass 1: relation data collected alongside nodes.

Enums§

Relations
Whether pass 1 collects the boundary and route relations of each way.

Functions§

element_to_feature
Convert a single OSM element to an InputFeature, if applicable.
pass1_nodes_and_relations
Run pass 1: collect nodes AND preprocess relations in a single PBF read.
pass1_or_cached
Pass 1, or with use_cache the node store of an earlier run when its sidecar metadata still matches source_pbf (then only the relations are read again). A fresh pass 1 with use_cache writes that metadata, so the next run can skip the node scan: hours on a planet file.
preprocess_relations
Preprocess OSM relations to build a way→relation lookup table.
scan_max_node_id
Find the maximum node ID of a PBF file.
sorted_max_node_id
The largest node id of a PBF sorted by type then id, or None when the header does not declare that order.
tags_to_properties
Convert OSM tags to property map.