From e27d60ca495e92e2a7f429b2401aa607249aa596 Mon Sep 17 00:00:00 2001 From: "Matt Johnson (via Claude)" Date: Mon, 8 Jun 2026 07:09:47 +0000 Subject: [PATCH] nws: lowercase wind speed, strip trailing punctuation on locations, fix compass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix 1: wind.lower() so 60 MPH winds becomes 60 mph winds. Fix 2: rstrip trailing period/comma/space from locations text. Fix 3: bearing is direction storm moves TOWARD, not FROM — remove the +180 flip and use (deg+22.5)/45 for correct compass bucketing. Co-Authored-By: Claude Opus 4.6 --- meshai/central/nws_handler.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/meshai/central/nws_handler.py b/meshai/central/nws_handler.py index 8240ece..961ebf8 100644 --- a/meshai/central/nws_handler.py +++ b/meshai/central/nws_handler.py @@ -117,13 +117,12 @@ def _parse_motion(params: dict) -> tuple: m = re.search(r"(\d+)DEG\.+(\d+)KT", raw) if not m: return None, None - deg = int(m.group(1)) + deg = float(m.group(1)) knots = int(m.group(2)) mph = round(knots * 1.15) - # Convert bearing (direction storm is coming FROM) to heading (direction moving TOWARD) - heading = (deg + 180) % 360 + # Bearing is the direction the storm is moving TOWARD dirs = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"] - compass = dirs[round(heading / 45) % 8] + compass = dirs[int((deg + 22.5) / 45) % 8] return compass, mph @@ -340,7 +339,7 @@ def _render(*, event_type, area_desc, geocoder_city, county, state, wind = (params.get("maxWindGust") or [""])[0] hail = (params.get("maxHailSize") or [""])[0] bits = [] - if wind and wind not in ("0 MPH", ""): bits.append(f"{wind} winds") + if wind and wind not in ("0 MPH", ""): bits.append(f"{wind.lower()} winds") if hail and hail not in ("0.00", "0", ""): bits.append(f"{hail} in hail") hazard = ", ".join(bits) confirm = "Radar confirmed" if certainty == "Observed" else "Radar indicated" @@ -375,7 +374,7 @@ def _render(*, event_type, area_desc, geocoder_city, county, state, # Line 4: motion + locations compass, speed_mph = _parse_motion(params) motion = f"Moving {compass} {speed_mph} mph" if compass and speed_mph else "" - locations = desc.get("locations") or "" + locations = (desc.get("locations") or "").rstrip("., ") if len(locations) > 40: locations = locations[:37] + "..." if motion and locations: