diff --git a/ShowMeYourBigSatellite.sublime-workspace b/ShowMeYourBigSatellite.sublime-workspace index f8cde74..5947031 100644 --- a/ShowMeYourBigSatellite.sublime-workspace +++ b/ShowMeYourBigSatellite.sublime-workspace @@ -3,6 +3,10 @@ { "selected_items": [ + [ + "sat", + "satlist" + ], [ "center", "centerStart" @@ -534,6 +538,7 @@ "file_history": [ "/home/jll/Documents/01_perso/14_ShowMeYourBigSatellite/.git/COMMIT_EDITMSG", + "/home/jll/Documents/01_perso/14_ShowMeYourBigSatellite/templates/dropdown_test.html", "/home/jll/Documents/01_perso/14_ShowMeYourBigSatellite/main.py", "/home/jll/Documents/01_perso/14_ShowMeYourBigSatellite/.gitignore", "/home/jll/dev/source/main/spacemetric/keystoneapi/build.xml", @@ -659,8 +664,7 @@ "/home/jll/dev/source_git/main_zwolle/csd/build.properties", "/home/jll/dev/source_git/main_zwolle/csd/db/build.properties", "/opt/spacemetric/keystone/config/keystone.postgres", - "/home/jll/Desktop/WEB-INF/web.xml", - "/home/jll/Documents/01_perso/19_jenkinsArduinoNotification/arduino/blink/Blink/Blink.ino" + "/home/jll/Desktop/WEB-INF/web.xml" ], "find": { @@ -861,7 +865,7 @@ "cols": [ 0.0, - 0.53850118085, + 0.472844615194, 1.0 ], "rows": diff --git a/main.py b/main.py index 574a7dc..1309552 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ from flask import Flask, jsonify +from flask import render_template from flask.ext.cors import cross_origin import os @@ -6,13 +7,29 @@ import whereismysat, ephem app = Flask('ShowMeYourBigSatellite', static_url_path='/static') -@app.route('/get_coordinates') +@app.route('/get_coordinates/') @cross_origin(headers=['Content-Type']) # allow all origins all methods. -def get_coordinates(): - sat=whereismysat.getPos("TERRA") +def get_coordinates(satName): + sat=whereismysat.getPos(satName) return jsonify(longitude=sat.sublong.real / ephem.degree, latitude=sat.sublat.real / ephem.degree) +@app.route('/satellites') +@cross_origin(headers=['Content-Type']) # allow all origins all methods. +def satellites(): + names = whereismysat.satlist.keys() + print names + return jsonify(name=whereismysat.satlist.keys()) + + +@app.route('/') +def hello(): + return render_template('simplemap.html', satellites=whereismysat.satlist.keys()) + +#### ######### +# Used for testing only +############## + @app.route('/css/') def static_proxy_css(path): # send_static_file will guess the correct MIME type diff --git a/mytornado.py b/mytornado.py new file mode 100644 index 0000000..35823e4 --- /dev/null +++ b/mytornado.py @@ -0,0 +1,8 @@ +from tornado.wsgi import WSGIContainer +from tornado.httpserver import HTTPServer +from tornado.ioloop import IOLoop +from main import app + +http_server = HTTPServer(WSGIContainer(app)) +http_server.listen(5000) +IOLoop.instance().start() diff --git a/requirements.txt b/requirements.txt index e895dd3..b906a7c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,9 +4,12 @@ Jinja2==2.7.3 MarkupSafe==0.23 Werkzeug==0.9.6 argparse==1.2.1 +backports.ssl-match-hostname==3.4.0.2 +certifi==14.05.14 ephem==3.7.5.3 itsdangerous==0.24 numpy==1.8.1 six==1.7.3 +tornado==4.0 wsgiref==0.1.2 yolk==0.4.3 diff --git a/static/css/simplemap.css b/static/css/simplemap.css new file mode 100644 index 0000000..8b9f2f6 --- /dev/null +++ b/static/css/simplemap.css @@ -0,0 +1,27 @@ +html, body{ + margin: 0; + padding: 0; + height: 100%; +} + +#map { + float:left; + margin: 0; + padding: 0; + height: 100%; + width: 90%; +} + +#menu{ + margin-left: 90%; + height: 100%; + padding: 5px; +} + +h1{ + font-size: 20px; +} + +h2{ + font-size: 16px; +} \ No newline at end of file diff --git a/static/js/mapsFun.js b/static/js/mapsFun.js index 9594370..14f076f 100644 --- a/static/js/mapsFun.js +++ b/static/js/mapsFun.js @@ -33,7 +33,11 @@ var satelliteIcon = L.icon({ // Gets the latest satellite position from the server function getPosition(){ - $.getJSON("http://localhost:5000/get_coordinates",function(result){ + var urlBase = "http://localhost:5000/get_coordinates/" + var satellite = $("#satellite").val(); + var url = urlBase + satellite; + console.log(url); + $.getJSON(url,function(result){ var pos = new L.latLng(result.latitude, result.longitude); satMarker.setLatLng(pos); map.panTo(satMarker.getLatLng()); diff --git a/static/simplemap.html b/static/simplemap.html deleted file mode 100644 index 772f303..0000000 --- a/static/simplemap.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - Simple Map - - - - - - - - -
- - - - - - - diff --git a/templates/simplemap.html b/templates/simplemap.html new file mode 100644 index 0000000..0cd9cff --- /dev/null +++ b/templates/simplemap.html @@ -0,0 +1,29 @@ + + + + Simple Map + + + + + + + + +
+ + + + + + + + diff --git a/whereismysat.py b/whereismysat.py index 5f5cb7c..5d2c9cb 100644 --- a/whereismysat.py +++ b/whereismysat.py @@ -15,7 +15,7 @@ class TleGroup: self.url = url self.name = name self.load() - + def load(self): """ Read a TLEs file stream and creates a list of satellites. This function aims to be called every day""" @@ -35,7 +35,6 @@ class TleGroup: s.close() print "%i satellites loaded into list / Total in list: %i"%(count,len(satlist)) - def getPos(name): global satlist for key in satlist.keys():