Rttningar
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user