source: trunk/anuga_core/source/anuga/coordinate_transforms/test_lat_long_UTM_conversion.py @ 7967

Last change on this file since 7967 was 7779, checked in by hudson, 14 years ago

Fixed wrong exception module import paths.

File size: 3.9 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
9
10from lat_long_UTM_conversion import *
11from redfearn import degminsec2decimal_degrees, decimal_degrees2degminsec
12from anuga.anuga_exceptions import ANUGAError
13
14import numpy as num
15
16
17#-------------------------------------------------------------
18
19class TestCase(unittest.TestCase):
20
21    def test_UTM_1(self):
22        #latitude:  -37 39' 10.15610"
23        #Longitude: 143 55' 35.38390"
24        #Site Name:    GDA-MGA: (UTM with GRS80 ellipsoid)
25        #Zone:   54   
26        #Easting:  758173.797  Northing: 5828674.340
27        #Latitude:   -37  39 ' 10.15610 ''  Longitude: 143  55 ' 35.38390 ''
28        #Grid Convergence:  1  47 ' 19.36 ''  Point Scale: 1.00042107
29
30        lat = degminsec2decimal_degrees(-37,39,10.15610)
31        lon = degminsec2decimal_degrees(143,55,35.38390) 
32        assert num.allclose(lat, -37.65282114)
33        assert num.allclose(lon, 143.9264955)
34
35
36        zone, easting, northing = LLtoUTM(lat,lon)
37
38        assert zone == 54
39        assert num.allclose(easting, 758173.797)
40        assert num.allclose(northing, 5828674.340)
41
42        lat_calced, long_calced = UTMtoLL(northing, easting, zone) 
43        assert num.allclose(lat,  lat_calced)
44        assert num.allclose(lon, long_calced)
45
46
47    def test_UTM_2(self):
48        #TEST 2
49
50        #Latitude:  -37 57 03.7203
51        #Longitude: 144 25 29.5244
52        #Zone:   55   
53        #Easting:  273741.297  Northing: 5796489.777
54        #Latitude:   -37  57 ' 3.72030 ''  Longitude: 144  25 ' 29.52440 ''
55        #Grid Convergence:  -1  35 ' 3.65 ''  Point Scale: 1.00023056
56
57        lat = degminsec2decimal_degrees(-37,57,03.7203)
58        lon = degminsec2decimal_degrees(144,25,29.5244) 
59
60        zone, easting, northing = LLtoUTM(lat,lon)
61
62       
63        assert zone == 55
64        assert num.allclose(easting, 273741.297)
65        assert num.allclose(northing, 5796489.777)
66
67        lat_calced, long_calced = UTMtoLL(northing, easting, zone) 
68        assert num.allclose(lat,  lat_calced)
69        assert num.allclose(lon, long_calced)
70       
71       
72    def test_UTM_3(self):
73        #Test 3
74        lat = degminsec2decimal_degrees(-60,0,0)
75        lon = degminsec2decimal_degrees(130,0,0) 
76
77        zone, easting, northing = LLtoUTM(lat,lon)
78
79        assert zone == 52
80        assert num.allclose(easting, 555776.267)
81        assert num.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 num.allclose(easting, 348157.631)
97        assert num.allclose(northing, 6175612.993) 
98
99        lat_calced, long_calced = UTMtoLL(northing, easting, zone,
100                                          isSouthernHemisphere=False) 
101        assert num.allclose(lat,  lat_calced)
102        assert num.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
113        assert zone == 56
114        assert num.allclose(easting, 308728.009)
115        assert num.allclose(northing, 6180432.601)
116
117        lat_calced, long_calced = UTMtoLL(northing, easting, zone) 
118        assert num.allclose(lat,  lat_calced)
119        assert num.allclose(lon, long_calced)
120
121#-------------------------------------------------------------
122
123if __name__ == "__main__":
124    mysuite = unittest.makeSuite(TestCase,'test')
125    runner = unittest.TextTestRunner()
126    runner.run(mysuite)
Note: See TracBrowser for help on using the repository browser.