pass through the mode on the map

This commit is contained in:
Jakob Ketterl 2019-07-11 23:40:09 +02:00
parent acbf2939c9
commit 2470c2bfa6
4 changed files with 24 additions and 11 deletions

View File

@ -57,6 +57,7 @@
title: update.callsign
}, getMarkerOpacityOptions(update.lastseen) ));
marker.lastseen = update.lastseen;
marker.mode = update.mode;
// TODO the trim should happen on the server side
if (expectedCallsign && expectedCallsign == update.callsign.trim()) {
@ -94,6 +95,7 @@
}, getRectangleOpacityOptions(update.lastseen) ));
rectangle.lastseen = update.lastseen;
rectangle.locator = update.location.locator;
rectangle.mode = update.mode;
if (expectedLocator && expectedLocator == update.location.locator) {
map.panTo(center);
@ -182,7 +184,7 @@
var showLocatorInfoWindow = function(locator, pos) {
if (!infowindow) infowindow = new google.maps.InfoWindow();
var inLocator = $.map(rectangles, function(r, callsign) {
return {callsign: callsign, locator: r.locator, lastseen: r.lastseen}
return {callsign: callsign, locator: r.locator, lastseen: r.lastseen, mode: r.mode}
}).filter(function(d) {
return d.locator == locator;
}).sort(function(a, b){
@ -194,7 +196,7 @@
'<ul>' +
inLocator.map(function(i){
var timestring = moment(i.lastseen).fromNow();
return '<li>' + i.callsign + ' (' + timestring + ')</li>'
return '<li>' + i.callsign + ' (' + timestring + ' via ' + i.mode + ')</li>'
}).join("") +
'</ul>'
);
@ -208,7 +210,7 @@
var timestring = moment(marker.lastseen).fromNow();
infowindow.setContent(
'<h3>' + callsign + '</h3>' +
'<div>' + timestring + '</div>'
'<div>' + timestring + ' via ' + marker.mode + '</div>'
);
infowindow.open(map, marker);
}

View File

@ -44,7 +44,8 @@ class Map(object):
{
"callsign": callsign,
"location": record["location"].__dict__(),
"lastseen": record["updated"].timestamp() * 1000
"lastseen": record["updated"].timestamp() * 1000,
"mode" : record["mode"]
}
for (callsign, record) in self.positions.items()
])
@ -55,14 +56,15 @@ class Map(object):
except ValueError:
pass
def updateLocation(self, callsign, loc: Location):
def updateLocation(self, callsign, loc: Location, mode: str):
ts = datetime.now()
self.positions[callsign] = {"location": loc, "updated": ts}
self.positions[callsign] = {"location": loc, "updated": ts, "mode": mode}
self.broadcast([
{
"callsign": callsign,
"location": loc.__dict__(),
"lastseen": ts.timestamp() * 1000
"lastseen": ts.timestamp() * 1000,
"mode" : mode
}
])

View File

@ -71,7 +71,8 @@ class YsfMetaEnricher(object):
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
Map.getSharedInstance().updateLocation(meta["source"], LatLngLocation(float(meta["lat"]), float(meta["lon"])))
loc = LatLngLocation(float(meta["lat"]), float(meta["lon"]))
Map.getSharedInstance().updateLocation(meta["source"], loc, "YSF")
return None

View File

@ -118,9 +118,15 @@ class WsjtParser(object):
self.handler = handler
self.locator_pattern = re.compile(".*\s([A-Z0-9]+)\s([A-R]{2}[0-9]{2})$")
modes = {
"~": "FT8"
}
def parse(self, data):
try:
msg = data.decode().rstrip()
# sample
# '222100 -15 -0.0 508 ~ CQ EA7MJ IM66'
# known debug messages we know to skip
if msg.startswith("<DecodeFinished>"):
return
@ -133,15 +139,17 @@ class WsjtParser(object):
out["db"] = float(msg[7:10])
out["dt"] = float(msg[11:15])
out["freq"] = int(msg[16:20])
modeChar = msg[21:22]
out["mode"] = mode = WsjtParser.modes[modeChar] if modeChar in WsjtParser.modes else "unknown"
wsjt_msg = msg[24:60].strip()
self.getLocator(wsjt_msg)
self.parseLocator(wsjt_msg, mode)
out["msg"] = wsjt_msg
self.handler.write_wsjt_message(out)
except ValueError:
logger.exception("error while parsing wsjt message")
def getLocator(self, msg):
def parseLocator(self, msg, mode):
m = self.locator_pattern.match(msg)
if m is None:
return
@ -149,4 +157,4 @@ class WsjtParser(object):
# likely this just means roger roger goodbye.
if m.group(2) == "RR73":
return
Map.getSharedInstance().updateLocation(m.group(1), LocatorLocation(m.group(2)))
Map.getSharedInstance().updateLocation(m.group(1), LocatorLocation(m.group(2)), mode)