Changeset 3297
- Timestamp:
- Jul 10, 2006, 4:22:33 PM (17 years ago)
- Location:
- inundation/geospatial_data
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/geospatial_data/geospatial_data.py
r3280 r3297 23 23 latitudes = None, 24 24 longitudes = None, 25 points_are_lats_longs = False, 25 26 verbose = False): 26 27 … … 105 106 raise ValueError, msg 106 107 file_name = None 107 if latitudes is not None or longitudes is not None: 108 if latitudes is not None or longitudes is not None or \ 109 points_are_lats_longs: 108 110 data_points, geo_reference = \ 109 111 self._set_using_lat_long(latitudes=latitudes, 110 longitudes=longitudes, 111 geo_reference=geo_reference, 112 data_points=data_points) 112 longitudes=longitudes, 113 geo_reference=geo_reference, 114 data_points=data_points, 115 points_are_lats_longs=points_are_lats_longs) 113 116 self.check_data_points(data_points) 114 117 self.set_attributes(attributes) … … 202 205 longitudes, 203 206 geo_reference, 204 data_points): 207 data_points, 208 points_are_lats_longs): 205 209 if geo_reference is not None: 206 210 msg = """A georeference is specified yet latitude and longitude are also specified!""" 207 211 raise ValueError, msg 208 209 if data_points is not None: 212 if data_points is not None and not points_are_lats_longs: 210 213 msg = """Data points are specified yet latitude and longitude are also specified!""" 214 raise ValueError, msg 215 216 if points_are_lats_longs: 217 if data_points is None: 218 msg = """Data points are not specified !""" 219 raise ValueError, msg 220 lats_longs = ensure_numeric(data_points) 221 latitudes = lats_longs[:,0:1] 222 longitudes = lats_longs[:,1:] 223 224 if latitudes is None and longitudes is None: 225 msg = """Latitudes and Longitudes are not.""" 211 226 raise ValueError, msg 212 227 … … 216 231 217 232 if longitudes is None: 218 msg = """ latitudes are specified yet longitudes aren't!"""233 msg = """Latitudes are specified yet longitudes aren't!""" 219 234 raise ValueError, msg 220 235 -
inundation/geospatial_data/test_geospatial_data.py
r3292 r3297 1302 1302 else: 1303 1303 self.failUnless(0 ==1, 'Error not thrown error!') 1304 1304 1305 def test_lat_long2(self): 1306 lat_gong = degminsec2decimal_degrees(-34,30,0.) 1307 lon_gong = degminsec2decimal_degrees(150,55,0.) 1308 1309 lat_2 = degminsec2decimal_degrees(-34,00,0.) 1310 lon_2 = degminsec2decimal_degrees(150,00,0.) 1311 1312 points = [[lat_gong, lon_gong], [lat_2, lon_2]] 1313 gsd = Geospatial_data(data_points=points, points_are_lats_longs=True) 1314 1315 points = gsd.get_data_points(absolute=True) 1316 1317 assert allclose(points[0][0], 308728.009) 1318 assert allclose(points[0][1], 6180432.601) 1319 assert allclose(points[1][0], 222908.705) 1320 assert allclose(points[1][1], 6233785.284) 1321 self.failUnless(gsd.get_geo_reference().get_zone() == 56, 1322 'Bad zone error!') 1323 1324 try: 1325 results = Geospatial_data(points_are_lats_longs=True) 1326 except ValueError: 1327 pass 1328 else: 1329 self.failUnless(0 ==1, 'Error not thrown error!') 1330 1305 1331 if __name__ == "__main__": 1306 1332
Note: See TracChangeset
for help on using the changeset viewer.