summaryrefslogtreecommitdiff
path: root/tools/mmd/tracker.wsgi
blob: cd649715d1a69370c0c3e2144af3e826cc00eff7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python

from cgi import escape
from urlparse import parse_qs

def application (environ, response):
  """
  beginning of WSGI/python application for
  MURSAT1 Tracker
  """
  
  body = '''
<!doctype html>
<html>
<head>
  <meta charset="utf-8" />
  <title>MURSAT1 tracker</title>
  <link rel="stylesheet" type="text/css" href="http://hofos.at/mmd/static/mmd.css" />
  <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
  <script src="static/predictlib.js" type="text/javascript"></script>
  <script src="static/tle.js" type="text/javascript"></script>
  <script src="static/orbtrak.js" type="text/javascript"></script>
  <script type="text/javascript">
    function load()
    {{
      Orb.startOSMTracking(90, {longitude}, {latitude}, {altitude}, '{name}');
    }}
  </script>
</head>
<body onload="load ()">
  <div class="groundstation">
    <span id="gsName"></span>,
    Lon:
    <span id="gsLongitude"></span>,
    Lat:
    <span id="gsLatitude"></span>,
    Alt:
    <span id="gsAltitude"></span>
  </div>
  <div id="osm"></div>
  <table class="current">
    <tr>
      <th class="telemetry">Longitude</th>
      <th class="telemetry">Latitude</th>
      <th class="telemetry">Azimuth</th>
      <th class="telemetry">Elevation</th>
      <th class="telemetry">Altitude</th>
    </tr>
    <tr>
      <td class="telemetry"  id="longitude">
      </td>
      <td class="telemetry"  id="latitude">
      </td>
      <td class="telemetry"  id="azimuth">
      </td>
      <td class="telemetry"  id="elevation">
      </td>
      <td class="telemetry"  id="altitude">
      </td>
    </tr>
  </table>
  <div class="telemetry">Set refresh rate to <span>
    <select class="telemetry" name="refresh" id="refresh">
    <option value="100">0.1</option>
    <option value="500">0.5</option>
    <option value="1000">1.0</option>
    <option value="2000">2.0</option>
    <option value="5000" selected="selected">5.0</option>
    </select> seconds</span>
  </div>
  <div class="telemetry">
    <input class="telemetry" type="submit" value="update" id="setPreviewMinutes" onClick="Orb.createSatelliteTrack ()" />
    preview for the next <input class="telemetry" type="text" name="previewMinutes" id="previewMinutes" value="30" size="5" />
    minutes
  </div>
  <pre id="debug"></pre>
</body>
'''

  qs = parse_qs (environ['QUERY_STRING'], True)
  if qs.has_key ('longitude') and qs.has_key ('latitude') and qs.has_key ('altitude'):
    query = {
      'longitude': escape (qs.get ('longitude')[0]),
      'latitude': escape (qs.get ('latitude')[0]),
      'altitude': escape (qs.get ('altitude')[0])
      }
    if qs.has_key ('name'):
      query ['name'] = escape (qs.get ('name')[0])
    else:
      query ['name'] = 'unknown set'
  else:
    query = {
      'longitude': 15.44226,
      'latitude': 47.06576,
      'altitude': 376,
      'name': 'Graz'
      }

  body = body.format (**query)
  headers = ([('Content-Type', 'text/html'), ('Content-Length', str (len (body)))])
  response ('200 OK', headers)

  return [body]

# vim: tw=0 ts=2 expandtab
# EOF