Add individual station veiw
parent
2959a35280
commit
d36587bb1c
95
satnogs.py
95
satnogs.py
|
@ -23,6 +23,7 @@ Passes = defaultdict(list)
|
|||
Stations = []
|
||||
TLEs = defaultdict(list)
|
||||
Transmitters = defaultdict(dict)
|
||||
StationsPasses = defaultdict(list)
|
||||
SatDescrip = defaultdict(str)
|
||||
CZML = []
|
||||
|
||||
|
@ -34,7 +35,7 @@ def getFuture():
|
|||
observations = defaultdict(dict )
|
||||
|
||||
start = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S%z')
|
||||
end = (datetime.utcnow() + timedelta(hours=2,minutes=30)).strftime('%Y-%m-%dT%H:%M:%S%z')
|
||||
end = (datetime.utcnow() + timedelta(hours=4,minutes=30)).strftime('%Y-%m-%dT%H:%M:%S%z')
|
||||
|
||||
passes = get_paginated_endpoint("https://network.satnogs.org/api/jobs/")
|
||||
obs = get_paginated_endpoint("https://network.satnogs.org/api/observations/?end="+end+"&format=json&start="+start)
|
||||
|
@ -52,6 +53,7 @@ def getFuture():
|
|||
# "transmitter":Transmitters[observations[x["id"]]["norad_cat_id"]][x["transmitter"]]
|
||||
Sats[observations[x["id"]]["norad_cat_id"]].append({"station":x["ground_station"],"transmitter":Transmitters[observations[x["id"]]["norad_cat_id"]][x["transmitter"]],"start":start,"end":end,"id":x["id"]})
|
||||
TLEs[observations[x["id"]]["norad_cat_id"]]=[x["tle0"],x["tle1"],x["tle2"]]
|
||||
StationsPasses[x["ground_station"]].append({"norad":observations[x["id"]]["norad_cat_id"],"transmitter":Transmitters[observations[x["id"]]["norad_cat_id"]][x["transmitter"]],"start":start,"end":end,"id":x["id"]})
|
||||
except Exception as e:
|
||||
print "Error on observation number: "+str(x["id"])+ " "+str(e)
|
||||
broken[observations[x["id"]]["norad_cat_id"]].update([x["transmitter"]])
|
||||
|
@ -121,8 +123,7 @@ def updateCZML():
|
|||
doc["version"]="1.0"
|
||||
doc["clock"]={}
|
||||
doc["clock"]["interval"]="0000-00-00T00:00:00Z/9999-12-31T24:00:00Z"
|
||||
doc["clock"]["currentTime"] = datetime.utcnow().isoformat()+"Z"
|
||||
doc["clock"]["step"] = "SYSTEM_CLOCK_MULTIPLER"
|
||||
doc["clock"]["step"] = "SYSTEM_CLOCK"
|
||||
CZML.append(doc)
|
||||
|
||||
StationList = {}
|
||||
|
@ -198,8 +199,12 @@ def updateCZML():
|
|||
|
||||
@app.route("/")
|
||||
def index():
|
||||
return render_template("index.html")
|
||||
|
||||
return render_template("index.html",url="/czml")
|
||||
|
||||
@app.route("/station/<int:station_id>")
|
||||
def index_station(station_id):
|
||||
return render_template("index.html",url="/czml/"+str(station_id))
|
||||
|
||||
|
||||
|
||||
@app.route('/future_sats')
|
||||
|
@ -219,7 +224,87 @@ def api_broken():
|
|||
|
||||
return json.dumps(output)
|
||||
|
||||
@app.route("/czml/<int:station_id>")
|
||||
def api_station(station_id):
|
||||
czml = []
|
||||
doc = {}
|
||||
doc["id"] = "document"
|
||||
doc["name"] = "sats"
|
||||
doc["version"]="1.0"
|
||||
doc["clock"]={}
|
||||
doc["clock"]["interval"]="0000-00-00T00:00:00Z/9999-12-31T24:00:00Z"
|
||||
doc["clock"]["currentTime"] = datetime.utcnow().isoformat()+"Z"
|
||||
doc["clock"]["step"] = "SYSTEM_CLOCK"
|
||||
czml.append(doc)
|
||||
|
||||
|
||||
for x in Stations:
|
||||
if x["id"] == station_id:
|
||||
color = [0,230,64,255]
|
||||
if x["status"] == "Testing":
|
||||
color = [248,148,6,255]
|
||||
if x["status"] == "Offline":
|
||||
color = [255,0,0,50]
|
||||
|
||||
station = {}
|
||||
station["id"] = str(x["id"])
|
||||
station["name"] = x["name"]
|
||||
station["point"] = {}
|
||||
station["show"] = True
|
||||
station["point"]["color"] = {}
|
||||
station["point"]["color"]["rgba"] = color
|
||||
station["point"]["outlineColor"] = {}
|
||||
station["point"]["outlineColor"]["rgba"] = [255,255,255,color[3]]
|
||||
station["point"]["outlineWidth"] = 2.0
|
||||
station["position"] = {}
|
||||
station["point"]["pixelSize"]=7.0
|
||||
station["position"]["cartographicDegrees"] = [x["lng"],x['lat'],x["altitude"]]
|
||||
station["description"] = "<b>ID: "+str(x["id"])+"</b><br><b>Total Observations: "
|
||||
station["description"]+=str(x["observations"])+"</b><br><b>Status: "+x["status"]+"</b><br><b>QTH: "
|
||||
station["description"]+=x["qthlocator"]+"</b><br></b>Description: </b>"+x["description"]
|
||||
czml.append(station)
|
||||
break
|
||||
|
||||
|
||||
for y in StationsPasses[station_id]:
|
||||
sat = {}
|
||||
sat["id"] = str(y["id"])
|
||||
sat["name"] = TLEs[y["norad"]][0]
|
||||
sat["show"] = True
|
||||
sat["point"] = {}
|
||||
sat["point"]["color"] = {}
|
||||
sat["point"]["color"]["rgba"] = [255,0,0,255]
|
||||
sat["point"]["pixelSize"]=8.0
|
||||
#sat["billboard"] = {"image":"static/sat.png","scale":0.50}
|
||||
sat["position"] = {}
|
||||
sat["position"]["cartographicDegrees"]=[]
|
||||
sat["description"] = SatDescrip[y["norad"]]
|
||||
temp = y["start"]
|
||||
satObj = EarthSatellite(TLEs[y["norad"]][1],TLEs[y["norad"]][2],TLEs[y["norad"]][0])
|
||||
time = 0
|
||||
while temp <= y["end"]+timedelta(minutes=1):
|
||||
|
||||
subpoint = satObj.at(ts.utc(temp)).subpoint()
|
||||
lat = subpoint.latitude.degrees
|
||||
lng = subpoint.longitude.degrees
|
||||
elevation = subpoint.elevation.m
|
||||
sat["position"]["cartographicDegrees"].extend([time,lng,lat,elevation])
|
||||
time+=60
|
||||
temp = temp+timedelta(minutes=1)
|
||||
sat["position"]["interpolationAlgorithm"] = "LAGRANGE"
|
||||
sat["position"]["interpolationDegree"] = 5
|
||||
sat["position"]["epoch"] = (y["start"].isoformat()+"Z").replace("+00:00","")
|
||||
sat["path"] = {"show":{"interval":(y["start"].isoformat()+"Z").replace("+00:00","")+"/"+((y["end"]+timedelta(minutes=1)).isoformat()+"Z").replace("+00:00",""),"boolean":True},"width":2,"material":{"solidColor":{"color":{"rgba":[0,255,0,255]}}},"leadTime":100000,"trailTime":100000 }
|
||||
|
||||
czml.append(sat)
|
||||
|
||||
for y in StationsPasses[station_id]:
|
||||
sat = {}
|
||||
sat["id"] = str(y["id"])+"Link"
|
||||
sat["polyline"] = {"show":{"interval":(y["start"].isoformat()+"Z").replace("+00:00","")+"/"+((y["end"]+timedelta(minutes=1)).isoformat()+"Z").replace("+00:00",""),"boolean":True},"width":2,"material":{"solidColor":{"color":{"rgba":y["transmitter"][1]}}},"followSurface":False,"positions":{"references":[str(y["id"])+"#position",str(station_id)+"#position"]}}
|
||||
czml.append(sat)
|
||||
|
||||
return json.dumps(czml)
|
||||
|
||||
|
||||
|
||||
|
|
Binary file not shown.
|
@ -21,7 +21,7 @@
|
|||
viewer.terrainProvider = Cesium.createWorldTerrain();
|
||||
viewer.scene.globe.shadows=Cesium.ShadowMode.CAST_ONLY
|
||||
viewer.scene.globe.enableLighting = true
|
||||
viewer.dataSources.add(Cesium.CzmlDataSource.load("/czml"))
|
||||
viewer.dataSources.add(Cesium.CzmlDataSource.load("{{ url }}"))
|
||||
var now = new Cesium.JulianDate();
|
||||
viewer.clock.currentTime = now;
|
||||
viewer.clock.shouldAnimate = true
|
||||
|
|
Loading…
Reference in New Issue