1
0
Fork 0

Start adding new veiws

merge-requests/2/head
wgaylord 2019-01-24 10:14:23 -06:00
parent c284032642
commit 827cd3d3dc
13 changed files with 156 additions and 48 deletions

View File

@ -4,7 +4,7 @@ from flask import Flask , render_template,redirect,url_for
import json
import random
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 ,get_paginated_endpoint
from satellite_tle import fetch_tles
scheduler = BackgroundScheduler()
@ -32,12 +32,8 @@ def getActive():
start = (datetime.utcnow() - timedelta(0,0,0,0,20)).strftime('%Y-%m-%dT%H:%M:%S%z')
end = (datetime.utcnow() + timedelta(0,0,0,0,30)).strftime('%Y-%m-%dT%H:%M:%S%z')
passesR = requests.get("https://network.satnogs.org/api/observations/?end="+end+"&format=json&start="+start)
passes = passesR.json()
if passesR.links.has_key("next"):
while passesR.links.has_key("next"):
passesR = requests.get(passesR.links["next"]["url"])
passes += passesR.json()
passes = get_paginated_endpoint("https://network.satnogs.org/api/observations/?end="+end+"&format=json&start="+start)
ground_stations = {}
for x in passes:
if datetime.strptime(x["start"],'%Y-%m-%dT%H:%M:%Sz') > datetime.utcnow() or datetime.strptime(x["end"],'%Y-%m-%dT%H:%M:%Sz') < datetime.utcnow():
@ -77,11 +73,7 @@ def getActive():
def GetGroundStations():
stationsR = requests.get("https://network.satnogs.org/api/stations/")
stations = stationsR.json()
while stationsR.links.has_key("next"):
stationsR = requests.get(stationsR.links["next"]["url"])
stations += stationsR.json()
stations = get_paginated_endpoint("https://network.satnogs.org/api/stations/?status=2")
for x in stations:
if x["last_seen"] == None:
@ -152,7 +144,11 @@ def updateTLE():
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)))
@app.route("/")
def index():
return render_template("index.html")
@app.route('/active_stations')
def api_active_stations():
sations = []

Binary file not shown.

View File

@ -0,0 +1,14 @@
<div class="container">
<div class="row"> .
<div class="col-md-12">
<center>
<img src="staic/satnogs-net-logo.png">
<br>
<br>
<iframe src = "/static/map/map.html" width="100%" height="100%" ></iframe>
</center>
</div>
</div>
</div>

View File

@ -0,0 +1,64 @@
self.importScripts("satellite.js");
norad = ""
groundStations = []
TLE = []
Orbits = []
onmessage = function(e) {
norad = e.data[0]
TLE = e.data[1]
getStations()
getOrbit()
}
setInterval(function(){
getStations()
}, 20000);
setInterval(function(){
var satrec = self.satellite_js.twoline2satrec(TLE[1],TLE[2]);
var gmst = self.satellite_js.gstime(new Date());
var positionAndVelocity = self.satellite_js.propagate(satrec, new Date());
var positionEci = positionAndVelocity.position
var positionGd = self.satellite_js.eciToGeodetic(positionEci, gmst)
var curLat = degress(positionGd.latitude)
var curLng = degress(positionGd.longitude)
if (groundStations[1] == undefined){
groundStations.push([])
}
postMessage([norad,TLE[0],[curLat,curLng],groundStations[0],groundStations[1],Orbits])
}, 1000);
function getStations(){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
groundStations = JSON.parse(this.responseText);
}
};
xhttp.open("GET", "/stations_from_sat/"+norad, true);
xhttp.send();
}
function degress (radians) {
return radians * 180 / Math.PI;
};
function getOrbit(){
var satrec = self.satellite_js.twoline2satrec(TLE[1],TLE[2]);
gmst = self.satellite_js.gstime(new Date());
while(Orbits.length < 300){
gmst = gmst+0.00833333333
if (gmst > 6.28318530718){
return
}
positionAndVelocity = self.satellite_js.propagate(satrec, (new Date() / 1000/60));
positionEci = positionAndVelocity.position
positionGd = self.satellite_js.eciToGeodetic(positionEci, gmst)
Orbits.push([degress(positionGd.latitude),degress(positionGd.longitude)])
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,54 @@
<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="moment.min.js"></script>
<script src="satellite.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');
var satrec = satellite_js.twoline2satrec("1 43017U 17073E 19015.35565251 .00000543 00000-0 48600-4 0 9995","2 43017 97.7201 302.7888 0257714 301.1255 56.4906 14.78360070 62455");
getObrit()
function getObrit(){
satelliteOrbit = []
for (var i = 0; i < 3000; i++){
time = moment().add(i*10,"m")
var gmst = satellite_js.gstime(new Date(time.valueOf()));
var positionAndVelocity = satellite_js.propagate(satrec, new Date(time.valueOf()));
var positionEci = positionAndVelocity.position
var positionGd = satellite_js.eciToGeodetic(positionEci, gmst)
satelliteOrbit = satelliteOrbit.concat(Cesium.Ellipsoid.WGS84.cartographicToCartesian(new Cesium.Cartographic(positionGd.longitude, positionGd.latitude, positionGd.height*1000)));
}
viewer.entities.add({
id: 1,
name: 'Orbit Polyline',
polyline: {
positions: satelliteOrbit,
width: 5,
followSurface: false,
material: new Cesium.Material({fabric : { type : 'Color', uniforms : {color : new Cesium.Color(1.0, 1.0, 0.0, 1.0)}}}),
}
});
}
function degress (radians) {
return radians * 180 / Math.PI;
};
</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>

1
views/globe/moment.min.js vendored 100644

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -17,25 +17,13 @@
</style>
<div class="container">
<div class="row"> .
<div class="col-md-12">
<center>
<img src="staic/map/satnogs-net-logo.png">
<br>
<br>
<div id="mapid" ></div>
</center>
</div>
</div>
</div>
<script>
test = null
var light_sat = L.icon({
iconUrl: 'staic/map/satellite-marker-light.png',
iconUrl: 'satellite-marker-light.png',
iconSize: [40, 40],
iconAnchor: [20, 20],
popupAnchor: [0, 0],
@ -43,7 +31,7 @@ var light_sat = L.icon({
});
var dark_sat = L.icon({
iconUrl: 'staic/map/satellite-marker-dark.png',
iconUrl: 'satellite-marker-dark.png',
iconSize: [40, 40],
iconAnchor: [20, 20],
popupAnchor: [0, 0],
@ -51,7 +39,7 @@ var dark_sat = L.icon({
});
var station = L.icon({
iconUrl: 'staic/map/station-marker.png',
iconUrl: 'station-marker.png',
iconSize: [10, 10],
iconAnchor: [5, 5],
popupAnchor: [0, 0],
@ -59,7 +47,7 @@ var station = L.icon({
});
var active_station = L.icon({
iconUrl: 'staic/map/active-station-marker.png',
iconUrl: 'active-station-marker.png',
iconSize: [20, 20],
iconAnchor: [10, 10],
popupAnchor: [0, 0],
@ -117,27 +105,17 @@ function UpdateMap(e) {
Sats[norad].bindPopup(popupText)
Sats[norad]._popup.setContent(popupText)
temp = []
e.data[3].forEach(function(x){
temp.push(x[0])
Object.keys(Lines[norad]).forEach(function(x){
Lines[norad][x].removeFrom(mymap)
delete Lines[norad][x]
})
e.data[3].forEach(function(x){
if (Object.keys(Lines[norad]).includes(String(x[0]))){
Object.keys(Lines[norad]).forEach(function(y){
Lines[norad][y]._latlngs[1]= {"lat":satPos[0],"lng":satPos[1]}
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);
})
})}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)};
})
Object.keys(Lines[norad]).forEach(function(x){
if (temp.includes(Number(x))){
}else{
Lines[norad][x].removeFrom(mymap)
delete Lines[norad][x]
}
})
}
@ -156,7 +134,7 @@ function UpdateMap(e) {
$.get("/occuring_sats", function(data, status){
data = JSON.parse(data)
Object.keys(data).forEach(function(x){
worker = new Worker('static/map/Worker.js');
worker = new Worker('Worker.js');
worker.onmessage = UpdateMap
worker.postMessage([x,data[x]]);
Workers[x] =worker
@ -171,7 +149,7 @@ $.get("/occuring_sats", function(data, status){
Object.keys(data).forEach(function(x){
if (x in Workers){
}else{
worker = new Worker('static/map/Worker.js');
worker = new Worker('Worker.js');
worker.onmessage = UpdateMap
worker.postMessage([x,data[x]]);
Workers[x] =worker

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB