mamut_routing_lib.geo¶
Geo sidecar of a collection base instance (format mamut-geo v3).
One geo sidecar per base instance (<base>.geo.json[.gz]), shared by every
problem-type variant of the base. It carries everything the site/workbench
needs to draw the instance on a map: per-node geodetic + local ENU positions,
the geodetic reference frame, and (for n <= 100) a complete road-path cache
over all ordered node pairs for the fastest and shortest metrics in an
indexed encoding: one geo-local vertex_lonlat table (the union of all
path vertices) plus per-metric maps from "i-j" arc keys to lists of
indices into that table. Measured at n=100 this is ~5x smaller gzipped than
repeating coordinate polylines per pair. The sidecar is static: it never
changes when BKS routes change (v3 retires the on-demand road_cache
growth of the v1/v2 meta.json).
Purely informative for solvers: the checker never reads it. Hashed over its
uncompressed canonical JSON bytes like every other sidecar, gzip mtime=0.
GeoFormatError
¶
Bases: ValueError
Raised when a geo sidecar violates the canonical format.
GeoNode
dataclass
¶
GeoNode(instance_node_id: int, poi_lon: float, poi_lat: float, enu_x: float, enu_y: float, demand: int, source_tag: str, graph_vertex_id: int | None = None)
One instance node on the map (depot included, instance_node_id 0-based).
GeoRoadCache
dataclass
¶
GeoRoadCache(vertex_lonlat: list[tuple[float, float]], paths: dict[str, dict[str, list[int]]] = dict())
Indexed road-path cache: paths as index lists over a local vertex table.
paths[metric]["i-j"] is the vertex-index polyline of the cached road
path from instance node i to instance node j (ordered pair,
indices into vertex_lonlat, at least two points). A complete cache
covers all ordered pairs of the instance for every metric it carries;
completeness is a family policy (Poryos2026: n <= 100 only), not a format
invariant.
paths
class-attribute
instance-attribute
¶
path_lonlat
¶
Decode one cached path back to a lon/lat polyline.
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/geo.py
InstanceGeo
dataclass
¶
InstanceGeo(base_name: str, benchmark_name: str, city: str, method: str, source_osm_file: str, reference_lla: dict[str, float], map_options: dict[str, Any], nodes: list[GeoNode], road_cache: GeoRoadCache | None = None, generator: dict[str, Any] = dict(), format_version: int = GEO_FORMAT_VERSION)
In-memory content of a geo sidecar.
generator
class-attribute
instance-attribute
¶
geo_to_canonical_json_bytes
¶
Serialize to the canonical JSON bytes (the input of the geo sha256).
Fixed key order, one node / one cache vertex / one cached path per line,
floats via Python's shortest round-trip repr, gzip-independent. Path maps
are ordered by (i, j).
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/geo.py
compute_geo_sha256
¶
save_instance_geo
¶
Write the sidecar; gzip iff the path ends with .geo.json.gz (mtime=0).