survive)."""
args_preview = summarise_args(name, args, bundle)
result_preview = summarise_result(name, result) or "—"
args_json = json.dumps(args, indent=2, ensure_ascii=False)
result_json = json.dumps(result, indent=2, default=str, ensure_ascii=False)
if len(result_json) > 1200:
result_json = result_json[:1197] + "…"
e = html.escape
return (
f''
)
# --- route geometry --------------------------------------------------------
def route_with_coords(stops, station_by_id: dict) -> list:
"""Annotate route_planner stops with lat/lon + carry through line and
transfer flags so the JS can draw per-line segments and mark transfer
stations (matching the /simulator dashboard's drawRoute behavior)."""
out = []
for s in stops or []:
if not isinstance(s, dict):
continue
sid = s.get("station_id")
geo = station_by_id.get(sid, {}) if sid else {}
out.append({
"station_id": sid,
"name": s.get("station_name") or geo.get("name"),
"lat": geo.get("lat"),
"lon": geo.get("lon"),
"line": s.get("line"),
"is_transfer": bool(s.get("is_transfer")),
})
return out