1
0
Fork 0
satnogsmap/static/globe/globe.html

190 lines
6.0 KiB
HTML

<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>
</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',{timeline:false,vrButton:false,homeButton:false,animation:false,baseLayerPicker:true});
viewer.terrainProvider = Cesium.createWorldTerrain();
Orbits = {}
Satelites = {}
Workers = {}
Stations = {}
Lines = {}
$.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
}
});
});
});
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.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)),
}
});
}
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>
<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>