perf: faster map overlay load #4

Merged
sirius merged 7 commits from perf/map-layer-load into master 2026-08-27 21:24:24 -04:00
Owner

Summary

Map layers hitch on first load and every pan because the default world view fetched cameras, NWS/SBW polygons, and WFIGS perimeters all at once, then tore them down and rebuilt them. This PR makes overlay load and pan/zoom cheap without changing API contracts.

What changed

  • Zoom-gate cameras / NWS-SBW / WFIGS perimeters+incidents at zoom ≤ 4 (aircraft/vessels still skip at ≤ 3). World view shows zoom in the count chip instead of fetching thousands of pins and national polygons.
  • Boot path: default basemap is static Blue Marble (no GIBS time-domain wait). News/summary/events load with their views. hls.min.js loads only on the first HLS camera popup.
  • Cache: 0.25° quantized bbox keys; per-key TTL locks so a slow NWS/WFIGS fetch no longer serializes trains/aircraft/radar.
  • IEM SBW fetched once (45s TTL) and clipped to the viewport; alert properties slimmed to popup fields.
  • WFIGS requests simplified geometry (maxAllowableOffset ~250 m, geometryPrecision=5, 500 records).
  • Slim payloads: GET /api/fires?format=heat{lat,lon,i,c}; camera list drops URLs (detail via GET /api/cameras/{id}); news omits content unless include_content=true; event blips skip body.
  • Shared httpx client, gzip, short Cache-Control on overlay GETs. Lifespan replaces deprecated on_event.
  • Frontend: AbortController on moveend, skip rebuild when the 0.01° cell is unchanged, in-place marker updates by id, canvas renderer for polygons, lazy camera popup HTML.

Contracts kept

  • GET /api/fires still returns full FireOut unless format=heat.
  • Aircraft still 422 without bbox.
  • /api/map/layers still {layers, overlays}.
  • No rtsp:// hrefs. AIS key stays server-side.

Tests

.venv-test/bin/python -m pytest tests/test_live_layers.py tests/test_api_live_layers.py tests/test_map_payloads.py tests/test_fire_sources.py -q29 passed.

How to verify

  1. Open the map at default zoom 2: network tab has no /api/cameras, /api/weather-alerts, /api/fire-perimeters.
  2. Zoom to 5 over CONUS: those layers appear; page stays interactive.
  3. Pan slightly: overlay GETs are cache hits or aborted, not a full cluster teardown.
  4. Open an HLS camera: hls.min.js downloads then, not on boot.
## Summary Map layers hitch on first load and every pan because the default world view fetched cameras, NWS/SBW polygons, and WFIGS perimeters all at once, then tore them down and rebuilt them. This PR makes overlay load and pan/zoom cheap without changing API contracts. ## What changed - **Zoom-gate** cameras / NWS-SBW / WFIGS perimeters+incidents at zoom ≤ 4 (aircraft/vessels still skip at ≤ 3). World view shows `zoom` in the count chip instead of fetching thousands of pins and national polygons. - **Boot path:** default basemap is static Blue Marble (no GIBS time-domain wait). News/summary/events load with their views. `hls.min.js` loads only on the first HLS camera popup. - **Cache:** 0.25° quantized bbox keys; per-key TTL locks so a slow NWS/WFIGS fetch no longer serializes trains/aircraft/radar. - **IEM SBW** fetched once (45s TTL) and clipped to the viewport; alert properties slimmed to popup fields. - **WFIGS** requests simplified geometry (`maxAllowableOffset` ~250 m, `geometryPrecision=5`, 500 records). - **Slim payloads:** `GET /api/fires?format=heat` → `{lat,lon,i,c}`; camera list drops URLs (detail via `GET /api/cameras/{id}`); news omits `content` unless `include_content=true`; event blips skip `body`. - Shared httpx client, gzip, short `Cache-Control` on overlay GETs. Lifespan replaces deprecated `on_event`. - Frontend: AbortController on `moveend`, skip rebuild when the 0.01° cell is unchanged, in-place marker updates by id, canvas renderer for polygons, lazy camera popup HTML. ## Contracts kept - `GET /api/fires` still returns full `FireOut` unless `format=heat`. - Aircraft still **422** without bbox. - `/api/map/layers` still `{layers, overlays}`. - No `rtsp://` hrefs. AIS key stays server-side. ## Tests `.venv-test/bin/python -m pytest tests/test_live_layers.py tests/test_api_live_layers.py tests/test_map_payloads.py tests/test_fire_sources.py -q` → **29 passed**. ## How to verify 1. Open the map at default zoom 2: network tab has **no** `/api/cameras`, `/api/weather-alerts`, `/api/fire-perimeters`. 2. Zoom to 5 over CONUS: those layers appear; page stays interactive. 3. Pan slightly: overlay GETs are cache hits or aborted, not a full cluster teardown. 4. Open an HLS camera: `hls.min.js` downloads then, not on boot.
sirius added 7 commits 2026-08-27 21:23:28 -04:00
World view no longer fetches cameras/NWS/WFIGS. Default Blue Marble so init
does not wait on GIBS times. News/summary/events load with their views.
hls.min.js loads only on the first HLS camera popup.
Nearby pans share a 0.25° cache cell. Slow NWS/WFIGS factories no longer
hold a process-wide lock that stalls trains/aircraft/radar fills.
National storm-based warnings are fetched once (45s TTL) and clipped to
the quantized bbox. Popup fields only — NWS descriptions stay off the wire.
Ask ArcGIS for 500 features, 5-decimal precision, and ~250m offset so
fire rings are outlines instead of tens of thousands of vertices.
Heatmap uses {lat,lon,i,c}. Camera list drops URLs (detail via GET
/api/cameras/{id}). Event blips skip body. News omits content unless
include_content=true.
Reuse one TLS pool for overlay upstreams (8s/3s timeouts). Gzip JSON
over 1 KB. Aircraft/vessels Cache-Control max-age=5, alerts/perimeters 30.
Lifespan replaces deprecated on_event startup.
moveend aborts in-flight overlay JSON and skips work when the 0.01° cell
is unchanged. Live aircraft/trains/vessels diff-update by id. Camera popup
HTML is built on open. Alert/perimeter polygons paint on canvas.
sirius merged commit 61feeb6c5a into master 2026-08-27 21:24:24 -04:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: sirius/osint-dashboard#4
No description provided.