- Preview
- A four-way intersection with one missing queue measurement.
- Inputs
- Intersection name, optional phase, plan and observation labels. Supply at most one approach per compass direction (north, east, south, west). Each approach has a label, signal (stop, caution, go or unknown), queuedVehicles as a non-negative integer or null, and optionally averageDelaySeconds.
- Source options
- Map measured counts and current signal indications from the traffic feed. Compute average delay upstream for a consistent window. Refresh the snapshot as telemetry arrives.
- Actions
- Select an approach on the plan with touch, click, Enter or Space to see its reported signal, queue and delay.
- Integration requirements
- The plan is a schematic. Missing counts or delays display a dash, and omitted directions are disabled. Use zero only for an observed zero.
{
"name": "Harbor Road × Juniper Avenue",
"phase": "East–west through",
"observedAtLabel": "14:08",
"approaches": [
{
"direction": "north",
"label": "Harbor Road north",
"signal": "stop",
"queuedVehicles": 7,
"averageDelaySeconds": 31
}
]
}
import type { ApproachDirection, IntersectionSignal, IntersectionSnapshot } from "@lumo/widgets/catalog/smart-city/intersection";
type FeedRow = { direction: ApproachDirection; road: string; light: "red" | "amber" | "green" | null; count: number | null; delayMs?: number };
const indications = { red: "stop", amber: "caution", green: "go" } satisfies Record<string, IntersectionSignal>;
export function toIntersectionSnapshot(name: string, rows: readonly FeedRow[]): IntersectionSnapshot {
return { name, approaches: rows.map(row => ({
direction: row.direction, label: row.road, signal: row.light ? indications[row.light] : "unknown",
queuedVehicles: row.count, averageDelaySeconds: row.delayMs === undefined ? null : row.delayMs / 1000,
})) };
}