From 243e73064a9b8e50d33898e1e502744920b0f122 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Tue, 17 Sep 2019 18:44:37 +0200 Subject: [PATCH] add band information to ysf locations --- owrx/meta.py | 19 +++++++++++++++---- owrx/source.py | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/owrx/meta.py b/owrx/meta.py index 1d7a63f..4cf507e 100644 --- a/owrx/meta.py +++ b/owrx/meta.py @@ -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) diff --git a/owrx/source.py b/owrx/source.py index ba31bdc..ad39480 100644 --- a/owrx/source.py +++ b/owrx/source.py @@ -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),