aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2023-05-31 21:16:16 +0200
committerDaniel Schadt <kingdread@gmx.de>2023-05-31 21:16:16 +0200
commit5db0d6b2f09beed78035cbcc87a6a537f6735673 (patch)
treed8cb865360203f1003e46c39e44bfb43e3ad979b
parent40f766ad52b9b8ba4546a55339a9acd76c1c9896 (diff)
downloadfietsboek-5db0d6b2f09beed78035cbcc87a6a537f6735673.tar.gz
fietsboek-5db0d6b2f09beed78035cbcc87a6a537f6735673.tar.bz2
fietsboek-5db0d6b2f09beed78035cbcc87a6a537f6735673.zip
fit: skip records that have no position set
-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"]),