From da53c5907af32d5b5a4cbc40737d5ee291d39d1a Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Tue, 5 Sep 2023 23:25:32 +0200 Subject: [PATCH] let's get some locations up on the map --- csdr/chain/dumphfdl.py | 5 ++--- htdocs/map.js | 5 +++-- owrx/hfdl/dumphfdl.py | 32 ++++++++++++++++++++++++++++++++ owrx/map.py | 2 ++ 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/csdr/chain/dumphfdl.py b/csdr/chain/dumphfdl.py index 8c7b08f7..f6a29c43 100644 --- a/csdr/chain/dumphfdl.py +++ b/csdr/chain/dumphfdl.py @@ -1,13 +1,12 @@ from csdr.chain.demodulator import ServiceDemodulator -from owrx.hfdl.dumphfdl import DumpHFDLModule -from csdr.module import JsonParser +from owrx.hfdl.dumphfdl import DumpHFDLModule, HFDLMessageParser class DumpHFDL(ServiceDemodulator): def __init__(self): super().__init__([ DumpHFDLModule(), - JsonParser("HFDL"), + HFDLMessageParser(), ]) def getFixedAudioRate(self) -> int: diff --git a/htdocs/map.js b/htdocs/map.js index 7f9c2776..1c75e2da 100644 --- a/htdocs/map.js +++ b/htdocs/map.js @@ -129,7 +129,7 @@ $(function(){ aprsOptions.symbol = update.location.symbol; aprsOptions.course = update.location.course; aprsOptions.speed = update.location.speed; - } else if (update.source.icao) { + } else if (update.source.icao || update.source.flight) { markerClass = PlaneMarker; aprsOptions = update.location; } @@ -382,6 +382,7 @@ $(function(){ if ('item' in source) return source['item']; if ('object' in source) return source['object']; if ('icao' in source) return source['icao']; + if ('flight' in source) return source['flight']; var key = source.callsign; if ('ssid' in source) key += '-' + source.ssid; return key; @@ -406,7 +407,7 @@ $(function(){ }; var linkifyAircraft = function(source, identification) { - var aircraftString = identification || source.icao; + var aircraftString = identification || source.icao || source.flight; var link = false; switch (aircraft_tracking_service) { case 'flightaware': diff --git a/owrx/hfdl/dumphfdl.py b/owrx/hfdl/dumphfdl.py index 406dd845..22d6f971 100644 --- a/owrx/hfdl/dumphfdl.py +++ b/owrx/hfdl/dumphfdl.py @@ -1,5 +1,17 @@ from pycsdr.modules import ExecModule from pycsdr.types import Format +from csdr.module import JsonParser +from owrx.adsb.modes import AirplaneLocation +from owrx.map import Map +from datetime import timedelta + + +class HfdlAirplaneLocation(AirplaneLocation): + def __init__(self, message): + super().__init__(None, message) + + def getTTL(self) -> timedelta: + return timedelta(minutes=60) class DumpHFDLModule(ExecModule): @@ -16,3 +28,23 @@ class DumpHFDLModule(ExecModule): "0", ] ) + + +class HFDLMessageParser(JsonParser): + def __init__(self): + super().__init__("HFDL") + + def process(self, line): + msg = super().process(line) + if msg is not None: + payload = msg["hfdl"] + if "lpdu" in payload: + lpdu = payload["lpdu"] + if lpdu["type"]["id"] in [13, 29]: + hfnpdu = lpdu["hfnpdu"] + if hfnpdu["type"]["id"] == 209: + if "pos" in hfnpdu: + pos = hfnpdu['pos'] + if abs(pos['lat']) <= 90 and abs(pos['lon']) <= 180: + Map.getSharedInstance().updateLocation({"flight": hfnpdu["flight_id"]}, HfdlAirplaneLocation(pos), "HFDL") + return msg diff --git a/owrx/map.py b/owrx/map.py index 9a7b5d20..315074ec 100644 --- a/owrx/map.py +++ b/owrx/map.py @@ -82,6 +82,8 @@ class Map(object): return "{callsign}-{ssid}".format(**source) elif "icao" in source: return source["icao"] + elif "flight" in source: + return source["flight"] return source["callsign"] def updateLocation(self, source, loc: Location, mode: str, band: Band = None):