Changeset 3717
- Timestamp:
- Oct 9, 2006, 5:25:58 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/geospatial_data/test_geospatial_data.py
r3714 r3717 422 422 [[0.5, 0.5], [1, -0.5], [1.5, 0]]) 423 423 424 425 424 def test_clip0_outside(self): 426 """test_clip0 (self):425 """test_clip0_outside(self): 427 426 428 427 Test that point sets can be clipped outside of a polygon … … 450 449 451 450 def test_clip1_outside(self): 452 """test_clip1(self): 453 454 Test that point sets can be clipped outside of a polygon given as 455 another Geospatial dataset 456 """ 457 458 from anuga.coordinate_transforms.geo_reference import Geo_reference 459 460 points = [[-1, 4], [0.2, 0.5], [1.0, 2.1], [0.4, 0.3], [3.0, 5.3], 461 [0, 0], [2.4, 3.3]] 462 G = Geospatial_data(points) 463 464 # First try the unit square 465 U = Geospatial_data([[0,0], [1,0], [1,1], [0,1]]) 466 assert allclose(G.clip_outside(U).get_data_points(), 467 [[-1, 4], [1.0, 2.1], [3.0, 5.3], [2.4, 3.3]]) 468 469 # Then a more complex polygon 470 points = [ [0.5, 1.4], [0.5, 0.5], [1, -0.5], [1.5, 0], [0.5, 1.5], [0.5, -0.5]] 471 G = Geospatial_data(points) 472 polygon = Geospatial_data([[0,0], [1,0], [0.5,-1], [2, -1], [2,1], [0,1]]) 473 474 475 assert allclose(G.clip_outside(polygon).get_data_points(), 476 [[0.5, 1.4], [0.5, 1.5], [0.5, -0.5]]) 477 478 451 """test_clip1_outside(self): 452 453 Test that point sets can be clipped outside of a polygon given as 454 another Geospatial dataset 455 """ 456 457 from anuga.coordinate_transforms.geo_reference import Geo_reference 458 459 points = [[-1, 4], [0.2, 0.5], [1.0, 2.1], [0.4, 0.3], [3.0, 5.3], 460 [0, 0], [2.4, 3.3]] 461 G = Geospatial_data(points) 462 463 # First try the unit square 464 U = Geospatial_data([[0,0], [1,0], [1,1], [0,1]]) 465 assert allclose(G.clip_outside(U).get_data_points(), 466 [[-1, 4], [1.0, 2.1], [3.0, 5.3], [2.4, 3.3]]) 467 468 # Then a more complex polygon 469 points = [ [0.5, 1.4], [0.5, 0.5], [1, -0.5], [1.5, 0], [0.5, 1.5], [0.5, -0.5]] 470 G = Geospatial_data(points) 471 polygon = Geospatial_data([[0,0], [1,0], [0.5,-1], [2, -1], [2,1], [0,1]]) 472 473 474 assert allclose(G.clip_outside(polygon).get_data_points(), 475 [[0.5, 1.4], [0.5, 1.5], [0.5, -0.5]]) 476 477 478 def no_test_clip1_inside_outside(self): 479 """test_clip1_inside_outside(self): 480 481 Test that point sets can be clipped outside of a polygon given as 482 another Geospatial dataset 483 """ 484 485 from anuga.coordinate_transforms.geo_reference import Geo_reference 486 487 points = [[-1, 4], [0.2, 0.5], [1.0, 2.1], [0.4, 0.3], [3.0, 5.3], 488 [0, 0], [2.4, 3.3]] 489 G = Geospatial_data(points) 490 491 # First try the unit square 492 U = Geospatial_data([[0,0], [1,0], [1,1], [0,1]]) 493 G1 = G.clip(U) 494 G2 = G.clip_outside(U) 495 496 assert allclose((G1+G2).get_data_points(),points) 479 497 480 498 def test_create_from_xya_file(self):
Note: See TracChangeset
for help on using the changeset viewer.