feat(geofence): hear quakes, WFIGS incidents, and news pins #61
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_02dd06a8"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
An active polygon now gets a
geofence_alertsrow when an earthquake, a WFIGS fire incident, or a news map pin falls inside it. A point outside writes nothing.source_kind=camerais never passed torecord_and_notify.Existing adsb/ais/firms callers are unchanged and may omit
evidence. The new kinds always include this object. Frozen — the frontend inbox card reads these keys and no others:Caps: at most 5 cameras (nearest the hit, inside the fence), at most 3 news items (most recent inside the fence). Empty arrays if none.
snapshot_urlis the proxy path only — the camera SQL does not selectcameras.snapshot_url, so an agency URL orrtsp://cannot leak.snapshotis a path+query (ts=), not a fetched body.GET /api/geofences/{gid}/atacceptstsas an alias oftimestamp.Hooks (premise corrections)
ingest_eventafter a new insert (source_type=earthquake, lat/lon required). Entity id israw.usgs_id, else url, else the event id. A catch-up scan ofevents(last 7 days, cap 200) runs on the ingester loop so a fence drawn after the quake was stored still hears it.run_ingester.geofence_feed_loop(sibling ofproducer_loop/fire_loop, same process,INGEST_INTERVAL, default 300s). Usesload_fire_incidents— nofire_last_knownmutation, no aircraft correlate, no FIRMS/AIS key. Entity id is IrwinID, else UniqueFireIdentifier, elsename|state|discovered. Markeridstays the incident name.news_itemson that same loop. Does not import the summarizer. Pins matchGET /api/news/map(kind=map, critical/high, lat/lon, last 24h). Entity id isnews_items.id.(fence_id, entity_id). Polled kinds also passskip_existing, so a later poll of the same incident id does not insert again (in-process set, plus ageofence_alertslookup after restart). Fail closed on that lookup so a broken read cannot page every fence.upsert_cameras,publish_new_cameras, andingest_event(source_type=camera)do not callrecord_and_notify.record_and_notifyrefusessource_kind=camera.GET /api/geofence-alerts?source_kind=now acceptsearthquake|fire_incident|newsand still 422scamera.No Telegram, webhook, or other delivery channel. No live fence created. No deploy.
Test plan
PYTHONPATH=app pytest tests/test_geofence.py -q→ 27 passedpayload.evidencematching the keys above; outside point → 0 rows, for earthquake, fire_incident, and newsrecord_and_notifydocker login 127.0.0.1:3000is not this change