source: branches/numpy/anuga/coordinate_transforms/test_lat_long_UTM_conversion.py @ 6410

Last change on this file since 6410 was 6410, checked in by rwilson, 16 years ago

numpy changes.

File size: 4.0 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.utilities.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        #print lat, lon
60
61        zone, easting, northing = LLtoUTM(lat,lon)
62
63       
64        assert zone == 55
65        assert num.allclose(easting, 273741.297)
66        assert num.allclose(northing, 5796489.777)
67
68        lat_calced, long_calced = UTMtoLL(northing, easting, zone) 
69        assert num.allclose(lat,  lat_calced)
70        assert num.allclose(lon, long_calced)
71       
72       
73    def test_UTM_3(self):
74        #Test 3
75        lat = degminsec2decimal_degrees(-60,0,0)
76        lon = degminsec2decimal_degrees(130,0,0) 
77
78        zone, easting, northing = LLtoUTM(lat,lon)
79        #print zone, easting, northing
80
81        assert zone == 52
82        assert num.allclose(easting, 555776.267)
83        assert num.allclose(northing, 3348167.264)
84
85        Lat, Long = UTMtoLL(northing, easting, zone)
86
87    def test_UTM_4(self):
88        #Test 4 (Kobenhavn, Northern hemisphere)
89        lat = 55.70248
90        dd,mm,ss = decimal_degrees2degminsec(lat)
91
92        lon = 12.58364
93        dd,mm,ss = decimal_degrees2degminsec(lon)
94
95        zone, easting, northing = LLtoUTM(lat,lon)
96       
97        assert zone == 33
98        assert num.allclose(easting, 348157.631)
99        assert num.allclose(northing, 6175612.993) 
100
101        lat_calced, long_calced = UTMtoLL(northing, easting, zone,
102                                          isSouthernHemisphere=False) 
103        assert num.allclose(lat,  lat_calced)
104        assert num.allclose(lon, long_calced)
105
106    def test_UTM_5(self):
107        #Test 5 (Wollongong)
108
109        lat = degminsec2decimal_degrees(-34,30,0.)
110        lon = degminsec2decimal_degrees(150,55,0.) 
111       
112        zone, easting, northing = LLtoUTM(lat,lon)
113
114        #print zone, easting, northing
115
116        assert zone == 56
117        assert num.allclose(easting, 308728.009)
118        assert num.allclose(northing, 6180432.601)
119
120        lat_calced, long_calced = UTMtoLL(northing, easting, zone) 
121        assert num.allclose(lat,  lat_calced)
122        assert num.allclose(lon, long_calced)
123
124#-------------------------------------------------------------
125
126if __name__ == "__main__":
127    mysuite = unittest.makeSuite(TestCase,'test')
128    runner = unittest.TextTestRunner()
129    runner.run(mysuite)
Note: See TracBrowser for help on using the repository browser.