diff --git a/satnogs.py b/satnogs.py index a35d1b0..97c8adc 100644 --- a/satnogs.py +++ b/satnogs.py @@ -114,7 +114,7 @@ def updateTransmitters(): Transmitters[str(x["norad_cat_id"])][x["uuid"]] = [x["description"],"#"+str("%06x" % random.randint(0, 0xFFFFFF))] #print Transmitters -@scheduler.scheduled_job('interval',minutes=3) +@scheduler.scheduled_job('interval',minutes=2) def updatePasses(): global Passes global Occuring_sats diff --git a/satnogs_api_client.pyc b/satnogs_api_client.pyc deleted file mode 100644 index 91a2e0b..0000000 Binary files a/satnogs_api_client.pyc and /dev/null differ diff --git a/static/Worker.js b/static/Worker.js index 72c91e0..72639f5 100644 --- a/static/Worker.js +++ b/static/Worker.js @@ -3,11 +3,13 @@ self.importScripts("satellite.js"); norad = "" groundStations = [] TLE = [] +Orbits = [] onmessage = function(e) { norad = e.data[0] TLE = e.data[1] getStations() + getOrbit() } setInterval(function(){ @@ -20,17 +22,16 @@ setInterval(function(){ var positionAndVelocity = self.satellite_js.propagate(satrec, new Date()); var positionEci = positionAndVelocity.position var positionGd = self.satellite_js.eciToGeodetic(positionEci, gmst) - var longitude = positionGd.longitude - var latitude = positionGd.latitude - + var curLat = degress(positionGd.latitude) + var curLng = degress(positionGd.longitude) if (groundStations[1] == undefined){ groundStations.push([]) } - postMessage([norad,TLE[0],[degress(latitude),degress(longitude)],groundStations[0],groundStations[1]]) + postMessage([norad,TLE[0],[curLat,curLng],groundStations[0],groundStations[1],Orbits]) -}, 500); +}, 1000); function getStations(){ var xhttp = new XMLHttpRequest(); @@ -45,4 +46,19 @@ var xhttp = new XMLHttpRequest(); function degress (radians) { return radians * 180 / Math.PI; -}; \ No newline at end of file +}; + +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)]) + } +} \ No newline at end of file diff --git a/templates/map.html b/templates/map.html index 3b9b0ab..87deac0 100644 --- a/templates/map.html +++ b/templates/map.html @@ -86,6 +86,8 @@ Stations = {} Workers = {} Lines = {} Sats = {} +Orbits = {} +CurrentOrbit = null dataS = null function UpdateMap(e) { @@ -96,8 +98,11 @@ function UpdateMap(e) { Sats[norad]._latlng = {"lat":satPos[0],"lng":satPos[1]} Sats[norad].update() }else{ - Sats[norad] = L.marker(satPos,{icon: dark_sat,zIndexOffset:1000}).addTo(mymap); + Sats[norad] = L.marker(satPos,{icon: dark_sat,zIndexOffset:1000,title:norad}).addTo(mymap); + Sats[norad].norad = norad + Sats[norad].on('click',SatClick) Lines[norad] = {} + Orbits[String(norad)] = e.data[5] @@ -188,6 +193,17 @@ $.get("/occuring_sats", function(data, status){ }, 20000); +function SatClick(e){ + if (CurrentOrbit == null){ + }else{ + CurrentOrbit.removeFrom(mymap) + } + + CurrentOrbit = L.polyline(Orbits[Number(e.target.norad)], {color: 'red'}); + CurrentOrbit.addTo(mymap) + +} +