Ignore:
Timestamp:
Apr 30, 2008, 4:34:19 PM (15 years ago)
Author:
duncan
Message:

Adding northern hemisphere tests for URS_points_needed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r5253 r5254  
    44394439    ll-long - lower left longitude, in decimal degrees
    44404440    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 
    44434443
    44444444
     
    44564456            file_name = file_name[:-4] + ".csv"
    44574457        geo.export_points_file(file_name)
     4458    return geo
    44584459
    44594460def URS_points_needed(boundary_polygon, zone, ll_lat,
     
    45314532                  isSouthHemisphere):
    45324533    """
    4533     seg is one point, in UTM
     4534    seg is two points, in UTM
    45344535    return a list of the points, in lats and longs that are needed to
    45354536    interpolate any point on the segment.
     
    45384539    #print "zone",zone
    45394540    geo_reference = Geo_reference(zone=zone)
     4541    #print "seg", seg
    45404542    geo = Geospatial_data(seg,geo_reference=geo_reference)
    45414543    seg_lat_long = geo.get_data_points(as_lat_long=True,
    45424544                                       isSouthHemisphere=isSouthHemisphere)
     4545    #print "seg_lat_long", seg_lat_long
    45434546    # 1.415 = 2^0.5, rounded up....
    45444547    sqrt_2_rounded_up = 1.415
     
    45504553    min_long = min(seg_lat_long[0][1], seg_lat_long[1][1]) - buffer
    45514554
     4555    #print "min_long", min_long
     4556    #print "ll_long", ll_long
     4557    #print "grid_spacing", grid_spacing
    45524558    first_row = (min_long - ll_long)/grid_spacing
    45534559    # To round up
     
    45774583    for index_lat in range(first_row_lat, last_row_lat + 1):
    45784584        for index_long in range(first_row_long, last_row_long + 1):
     4585            #print "index_lat", index_lat
     4586            #print "index_long", index_long
    45794587            lat = ll_lat + index_lat*grid_spacing
    45804588            long = ll_long + index_long*grid_spacing
     
    45984606    x2 = seg[1][0]
    45994607    y2 = seg[1][1]
    4600 
    46014608    x2_1 = x2-x1
    46024609    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   
    46044623    if d <= max_distance:
    46054624        return True
Note: See TracChangeset for help on using the changeset viewer.