mirror of
https://github.com/jketterl/openwebrx.git
synced 2025-12-06 07:12:09 +01:00
pass additional data to the map
This commit is contained in:
parent
06d2fbab85
commit
b109ee5c45
|
|
@ -114,6 +114,7 @@ $(function(){
|
||||||
|
|
||||||
switch (update.location.type) {
|
switch (update.location.type) {
|
||||||
case 'latlon':
|
case 'latlon':
|
||||||
|
if (!update.location.lat || !update.location.lon) break;
|
||||||
var pos = new google.maps.LatLng(update.location.lat, update.location.lon);
|
var pos = new google.maps.LatLng(update.location.lat, update.location.lon);
|
||||||
var marker;
|
var marker;
|
||||||
var markerClass = google.maps.Marker;
|
var markerClass = google.maps.Marker;
|
||||||
|
|
@ -125,6 +126,7 @@ $(function(){
|
||||||
aprsOptions.speed = update.location.speed;
|
aprsOptions.speed = update.location.speed;
|
||||||
} else if (update.source.icao) {
|
} else if (update.source.icao) {
|
||||||
markerClass = PlaneMarker;
|
markerClass = PlaneMarker;
|
||||||
|
aprsOptions = update.location;
|
||||||
}
|
}
|
||||||
if (markers[key]) {
|
if (markers[key]) {
|
||||||
marker = markers[key];
|
marker = markers[key];
|
||||||
|
|
@ -438,8 +440,14 @@ $(function(){
|
||||||
if (receiverMarker) {
|
if (receiverMarker) {
|
||||||
distance = " at " + distanceKm(receiverMarker.position, marker.position) + " km";
|
distance = " at " + distanceKm(receiverMarker.position, marker.position) + " km";
|
||||||
}
|
}
|
||||||
|
var title;
|
||||||
|
if (marker.icao) {
|
||||||
|
title = marker.identification || marker.icao;
|
||||||
|
} else {
|
||||||
|
linkifySource(source);
|
||||||
|
}
|
||||||
infowindow.setContent(
|
infowindow.setContent(
|
||||||
'<h3>' + linkifySource(source) + distance + '</h3>' +
|
'<h3>' + title + distance + '</h3>' +
|
||||||
'<div>' + timestring + ' using ' + marker.mode + ( marker.band ? ' on ' + marker.band : '' ) + '</div>' +
|
'<div>' + timestring + ' using ' + marker.mode + ( marker.band ? ' on ' + marker.band : '' ) + '</div>' +
|
||||||
commentString
|
commentString
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
from abc import ABC
|
||||||
|
|
||||||
from csdr.module import PickleModule
|
from csdr.module import PickleModule
|
||||||
from math import sqrt, atan2, pi, floor, acos, cos
|
from math import sqrt, atan2, pi, floor, acos, cos
|
||||||
from owrx.map import LatLngLocation, Map
|
from owrx.map import LatLngLocation, IncrementalUpdate, Location, Map
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
@ -15,9 +17,28 @@ d_lat_even = 360 / (4 * nz)
|
||||||
d_lat_odd = 360 / (4 * nz - 1)
|
d_lat_odd = 360 / (4 * nz - 1)
|
||||||
|
|
||||||
|
|
||||||
class AirplaneLocation(LatLngLocation):
|
class AirplaneLocation(LatLngLocation, IncrementalUpdate, ABC):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
|
self.props = message
|
||||||
|
if "lat" in message and "lon" in message:
|
||||||
super().__init__(message["lat"], message["lon"])
|
super().__init__(message["lat"], message["lon"])
|
||||||
|
else:
|
||||||
|
self.lat = None
|
||||||
|
self.lon = None
|
||||||
|
|
||||||
|
def update(self, previousLocation: Location):
|
||||||
|
props = previousLocation.props
|
||||||
|
props.update(self.props)
|
||||||
|
self.props = props
|
||||||
|
if "lat" in props:
|
||||||
|
self.lat = props["lat"]
|
||||||
|
if "lon" in props:
|
||||||
|
self.lon = props["lon"]
|
||||||
|
|
||||||
|
def __dict__(self):
|
||||||
|
dict = super().__dict__()
|
||||||
|
dict.update(self.props)
|
||||||
|
return dict
|
||||||
|
|
||||||
|
|
||||||
class CprCache:
|
class CprCache:
|
||||||
|
|
@ -54,7 +75,7 @@ class ModeSParser(PickleModule):
|
||||||
message["capability"] = input[0] & 0b111
|
message["capability"] = input[0] & 0b111
|
||||||
message["icao"] = icao = input[1:4].hex()
|
message["icao"] = icao = input[1:4].hex()
|
||||||
type = (input[4] & 0b11111000) >> 3
|
type = (input[4] & 0b11111000) >> 3
|
||||||
message["type"] = type
|
message["adsb_type"] = type
|
||||||
|
|
||||||
if type in [1, 2, 3, 4]:
|
if type in [1, 2, 3, 4]:
|
||||||
# identification message
|
# identification message
|
||||||
|
|
@ -181,9 +202,9 @@ class ModeSParser(PickleModule):
|
||||||
# Mode-S All-call reply
|
# Mode-S All-call reply
|
||||||
message["icao"] = input[1:4].hex()
|
message["icao"] = input[1:4].hex()
|
||||||
|
|
||||||
if "icao" in message and "lat" in message and "lon" in message:
|
if "icao" in message and ['lat', 'lon', 'altitude', 'heading', 'groundtrack', 'identification'] & message.keys():
|
||||||
loc = AirplaneLocation(message)
|
loc = AirplaneLocation(message)
|
||||||
Map.getSharedInstance().updateLocation({"icao": icao}, loc, "ADS-B", None)
|
Map.getSharedInstance().updateLocation({"icao": message['icao']}, loc, "ADS-B", None)
|
||||||
|
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from owrx.config import Config
|
from owrx.config import Config
|
||||||
from owrx.bands import Band
|
from owrx.bands import Band
|
||||||
|
from abc import abstractmethod, ABCMeta
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -88,6 +89,8 @@ class Map(object):
|
||||||
ts = datetime.now()
|
ts = datetime.now()
|
||||||
key = self._sourceToKey(source)
|
key = self._sourceToKey(source)
|
||||||
with self.positionsLock:
|
with self.positionsLock:
|
||||||
|
if isinstance(loc, IncrementalUpdate) and key in self.positions:
|
||||||
|
loc.update(self.positions[key]["location"])
|
||||||
self.positions[key] = {"source": source, "location": loc, "updated": ts, "mode": mode, "band": band}
|
self.positions[key] = {"source": source, "location": loc, "updated": ts, "mode": mode, "band": band}
|
||||||
self.broadcast(
|
self.broadcast(
|
||||||
[
|
[
|
||||||
|
|
@ -148,3 +151,9 @@ class LocatorLocation(Location):
|
||||||
|
|
||||||
def __dict__(self):
|
def __dict__(self):
|
||||||
return {"type": "locator", "locator": self.locator}
|
return {"type": "locator", "locator": self.locator}
|
||||||
|
|
||||||
|
|
||||||
|
class IncrementalUpdate(Location, metaclass=ABCMeta):
|
||||||
|
@abstractmethod
|
||||||
|
def update(self, previousLocation: Location):
|
||||||
|
pass
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue