mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-06-11 01:14:45 +02:00
fix(wfigs): add IncidentSize to acres keys and curated town_anchors lookup
Acres: prepend IncidentSize to _WFIGS_ACRES_RAW_KEYS so the normalizer picks up the primary size field before falling back to DiscoveryAcres and FinalAcres. Location anchor: query the curated town_anchors table before falling back to the Photon geocoder nearest_town call, giving consistent anchor names for Idaho fires. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ebb34b75ef
commit
b09a5843ce
2 changed files with 25 additions and 1 deletions
|
|
@ -401,6 +401,30 @@ def _location_anchor(n: dict) -> str:
|
|||
lat = n.get("lat")
|
||||
lon = n.get("lon")
|
||||
if isinstance(lat, (int, float)) and isinstance(lon, (int, float)):
|
||||
# Try curated town_anchors first
|
||||
try:
|
||||
from meshai.persistence import get_db
|
||||
from meshai.central_normalizer import _haversine_miles as _haversine_mi
|
||||
from meshai.central_normalizer import _bearing_compass
|
||||
rows = get_db().execute(
|
||||
"SELECT name, lat, lon FROM town_anchors WHERE lat IS NOT NULL AND lon IS NOT NULL"
|
||||
).fetchall()
|
||||
best = None
|
||||
best_d = float("inf")
|
||||
for row in rows:
|
||||
d = _haversine_mi(lat, lon, row["lat"], row["lon"])
|
||||
if d < best_d:
|
||||
best_d = d
|
||||
best = row
|
||||
if best and best_d <= float(adapter_config.wfigs.anchor_max_mi):
|
||||
bearing = _bearing_compass(lat, lon, best["lat"], best["lon"])
|
||||
d_int = int(round(best_d))
|
||||
if d_int < 1:
|
||||
return f"near {best['name']}"
|
||||
return f"{d_int} mi {bearing} of {best['name']}"
|
||||
except Exception:
|
||||
logger.exception("town_anchors lookup failed; falling back to Photon")
|
||||
|
||||
try:
|
||||
from meshai.central_normalizer import nearest_town
|
||||
nt = nearest_town(lat, lon, max_distance_mi=float(adapter_config.wfigs.anchor_max_mi))
|
||||
|
|
|
|||
|
|
@ -618,7 +618,7 @@ def _parse_wzdx_federal(inner_data: dict, geo: dict) -> dict:
|
|||
# them through verbatim per Matt's call -- they at least signal "new fire
|
||||
# in <county>" even without an interesting name.
|
||||
_WFIGS_ACRES_KEYS = ("DailyAcres", "IncidentSize")
|
||||
_WFIGS_ACRES_RAW_KEYS = ("DiscoveryAcres", "FinalAcres")
|
||||
_WFIGS_ACRES_RAW_KEYS = ("IncidentSize", "DiscoveryAcres", "FinalAcres")
|
||||
_WFIGS_CONTAINED_KEYS = ("PercentContained",)
|
||||
_WFIGS_CONTAINED_RAW_KEYS = ("PercentContained",)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue