kopia lustrzana https://github.com/projecthorus/radiosonde_auto_rx
Add KML provider
rodzic
3d77f5c997
commit
f2be000ba2
|
@ -175,6 +175,7 @@ class SondeDecoder(object):
|
||||||
self.rs41_drift_tweak = rs41_drift_tweak
|
self.rs41_drift_tweak = rs41_drift_tweak
|
||||||
self.experimental_decoder = experimental_decoder
|
self.experimental_decoder = experimental_decoder
|
||||||
self.imet_location = imet_location
|
self.imet_location = imet_location
|
||||||
|
self.telemetry = {}
|
||||||
|
|
||||||
# iMet ID store. We latch in the first iMet ID we calculate, to avoid issues with iMet-1-RS units
|
# iMet ID store. We latch in the first iMet ID we calculate, to avoid issues with iMet-1-RS units
|
||||||
# which don't necessarily have a consistent packet count to time increment ratio.
|
# which don't necessarily have a consistent packet count to time increment ratio.
|
||||||
|
@ -1161,11 +1162,11 @@ class SondeDecoder(object):
|
||||||
_exporter(_telemetry)
|
_exporter(_telemetry)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log_error("Exporter Error %s" % str(e))
|
self.log_error("Exporter Error %s" % str(e))
|
||||||
|
self.telemetry = _telemetry
|
||||||
return _telem_ok
|
return _telem_ok
|
||||||
|
|
||||||
def log_debug(self, line):
|
def log_debug(self, line):
|
||||||
""" Helper function to log a debug message with a descriptive heading.
|
""" Helper function to log a debug message with a descriptive heading.
|
||||||
Args:
|
Args:
|
||||||
line (str): Message to be logged.
|
line (str): Message to be logged.
|
||||||
"""
|
"""
|
||||||
|
@ -1202,13 +1203,16 @@ class SondeDecoder(object):
|
||||||
self.decoder.join()
|
self.decoder.join()
|
||||||
|
|
||||||
def running(self):
|
def running(self):
|
||||||
""" Check if the decoder subprocess is running.
|
""" Check if the decoder subprocess is running.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: True if the decoder subprocess is running.
|
bool: True if the decoder subprocess is running.
|
||||||
"""
|
"""
|
||||||
return self.decoder_running
|
return self.decoder_running
|
||||||
|
|
||||||
|
def getTelemetry(self):
|
||||||
|
""" Return telemetry data """
|
||||||
|
return self.telemetry
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Test script.
|
# Test script.
|
||||||
|
|
|
@ -118,6 +118,59 @@ def flask_get_task_list():
|
||||||
# Convert the task list to a JSON blob, and return.
|
# Convert the task list to a JSON blob, and return.
|
||||||
return json.dumps(_sdr_list)
|
return json.dumps(_sdr_list)
|
||||||
|
|
||||||
|
@app.route("/rs.kml")
|
||||||
|
def flak_get_kml():
|
||||||
|
""" Return KML with autorefresh """
|
||||||
|
kml = "<kml xmlns=\"http://earth.google.com/kml/2.0\" > \
|
||||||
|
<Document>\
|
||||||
|
<NetworkLink>\
|
||||||
|
<name>Radiosonde AutoRX</name>\
|
||||||
|
<description>Live tracking of high altitude balloons via Google Earth</description>\
|
||||||
|
<Url>\
|
||||||
|
<href>" + flask.request.host_url + "rs_feed.kml</href>\
|
||||||
|
<refreshMode>onInterval</refreshMode>\
|
||||||
|
<refreshInterval>10</refreshInterval>\
|
||||||
|
</Url>\
|
||||||
|
</NetworkLink>\
|
||||||
|
</Document>\
|
||||||
|
</kml>"
|
||||||
|
return kml, 200, { 'content-type':'application/vnd.google-earth.kml+xml' }
|
||||||
|
|
||||||
|
@app.route("/rs_feed.kml")
|
||||||
|
def flak_get_kml_feed():
|
||||||
|
""" Return KML with RS telemetry """
|
||||||
|
|
||||||
|
header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><kml xmlns=\"http://earth.google.com/kml/2.2\">"
|
||||||
|
body = ""
|
||||||
|
# Read in the task list, index by SDR ID.
|
||||||
|
_task_list = {}
|
||||||
|
for _task in autorx.task_list.keys():
|
||||||
|
if hasattr(autorx.task_list[_task]['task'], "getTelemetry"):
|
||||||
|
try:
|
||||||
|
telemetry = autorx.task_list[_task]['task'].getTelemetry()
|
||||||
|
print (telemetry);
|
||||||
|
body += "<Placemark> \
|
||||||
|
<name>"+telemetry['id']+"</name> \
|
||||||
|
<description>"+telemetry['type']+"</description> \
|
||||||
|
<visibility>1</visibility>\
|
||||||
|
<LookAt>\
|
||||||
|
<longitude>"+str(telemetry['lon'])+"</longitude>\
|
||||||
|
<latitude>"+str(telemetry['lat'])+"</latitude>\
|
||||||
|
<altitude>"+str(telemetry['alt'])+"</altitude>\
|
||||||
|
<altitudeMode>absolute</altitudeMode>\
|
||||||
|
<range>20000</range>\
|
||||||
|
<tilt>25</tilt>\
|
||||||
|
<heading>0</heading>\
|
||||||
|
</LookAt>\
|
||||||
|
<Point> \
|
||||||
|
<altitudeMode>absolute</altitudeMode>\
|
||||||
|
<coordinates>"+str(telemetry['lat'])+","+str(telemetry['lon'])+","+str(telemetry['alt'])+"</coordinates> \
|
||||||
|
</Point> \
|
||||||
|
</Placemark>"
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
footer = "</kml></xml>"
|
||||||
|
return header+body+footer, 200, { 'content-type':'application/vnd.google-earth.kml+xml' }
|
||||||
|
|
||||||
@app.route("/rs.kml")
|
@app.route("/rs.kml")
|
||||||
def flask_get_kml():
|
def flask_get_kml():
|
||||||
|
|
Ładowanie…
Reference in New Issue