add band information to ysf locations

This commit is contained in:
Jakob Ketterl 2019-09-17 18:44:37 +02:00
parent 8df4f9ce52
commit 243e73064a
2 changed files with 16 additions and 4 deletions

View File

@ -5,6 +5,7 @@ from datetime import datetime, timedelta
import logging
import threading
from owrx.map import Map, LatLngLocation
from owrx.bands import Bandplan
logger = logging.getLogger(__name__)
@ -71,19 +72,29 @@ class DmrMetaEnricher(object):
class YsfMetaEnricher(object):
def __init__(self, parser):
self.parser = parser
def enrich(self, meta):
if "source" in meta and "lat" in meta and "lon" in meta:
# TODO parsing the float values should probably happen earlier
loc = LatLngLocation(float(meta["lat"]), float(meta["lon"]))
Map.getSharedInstance().updateLocation(meta["source"], loc, "YSF")
Map.getSharedInstance().updateLocation(meta["source"], loc, "YSF", self.parser.getBand())
return None
class MetaParser(object):
enrichers = {"DMR": DmrMetaEnricher(), "YSF": YsfMetaEnricher()}
def __init__(self, handler):
self.handler = handler
self.enrichers = {"DMR": DmrMetaEnricher(), "YSF": YsfMetaEnricher(self)}
self.band = None
def setDialFrequency(self, freq):
self.band = Bandplan.getSharedInstance().findBand(freq)
def getBand(self):
return self.band
def parse(self, meta):
fields = meta.split(";")
@ -91,8 +102,8 @@ class MetaParser(object):
if "protocol" in meta:
protocol = meta["protocol"]
if protocol in MetaParser.enrichers:
additional_data = MetaParser.enrichers[protocol].enrich(meta)
if protocol in self.enrichers:
additional_data = self.enrichers[protocol].enrich(meta)
if additional_data is not None:
meta["additional"] = additional_data
self.handler.write_metadata(meta)

View File

@ -537,6 +537,7 @@ class DspManager(csdr.output):
freq = self.localProps["center_freq"] + self.localProps["offset_freq"]
self.wsjtParser.setDialFrequency(freq)
self.aprsParser.setDialFrequency(freq)
self.metaParser.setDialFrequency(freq)
self.subscriptions = [
self.localProps.getProperty("audio_compression").wire(self.dsp.set_audio_compression),