aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fietsboek/convert.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/fietsboek/convert.py b/fietsboek/convert.py
index a73883d..bf0664a 100644
--- a/fietsboek/convert.py
+++ b/fietsboek/convert.py
@@ -2,6 +2,8 @@
import fitparse
from gpxpy.gpx import GPX, GPXTrack, GPXTrackPoint, GPXTrackSegment
+FIT_RECORD_FIELDS = ["position_lat", "position_long", "altitude", "timestamp"]
+
def semicircles_to_deg(circles: int) -> float:
"""Convert semicircles coordinate to degree coordinate.
@@ -27,6 +29,8 @@ def from_fit(data: bytes) -> GPX:
for record in fitfile.get_messages("record"):
values = record.get_values()
try:
+ if any(values[field] is None for field in FIT_RECORD_FIELDS):
+ continue
point = GPXTrackPoint(
latitude=semicircles_to_deg(values["position_lat"]),
longitude=semicircles_to_deg(values["position_long"]),