Merge pull request #118 from makrsmark/opens-circling

fix crash when no position
This commit is contained in:
Jack Sweeney 2023-05-12 14:29:33 -04:00 committed by GitHub
commit 841a78dc04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -17,6 +17,9 @@ def calculate_cardinal(d):
card = dirs[ix % len(dirs)] card = dirs[ix % len(dirs)]
return card return card
def calculate_deg_change(new_heading, original_heading): def calculate_deg_change(new_heading, original_heading):
if new_heading is None:
print("Track heading missing. No change")
return 0
"""Calculates change between two headings, returns negative degree if change is left, positive if right""" """Calculates change between two headings, returns negative degree if change is left, positive if right"""
normal = abs(original_heading-new_heading) normal = abs(original_heading-new_heading)
across_inital = 360 - abs(original_heading-new_heading) across_inital = 360 - abs(original_heading-new_heading)

View File

@ -618,7 +618,8 @@ class Plane:
from calculate_headings import calculate_deg_change from calculate_headings import calculate_deg_change
track_change = calculate_deg_change(self.track, self.last_track) track_change = calculate_deg_change(self.track, self.last_track)
track_change = round(track_change, 3) track_change = round(track_change, 3)
self.circle_history["traces"].append((time.time(), self.latitude, self.longitude, track_change)) if self.latitude is not None and self.longitude is not None:
self.circle_history["traces"].append((time.time(), self.latitude, self.longitude, track_change))
total_change = 0 total_change = 0
coords = [] coords = []