Changeset 3739
- Timestamp:
- Oct 11, 2006, 10:43:29 AM (17 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/coordinate_transforms/redfearn.py
r3616 r3739 164 164 165 165 166 def convert_points_from_latlon_to_utm(points, 167 false_easting=None, 168 false_northing=None): 169 """Convert a list of points given in latitude and longitude to UTM 166 def convert_from_latlon_to_utm(latitudes=None, 167 longitudes=None, 168 points=None, 169 false_easting=None, 170 false_northing=None): 171 """Convert latitude and longitude data to UTM as a list of coordinates. 170 172 171 173 172 174 Input 173 175 174 points: list of points given in decimal degrees (latitude, longitude) 176 points: list of points given in decimal degrees (latitude, longitude) or 177 latitudes: list of latitudes and 178 longitudes: list of longitudes 175 179 false_easting (optional) 176 180 false_northing (optional) … … 185 189 186 190 Assume the false_easting and false_northing are the same for each list. 187 If points end up belonging to different UTM zones, an ANUGAerror is thrown. 188 189 190 191 If points end up belonging to different UTM zones, an ANUGAerror is thrown. 191 192 """ 192 193 193 194 old_geo = Geo_reference() 194 195 utm_points = [] 196 if points == None: 197 198 assert len(latitudes) == len(longitudes) 199 points = map(None, latitudes, longitudes) 195 200 for point in points: 196 201 zone, easting, northing = redfearn(float(point[0]), … … 198 203 false_easting=false_easting, 199 204 false_northing=false_northing) 200 201 205 new_geo = Geo_reference(zone) 202 old_geo.reconcile_zones(new_geo) 203 206 old_geo.reconcile_zones(new_geo) 204 207 utm_points.append([easting, northing]) 205 208 206 207 209 return utm_points, old_geo.get_zone() 208 209 210 211 212 213 # FIXME (Ole): Is this not supersedede by the above?214 def convert_lats_longs(latitudes,215 longitudes,216 false_easting=None,217 false_northing=None):218 """219 Redfearn a list of latitudes and longitudes.220 221 Assume the false_easting and false_northing are the same for each list.222 223 Note, if a zone turns out to be different, an ANUGAerror is thrown.224 """225 # Using geo_ref so there is only one point in the code where zones226 # are checked.227 old_geo = Geo_reference()228 points = []229 for lat, long in map(None, latitudes, longitudes,):230 zone, easting, northing = redfearn(float(lat),231 float(long),232 false_easting=false_easting,233 false_northing=false_northing)234 new_geo = Geo_reference(zone)235 old_geo.reconcile_zones(new_geo)236 #print "old_geo.get_zone()", old_geo.get_zone()237 points.append([easting, northing])238 239 return old_geo.get_zone(), points -
anuga_core/source/anuga/coordinate_transforms/test_redfearn.py
r3616 r3739 156 156 lats = [lat_gong, lat_2] 157 157 longs = [lon_gong, lon_2] 158 zone, points = convert_lats_longs(lats, longs)158 points, zone = convert_from_latlon_to_utm(lats, longs) 159 159 160 160 assert allclose(points[0][0], 308728.009) … … 183 183 184 184 try: 185 zone, points = convert_lats_longs(lats, longs)185 points, zone = convert_from_latlon_to_utm(lats, longs) 186 186 except ANUGAError: 187 187 pass … … 206 206 longs = [lon_gong, lon_2] 207 207 try: 208 zone, points = convert_lats_longs(lats, longs)208 points, zone = convert_from_latlon_to_utm(lats, longs) 209 209 except ANUGAError: 210 210 pass … … 213 213 'Error not thrown error!') 214 214 215 # Similar test for alternative interface216 215 def test_convert_latlon_to_UTM1(self): 217 216 … … 229 228 230 229 points = [[lat_gong, lon_gong], [lat_2, lon_2]] 231 points, zone = convert_ points_from_latlon_to_utm(points)232 230 points, zone = convert_from_latlon_to_utm(points=points) 231 #print "points",points 233 232 assert allclose(points[0][0], 308728.009) 234 233 assert allclose(points[0][1], 6180432.601) … … 255 254 256 255 try: 257 points, zone = convert_ points_from_latlon_to_utm(points)256 points, zone = convert_from_latlon_to_utm(points=points) 258 257 except ANUGAError: 259 258 pass … … 277 276 278 277 try: 279 points, zone = convert_ points_from_latlon_to_utm(points)278 points, zone = convert_from_latlon_to_utm(points=points) 280 279 except ANUGAError: 281 280 pass … … 287 286 if __name__ == "__main__": 288 287 288 #mysuite = unittest.makeSuite(TestCase,'test_convert_latlon_to_UTM1') 289 289 mysuite = unittest.makeSuite(TestCase,'test') 290 290 runner = unittest.TextTestRunner() -
anuga_core/source/anuga/geospatial_data/geospatial_data.py
r3738 r3739 11 11 from anuga.utilities.numerical_tools import ensure_numeric 12 12 from anuga.coordinate_transforms.geo_reference import Geo_reference, TitleError 13 from anuga.coordinate_transforms.redfearn import convert_ lats_longs13 from anuga.coordinate_transforms.redfearn import convert_from_latlon_to_utm 14 14 15 15 … … 324 324 raise ValueError, msg 325 325 326 zone, data_points = convert_lats_longs(latitudes, longitudes)326 data_points, zone = convert_from_latlon_to_utm(latitudes, longitudes) 327 327 328 328 return data_points, Geo_reference(zone=zone)
Note: See TracChangeset
for help on using the changeset viewer.