central/sql/migrations/028_add_tomtom_incidents_adapter.sql

17 lines
926 B
MySQL
Raw Normal View History

feat(tomtom_incidents): TomTom real-time traffic incidents adapter (v0.9.5) Fourth CENTRAL_TRAFFIC event adapter. Complements wzdx (federal work zones) and state_511_atis (state-DOT reports) with TomTom commercial vehicle-telematics coverage. Polls the Orbis incidentDetails endpoint per metro bbox, emits one event per incident to central.traffic.incident.<state>. Ships disabled. central-supervisor + central-gui restart only -- adapter row on the EXISTING CENTRAL_TRAFFIC stream, so NO archive restart and no new stream/dependency. Reuses the existing "tomtom" api key. - Bbox limit refutation: incidentDetails rejects bbox > 10,000 km^2, so coverage is per-metro bboxes (Treasure Valley / Boise, 8,601 km^2), NOT statewide. One bbox @ 1800s = 1,440 calls/mo = 58% of the 2,500/mo free-tier cap. Expansion rows must respect N*(43200/cadence_min) <= 2500. - category="incident.tomtom_incidents" -> GUI event_type "incident" (shared with state_511_atis; cross-source overlap is by design = additive coverage, distinct dedup ids + categories, no Central-side cross-source dedup). - Severity from magnitudeOfDelay (0->1,1->1,2->2,3->3,4->4; 4=closure). Never None. - geo.geometry carries TomTom's Point/LineString directly (already lon/lat GeoJSON; the v0.9.3 framework renders the affected road as a polyline). No decode needed. - Dedup id <state_code>:tomtom:<tomtom_id> (upstream id stable across polls, verified 154/154 over 60s). Inherits the v0.9.1 dedup mixin. - aiohttp params= URL-encodes the fields{} GraphQL braces (no curl-glob issue); key redacted from logs; poll skips cleanly without a key. Full suite: 809 passed, 1 skipped (central and unprivileged zvx, 3x each). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 00:25:27 +00:00
-- Migration: 028_add_tomtom_incidents_adapter
-- Adds the tomtom_incidents adapter onto the EXISTING CENTRAL_TRAFFIC stream
-- (central.traffic.incident.<state>). No new stream -> no central-archive restart.
-- Reuses the existing "tomtom" api key. Ships disabled; operator enables via GUI.
-- NOTE: TomTom incidentDetails rejects any bbox > 10,000 km^2, so coverage is
-- per-metro bboxes (Treasure Valley here), NOT statewide. Expansion = more bbox
-- rows, but mind the 2,500/mo free-tier cap: N_bboxes * (43200/cadence_min) <= 2500.
-- Additive-only: idempotent via ON CONFLICT DO NOTHING.
INSERT INTO config.adapters (name, enabled, cadence_s, settings)
VALUES (
'tomtom_incidents',
false,
1800,
'{"api_key_alias": "tomtom", "bboxes": [{"name": "treasure_valley", "min_lon": -116.85, "min_lat": 43.30, "max_lon": -115.65, "max_lat": 44.10, "state_code": "ID"}]}'::jsonb
)
ON CONFLICT (name) DO NOTHING;