Storm-based polygon matching for NWS warnings #71

Closed
opened 2026-07-18 05:31:33 +00:00 by claude-bot · 1 comment
Contributor

NWS warnings carry polygon geometry; WeatherBot matches on zones (affectedZones), which over-alert relative to the actual warned polygon — a hilltop location gets the county's flash-flood warning. The point-in-polygon machinery already exists in spc.py. Use alert geometry when present (fall back to zones), per-location opt-in. Probably missed because zone matching was the natural MVP and SPC polygon code came later. Effort M, value High — directly reduces false alarms, the main quality lever for an alerting tool.


Filed from the 2026-07-17 codebase audit (docs/.internal/report-2026-07-17.md), finding I-01.

NWS warnings carry polygon geometry; WeatherBot matches on zones (`affectedZones`), which over-alert relative to the actual warned polygon — a hilltop location gets the county's flash-flood warning. The point-in-polygon machinery already exists in `spc.py`. Use alert geometry when present (fall back to zones), per-location opt-in. Probably missed because zone matching was the natural MVP and SPC polygon code came later. Effort M, value High — directly reduces false alarms, the main quality lever for an alerting tool. --- _Filed from the 2026-07-17 codebase audit (`docs/.internal/report-2026-07-17.md`), finding I-01._
Author
Contributor

Closing as already implemented. The polygon-matching this issue asks for already exists and is active in the alert path — the audit pointed at the SPC point_in_geometry helper and missed that the NWS-alert path has its own equivalent.

In app/services/alert_identity.py:

  • point_in_alert_geometry(location, alert) (lines 53-61) does point-in-polygon against the alert's Polygon/MultiPolygon geometry, returning True when the alert carries no polygon.
  • location_matches_alert(location, alert) (lines 64-69) requires a zone/county-zone intersection and point_in_alert_geometry — i.e. it already "uses the alert geometry when present, falls back to zones" when NWS supplies no polygon. NWSAlert.geometry is parsed in nws.py (~line 340), and the CAP ATOM fallback path sets empty geometry so it degrades to zone-only.

So a location inside a warned zone but outside the storm-based warning polygon is already not alerted — the exact over-alarm this issue describes is already avoided. The one thing not built is making it a per-location toggle, but since polygon precision is the correct default for storm-based warnings (the polygon is the threat area) and mandatory precision matches current behavior, we've decided (2026-07-19) not to add an opt-out toggle for now. If a "never-miss / alert me for my whole county" mode is wanted later, it can be filed fresh with that framing.

No milestone impact beyond removing this from v1.5.0 scope.

Closing as **already implemented**. The polygon-matching this issue asks for already exists and is active in the alert path — the audit pointed at the SPC `point_in_geometry` helper and missed that the NWS-alert path has its own equivalent. In `app/services/alert_identity.py`: - `point_in_alert_geometry(location, alert)` (lines 53-61) does point-in-polygon against the alert's `Polygon`/`MultiPolygon` geometry, returning `True` when the alert carries no polygon. - `location_matches_alert(location, alert)` (lines 64-69) requires a zone/county-zone intersection **and** `point_in_alert_geometry` — i.e. it already "uses the alert geometry when present, falls back to zones" when NWS supplies no polygon. `NWSAlert.geometry` is parsed in `nws.py` (~line 340), and the CAP ATOM fallback path sets empty geometry so it degrades to zone-only. So a location inside a warned zone but outside the storm-based warning polygon is already **not** alerted — the exact over-alarm this issue describes is already avoided. The one thing not built is making it a per-location toggle, but since polygon precision is the correct default for storm-based warnings (the polygon *is* the threat area) and mandatory precision matches current behavior, we've decided (2026-07-19) not to add an opt-out toggle for now. If a "never-miss / alert me for my whole county" mode is wanted later, it can be filed fresh with that framing. No milestone impact beyond removing this from v1.5.0 scope.
Sign in to join this conversation.
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
rbrooks/WeatherBot#71
No description provided.