Progress
parent
827cd3d3dc
commit
062f7d3099
|
@ -74,11 +74,16 @@ def getActive():
|
|||
|
||||
def GetGroundStations():
|
||||
stations = get_paginated_endpoint("https://network.satnogs.org/api/stations/?status=2")
|
||||
|
||||
stations += get_paginated_endpoint("https://network.satnogs.org/api/stations/?status=1")
|
||||
|
||||
for x in stations:
|
||||
|
||||
if x["last_seen"] == None:
|
||||
stations.remove(x)
|
||||
continue
|
||||
if x["status"] == "Offline":
|
||||
stations.remove(x)
|
||||
continue
|
||||
|
||||
if datetime.strptime(x["last_seen"],'%Y-%m-%dT%H:%M:%Sz') < (datetime.utcnow()- timedelta(10,0,0,0)):
|
||||
stations.remove(x)
|
||||
|
@ -87,6 +92,10 @@ def GetGroundStations():
|
|||
stations.remove(x)
|
||||
continue
|
||||
|
||||
if x["status"] == "Offline":
|
||||
stations.remove(x)
|
||||
continue
|
||||
|
||||
if datetime.strptime(x["last_seen"],'%Y-%m-%dT%H:%M:%Sz') < (datetime.utcnow()- timedelta(10,0,0,0)):
|
||||
stations.remove(x)
|
||||
|
||||
|
@ -153,7 +162,7 @@ def index():
|
|||
def api_active_stations():
|
||||
sations = []
|
||||
for x in Stations:
|
||||
sations.append({'id':x['id'],'name':x['name'],'lat_lng':[x["lat"],x['lng']]})
|
||||
sations.append({'id':x['id'],'name':x['name'],'lat_lng':[x["lat"],x['lng'],x["altitude"]],'type':x["status"],'description':x["description"],'total_obs':x["observations"],'qthlocator':x["qthlocator"]})
|
||||
return json.dumps(sations)
|
||||
|
||||
@app.route('/stations_from_sat/<string:norad>')
|
||||
|
|
|
@ -1,37 +1,44 @@
|
|||
self.importScripts("satellite.js");
|
||||
self.importScripts("moment.min.js");
|
||||
self.importScripts("https://cesiumjs.org/releases/1.53/Build/Cesium/Cesium.js")
|
||||
|
||||
norad = ""
|
||||
groundStations = []
|
||||
TLE = []
|
||||
satrec = null
|
||||
Orbits = []
|
||||
name = ""
|
||||
|
||||
onmessage = function(e) {
|
||||
norad = e.data[0]
|
||||
TLE = e.data[1]
|
||||
name = e.data[1][0]
|
||||
satrec = self.satellite_js.twoline2satrec(e.data[1][1],e.data[1][2]);
|
||||
getStations()
|
||||
getOrbit()
|
||||
Orbits = getObrit()
|
||||
}
|
||||
|
||||
setInterval(function(){
|
||||
getStations()
|
||||
}, 20000);
|
||||
}, 10000);
|
||||
|
||||
setInterval(function(){
|
||||
var satrec = self.satellite_js.twoline2satrec(TLE[1],TLE[2]);
|
||||
getObrit()
|
||||
}, 60000*5);
|
||||
|
||||
setInterval(function(){
|
||||
|
||||
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])
|
||||
postMessage([norad,name,self.Cesium.Ellipsoid.WGS84.cartographicToCartesian(new self.Cesium.Cartographic(positionGd.longitude, positionGd.latitude, (positionGd.height*1000))),groundStations[0],groundStations[1],Orbits])
|
||||
|
||||
|
||||
}, 1000);
|
||||
}, 10000);
|
||||
|
||||
function getStations(){
|
||||
var xhttp = new XMLHttpRequest();
|
||||
|
@ -48,17 +55,19 @@ 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)])
|
||||
}
|
||||
}
|
||||
|
||||
function getObrit(){
|
||||
|
||||
satelliteOrbit = []
|
||||
for (var i = 0; i < 30; i++){
|
||||
time = moment().subtract(10,"m").add(i*1,"m")
|
||||
var gmst = self.satellite_js.gstime(new Date(time.valueOf()));
|
||||
var positionAndVelocity = self.satellite_js.propagate(satrec, new Date(time.valueOf()));
|
||||
var positionEci = positionAndVelocity.position
|
||||
var positionGd = self.satellite_js.eciToGeodetic(positionEci, gmst)
|
||||
|
||||
satelliteOrbit = satelliteOrbit.concat(self.Cesium.Ellipsoid.WGS84.cartographicToCartesian(new self.Cesium.Cartographic(positionGd.longitude, positionGd.latitude, positionGd.height*1000)));
|
||||
}
|
||||
return satelliteOrbit
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
<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>
|
||||
<script src="moment.min.js"></script>
|
||||
<script src="satellite.js"></script>
|
||||
|
||||
|
@ -16,38 +17,172 @@
|
|||
<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()
|
||||
var viewer = new Cesium.Viewer('cesiumContainer',{timeline:false,vrButton:false,homeButton:false,animation:false,baseLayerPicker:true});
|
||||
viewer.terrainProvider = Cesium.createWorldTerrain();
|
||||
Orbits = {}
|
||||
Satelites = {}
|
||||
Workers = {}
|
||||
Stations = {}
|
||||
Lines = {}
|
||||
|
||||
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)));
|
||||
$.get("/active_stations", function(data, status){
|
||||
data = JSON.parse(data)
|
||||
dataS = data
|
||||
data.forEach(function(x){
|
||||
description = "<b>ID: "+x["id"]+"</b><br><b>Total Observations: "+x["total_obs"]+"</b><br><b>Status: "+x["type"]+"</b><br><b>QTH: "+x["qthlocator"]+"</b><br></b>Description: </b>"+x["description"]
|
||||
Color = Cesium.Color.GREEN
|
||||
if(x["type"]=="Testing"){
|
||||
Color = Cesium.Color.ORANGE
|
||||
}
|
||||
Stations[x["id"]] = viewer.entities.add({
|
||||
position : Cesium.Cartesian3.fromDegrees(x["lat_lng"][1],x["lat_lng"][0],x["lat_lng"][2]),
|
||||
name: x["name"],
|
||||
id: x["id"],
|
||||
description:description,
|
||||
point : {
|
||||
pixelSize : 5,
|
||||
color : Color,
|
||||
|
||||
outlineColor : Cesium.Color.WHITE,
|
||||
outlineWidth : 2
|
||||
}
|
||||
viewer.entities.add({
|
||||
id: 1,
|
||||
name: 'Orbit Polyline',
|
||||
polyline: {
|
||||
positions: satelliteOrbit,
|
||||
width: 5,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function UpdateMap(e) {
|
||||
var norad = e.data[0]
|
||||
var name = e.data[1]
|
||||
var satPos = e.data[2]
|
||||
|
||||
var observingStations = e.data[3]
|
||||
var transmitters = e.data[4]
|
||||
var Orbit = e.data[5]
|
||||
|
||||
if(Object.keys(Orbits).includes(norad)){
|
||||
Orbits[norad].polyline = {
|
||||
positions: Orbit,
|
||||
width: 1,
|
||||
followSurface: false,
|
||||
material: new Cesium.Material({fabric : { type : 'Color', uniforms : {color : new Cesium.Color(1.0, 1.0, 0.0, 1.0)}}}),
|
||||
material: new Cesium.ColorMaterialProperty(Cesium.Color(1.0, 1.0, 0.0, 0.5)),
|
||||
}
|
||||
}else{
|
||||
Orbits[norad] = viewer.entities.add({
|
||||
nane: name+" Obirt",
|
||||
polyline: {
|
||||
positions: Orbit,
|
||||
width: 1,
|
||||
followSurface: false,
|
||||
material: new Cesium.ColorMaterialProperty(Cesium.Color(1.0, 1.0, 0.0, 0.5)),
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function degress (radians) {
|
||||
return radians * 180 / Math.PI;
|
||||
};
|
||||
|
||||
popupText = "<b>Name: "+name+"</b><br><b>Norad: "+norad+"</b><br><b>Station Count: "+observingStations.length+"</b><br>"
|
||||
transmitters.forEach(function(x){
|
||||
//console.log(x + " "+norad)
|
||||
popupText = popupText + '<div class="trans" style="background-color:'+x[1]+'";>'+x[0]+"</div>"
|
||||
})
|
||||
|
||||
if(Object.keys(Satelites).includes(norad)){
|
||||
|
||||
Satelites[norad].position = satPos
|
||||
Satelites[norad].description = popupText
|
||||
}else{
|
||||
Satelites[norad] =viewer.entities.add({
|
||||
position : satPos,
|
||||
name: name,
|
||||
id: norad,
|
||||
description:popupText,
|
||||
point : {
|
||||
pixelSize : 10,
|
||||
color : Cesium.Color.RED,
|
||||
outlineWidth : 2
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if(Object.keys(Lines).includes(norad)){
|
||||
Object.keys(Lines[norad]).forEach(
|
||||
function(x){
|
||||
|
||||
viewer.entities.remove(Lines[norad][x])
|
||||
delete Lines[norad][x]
|
||||
})
|
||||
|
||||
}else{
|
||||
Lines[norad] = {}
|
||||
}
|
||||
|
||||
|
||||
observingStations.forEach(function(x){
|
||||
|
||||
|
||||
Lines[norad][x[0]] = viewer.entities.add({polyline: {
|
||||
followSurface: false,
|
||||
width:4,
|
||||
positions: new Cesium.PositionPropertyArray([
|
||||
new Cesium.ReferenceProperty(
|
||||
viewer.entities,
|
||||
Satelites[norad].id,
|
||||
[ 'position' ]
|
||||
),
|
||||
new Cesium.ReferenceProperty(
|
||||
viewer.entities,
|
||||
Stations[x[0]].id,
|
||||
[ 'position' ]
|
||||
)
|
||||
]),
|
||||
material: new Cesium.ColorMaterialProperty(Cesium.Color.fromCssColorString(x[1]))
|
||||
|
||||
}
|
||||
})})
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$.get("/occuring_sats", function(data, status){
|
||||
data = JSON.parse(data)
|
||||
Object.keys(data).forEach(function(x){
|
||||
worker = new Worker('Worker.js');
|
||||
worker.onmessage = UpdateMap
|
||||
worker.postMessage([x,data[x]]);
|
||||
Workers[x] =worker
|
||||
});
|
||||
});
|
||||
setInterval(function(){
|
||||
$.get("/occuring_sats", function(data, status){
|
||||
data = JSON.parse(data)
|
||||
Object.keys(Workers).forEach(function(x){
|
||||
if(Object.keys(data).includes(x)){}else{
|
||||
console.log(x)
|
||||
Workers[x].terminate()
|
||||
delete Workers[x]
|
||||
viewer.entities.remove(Satelites[x])
|
||||
viewer.entities.remove(Orbits[x])
|
||||
viewer.entities.remove(Satelites[x])
|
||||
viewer.entities.remove(Orbits[x])
|
||||
delete Satelites[x]
|
||||
delete Orbits[x]
|
||||
delete Workers[x]
|
||||
}
|
||||
});
|
||||
Object.keys(data).forEach(function(x){
|
||||
worker = new Worker('Worker.js');
|
||||
worker.onmessage = UpdateMap
|
||||
worker.postMessage([x,data[x]]);
|
||||
Workers[x] =worker
|
||||
});
|
||||
});
|
||||
}, 60000);
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue