Changeset 3071
- Timestamp:
- Jun 5, 2006, 12:02:15 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/coordinate_transforms/geo_reference.py
r2942 r3071 146 146 """ 147 147 148 # FIXME: Use ensure_numeric149 150 148 is_list = False 151 149 if type(points) == types.ListType: … … 160 158 points = reshape(points, (1,2)) 161 159 160 msg = 'Input must be an N x 2 array or list of (x,y) values. ' 161 msg += 'I got an %d x %d array' %points.shape 162 assert points.shape[1] == 2, msg 163 162 164 163 165 if points_geo_ref is not self: … … 183 185 return the points as absolute values. 184 186 """ 185 187 188 186 189 is_list = False 187 190 if type(points) == types.ListType: 188 191 is_list = True 189 if len(points)>0 and type(points[0]) \ 190 not in [types.ListType,types.TupleType]: 191 #a single point is being passed. make it a list of lists 192 points = [points] 193 elif type(points) == ArrayType: 194 if len(points.shape) == 1: 195 points = [points] 196 197 # convert into array 198 points = array(points).astype(Float) 199 # add primary geo ref from points 192 193 points = ensure_numeric(points, Float) 194 195 if len(points.shape) == 1: 196 #One point has been passed 197 msg = 'Single point must have two elements' 198 assert len(points) == 2, msg 199 points = reshape(points, (1,2)) 200 201 202 msg = 'Input must be an N x 2 array or list of (x,y) values. ' 203 msg += 'I got an %d x %d array' %points.shape 204 assert points.shape[1] == 2, msg 205 206 207 # Old code 208 #is_list = False 209 #if type(points) == types.ListType: 210 # is_list = True 211 # if len(points)>0 and type(points[0]) \ 212 # not in [types.ListType,types.TupleType]: 213 # #a single point is being passed. make it a list of lists 214 # points = [points] 215 #elif type(points) == ArrayType: 216 # if len(points.shape) == 1: 217 # points = [points] 218 219 ## convert into array 220 #points = array(points).astype(Float) 221 222 223 # Add primary geo ref from points 224 225 226 200 227 points[:,0] += self.xllcorner 201 228 points[:,1] += self.yllcorner 229 230 202 231 if is_list: 203 232 points = points.tolist() … … 208 237 def reconcile_zones(self, other): 209 238 210 if self.zone == other.zone or self.zone == DEFAULT_ZONE and other.zone == DEFAULT_ZONE: 239 if self.zone == other.zone or\ 240 self.zone == DEFAULT_ZONE and other.zone == DEFAULT_ZONE: 211 241 pass 212 242 elif self.zone == DEFAULT_ZONE: … … 216 246 else: 217 247 msg = 'Both geospatial_data objects must be in the same \ 218 ZONE to allow reconciliation. I got zone %d and %d' %(self.zone, other.zone) 248 ZONE to allow reconciliation. I got zone %d and %d'\ 249 %(self.zone, other.zone) 219 250 raise ANUGAError, msg 220 251
Note: See TracChangeset
for help on using the changeset viewer.