diff options
author | Daniel Schadt <kingdread@gmx.de> | 2023-05-31 21:16:16 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2023-05-31 21:16:16 +0200 |
commit | 5db0d6b2f09beed78035cbcc87a6a537f6735673 (patch) | |
tree | d8cb865360203f1003e46c39e44bfb43e3ad979b /fietsboek/convert.py | |
parent | 40f766ad52b9b8ba4546a55339a9acd76c1c9896 (diff) | |
download | fietsboek-5db0d6b2f09beed78035cbcc87a6a537f6735673.tar.gz fietsboek-5db0d6b2f09beed78035cbcc87a6a537f6735673.tar.bz2 fietsboek-5db0d6b2f09beed78035cbcc87a6a537f6735673.zip |
fit: skip records that have no position set
Diffstat (limited to 'fietsboek/convert.py')
-rw-r--r-- | fietsboek/convert.py | 4 |
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"]), |