let's get some locations up on the map

This commit is contained in:
Jakob Ketterl 2023-09-05 23:25:32 +02:00
parent 5a942c23c5
commit da53c5907a
4 changed files with 39 additions and 5 deletions

View file

@ -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:

View file

@ -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':

View file

@ -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

View file

@ -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):