Changeset 5254 for anuga_core/source/anuga/shallow_water/data_manager.py
- Timestamp:
- Apr 30, 2008, 4:34:19 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/data_manager.py
r5253 r5254 4439 4439 ll-long - lower left longitude, in decimal degrees 4440 4440 grid_spacing - in deciamal degrees 4441 lat_amount - number of latitudes 4442 long_amount- number of longs 4441 lat_amount - number of latitudes 4442 long_amount- number of longs 4443 4443 4444 4444 … … 4456 4456 file_name = file_name[:-4] + ".csv" 4457 4457 geo.export_points_file(file_name) 4458 return geo 4458 4459 4459 4460 def URS_points_needed(boundary_polygon, zone, ll_lat, … … 4531 4532 isSouthHemisphere): 4532 4533 """ 4533 seg is one point, in UTM4534 seg is two points, in UTM 4534 4535 return a list of the points, in lats and longs that are needed to 4535 4536 interpolate any point on the segment. … … 4538 4539 #print "zone",zone 4539 4540 geo_reference = Geo_reference(zone=zone) 4541 #print "seg", seg 4540 4542 geo = Geospatial_data(seg,geo_reference=geo_reference) 4541 4543 seg_lat_long = geo.get_data_points(as_lat_long=True, 4542 4544 isSouthHemisphere=isSouthHemisphere) 4545 #print "seg_lat_long", seg_lat_long 4543 4546 # 1.415 = 2^0.5, rounded up.... 4544 4547 sqrt_2_rounded_up = 1.415 … … 4550 4553 min_long = min(seg_lat_long[0][1], seg_lat_long[1][1]) - buffer 4551 4554 4555 #print "min_long", min_long 4556 #print "ll_long", ll_long 4557 #print "grid_spacing", grid_spacing 4552 4558 first_row = (min_long - ll_long)/grid_spacing 4553 4559 # To round up … … 4577 4583 for index_lat in range(first_row_lat, last_row_lat + 1): 4578 4584 for index_long in range(first_row_long, last_row_long + 1): 4585 #print "index_lat", index_lat 4586 #print "index_long", index_long 4579 4587 lat = ll_lat + index_lat*grid_spacing 4580 4588 long = ll_long + index_long*grid_spacing … … 4598 4606 x2 = seg[1][0] 4599 4607 y2 = seg[1][1] 4600 4601 4608 x2_1 = x2-x1 4602 4609 y2_1 = y2-y1 4603 d = abs((x2_1)*(y1-y0)-(x1-x0)*(y2_1))/sqrt((x2_1)*(x2_1)+(y2_1)*(y2_1)) 4610 try: 4611 d = abs((x2_1)*(y1-y0)-(x1-x0)*(y2_1))/sqrt( \ 4612 (x2_1)*(x2_1)+(y2_1)*(y2_1)) 4613 except ZeroDivisionError: 4614 #print "seg", seg 4615 #print "x0", x0 4616 #print "y0", y0 4617 if sqrt((x2_1)*(x2_1)+(y2_1)*(y2_1)) == 0 and \ 4618 abs((x2_1)*(y1-y0)-(x1-x0)*(y2_1)) == 0: 4619 return True 4620 else: 4621 return False 4622 4604 4623 if d <= max_distance: 4605 4624 return True
Note: See TracChangeset
for help on using the changeset viewer.