Changeset 3149
- Timestamp:
- Jun 13, 2006, 4:33:40 PM (18 years ago)
- Location:
- inundation/geospatial_data
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/geospatial_data/geospatial_data.py
r3056 r3149 98 98 99 99 self.set_verbose(verbose) 100 100 self.geo_reference=None #create the attribute 101 101 if file_name is None: 102 102 if delimiter is not None: … … 165 165 from coordinate_transforms.geo_reference import Geo_reference 166 166 167 168 167 if geo_reference is None: 169 self.geo_reference = Geo_reference() # Use default 170 elif isinstance(geo_reference, Geo_reference): 171 self.geo_reference = geo_reference 172 else: 168 geo_reference = Geo_reference() # Use default 169 if not isinstance(geo_reference, Geo_reference): 173 170 msg = 'Argument geo_reference must be a valid Geo_reference \n' 174 171 msg += 'object or None.' 175 172 raise msg 173 174 # if a geo ref already exists, change the point data to 175 # represent the new geo-ref 176 if self.geo_reference is not None: 177 #print "self.geo_reference",self.geo_reference 178 #print "geo_reference",geo_reference 179 #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) 183 184 self.geo_reference = geo_reference 176 185 177 186 -
inundation/geospatial_data/test_geospatial_data.py
r3056 r3149 113 113 raise 'Should have raised exception' 114 114 115 115 def test_set_geo_reference(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 spatial = Geospatial_data(points_rel) 122 # since the geo_ref wasn't set 123 assert not allclose( points_ab, spatial.get_data_points(absolute=True)) 124 125 spatial = Geospatial_data(points_rel, geo_reference=geo_ref) 126 assert allclose( points_ab, spatial.get_data_points(absolute=True)) 127 128 x_p = 10 129 y_p = 400 130 new_geo_ref = Geo_reference(56, x_p, y_p) 131 spatial.set_geo_reference(new_geo_ref) 132 assert allclose( points_ab, spatial.get_data_points(absolute=True)) 133 134 135 116 136 def test_conversions_to_points_dict(self): 117 137 """test conversions to points_dict … … 1170 1190 1171 1191 if __name__ == "__main__": 1172 #suite = unittest.makeSuite(Test_Geospatial_data, 'test_ check_geo_reference1')1192 #suite = unittest.makeSuite(Test_Geospatial_data, 'test_set_geo_reference') 1173 1193 suite = unittest.makeSuite(Test_Geospatial_data, 'test') 1174 1194 runner = unittest.TextTestRunner()
Note: See TracChangeset
for help on using the changeset viewer.