Added new transmitter information!
parent
81dd452588
commit
c5e531facb
27
satnogs.py
27
satnogs.py
|
@ -2,6 +2,7 @@ from datetime import datetime , timedelta
|
||||||
import requests
|
import requests
|
||||||
from flask import Flask , render_template,redirect,url_for
|
from flask import Flask , render_template,redirect,url_for
|
||||||
import json
|
import json
|
||||||
|
import random
|
||||||
from apscheduler.schedulers.background import BackgroundScheduler
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
from satnogs_api_client import fetch_satellites, DB_BASE_URL,fetch_tle_of_observation
|
from satnogs_api_client import fetch_satellites, DB_BASE_URL,fetch_tle_of_observation
|
||||||
from satellite_tle import fetch_tles
|
from satellite_tle import fetch_tles
|
||||||
|
@ -14,6 +15,7 @@ Passes = []
|
||||||
Occuring_sats = {}
|
Occuring_sats = {}
|
||||||
Stations = []
|
Stations = []
|
||||||
TLEs = {}
|
TLEs = {}
|
||||||
|
Transmitters = {}
|
||||||
|
|
||||||
class Pass:
|
class Pass:
|
||||||
id = 0
|
id = 0
|
||||||
|
@ -61,6 +63,7 @@ def getActive():
|
||||||
temp.start = datetime.strptime(x["start"],'%Y-%m-%dT%H:%M:%Sz')
|
temp.start = datetime.strptime(x["start"],'%Y-%m-%dT%H:%M:%Sz')
|
||||||
temp.end = datetime.strptime(x["end"],'%Y-%m-%dT%H:%M:%Sz')
|
temp.end = datetime.strptime(x["end"],'%Y-%m-%dT%H:%M:%Sz')
|
||||||
temp.ground_station = x["ground_station"]
|
temp.ground_station = x["ground_station"]
|
||||||
|
temp.transmitter = x["transmitter"]
|
||||||
temp.norad = str(x["norad_cat_id"])
|
temp.norad = str(x["norad_cat_id"])
|
||||||
try:
|
try:
|
||||||
temp.satellite = requests.get("https://db.satnogs.org/api/satellites/"+str(x["norad_cat_id"])).json()
|
temp.satellite = requests.get("https://db.satnogs.org/api/satellites/"+str(x["norad_cat_id"])).json()
|
||||||
|
@ -98,6 +101,18 @@ def GetGroundStations():
|
||||||
|
|
||||||
return stations
|
return stations
|
||||||
|
|
||||||
|
@scheduler.scheduled_job('interval',days=5)
|
||||||
|
def updateTransmitters():
|
||||||
|
global Transmitters
|
||||||
|
print "Updating Transmitters"
|
||||||
|
temp = requests.get("https://db.satnogs.org/api/transmitters/").json()
|
||||||
|
for x in temp:
|
||||||
|
if str(x["norad_cat_id"]) in Transmitters.keys():
|
||||||
|
Transmitters[str(x["norad_cat_id"])][x["uuid"]] = [x["description"],"#"+str("%06x" % random.randint(0, 0xFFFFFF))]
|
||||||
|
else:
|
||||||
|
Transmitters[str(x["norad_cat_id"])]={}
|
||||||
|
Transmitters[str(x["norad_cat_id"])][x["uuid"]] = [x["description"],"#"+str("%06x" % random.randint(0, 0xFFFFFF))]
|
||||||
|
#print Transmitters
|
||||||
|
|
||||||
@scheduler.scheduled_job('interval',minutes=3)
|
@scheduler.scheduled_job('interval',minutes=3)
|
||||||
def updatePasses():
|
def updatePasses():
|
||||||
|
@ -153,11 +168,18 @@ def api_active_stations():
|
||||||
@app.route('/stations_from_sat/<string:norad>')
|
@app.route('/stations_from_sat/<string:norad>')
|
||||||
def api_occuring_observations(norad):
|
def api_occuring_observations(norad):
|
||||||
obs = []
|
obs = []
|
||||||
|
trans = []
|
||||||
for x in Passes:
|
for x in Passes:
|
||||||
if x.norad == norad:
|
if x.norad == norad:
|
||||||
obs.append(x.ground_station)
|
obs.append([x.ground_station,Transmitters[norad][x.transmitter][1]])
|
||||||
|
trans.append(x.transmitter)
|
||||||
|
#print Transmitters[norad].values()
|
||||||
|
|
||||||
return json.dumps(obs)
|
transList = []
|
||||||
|
for x in set(trans):
|
||||||
|
transList.append(Transmitters[norad][x])
|
||||||
|
#print transList,norad
|
||||||
|
return json.dumps([obs,transList])
|
||||||
|
|
||||||
@app.route('/occuring_sats')
|
@app.route('/occuring_sats')
|
||||||
def api_occuring_sats():
|
def api_occuring_sats():
|
||||||
|
@ -170,5 +192,6 @@ def api_occuring_sats():
|
||||||
updatePasses()
|
updatePasses()
|
||||||
updateStations()
|
updateStations()
|
||||||
updateTLE()
|
updateTLE()
|
||||||
|
updateTransmitters()
|
||||||
scheduler.start()
|
scheduler.start()
|
||||||
app.run(use_reloader=False,host = "0.0.0.0",port=5001)
|
app.run(use_reloader=False,host = "0.0.0.0",port=5001)
|
Binary file not shown.
|
@ -23,7 +23,11 @@ setInterval(function(){
|
||||||
var longitude = positionGd.longitude
|
var longitude = positionGd.longitude
|
||||||
var latitude = positionGd.latitude
|
var latitude = positionGd.latitude
|
||||||
|
|
||||||
postMessage([norad,TLE[0],[degress(latitude),degress(longitude)],groundStations])
|
if (groundStations[1] == undefined){
|
||||||
|
groundStations.push([])
|
||||||
|
}
|
||||||
|
|
||||||
|
postMessage([norad,TLE[0],[degress(latitude),degress(longitude)],groundStations[0],groundStations[1]])
|
||||||
|
|
||||||
|
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
|
@ -95,21 +95,38 @@ function UpdateMap(e) {
|
||||||
Sats[norad].update()
|
Sats[norad].update()
|
||||||
}else{
|
}else{
|
||||||
Sats[norad] = L.marker(satPos,{icon: dark_sat,zIndexOffset:1000}).addTo(mymap);
|
Sats[norad] = L.marker(satPos,{icon: dark_sat,zIndexOffset:1000}).addTo(mymap);
|
||||||
Sats[norad].bindPopup("<b>Name: "+name+"</b><br><b>Norad: "+norad+"</b>");
|
|
||||||
Lines[norad] = {}
|
Lines[norad] = {}
|
||||||
e.data[3].forEach(function(x){
|
|
||||||
Lines[norad][x] = new L.Polyline([[Stations[x]._latlng.lat,Stations[x]._latlng.lng],[satPos[0],satPos[1]]], {color: '#'+norad.toString(16).repeat(2).substr(0,6),weight: 3,opacity: 1,smoothFactor: 1});
|
|
||||||
Lines[norad][x].addTo(mymap)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.keys(Lines[norad]).forEach(function(x){
|
popupText = "<b>Name: "+name+"</b><br><b>Norad: "+norad+"</b><br><b>Station Count: "+e.data[3].length+"</b><br>"
|
||||||
if (e.data[3].includes(Number(x))){
|
|
||||||
Lines[norad][x]._latlngs[1]= {"lat":satPos[0],"lng":satPos[1]}
|
e.data[4].forEach(function(x){
|
||||||
|
//console.log(x + " "+norad)
|
||||||
|
popupText = popupText + '<div style="background-color:'+x[1]+'";>'+x[0]+"</div><br>"
|
||||||
|
})
|
||||||
|
Sats[norad].bindPopup(popupText)
|
||||||
|
Sats[norad]._popup.setContent(popupText)
|
||||||
|
|
||||||
|
temp = []
|
||||||
|
e.data[3].forEach(function(x){
|
||||||
|
temp.push(x[0])
|
||||||
|
})
|
||||||
|
|
||||||
|
e.data[3].forEach(function(x){
|
||||||
|
if (Object.keys(Lines[norad]).includes(Number(x[0]))){
|
||||||
|
Object.keys(Lines[norad]).forEach(function(y){
|
||||||
|
if (temp.includes(Number(y))){
|
||||||
|
Lines[norad][y]._latlngs[1]= {"lat":satPos[0],"lng":satPos[1]}
|
||||||
}else{
|
}else{
|
||||||
Lines[norad][x].removeFrom(mymap)
|
Lines[norad][x[0]].removeFrom(mymap)
|
||||||
delete Lines[norad][x]
|
delete Lines[norad][x[0]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
})}else{Lines[norad][x[0]] = new L.Polyline([[Stations[x[0]]._latlng.lat,Stations[x[0]]._latlng.lng],[satPos[0],satPos[1]]], {color: x[1],weight: 3,opacity: 1,smoothFactor: 1});
|
||||||
|
Lines[norad][x[0]].addTo(mymap)};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue