1
0
Fork 0

Color the lines and make the case of no TLE work better.

dev
wgaylord 2018-10-24 16:37:05 -05:00
parent 385d5a091d
commit 8fd414dc9f
2 changed files with 7 additions and 5 deletions

View File

@ -4,7 +4,7 @@ from flask import Flask , render_template,redirect,url_for
import json
from apscheduler.schedulers.background import BackgroundScheduler
import ephem
from satnogs_api_client import fetch_satellites, DB_BASE_URL
from satnogs_api_client import fetch_satellites, DB_BASE_URL,fetch_tle_of_observation
from satellite_tle import fetch_tles
scheduler = BackgroundScheduler()
@ -177,8 +177,8 @@ def api_occuring_sats():
obs = {}
for x in Passes:
if x.satellite['norad_cat_id'] not in TLEs.keys():
q = requests.get("https://db.satnogs.org/satellite_position/"+str( x.satellite['norad_cat_id'])).json()
TLEs[ x.satellite['norad_cat_id'] ] = [str(q["name"]),str(q["tle1"]),str(q["tle2"])]
q = fetch_tle_of_observation(x.id)
TLEs[ x.satellite['norad_cat_id'] ] = [str(x.satellite["name"]),str(q[0]),str(q[1])]
satellite = ephem.readtle(TLEs[x.satellite['norad_cat_id']][0],TLEs[x.satellite['norad_cat_id']][1],TLEs[x.satellite['norad_cat_id']][2])
now = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
satellite.compute(now)

View File

@ -68,6 +68,8 @@ stationList = {}
{%endfor%}
var sats = {}
var links = {}
@ -85,7 +87,7 @@ var links = {}
$.get("/api/satstationpairs", function(data, status){
data = JSON.parse(data)
data.forEach(function(entry){
firstpolyline = new L.Polyline([[stationList[entry[0]]._latlng.lat,stationList[entry[0]]._latlng.lng],[sats[entry[1]]._latlng.lat,sats[entry[1]]._latlng.lng]], {color: 'red',weight: 3,opacity: 1,smoothFactor: 1});
firstpolyline = new L.Polyline([[stationList[entry[0]]._latlng.lat,stationList[entry[0]]._latlng.lng],[sats[entry[1]]._latlng.lat,sats[entry[1]]._latlng.lng]], {color: '#'+entry[1].toString(16).repeat(2).substr(0,6),weight: 3,opacity: 1,smoothFactor: 1});
firstpolyline.addTo(mymap)
firstpolyline.bringToFront()
links[entry[0]] = firstpolyline
@ -133,7 +135,7 @@ setInterval(function(){
})
data.forEach(function(entry){
firstpolyline = new L.Polyline([[stationList[entry[0]]._latlng.lat,stationList[entry[0]]._latlng.lng],[sats[entry[1]]._latlng.lat,sats[entry[1]]._latlng.lng]], {color: 'red',weight:3,opacity:1,smoothFactor: 1});
firstpolyline = new L.Polyline([[stationList[entry[0]]._latlng.lat,stationList[entry[0]]._latlng.lng],[sats[entry[1]]._latlng.lat,sats[entry[1]]._latlng.lng]], {color: '#'+entry[1].toString(16).repeat(2).substr(0,6),weight:3,opacity:1,smoothFactor: 1});
firstpolyline.addTo(mymap)
links[entry[0]] = firstpolyline
stationList[entry[0]].setIcon(active_station)