Package mosp :: Package test :: Module test_utm
[hide private]
[frames] | no frames]

Source Code for Module mosp.test.test_utm

 1  """Tests for own UTM implementation""" 
 2   
 3  import sys 
 4  sys.path.extend(['.', '..','../..']) 
 5   
 6  import unittest 
 7  from mosp.geo import utm 
 8  from mosp.geo.osm import round_utm_coord 
 9   
10  __author__ = "F. Ludwig, P. Tute" 
11  __maintainer__ = "B. Henne" 
12  __contact__ = "henne@dcsec.uni-hannover.de" 
13  __copyright__ = "(c) 2010-2011, DCSec, Leibniz Universitaet Hannover, Germany" 
14  __license__ = "GPLv3" 
15   
16   
17 -class UTMTest(unittest.TestCase):
18 """Tests mosp.geo.utm basic functions""" 19
20 - def test_deg_to_rad(self):
21 """Tests deg_to_rad()""" 22 self.assertEqual(round_utm_coord(utm.deg_to_rad(57.3)), 1) 23 self.assertEqual(round_utm_coord(utm.deg_to_rad(114.59)), 2) 24 self.assertEqual(round_utm_coord(utm.deg_to_rad(171.89)), 3)
25
26 - def test_rad_to_deg(self):
27 """Tests rad_to_deg()""" 28 self.assertEqual(round(utm.rad_to_deg(1), 1), 57.3) 29 self.assertEqual(round(utm.rad_to_deg(2), 2), 114.59) 30 self.assertEqual(round(utm.rad_to_deg(3), 2), 171.89)
31
32 - def test_latlong_to_utm(self):
33 """Tests latlong_to_utm() 34 35 coordinates tested against: 36 http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html""" 37 coords = utm.latlong_to_utm(13.73, 51.03, 33) # , zone, [0, 0]) 38 self.assertEqual(round_utm_coord(coords[0]), 410943.61) 39 self.assertEqual(round_utm_coord(coords[1]), 5653928.43)
40
41 - def test_utm_to_latlong(self):
42 """Tests utm_to_latlong()""" 43 coords = utm.utm_to_latlong(410943.6064656443, 5653928.43291308, 33, False) 44 self.assertEqual(round(coords[0], 2), 13.73) 45 self.assertEqual(round(coords[1], 2), 51.03)
46 47
48 - def test_utm_latlong(self):
49 """Test utm to latlong and latlong to utm by trying 100 coordinates 50 in both functions. What about southern hemisphere?!??""" 51 for lat in xrange(10): 52 for lon in xrange(10): 53 zone = utm.long_to_zone(lon) 54 coords = utm.latlong_to_utm(lat, lon, zone) 55 coords = utm.utm_to_latlong(coords[0], coords[1], zone, False) 56 self.assertEqual(round_utm_coord(coords[0]), lat) 57 self.assertEqual(round_utm_coord(coords[1]), lon)
58 # !TODO: check southern hemisphere !!! 59
60 - def test_long_to_zone(self):
61 """Tests long_to_zone() 62 63 http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html""" 64 self.assertEqual(utm.long_to_zone(13.73), 33) 65 self.assertEqual(utm.long_to_zone(23.0), 34) 66 self.assertEqual(utm.long_to_zone(42.0), 38)
67 68 69 if __name__ == "__main__": 70 unittest.main() 71