From d07617fd3fb065a304ecdd53096e45954d07ee1e Mon Sep 17 00:00:00 2001 From: Jogi Hofmüller Date: Thu, 11 Aug 2011 08:45:41 +0000 Subject: - more Satellite code git-svn-id: https://svn.spreadspace.org/mur.sat@120 7de4ea59-55d0-425e-a1af-a3118ea81d4c --- tools/mmd/MmdSatellite.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'tools/mmd/MmdSatellite.py') diff --git a/tools/mmd/MmdSatellite.py b/tools/mmd/MmdSatellite.py index 1575648..8085773 100644 --- a/tools/mmd/MmdSatellite.py +++ b/tools/mmd/MmdSatellite.py @@ -47,16 +47,18 @@ class Satellite: self.db = Db () def getCurrentSSP (self): - pass + ssp = self._loadCurrentSSP () + return ssp['timestamp'], ssp['longitude'], ssp['latitude'] def getTrajectoryAsJavaArray (self, minutes = 180): - pass + # FIXME include java array code here + return self._loadTrajectory (minutes) def _loadTrajectory (self, minutes): - pass + return self.db.satelliteLoadTrajectory (time.strftime ('%s'), minutes) def _loadCurrentSSP (self): - pass + return self.db.satelliteLoadCurrentSSP (time.strftime ('%s')) def computeTrajectory (self): sat = ephem.readtle (self._tle[0], self._tle[1], self._tle[2]) @@ -96,10 +98,20 @@ class Satellite: if __name__ == "__main__": satellite = Satellite () + minutes = 30 try: assert satellite._loadTLE (), 'loading TLE failed' print satellite._tle assert satellite.computeTrajectory (), 'computing trajectory failed' + trajectory = satellite.getTrajectoryAsJavaArray (minutes) + assert trajectory, 'got not trajectory' + assert len (trajectory) == minutes, 'count={0}, minutes={1}'.format (len (trajectory), minutes) + print time.strftime ('%c', time.gmtime (float (time.strftime ('%s')))), time.strftime ('%s') + for t in trajectory: + print t['timestamp'], time.strftime ('%c', time.gmtime (t['timestamp'])) + t, lon, lat = satellite.getCurrentSSP () + assert t, 'loading current SSP failed' + print lon, lat, time.strftime ('%c', time.gmtime (t)) except AssertionError as e: print 'Error: {0}'.format (e) -- cgit v1.2.3