From 5db0d6b2f09beed78035cbcc87a6a537f6735673 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Wed, 31 May 2023 21:16:16 +0200 Subject: fit: skip records that have no position set --- fietsboek/convert.py | 4 ++++ 1 file changed, 4 insertions(+) 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"]), -- cgit v1.2.3