Ignore:
Timestamp:
Feb 9, 2006, 2:37:57 PM (19 years ago)
Author:
ole
Message:

Added georeferencing to polygon_function and added test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/utilities/test_polygon.py

    r2311 r2375  
    5656
    5757
     58    def test_polygon_function_georef(self):
     59        """Check that georeferencing works
     60        """
     61
     62        from coordinate_transforms.geo_reference import Geo_reference
     63
     64        geo = Geo_reference(56, 200, 1000)
     65
     66        #Make points 'absolute'
     67        p1 = [[200,1000], [210,1000], [210,1010], [200,1010]]
     68        p2 = [[200,1000], [210,1010], [215,1005], [220, 1010], [225,1000],
     69              [230,1010], [240,990]]
     70
     71        f = Polygon_function( [(p1, 1.0)], geo_reference = geo )
     72        z = f([5, 5, 27, 35], [5, 9, 8, -5]) #Two first inside p1
     73
     74        assert allclose(z, [1,1,0,0])
     75
     76
     77        f = Polygon_function( [(p2, 2.0)], geo_reference = geo )
     78        z = f([5, 5, 27, 35], [5, 9, 8, -5]) #First and last inside p2
     79        assert allclose(z, [2,0,0,2])
     80
     81
     82        #Combined
     83        f = Polygon_function( [(p1, 1.0), (p2, 2.0)], geo_reference = geo )
     84        z = f([5, 5, 27, 35], [5, 9, 8, -5])
     85        assert allclose(z, [2,1,0,2])
     86
     87
     88        #Check that it would fail without geo
     89        f = Polygon_function( [(p1, 1.0), (p2, 2.0)])
     90        z = f([5, 5, 27, 35], [5, 9, 8, -5])
     91        assert not allclose(z, [2,1,0,2])       
     92
     93
     94
    5895    def test_polygon_function_callable(self):
    5996        """Check that values passed into Polygon_function can be callable
     
    84121        z = f([5, 5, 27, 35], [5, 9, 8, -5])
    85122        assert allclose(z, [2,14,35,2])
     123
    86124
    87125
Note: See TracChangeset for help on using the changeset viewer.