Changeset 3723 for anuga_core/source/anuga
- Timestamp:
- Oct 10, 2006, 12:10:07 PM (18 years ago)
- Location:
- anuga_core/source/anuga/geospatial_data
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/geospatial_data/geospatial_data.py
r3714 r3723 376 376 377 377 # sets xll and yll as the smallest from self and other 378 # FIXME (Duncan and Ole): use lower left corner derived from absolute coordinates 378 # FIXME (Duncan and Ole): use lower left corner derived from 379 # absolute coordinates 379 380 if self.geo_reference.xllcorner <= other.geo_reference.xllcorner: 380 381 xll = self.geo_reference.xllcorner … … 394 395 395 396 396 new_relative_points1 = new_geo_ref.change_points_geo_ref(relative_points1, geo_ref1) 397 new_relative_points2 = new_geo_ref.change_points_geo_ref(relative_points2, geo_ref2) 398 399 #Now both point sets are relative to new_geo_ref and zones have been reconciled 397 new_relative_points1 = new_geo_ref.\ 398 change_points_geo_ref(relative_points1, 399 geo_ref1) 400 new_relative_points2 = new_geo_ref.\ 401 change_points_geo_ref(relative_points2, 402 geo_ref2) 403 404 # Now both point sets are relative to new_geo_ref and 405 # zones have been reconciled 400 406 401 407 # Concatenate points … … 404 410 axis = 0) 405 411 406 # Concatenate attributes 407 new_attributes = {} 408 for x in self.attributes.keys(): 409 if other.attributes.has_key(x): 410 411 attrib1 = self.attributes[x] 412 attrib2 = other.attributes[x] 413 new_attributes[x] = concatenate((attrib1, attrib2)) 414 415 else: 412 # Concatenate attributes if any 413 if self.attributes is None: 414 if other.attributes is not None: 416 415 msg = 'Both geospatial_data objects must have the same \n' 417 416 msg += 'attributes to allow addition.' 418 raise msg 417 raise Exception, msg 418 419 new_attributes = None 420 else: 421 new_attributes = {} 422 for x in self.attributes.keys(): 423 if other.attributes.has_key(x): 424 425 attrib1 = self.attributes[x] 426 attrib2 = other.attributes[x] 427 new_attributes[x] = concatenate((attrib1, attrib2)) 428 429 else: 430 msg = 'Both geospatial_data objects must have the same \n' 431 msg += 'attributes to allow addition.' 432 raise Exception, msg 419 433 420 434 # Instantiate new data object and return -
anuga_core/source/anuga/geospatial_data/test_geospatial_data.py
r3717 r3723 476 476 477 477 478 def no_test_clip1_inside_outside(self):478 def test_clip1_inside_outside(self): 479 479 """test_clip1_inside_outside(self): 480 480 … … 487 487 points = [[-1, 4], [0.2, 0.5], [1.0, 2.1], [0.4, 0.3], [3.0, 5.3], 488 488 [0, 0], [2.4, 3.3]] 489 489 490 G = Geospatial_data(points) 490 491 … … 492 493 U = Geospatial_data([[0,0], [1,0], [1,1], [0,1]]) 493 494 G1 = G.clip(U) 495 assert allclose(G1.get_data_points(),[[0.2, 0.5], [0.4, 0.3], [0, 0]]) 496 494 497 G2 = G.clip_outside(U) 495 496 assert allclose((G1+G2).get_data_points(),points) 498 assert allclose(G2.get_data_points(),[[-1, 4], [1.0, 2.1], 499 [3.0, 5.3], [2.4, 3.3]]) 500 501 502 # New ordering 503 new_points = [[0.2, 0.5], [0.4, 0.3], [0, 0]] +\ 504 [[-1, 4], [1.0, 2.1], [3.0, 5.3], [2.4, 3.3]] 505 506 assert allclose((G1+G2).get_data_points(), new_points) 507 497 508 498 509 def test_create_from_xya_file(self):
Note: See TracChangeset
for help on using the changeset viewer.