mamut_routing_tools.td.bridge¶
The TD-bridge contract: in-memory types and their JSON serialization.
The bridge is the hand-off between the traffic generator (the producer,
:mod:mamut_routing_tools.td.traffic) and the family builder (the consumer,
:mod:mamut_routing_tools.family). Three record types carry it:
- :class:
BridgeGraph— deduplicated directed edges(osm_u, osm_v, length_m, class, free_speed_ms)keyed by OSM node ids (the free-flow limit uses the same 3-decimal rounding as the speed profiles) plus every incident vertex's WGS84 position; - :class:
BridgeSpeeds— per-edge hourly speed profiles (m/s), aligned withBridgeGraph.edges; - :class:
BridgeNodes— one stage-1 instance's nodes mapped to OSM node ids, depot first.
These records ARE the contract; the graph.json /
speeds-<model>-<intensity>.json / nodes-<instance_base>.json files are
just their serialized form. serialize_bridge_* and load_bridge_* are
exact inverses, so building the records in memory (the streamlined default) and
round-tripping them through disk (the cached / inspectable path) yield equal
records. The JSON is a git-ignored intermediate; every published byte is
canonicalized downstream by the Python builder.
BridgeFormatError
¶
Bases: ValueError
Raised when a TD bridge file violates the expected format.
serialize_bridge_graph
¶
The graph.json payload for a :class:BridgeGraph.
Vertices ship as [osm_id, lon, lat] sorted by OSM id (the consumer
reads them into a dict, so order is cosmetic but kept stable); edges ship as
[osm_u, osm_v, length_m, class, free_speed_ms] in BridgeGraph.edges
order (the speed profiles align with it).
Source code in MAMUT-routing-tools/src/mamut_routing_tools/td/bridge.py
serialize_bridge_speeds
¶
The speeds-<model>-<intensity>.json payload for a :class:BridgeSpeeds.
Source code in MAMUT-routing-tools/src/mamut_routing_tools/td/bridge.py
serialize_bridge_nodes
¶
The nodes-<instance_base>.json payload for a :class:BridgeNodes.