- Timestamp:
- Feb 6, 2007, 2:28:47 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/geospatial_data/test_geospatial_data.py
r4202 r4223 7 7 from math import sqrt, pi 8 8 import tempfile 9 from sets import ImmutableSet 9 10 10 11 from anuga.geospatial_data.geospatial_data import * … … 162 163 assert allclose(results, points_rel) 163 164 164 165 166 def test_get_data_points_lat_long(self): 167 # lat long [-30.],[130] 168 #Zone: 52 169 #Easting: 596450.153 Northing: 6680793.777 170 # lat long [-32.],[131] 171 #Zone: 52 172 #Easting: 688927.638 Northing: 6457816.509 173 174 points_Lat_long = [[-30.,130], [-32,131]] 175 176 spatial = Geospatial_data(latitudes=[-30, -32.], 177 longitudes=[130, 131]) 178 179 results = spatial.get_data_points(as_lat_long=True) 180 #print "test_get_data_points_lat_long - results", results 181 #print "points_Lat_long",points_Lat_long 182 assert allclose(results, points_Lat_long) 183 184 def test_get_data_points_lat_longII(self): 185 # x,y North,east long,lat 186 boundary_polygon = [[ 250000, 7630000]] 187 zone = 50 188 189 geo_reference = Geo_reference(zone=zone) 190 geo = Geospatial_data(boundary_polygon,geo_reference=geo_reference) 191 seg_lat_long = geo.get_data_points(as_lat_long=True) 192 lat_result = degminsec2decimal_degrees(-21,24,54) 193 long_result = degminsec2decimal_degrees(114,35,17.89) 194 #print "seg_lat_long", seg_lat_long [0][0] 195 #print "lat_result",lat_result 196 assert allclose(seg_lat_long[0][0], lat_result)#lat 197 assert allclose(seg_lat_long[0][1], long_result)#long 198 199 165 200 def test_set_geo_reference(self): 166 201 points_ab = [[12.5,34.7],[-4.5,-60.0]] … … 1058 1093 1059 1094 def verbose_test_load_pts_blocking(self): 1060 """ test_load_csv(self): 1061 space delimited 1062 """ 1095 1063 1096 import os 1064 1097 … … 1130 1163 [10.0, 0.0]) 1131 1164 assert allclose(geo_list[1].get_data_points(), 1132 [[1.0, 0.0] ])1165 [[1.0, 0.0],[0.0, 1.0] ]) 1133 1166 assert allclose(geo_list[1].get_attributes(attribute_name='elevation'), 1134 [10. 4])1167 [10.0, 0.0]) 1135 1168 1136 1169 os.remove(fileName) … … 1981 2014 self.failUnless(0 ==1, 'Error not thrown error!') 1982 2015 2016 2017 def test_lat_long_set(self): 2018 lat_gong = degminsec2decimal_degrees(-34,30,0.) 2019 lon_gong = degminsec2decimal_degrees(150,55,0.) 2020 2021 lat_2 = degminsec2decimal_degrees(-34,00,0.) 2022 lon_2 = degminsec2decimal_degrees(150,00,0.) 2023 p1 = (lat_gong, lon_gong) 2024 p2 = (lat_2, lon_2) 2025 points = ImmutableSet([p1, p2, p1]) 2026 gsd = Geospatial_data(data_points=list(points), 2027 points_are_lats_longs=True) 2028 2029 points = gsd.get_data_points(absolute=True) 2030 2031 assert allclose(points[0][0], 308728.009) 2032 assert allclose(points[0][1], 6180432.601) 2033 assert allclose(points[1][0], 222908.705) 2034 assert allclose(points[1][1], 6233785.284) 2035 self.failUnless(gsd.get_geo_reference().get_zone() == 56, 2036 'Bad zone error!') 2037 points = gsd.get_data_points(as_lat_long=True) 2038 #print "test_lat_long_set points", points 2039 assert allclose(points[1][0], -34) 2040 assert allclose(points[1][1], 150) 2041 1983 2042 def test_len(self): 1984 2043 … … 2025 2084 if __name__ == "__main__": 2026 2085 2027 # suite = unittest.makeSuite(Test_Geospatial_data, 'test_split')2028 # suite = unittest.makeSuite(Test_Geospatial_data, 'test_clip0')2029 suite = unittest.makeSuite(Test_Geospatial_data, 'test')2086 suite = unittest.makeSuite(Test_Geospatial_data, 'test_lat_long_set') 2087 #suite = unittest.makeSuite(Test_Geospatial_data, 'verbose_test_load_pts_blocking') 2088 #suite = unittest.makeSuite(Test_Geospatial_data, 'test') 2030 2089 runner = unittest.TextTestRunner() 2031 2090 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.