Changeset 3154


Ignore:
Timestamp:
Jun 13, 2006, 5:10:24 PM (19 years ago)
Author:
duncan
Message:

more flexibility..

Location:
inundation/geospatial_data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inundation/geospatial_data/geospatial_data.py

    r3149 r3154  
    178178            #print "geo_reference",geo_reference
    179179            #FIXME: Maybe put out a warning here...
    180             self.data_points = geo_reference.change_points_geo_ref \
    181                                (self.data_points,
    182                                 self.geo_reference)
     180            self.data_points = self.get_data_points \
     181                               (geo_reference=geo_reference)
     182            #self.data_points = geo_reference.change_points_geo_ref \
     183            #                   (self.data_points,
     184            #                    self.geo_reference)
    183185           
    184186        self.geo_reference = geo_reference
     
    197199        return self.geo_reference
    198200       
    199     def get_data_points(self, absolute = True):
     201    def get_data_points(self, absolute = True, geo_reference=None):
    200202        """Get coordinates for all data points as an Nx2 array
    201203
     
    207209        """
    208210
    209         if absolute is True:
     211        if absolute is True and geo_reference is None:
    210212            return self.geo_reference.get_absolute(self.data_points)
    211         else:
    212             return self.data_points       
     213        elif geo_reference is not None:
     214            return geo_reference.change_points_geo_ref \
     215                               (self.data_points,
     216                                self.geo_reference)
     217        else:
     218            return self.data_points
    213219       
    214220   
  • inundation/geospatial_data/test_geospatial_data.py

    r3149 r3154  
    113113            raise 'Should have raised exception'
    114114
     115    def test_get_data_points(self):
     116        points_ab = [[12.5,34.7],[-4.5,-60.0]]
     117        x_p = -10
     118        y_p = -40
     119        geo_ref = Geo_reference(56, x_p, y_p)
     120        points_rel = geo_ref.change_points_geo_ref(points_ab)
     121       
     122        spatial = Geospatial_data(points_rel, geo_reference=geo_ref)
     123
     124        results = spatial.get_data_points(absolute=False)
     125       
     126        assert allclose(results, points_rel)
     127       
     128        x_p = -1770
     129        y_p = 4.01
     130        geo_ref = Geo_reference(56, x_p, y_p)
     131        points_rel = geo_ref.change_points_geo_ref(points_ab)
     132        results = spatial.get_data_points \
     133                  ( geo_reference=geo_ref)
     134       
     135        assert allclose(results, points_rel)
     136
     137       
    115138    def test_set_geo_reference(self):
    116139        points_ab = [[12.5,34.7],[-4.5,-60.0]]
     
    10911114
    10921115        results = Geospatial_data(fileName)
    1093        
    1094         assert allclose(results.get_data_points(absolute=False), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1095         assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
    1096         assert allclose(results.get_attributes(attribute_name='speed'), [0.0, 10.0, 40.0])
     1116        assert allclose(results.get_data_points(absolute=False), \
     1117                        [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
     1118        assert allclose(results.get_attributes(attribute_name='elevation'), \
     1119                        [10.0, 0.0, 10.4])
     1120        assert allclose(results.get_attributes(attribute_name='speed'), \
     1121                        [0.0, 10.0, 40.0])
    10971122
    10981123        os.remove(fileName)
     
    11901215
    11911216if __name__ == "__main__":
    1192     #suite = unittest.makeSuite(Test_Geospatial_data, 'test_set_geo_reference')
     1217
     1218    #suite = unittest.makeSuite(Test_Geospatial_data, 'test_isinstance')
    11931219    suite = unittest.makeSuite(Test_Geospatial_data, 'test')
    11941220    runner = unittest.TextTestRunner()
Note: See TracChangeset for help on using the changeset viewer.