Changeset 3056 for inundation/pmesh


Ignore:
Timestamp:
Jun 2, 2006, 3:10:48 PM (19 years ago)
Author:
duncan
Message:

Fixing mesh_interface tests. geospatial_data.py now has ensure_geospatial.

Location:
inundation/pmesh
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inundation/pmesh/mesh_interface.py

    r3051 r3056  
    1717    from mesh import Mesh
    1818
     19import exceptions
     20class PolygonError(exceptions.Exception): pass
    1921
    2022def create_mesh_from_regions(bounding_polygon,
     
    4446
    4547    poly_geo_reference is the geo_reference of the polygons.
     48    The bounding polygon and the interior polygons
    4649    If none, assume absolute.  Please pass one though, since absolute
    4750    references have a zone.
     
    6164    # To do make maximum_triangle_area optional?
    6265    # check the segment indexes - throw an error if they are out of bounds
    63     #
     66    #(DSG) Yes!
     67   
    6468    #In addition I reckon the polygons could be of class Geospatial_data
    65 
     69    #(DSG) Yes!
    6670
    6771    # First check that interior polygons are fully contained in bounding polygon
    68 
    69     # FIXME (Ole): This causes the tests to fail because coordinates have been
    70     # converted to relative coordinates (I think). How can we simplify this?
    71     #
    72     #FIXME (DSG-DSG) this code does not take into account geo-referencing
    73     #if interior_regions is not None:       
     72    #Note, Both poly's have the same geo_ref, therefore don't take into account
     73    # geo_ref
     74    if interior_regions is not None:       
    7475     
    75      #   for interior_polygon, res in interior_regions:
    76       #      indices = inside_polygon(interior_polygon, bounding_polygon,
    77        #                              closed = True, verbose = False)
     76        for interior_polygon, res in interior_regions:
     77            indices = inside_polygon(interior_polygon, bounding_polygon,
     78                                     closed = True, verbose = False)
    7879   
    79        #     if len(indices) <> len(interior_polygon):
    80         #        msg = 'Interior polygon %s is outside bounding polygon: %s'\
    81          #             %(str(interior_polygon), str(bounding_polygon))
    82           #      raise msg
     80            if len(indices) <> len(interior_polygon):
     81                msg = 'Interior polygon %s is outside bounding polygon: %s'\
     82                      %(str(interior_polygon), str(bounding_polygon))
     83                raise PolygonError, msg
    8384
    8485
  • inundation/pmesh/test_mesh_interface.py

    r3052 r3056  
    113113
    114114        # These are the absolute values
    115         min_x = 10
    116         min_y = 88
     115        min_x = -10
     116        min_y = -88
    117117        polygon_absolute = [[min_x,min_y],[1000,100],[1000,1000],[100,1000]]
    118118       
     
    170170
    171171        # These are the absolute values
    172         min_x = 10
    173         min_y = 88
     172        min_x = -10
     173        min_y = -88
    174174        polygon = [[min_x,min_y],[1000,100],[1000,1000],[100,1000]]
    175175       
     
    221221                        'FAILED!')
    222222
    223     def NOT_IMPLEMEMTED_test_create_mesh_from_regions_interior_regions(self):
     223    def test_create_mesh_from_regions_interior_regions(self):
    224224        ### Test that create_mesh_from_regions fails when an interior region is
    225225        ### outside bounding polygon.
     
    301301    suite = unittest.makeSuite(TestCase,'test')
    302302    #suite = unittest.makeSuite(meshTestCase,'test_asciiFile')
    303     runner = unittest.TextTestRunner(verbosity=2) #verbosity=2)
     303    runner = unittest.TextTestRunner() #verbosity=2)
    304304    runner.run(suite)
    305305   
Note: See TracChangeset for help on using the changeset viewer.