Beispiel #1
0
def pick_transects(center, side_of_square, number_of_transects,
                   number_of_points_per_transect, magnetic_declination):
    result = []

    if number_of_transects > 20:
        number_of_transects = 20
    new_transects = pick_transect_angles(number_of_transects)
    for tr in new_transects:

        transect = {}
        transect_heading = tr
        transect_length = length_of_transect(transect_heading, side_of_square)
        transect['heading'] = radians_to_degrees(transect_heading)
        transect['heading_radians'] = transect_heading

        tmp = radians_to_degrees(transect_heading) + magnetic_declination
        if tmp < 0:
            tmp += 360
        transect['heading_wrt_magnetic_north'] = tmp
        transect['length'] = transect_length
        transect['edge'] = walk_transect(
            center, transect_length, transect_heading)
        points = []

        min_d = minimum_distance_between_points(
            transect_length, number_of_points_per_transect)

        for j in range(number_of_points_per_transect):
            new_point = {}
            distance = pick_new_distance(
                [p['distance'] for p in points], transect_length, min_d)

            point = walk_transect(center, distance, transect_heading)
            new_point['point'] = point
            new_point['heading'] = radians_to_degrees(transect_heading)
            new_point['distance'] = distance
            points.append(new_point)
        transect['points'] = sorted(points, key=lambda p: (p['distance']))
        result.append(transect)
    sorted_transects = sorted(result, key=lambda t: (t['heading']))
    transect_index, point_index = 0, 0
    for t in sorted_transects:
        transect_index += 1
        t['transect_id'] = transect_index
        t['team_letter'] = string.ascii_uppercase[transect_index - 1]
        point_index_2 = 0
        for p in t['points']:
            point_index += 1
            point_index_2 += 1
            p['point_id'] = point_index
            p['point_index_2'] = point_index_2
            p['transect_id'] = transect_index
    return sorted_transects
Beispiel #2
0
 def test_radians_to_degrees_neg(self):
     self.radians = radians_to_degrees(-35)
     self.assertEquals(self.radians, -1645.3522829578812)
Beispiel #3
0
 def test_radians_to_degrees(self):
     self.radians = radians_to_degrees(80)
     self.assertEquals(self.radians, 80 * 180.0 / pi)