1
0
Fork 0

Add rotating earth view

merge-requests/2/head
root 2019-03-13 11:50:50 -05:00
parent d36587bb1c
commit bdea461bee
4 changed files with 94 additions and 5 deletions

View File

@ -1,9 +1,9 @@
from datetime import datetime , timedelta
import requests
from tqdm import tqdm
from flask import Flask , render_template,redirect,url_for
from flask import Flask , render_template,redirect,url_for, request
import json
from collections import defaultdict
from collections import defaultdict, Counter
import random
from apscheduler.schedulers.background import BackgroundScheduler
from satnogs_api_client import fetch_satellites, DB_BASE_URL,fetch_tle_of_observation ,get_paginated_endpoint
@ -18,6 +18,8 @@ ts = load.timescale()
broken = defaultdict(set)
Usage = Counter()
Sats = defaultdict(list)
Passes = defaultdict(list)
Stations = []
@ -184,6 +186,7 @@ def updateCZML():
temp = temp+timedelta(minutes=1)
sat["position"]["interpolationAlgorithm"] = "LAGRANGE"
sat["position"]["interpolationDegree"] = 5
# sat["position"]["referenceFrame"] = "INERTIAL"
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 }
@ -199,10 +202,20 @@ def updateCZML():
@app.route("/")
def index():
Usage.update([str(request.headers.get("CF-IPCountry"))])
return render_template("index.html",url="/czml")
@app.route("/rotating")
def index():
Usage.update([str(request.headers.get("CF-IPCountry"))])
return render_template("rotating.html",url="/czml")
@app.route("/station/<int:station_id>")
def index_station(station_id):
Usage.update(request.headers.get("CF-IPCountry"))
return render_template("index.html",url="/czml/"+str(station_id))
@ -220,10 +233,13 @@ def api_broken():
output = defaultdict(list)
for x in broken.keys():
output[x]=list(broken[x])
return json.dumps(output)
@app.route("/usage")
def usage():
return json.dumps(Usage)
@app.route("/czml/<int:station_id>")
def api_station(station_id):
czml = []

Binary file not shown.

View File

@ -27,7 +27,13 @@
viewer.clock.shouldAnimate = true
setInterval(function(){
viewer.dataSources.removeAll()
viewer.dataSources.add(Cesium.CzmlDataSource.load("{{ url }}"))
}, 1000*60*60);

View File

@ -0,0 +1,67 @@
<head>
<script src="https://cesiumjs.org/releases/1.53/Build/Cesium/Cesium.js"></script>
<link href="https://cesiumjs.org/releases/1.53/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<style>
</style>
<div id="cesiumContainer" style="width: 100%; height:100%"></div>
<script>
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIwYmEwOTc5YS01N2I3LTRhYmQtOGE0MS1lNTkyMWU2ZmM3YWUiLCJpZCI6Njg1OCwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU0NzU5ODkxOX0.p4alNyuyt_Eufuo8xX_SB6HKHuSixBTxgiVpD6UGI3Y';
var viewer = new Cesium.Viewer('cesiumContainer',{shadows:true,timeline:false,vrButton:false,homeButton:false,animation:true,baseLayerPicker:true});
viewer.terrainProvider = Cesium.createWorldTerrain();
viewer.scene.globe.shadows=Cesium.ShadowMode.CAST_ONLY
viewer.scene.globe.enableLighting = true
viewer.dataSources.add(Cesium.CzmlDataSource.load("{{ url }}"))
var now = new Cesium.JulianDate();
viewer.clock.currentTime = now;
viewer.clock.shouldAnimate = true
temp = 0
function icrf(scene, time) {
if (scene.mode !== Cesium.SceneMode.SCENE3D) {
return;
}
t = Object()
t.dayNumber = time.dayNumber
t.secondsOfDay = temp
icrfToFixed = Cesium.Transforms.computeIcrfToFixedMatrix(t);
if (Cesium.defined(icrfToFixed)) {
var camera = viewer.camera;
var offset = Cesium.Cartesian3.clone(camera.position);
var transform = Cesium.Matrix4.fromRotationTranslation(icrfToFixed);
camera.lookAtTransform(transform, offset);
}
temp+=120
if (temp > 86400){
temp = 0
}
}
viewer.scene.postUpdate.addEventListener(icrf);
setInterval(function(){
viewer.dataSources.removeAll()
viewer.dataSources.add(Cesium.CzmlDataSource.load("{{ url }}"))
}, 1000*60*60);
</script>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>