1
0
Fork 0

Add in changes from the live server :/

dev
wgaylord 2018-10-24 15:35:01 -05:00
parent 0a21df4643
commit a4dc3721f6
2 changed files with 21 additions and 19 deletions

View File

@ -115,6 +115,7 @@ def updateStations():
@scheduler.scheduled_job('interval',days=1)
def updateTLE():
print "Updating TLE"
global TlEs
sats = fetch_satellites(url=DB_BASE_URL, max_satellites=None)
satnogs_db_norad_ids = set(sat['norad_cat_id'] for sat in sats if sat['status'] != 're-entered')
# Remove satellites with temporary norad ids
@ -123,7 +124,7 @@ def updateTLE():
# Fetch TLEs for the satellites of interest
tles = fetch_tles(satnogs_db_norad_ids)
TLEs = {}
for norad_id, (source, tle) in tles.items():
TLEs[norad_id] = [str(tle[0]),str(tle[1]),str(tle[2])]
print('\nTLEs for {} of {} requested satellites found ({} satellites with temporary norad ids skipped).'.format(len(tles), len(satnogs_db_norad_ids), len(temporary_norad_ids)))
@ -175,6 +176,9 @@ def api_occuring_observations():
def api_occuring_sats():
obs = {}
for x in Passes:
if x.satellite['norad_cat_id'] not in TLEs.keys():
q = requests.get("https://db.satnogs.org/satellite_position/"+str( x.satellite['norad_cat_id'])).json()
TLEs[ x.satellite['norad_cat_id'] ] = [str(q["name"]),str(q["tle1"]),str(q["tle2"])]
satellite = ephem.readtle(TLEs[x.satellite['norad_cat_id']][0],TLEs[x.satellite['norad_cat_id']][1],TLEs[x.satellite['norad_cat_id']][2])
now = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
satellite.compute(now)

View File

@ -16,8 +16,7 @@
<div class="row"> .
<div class="col-md-12">
<center>
<img src="/static/satnogs-net-logo.png">
<br>
<img src="/static/satnogs-net-logo.png">
<div id="mapid" ></div>
</center>
@ -86,34 +85,28 @@ links = {}
$.get("/api/satstationpairs", function(data, status){
data = JSON.parse(data)
data.forEach(function(entry){
var firstpolyline = new L.Polyline([[stationList[entry[0]]._latlng.lat,stationList[entry[0]]._latlng.lng],[sats[entry[1]]._latlng.lat,sats[entry[1]]._latlng.lng]], {color: 'red',weight: 3,opacity: 1,smoothFactor: 1});
firstpolyline = new L.Polyline([[stationList[entry[0]]._latlng.lat,stationList[entry[0]]._latlng.lng],[sats[entry[1]]._latlng.lat,sats[entry[1]]._latlng.lng]], {color: 'red',weight: 3,opacity: 1,smoothFactor: 1});
firstpolyline.addTo(mymap)
firstpolyline.bringToFront()
links[entry[1]] = firstpolyline
stationList[entry[0]].setIcon(active_station)
stationList[entry[0]].setZIndexOffset(500)
});
});
setInterval(function(){
Object.keys(links).forEach(function(key){
links[key].setStyle({opacity:0})
links[key].removeFrom(mymap)
delete links[key]
})
Object.keys(links).forEach(function(key){
links[key].removeFrom(mymap)
delete links[key]
})
Object.keys(stationList).forEach(function(key){
stationList[key].setIcon(station)
stationList[key].setZIndexOffset(-1000)
})
$.get("/api/occuringsats", function(data, status){
data = JSON.parse(data)
Object.keys(sats).forEach(function(key){
@ -123,7 +116,7 @@ setInterval(function(){
Object.keys(data).forEach(function(key){
marker = L.marker(data[key]["lat_lng"],{icon: sat,zIndexOffset:1000}).addTo(mymap);
marker.bindPopup("<b>Name: "+data[key]["name"]+"</b>");
marker.bindPopup("<b>Name: "+data[key]["name"]+"</b><br><b>Norad: "+key+"</b>");
sats[key] = marker;
});
@ -132,16 +125,21 @@ setInterval(function(){
$.get("/api/satstationpairs", function(data, status){
data = JSON.parse(data)
var usedStations = []
Object.keys(stationList).forEach(function(key){
stationList[key].setIcon(station)
})
data.forEach(function(entry){
var firstpolyline = new L.Polyline([[stationList[entry[0]]._latlng.lat,stationList[entry[0]]._latlng.lng],[sats[entry[1]]._latlng.lat,sats[entry[1]]._latlng.lng]], {color: 'red',weight:3,opacity:1,smoothFactor: 1});
firstpolyline = new L.Polyline([[stationList[entry[0]]._latlng.lat,stationList[entry[0]]._latlng.lng],[sats[entry[1]]._latlng.lat,sats[entry[1]]._latlng.lng]], {color: 'red',weight:3,opacity:1,smoothFactor: 1});
firstpolyline.addTo(mymap)
links[entry[1]] = firstpolyline
stationList[entry[0]].setIcon(active_station)
stationList[entry[0]].setZIndexOffset(500)
});
});
console.log(links)
}, 60000*2);
}, 10000);
</script>