Skip to content

Commit

Permalink
fix sector orientation; with symmetrical sector orientation, the orie…
Browse files Browse the repository at this point in the history
…ntation should point inward. the cause of this was that previous and next were reversed. incidentally another bug hid this fix. fixing the orientation angle recently brought up this problem. also had to change line cross logic
  • Loading branch information
GliderGeek committed Jul 17, 2023
1 parent 3c88bb6 commit 5e8ef93
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
16 changes: 7 additions & 9 deletions opensoar/task/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def __init__(self, waypoints: List[Waypoint], timezone: int, start_opening: date
self.start_time_buffer = start_time_buffer
self.multistart = multistart

# TODO: wouldn't this be better set in waypoint initialization?
# reason could be line cross logic depending on "next" and "previous"
self.set_orientation_angles(self.waypoints)

def __eq__(self, other):
Expand Down Expand Up @@ -72,19 +74,15 @@ def set_orientation_angles(waypoints):
for index in range(len(waypoints)):

if index == 0: # necessary for index out of bounds
_, angle = calculate_distance_bearing(waypoints[index + 1].fix, waypoints[index].fix,
final_bearing=True)
_, angle = calculate_distance_bearing(waypoints[index].fix, waypoints[index + 1].fix)
waypoints[index].set_orientation_angle(angle_next=angle)
elif index == len(waypoints) - 1: # necessary for index out of bounds
_, angle = calculate_distance_bearing(waypoints[index - 1].fix, waypoints[index].fix,
final_bearing=True)
_, angle = calculate_distance_bearing(waypoints[index].fix, waypoints[index - 1].fix)
waypoints[index].set_orientation_angle(angle_previous=angle)
else:
_, angle_start = calculate_distance_bearing(waypoints[0].fix, waypoints[index].fix, final_bearing=True)
_, angle_previous = calculate_distance_bearing(waypoints[index - 1].fix, waypoints[index].fix,
final_bearing=True)
_, angle_next = calculate_distance_bearing(waypoints[index + 1].fix, waypoints[index].fix,
final_bearing=True)
_, angle_start = calculate_distance_bearing(waypoints[index].fix, waypoints[0].fix)
_, angle_previous = calculate_distance_bearing(waypoints[index].fix, waypoints[index - 1].fix)
_, angle_next = calculate_distance_bearing(waypoints[index].fix, waypoints[index + 1].fix)
waypoints[index].set_orientation_angle(angle_start=angle_start,
angle_previous=angle_previous,
angle_next=angle_next)
Expand Down
4 changes: 2 additions & 2 deletions opensoar/task/waypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def crossed_line(self, fix1, fix2):
angle_wrt_orientation2 = abs(calculate_bearing_difference(self.orientation_angle, bearing2))

if self.sector_orientation == "next": # start line
return angle_wrt_orientation1 < 90 < angle_wrt_orientation2
elif self.sector_orientation == "previous": # finish line
return angle_wrt_orientation2 < 90 < angle_wrt_orientation1
elif self.sector_orientation == "previous": # finish line
return angle_wrt_orientation1 < 90 < angle_wrt_orientation2
else:
raise ValueError("A line with this orientation is not implemented!")
8 changes: 7 additions & 1 deletion opensoar/utilities/geojson_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ def task_to_geojson_features(task) -> List[dict]:
return features


def trip_to_geojson_features(trip, color) -> List[dict]:
def trip_to_geojson_features(trip, color: str) -> List[dict]:
"""
:param trip:
:param color: hex string with leading hashtag (e.g. "#062123")
:return:
"""

features = []

for sector in trip.sector_fixes:
Expand Down

0 comments on commit 5e8ef93

Please sign in to comment.