Changeset 3154
- Timestamp:
- Jun 13, 2006, 5:10:24 PM (19 years ago)
- Location:
- inundation/geospatial_data
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/geospatial_data/geospatial_data.py
r3149 r3154 178 178 #print "geo_reference",geo_reference 179 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) 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) 183 185 184 186 self.geo_reference = geo_reference … … 197 199 return self.geo_reference 198 200 199 def get_data_points(self, absolute = True ):201 def get_data_points(self, absolute = True, geo_reference=None): 200 202 """Get coordinates for all data points as an Nx2 array 201 203 … … 207 209 """ 208 210 209 if absolute is True :211 if absolute is True and geo_reference is None: 210 212 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 213 219 214 220 -
inundation/geospatial_data/test_geospatial_data.py
r3149 r3154 113 113 raise 'Should have raised exception' 114 114 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 115 138 def test_set_geo_reference(self): 116 139 points_ab = [[12.5,34.7],[-4.5,-60.0]] … … 1091 1114 1092 1115 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]) 1097 1122 1098 1123 os.remove(fileName) … … 1190 1215 1191 1216 if __name__ == "__main__": 1192 #suite = unittest.makeSuite(Test_Geospatial_data, 'test_set_geo_reference') 1217 1218 #suite = unittest.makeSuite(Test_Geospatial_data, 'test_isinstance') 1193 1219 suite = unittest.makeSuite(Test_Geospatial_data, 'test') 1194 1220 runner = unittest.TextTestRunner()
Note: See TracChangeset
for help on using the changeset viewer.