- Timestamp:
- Jan 31, 2007, 3:20:39 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/geospatial_data/test_geospatial_data.py
r4199 r4202 162 162 assert allclose(results, points_rel) 163 163 164 165 def DSG_test_get_data_points_lat_long(self): 166 # lat long [-30.],[130] 167 #Zone: 52 168 #Easting: 596450.153 Northing: 6680793.777 169 # lat long [-32.],[131] 170 #Zone: 52 171 #Easting: 688927.638 Northing: 6457816.509 172 173 points_Lat_long = [[-30.,130], [-32,131]] 174 175 spatial = Geospatial_data(latitudes=[-30, -32.], 176 longitudes=[130, 131]) 177 178 results = spatial.get_data_points() 179 print "results UTM",results 180 181 results = spatial.get_data_points(as_lat_long=True) 182 print "results",results 183 assert allclose(results, points_rel) 184 185 x_p = -1770 186 y_p = 4.01 187 geo_ref = Geo_reference(56, x_p, y_p) 188 points_rel = geo_ref.change_points_geo_ref(points_ab) 189 results = spatial.get_data_points \ 190 ( geo_reference=geo_ref) 191 192 assert allclose(results, points_rel) 193 194 164 195 165 def test_set_geo_reference(self): 196 166 points_ab = [[12.5,34.7],[-4.5,-60.0]] … … 710 680 [0.0, 10.0, 40.0]) 711 681 712 def test_load_csv(self):713 714 import os715 import tempfile716 717 fileName = tempfile.mktemp(".csv")718 file = open(fileName,"w")719 file.write("lat,long,elevation speed \n\720 1.0 0.0 10.0 0.0\n\721 0.0 1.0 0.0 10.0\n\722 1.0 0.0 10.4 40.0\n")723 file.close()724 #print fileName725 results = Geospatial_data(fileName, delimiter=',')726 os.remove(fileName)727 # print 'data', results.get_data_points()728 assert allclose(results.get_data_points(), [[1.0, 0.0],[0.0, 1.0],729 [1.0, 0.0]])730 assert allclose(results.get_attributes(attribute_name='elevation'),731 [10.0, 0.0, 10.4])732 assert allclose(results.get_attributes(attribute_name='speed'),733 [0.0, 10.0, 40.0])734 735 682 736 683 def test_load_xya(self): … … 1898 1845 fileName = tempfile.mktemp(".csv") 1899 1846 file = open(fileName,"w") 1900 file.write("long,lat, z\n\1901 150.916666667,-34.50,452.688000 \n\1902 150.0,-34,459.126000 \n")1847 file.write("long,lat, elevation, yeah \n\ 1848 150.916666667,-34.50,452.688000, 10\n\ 1849 150.0,-34,459.126000, 10\n") 1903 1850 file.close() 1904 1851 results = Geospatial_data(fileName, delimiter=',') … … 1906 1853 points = results.get_data_points() 1907 1854 1908 1909 assert allclose(points[0][0], 6180432.601) 1910 assert allclose(points[0][1], 308728.009) 1911 assert allclose(points[1][0], 6233785.284) 1912 assert allclose(points[1][1], 222908.705) 1855 assert allclose(points[0][0], 308728.009) 1856 assert allclose(points[0][1], 6180432.601) 1857 assert allclose(points[1][0], 222908.705) 1858 assert allclose(points[1][1], 6233785.284) 1913 1859 1914 1860 … … 1928 1874 points = results.get_data_points() 1929 1875 1930 assert allclose(points[0][0], 6180432.601)1931 assert allclose(points[0][1], 308728.009)1932 assert allclose(points[1][0], 6233785.284)1933 assert allclose(points[1][1], 222908.705)1934 1876 assert allclose(points[0][0], 308728.009) 1877 assert allclose(points[0][1], 6180432.601) 1878 assert allclose(points[1][0], 222908.705) 1879 assert allclose(points[1][1], 6233785.284) 1880 1935 1881 1936 1882 def test_load_csv_lat_long_bad(self): … … 1956 1902 1957 1903 def test_lat_long(self): 1958 #Zone: 561959 #Easting: 308728.009 Northing: 6180432.6011960 #Latitude: -34 30 ' 0.00000 '' Longitude: 150 55 ' 0.00000 ''1961 1962 1904 lat_gong = degminsec2decimal_degrees(-34,30,0.) 1963 1905 lon_gong = degminsec2decimal_degrees(150,55,0.) … … 1972 1914 points = gsd.get_data_points(absolute=True) 1973 1915 1974 assert allclose(points[0][0], 6180432.601)1975 assert allclose(points[0][1], 308728.009)1976 assert allclose(points[1][0], 6233785.284)1977 assert allclose(points[1][1], 222908.705)1916 assert allclose(points[0][0], 308728.009) 1917 assert allclose(points[0][1], 6180432.601) 1918 assert allclose(points[1][0], 222908.705) 1919 assert allclose(points[1][1], 6233785.284) 1978 1920 self.failUnless(gsd.get_geo_reference().get_zone() == 56, 1979 1921 'Bad zone error!') … … 2025 1967 points = gsd.get_data_points(absolute=True) 2026 1968 2027 assert allclose(points[0][0], 6180432.601) 2028 assert allclose(points[0][1], 308728.009) 2029 assert allclose(points[1][0], 6233785.284) 2030 assert allclose(points[1][1], 222908.705) 2031 1969 assert allclose(points[0][0], 308728.009) 1970 assert allclose(points[0][1], 6180432.601) 1971 assert allclose(points[1][0], 222908.705) 1972 assert allclose(points[1][1], 6233785.284) 2032 1973 self.failUnless(gsd.get_geo_reference().get_zone() == 56, 2033 1974 'Bad zone error!')
Note: See TracChangeset
for help on using the changeset viewer.