Add ground station placemark

Add line of sight
Move each RS into its own folder
Strip Document ID

Signed-off-by: Ilias Daradimos <judgedrid@gmail.com>
pull/304/head
Ilias Daradimos 2020-12-24 02:18:49 +02:00
rodzic 7b6cf34aaa
commit 0219c7d36e
1 zmienionych plików z 45 dodań i 83 usunięć

Wyświetl plik

@ -22,6 +22,7 @@ from threading import Thread
import flask
from flask import request, abort
from flask_socketio import SocketIO
import re
try:
from simplekml import Kml, AltitudeMode
@ -37,7 +38,7 @@ try:
except ImportError:
# Python 3
from queue import Queue
from simplekml import Kml, AltitudeMode
# Inhibit Flask warning message about running a development server... (we know!)
cli = sys.modules["flask.cli"]
@ -125,77 +126,7 @@ def flask_get_kml():
_config = autorx.config.global_config
kml = Kml()
netlink = kml.newnetworklink(name="Radiosonde AutoRX")
netlink.open = 1
netlink.link.href = flask.request.host_url + "rs_feed.kml"
try:
netlink.link.refreshinterval = _config['kml_refresh_rate']
except KeyError:
netlink.link.refreshinterval = 10
netlink.link.refreshmode = 'onInterval'
return kml.kml(), 200, \
{'content-type': 'application/vnd.google-earth.kml+xml'}
@app.route("/rs_feed.kml")
def flask_get_kml_feed():
""" Return KML with RS telemetry """
kml = Kml()
for rs_id in flask_telemetry_store:
try:
coordinates = []
for tp in flask_telemetry_store[rs_id]['track'].track_history:
coordinates.append((tp[2], tp[1], tp[3]))
rs_data = '''\
{type}/{subtype}
Frequency: {freq}
Altitude: {alt}m
Heading: {heading}
Velocity: {vel_h}
Vertical speed: {vel_v}
Temperature: {temp}C
Humidity: {humidity}%
Pressure: {pressure}hPa
'''
if flask_telemetry_store[rs_id]['latest_telem']['vel_v'] > -5:
icon = flask.request.host_url + 'static/img/balloon-green.png'
else:
icon = flask.request.host_url + 'static/img/parachute-green.png'
pnt = kml.newpoint(name=rs_id,
altitudemode=AltitudeMode.absolute,
description=rs_data.
format(**flask_telemetry_store[rs_id]
['latest_telem']))
pnt.iconstyle.icon.href = icon
pnt.coords = [(flask_telemetry_store[rs_id]
['latest_telem']['lon'], flask_telemetry_store[rs_id]
['latest_telem']['lat'],
flask_telemetry_store[rs_id]
['latest_telem']['alt'])]
linestring = kml.newlinestring(name=rs_id)
linestring.coords = coordinates
linestring.altitudemode = AltitudeMode.absolute
linestring.extrude = 1
linestring.stylemap.normalstyle.linestyle.color = 'ff03bafc'
linestring.stylemap.highlightstyle.linestyle.color = 'ff03bafc'
linestring.stylemap.normalstyle.polystyle.color = 'AA03bafc'
linestring.stylemap.highlightstyle.polystyle.color = 'CC03bafc'
except Exception as e:
print(e)
return kml.kml(), 200, \
{'content-type': 'application/vnd.google-earth.kml+xml'}
@app.route("/rs.kml")
def flask_get_kml():
""" Return KML with autorefresh """
_config = autorx.config.global_config
kml = Kml()
netlink = kml.newnetworklink(name="Radiosonde AutoRX")
netlink = kml.newnetworklink(name="Radiosonde Auto-RX Live Telemetry")
netlink.open = 1
netlink.link.href = flask.request.host_url + "rs_feed.kml"
try:
@ -210,6 +141,24 @@ def flask_get_kml():
def flask_get_kml_feed():
""" Return KML with RS telemetry """
kml = Kml()
kml.resetidcounter()
kml.document.name = "Track"
kml.document.open = 1
# Station Placemark
pnt = kml.newpoint(
name='Ground Station',
altitudemode=AltitudeMode.absolute,
description="AutoRX Ground Station",
)
pnt.open = 1
pnt.iconstyle.icon.href = flask.request.host_url + "static/img/antenna-green.png"
pnt.coords = [
(
autorx.config.global_config['station_lon'],
autorx.config.global_config['station_lat'],
autorx.config.global_config['station_alt']
)
]
for rs_id in flask_telemetry_store:
try:
coordinates = []
@ -233,8 +182,10 @@ def flask_get_kml_feed():
else:
icon = flask.request.host_url + "static/img/parachute-green.png"
pnt = kml.newpoint(
name=rs_id,
# Add folder
fol = kml.newfolder(name=rs_id)
# HAB Placemark
pnt = fol.newpoint(name=rs_id,
altitudemode=AltitudeMode.absolute,
description=rs_data.format(
**flask_telemetry_store[rs_id]["latest_telem"]
@ -248,7 +199,7 @@ def flask_get_kml_feed():
flask_telemetry_store[rs_id]["latest_telem"]["alt"],
)
]
linestring = kml.newlinestring(name=rs_id)
linestring = fol.newlinestring(name='Track')
linestring.coords = coordinates
linestring.altitudemode = AltitudeMode.absolute
linestring.extrude = 1
@ -256,10 +207,25 @@ def flask_get_kml_feed():
linestring.stylemap.highlightstyle.linestyle.color = "ff03bafc"
linestring.stylemap.normalstyle.polystyle.color = "AA03bafc"
linestring.stylemap.highlightstyle.polystyle.color = "CC03bafc"
# Add LOS line
linestring = fol.newlinestring(name='LOS')
linestring.altitudemode = AltitudeMode.absolute
linestring.coords = [
(
autorx.config.global_config['station_lon'],
autorx.config.global_config['station_lat'],
autorx.config.global_config['station_alt']
),
(
flask_telemetry_store[rs_id]['latest_telem']['lon'],
flask_telemetry_store[rs_id]['latest_telem']['lat'],
flask_telemetry_store[rs_id]['latest_telem']['alt']
)
]
except Exception as e:
logging.error("KML - Could not parse data from RS %s - %s" % (rs_id, str(e)))
return kml.kml(), 200, {"content-type": "application/vnd.google-earth.kml+xml"}
return re.sub('<Document.*>','<Document>',kml.kml()), 200, {"content-type": "application/vnd.google-earth.kml+xml"}
@app.route("/get_config")
@ -308,7 +274,7 @@ def shutdown_flask(shutdown_key):
@app.route("/start_decoder", methods=["POST"])
def flask_start_decoder():
""" Inject a scan result, which will cause a decoder to be started if there
are enough resources (SDRs) to do so.
are enough resources (SDRs) to do so.
Example:
curl -d "type=DFM&freq=403240000" -X POST http://localhost:5000/start_decoder
"""
@ -327,7 +293,7 @@ def flask_start_decoder():
@app.route("/stop_decoder", methods=["POST"])
def flask_stop_decoder():
""" Request that a decoder process be halted.
""" Request that a decoder process be halted.
Example:
curl -d "freq=403250000" -X POST http://localhost:5000/stop_decoder
"""
@ -512,10 +478,6 @@ class WebExporter(object):
"WebExporter - JSON object missing required field %s" % _field
)
return
==== BASE ====
_telem = telemetry.copy()
==== BASE ====
_telem = telemetry.copy()