feat: toggleable live map feeds (ADS-B, trains, AIS, radar, WFIGS, NWS)

Wire the free data streams from docs/free-data-streams.md into the
dashboard as layer-panel toggles. Third-party APIs are proxied/cached
in FastAPI; raster tiles (IEM, RainViewer, GIBS) stay in the browser.

- Aircraft via ADSB.lol viewport poll (bbox required, radius ≤ 150 nm)
- Amtraker trains, NHC storms, WFIGS incidents/perimeters
- NWS + IEM SBW as /api/weather-alerts (does not collide with /api/alerts)
- AISStream worker is server-side only and idles without AISSTREAM_API_KEY
- Caltrans CWWP2 D1–D12 camera parser; FIRMS dual-write NOAA-20/21
This commit is contained in:
Sirius DevOps 2026-08-27 19:08:30 -04:00
commit f779b1f225
15 changed files with 1662 additions and 39 deletions

View file

@ -326,6 +326,59 @@ def parse_alertwest_json(text: str, source_name: str) -> list[dict]:
return out
def parse_caltrans_json(text: str, source_name: str) -> list[dict]:
"""Parse Caltrans CWWP2 cctvStatus JSON (districts 1–12, same schema).
Skip cameras that are not in service. Store the JPEG still as snapshot_url
(map thumbs) and the HLS playlist as source_url when present. Never RTSP.
"""
try:
payload = json.loads(text)
except (json.JSONDecodeError, ValueError):
return []
rows = payload.get("data") if isinstance(payload, dict) else None
if not isinstance(rows, list):
return []
out: list[dict] = []
for row in rows:
cctv = (row or {}).get("cctv") or row or {}
loc = cctv.get("location") or {}
in_service = str(cctv.get("inService") or "").strip().lower()
if in_service not in ("true", "1", "yes"):
continue
img = ((cctv.get("imageData") or {}).get("static") or {})
jpeg = (img.get("currentImageURL") or img.get("currentImageUrl") or "").strip()
hls = str((cctv.get("imageData") or {}).get("streamingVideoURL") or "").strip()
if hls.lower().startswith("rtsp://") or jpeg.lower().startswith("rtsp://"):
continue
if not jpeg and not hls:
continue
try:
lat = float(loc["latitude"]) if loc.get("latitude") not in (None, "") else None
lon = float(loc["longitude"]) if loc.get("longitude") not in (None, "") else None
except (TypeError, ValueError):
lat = lon = None
bits = [
loc.get("locationName"),
loc.get("route") and f"SR-{loc.get('route')}",
loc.get("nearbyPlace") or loc.get("county"),
]
name = ", ".join(str(b) for b in bits if b)
ident = hls or jpeg
dtype = "hls" if hls else "http"
out.append({
"source_url": ident,
"snapshot_url": jpeg or hls,
"discovery_source": "caltrans",
"location_lat": lat,
"location_lon": lon,
"location_name": name or None,
"vendor": "Caltrans",
"device_type": dtype,
})
return out
def parse_live_streams_geojson(text: str, source_name: str) -> list[dict]:
"""Parse willytop8/Live-Environment-Streams GeoJSON.
@ -435,7 +488,9 @@ async def scrape_source(client: RateLimitedClient, geo: Geocoder,
name = urlparse(src_url).netloc
ctype = resp.headers.get("content-type", "")
body = resp.text
if ("getCameraDataByLoc" in src_url
if "cwwp2.dot.ca.gov" in src_url or "cctvStatus" in src_url:
cams = parse_caltrans_json(body, name)
elif ("getCameraDataByLoc" in src_url
or ("json" in ctype and '"locs"' in body[:4000] and '"cams"' in body[:8000])):
cams = parse_alertwest_json(body, name)
elif (src_url.endswith(".geojson") or src_url.endswith("/streams.geojson")