Changeset 3054 for inundation/utilities/test_polygon.py
- Timestamp:
- Jun 2, 2006, 3:02:36 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/utilities/test_polygon.py
r3052 r3054 5 5 from Numeric import zeros, array, allclose 6 6 from math import sqrt, pi 7 from utilities.numerical_tools import ensure_numeric 7 8 8 9 from polygon import * 9 10 from coordinate_transforms.geo_reference import Geo_reference 11 from geospatial_data.geospatial_data import Geospatial_data 10 12 11 13 def test_function(x, y): … … 631 633 632 634 633 def test_inside_polygon_geo_ref(self): 635 def test_inside_polygon_geospatial(self): 636 637 638 polygon_absolute = [[0,0], [1,0], [1,1], [0,1]] 639 poly_geo_ref = Geo_reference(57,100,100) 640 641 634 642 635 643 … … 638 646 poly_geo_ref = Geo_reference(57,100,100) 639 647 polygon = poly_geo_ref.change_points_geo_ref(polygon_absolute) 640 648 poly_spatial = Geospatial_data(polygon, 649 geo_reference=poly_geo_ref) 650 641 651 points_absolute = (0.5, 0.5) 642 652 points_geo_ref = Geo_reference(57,78,-56) 643 653 points = points_geo_ref.change_points_geo_ref(points_absolute) 654 points_spatial = Geospatial_data(points, 655 geo_reference=points_geo_ref) 656 657 assert is_inside_polygon(points_absolute, polygon_absolute) 658 assert is_inside_polygon(ensure_numeric(points_absolute), 659 ensure_numeric(polygon_absolute)) 660 assert is_inside_polygon(points_absolute, poly_spatial) 661 assert is_inside_polygon(points_spatial, poly_spatial) 662 assert is_inside_polygon(points_spatial, polygon_absolute) 644 663 645 664 assert is_inside_polygon(points_absolute, polygon_absolute) 646 665 647 points_inside = inside_polygon(points, polygon, 648 polygon_geo_ref=poly_geo_ref, 649 points_geo_ref=points_geo_ref) 650 #print "points_inside",points_inside 651 #assert 1 == len(inside_polygon( points, polygon, 652 # polygon_geo_ref=poly_geo_ref, 653 # points_geo_ref=points_geo_ref)) 654 assert not is_inside_polygon((0.5, 1.5), polygon, 655 polygon_geo_ref=poly_geo_ref ) 656 assert not is_inside_polygon((0.5, -0.5), polygon, 657 polygon_geo_ref=poly_geo_ref ) 658 assert not is_inside_polygon((-0.5, 0.5), polygon, 659 polygon_geo_ref=poly_geo_ref ) 660 assert not is_inside_polygon((1.5, 0.5), polygon, 661 polygon_geo_ref=poly_geo_ref ) 666 662 667 #------------------------------------------------------------- 663 668 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.