source: anuga_core/source/anuga/coordinate_transforms/test_lat_long_UTM_conversion.py @ 5421

Last change on this file since 5421 was 4197, checked in by duncan, 17 years ago

converting utm to lat, long

File size: 4.1 KB
Line 
1
2#Test of redfearns formula. Tests can be verified at
3#
4#http://www.cellspark.com/UTM.html
5#http://www.ga.gov.au/nmd/geodesy/datums/redfearn_geo_to_grid.jsp
6
7
8import unittest
9from Numeric import allclose
10
11from lat_long_UTM_conversion import *
12from redfearn import degminsec2decimal_degrees, decimal_degrees2degminsec
13from anuga.utilities.anuga_exceptions import ANUGAError
14
15#-------------------------------------------------------------
16
17class TestCase(unittest.TestCase):
18
19    def test_UTM_1(self):
20        #latitude:  -37 39' 10.15610"
21        #Longitude: 143 55' 35.38390"
22        #Site Name:    GDA-MGA: (UTM with GRS80 ellipsoid)
23        #Zone:   54   
24        #Easting:  758173.797  Northing: 5828674.340
25        #Latitude:   -37  39 ' 10.15610 ''  Longitude: 143  55 ' 35.38390 ''
26        #Grid Convergence:  1  47 ' 19.36 ''  Point Scale: 1.00042107
27
28        lat = degminsec2decimal_degrees(-37,39,10.15610)
29        lon = degminsec2decimal_degrees(143,55,35.38390) 
30        assert allclose(lat, -37.65282114)
31        assert allclose(lon, 143.9264955)
32
33
34        zone, easting, northing = LLtoUTM(lat,lon)
35
36        assert zone == 54
37        assert allclose(easting, 758173.797)
38        assert allclose(northing, 5828674.340)
39
40        lat_calced, long_calced = UTMtoLL(northing, easting, zone) 
41        assert allclose(lat,  lat_calced)
42        assert allclose(lon, long_calced)
43
44
45    def test_UTM_2(self):
46        #TEST 2
47
48        #Latitude:  -37 57 03.7203
49        #Longitude: 144 25 29.5244
50        #Zone:   55   
51        #Easting:  273741.297  Northing: 5796489.777
52        #Latitude:   -37  57 ' 3.72030 ''  Longitude: 144  25 ' 29.52440 ''
53        #Grid Convergence:  -1  35 ' 3.65 ''  Point Scale: 1.00023056
54
55        lat = degminsec2decimal_degrees(-37,57,03.7203)
56        lon = degminsec2decimal_degrees(144,25,29.5244) 
57        #print lat, lon
58
59        zone, easting, northing = LLtoUTM(lat,lon)
60
61       
62        assert zone == 55
63        assert allclose(easting, 273741.297)
64        assert allclose(northing, 5796489.777)
65
66        lat_calced, long_calced = UTMtoLL(northing, easting, zone) 
67        assert allclose(lat,  lat_calced)
68        assert allclose(lon, long_calced)
69       
70       
71    def test_UTM_3(self):
72        #Test 3
73        lat = degminsec2decimal_degrees(-60,0,0)
74        lon = degminsec2decimal_degrees(130,0,0) 
75
76        zone, easting, northing = LLtoUTM(lat,lon)
77        #print zone, easting, northing
78
79        assert zone == 52
80        assert allclose(easting, 555776.267)
81        assert allclose(northing, 3348167.264)
82
83        Lat, Long = UTMtoLL(northing, easting, zone)
84
85    def test_UTM_4(self):
86        #Test 4 (Kobenhavn, Northern hemisphere)
87        lat = 55.70248
88        dd,mm,ss = decimal_degrees2degminsec(lat)
89
90        lon = 12.58364
91        dd,mm,ss = decimal_degrees2degminsec(lon)
92
93        zone, easting, northing = LLtoUTM(lat,lon)
94       
95        assert zone == 33
96        assert allclose(easting, 348157.631)
97        assert allclose(northing, 6175612.993) 
98
99        lat_calced, long_calced = UTMtoLL(northing, easting, zone,
100                                          isSouthernHemisphere=False) 
101        assert allclose(lat,  lat_calced)
102        assert allclose(lon, long_calced)
103
104    def test_UTM_5(self):
105        #Test 5 (Wollongong)
106
107        lat = degminsec2decimal_degrees(-34,30,0.)
108        lon = degminsec2decimal_degrees(150,55,0.) 
109       
110        zone, easting, northing = LLtoUTM(lat,lon)
111
112        #print zone, easting, northing
113
114        assert zone == 56
115        assert allclose(easting, 308728.009)
116        assert allclose(northing, 6180432.601)
117
118        lat_calced, long_calced = UTMtoLL(northing, easting, zone) 
119        assert allclose(lat,  lat_calced)
120        assert allclose(lon, long_calced)
121#-------------------------------------------------------------
122if __name__ == "__main__":
123
124    #mysuite = unittest.makeSuite(TestCase,'test_convert_latlon_to_UTM1')
125    mysuite = unittest.makeSuite(TestCase,'test')
126    runner = unittest.TextTestRunner()
127    runner.run(mysuite)
Note: See TracBrowser for help on using the repository browser.