From a2e030146dbb79085fa71eeb488b33b780f4fa70 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 10 Sep 2023 18:40:44 +0200 Subject: [PATCH] don't send location to map if we have no id at all --- owrx/hfdl/dumphfdl.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/owrx/hfdl/dumphfdl.py b/owrx/hfdl/dumphfdl.py index 2eb1d96f..204696b0 100644 --- a/owrx/hfdl/dumphfdl.py +++ b/owrx/hfdl/dumphfdl.py @@ -76,22 +76,27 @@ class HFDLMessageParser(AcarsProcessor): pos = hfnpdu["pos"] if abs(pos['lat']) <= 90 and abs(pos['lon']) <= 180: flight = self.processFlight(hfnpdu["flight_id"]) - msg = { - "lat": pos["lat"], - "lon": pos["lon"], - "flight": flight - } - if icao is None: + + if icao is not None: + source = IcaoSource(icao, flight=flight) + elif flight: source = HfdlSource(flight) else: - source = IcaoSource(icao, flight=flight) - if "utc_time" in hfnpdu: - ts = self.processTimestamp(**hfnpdu["utc_time"]) - elif "time" in hfnpdu: - ts = self.processTimestamp(**hfnpdu["time"]) - else: - ts = None - Map.getSharedInstance().updateLocation(source, HfdlAirplaneLocation(msg), "HFDL", timestamp=ts) + source = None + + if source: + msg = { + "lat": pos["lat"], + "lon": pos["lon"], + "flight": flight + } + if "utc_time" in hfnpdu: + ts = self.processTimestamp(**hfnpdu["utc_time"]) + elif "time" in hfnpdu: + ts = self.processTimestamp(**hfnpdu["time"]) + else: + ts = None + Map.getSharedInstance().updateLocation(source, HfdlAirplaneLocation(msg), "HFDL", timestamp=ts) def processTimestamp(self, hour, min, sec) -> datetime: now = datetime.now(timezone.utc)