From 9ec0b02148363742768cc5cf5698b67a8ea19cfd Mon Sep 17 00:00:00 2001 From: Jogi Hofmüller Date: Tue, 9 Aug 2011 19:02:08 +0000 Subject: - we are tracking ARISSAT-1 now ;) git-svn-id: https://svn.spreadspace.org/mur.sat@106 7de4ea59-55d0-425e-a1af-a3118ea81d4c --- tools/mmd/MmdWidgets.py | 95 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 85 insertions(+), 10 deletions(-) (limited to 'tools/mmd/MmdWidgets.py') diff --git a/tools/mmd/MmdWidgets.py b/tools/mmd/MmdWidgets.py index 4f0d582..accb87e 100644 --- a/tools/mmd/MmdWidgets.py +++ b/tools/mmd/MmdWidgets.py @@ -3,8 +3,54 @@ web widgets for MURSAT1 Dashboard """ import time +import ephem from MmdLocation import Location +def createJavaArray (jarray, name): + astring = '''var {0} = new Array ('''.format (name) + for e in jarray: + astring = '''{0}\n\t{1}'''.format (astring, e) + astring = '''{0}\n);'''.format (astring) + return astring + +def dms2degdec (lonlat): + parts = lonlat.split (':') + if len (parts) != 3: + return 0.0 + degrees = float (parts[0]) + fraction = (float (parts[1]) * 60.0 + float (parts[2])) / 3600 + if parts[0][0] == '-': + return degrees - fraction + return degrees + fraction + +def computeTrajectory (longitude, latitude, elevation): + """ + test for static TLE to trajectory computation + """ + line0 = "ARISSAT-1/RADIOSCAF-B" + line1 = "1 37772U 98067CK 11220.22334818 .00031592 00000-0 37647-3 0 118" + line2 = "2 37772 51.6391 258.8215 0013530 58.1430 19.7106 15.60689826 619" + + sat = ephem.readtle (line0, line1, line2) + graz = ephem.Observer () + graz.long, graz.lat, graz.elevation = longitude, latitude, elevation + + sat.compute (graz) + array_string = 'new OpenLayers.LonLat ({0}, {1}).transform (from, to){2}' + longitude = dms2degdec (sat.sublong.__str__ ()) + latitude = dms2degdec (sat.sublat.__str__ ()) + java_array = [array_string.format (dms2degdec (sat.sublong.__str__ ()), dms2degdec (sat.sublat.__str__ ()), ',')] + for i in range (12 * 24): + graz.date += 5 * ephem.minute + sat.compute (graz) + java_array.append (array_string.format (dms2degdec (sat.sublong.__str__ ()), dms2degdec (sat.sublat.__str__ ()), ',')) + + graz.date += 5 * ephem.minute + sat.compute (graz) + java_array.append (array_string.format (dms2degdec (sat.sublong.__str__ ()), dms2degdec (sat.sublat.__str__ ()), '')) + + return longitude, latitude, createJavaArray (java_array, 'trajectory') + def loginFormWidget (): html = ''' Please enter your email and password in the form below. @@ -155,30 +201,59 @@ def osmWidget (satellite, user): user_location = user.getDefaultLocation () if not user_location: user_location = Location () + longitude, latitude, java = computeTrajectory (user_location.longitude, user_location.latitude, 300) + + # + # how can we use { and } in javascript that can be ignored by python format ()? + # html = '''
- - '''.format (satellite['longitude'], satellite['latitude'], user_location.longitude, user_location.latitude) + '''.format (longitude, latitude, user_location.longitude, user_location.latitude, java) return html -- cgit v1.2.3