Rttningar

This commit is contained in:
root
2026-05-03 06:39:58 +00:00
parent b5d65c4a52
commit 3a066ea589
3 changed files with 33 additions and 13 deletions

View File

@@ -28,6 +28,21 @@ from maidenhead import latlon_to_subsquare, subsquare_bounds
import re as _re
def _valid_position(lat, lon) -> bool:
"""Filter out corrupt or irrelevant positions."""
if lat is None or lon is None:
return False
if lat != lat or lon != lon: # NaN check
return False
if abs(lat) < 0.01 and abs(lon) < 0.01: # 0,0 = no GPS fix
return False
if lat < 54 or lat > 72: # outside Scandinavia
return False
if lon < 4 or lon > 32: # outside Scandinavia
return False
return True
def _extract_digis(path: str) -> str:
"""
Reduce a raw APRS path to the actual physical digipeaters that handled it.
@@ -187,6 +202,10 @@ async def ingest_rf(frame: RFFrameIn) -> None:
lat, lon, _ = _parse_position(tnc2)
# Nullify invalid positions so they are stored as NULL rather than corrupt data
if not _valid_position(lat, lon):
lat, lon = None, None
logger.info(
"RF %-6s %-9s [%s] lat=%s lon=%s",
"DIRECT" if frame.heard_direct else "VIA",