From 990f24d8971bda8a4343a93cbde3751098f1e277 Mon Sep 17 00:00:00 2001 From: Johann Rudloff Date: Sat, 6 Mar 2021 19:09:18 +0100 Subject: [PATCH] Extract elevation data from FIT and GPX files --- activities/activity.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/activities/activity.py b/activities/activity.py index aaf2fb3..417103f 100644 --- a/activities/activity.py +++ b/activities/activity.py @@ -54,6 +54,7 @@ def from_gpx_bytes(content: BinaryIO): positions.append((point_time, point.latitude, point.longitude, + point.elevation, )) for ext_elem in point.extensions: hr_elem = ext_elem.find('gpxtpx:hr', namespaces=GPX_NAMESPACES) @@ -92,9 +93,15 @@ def from_fit_bytes(content: BinaryIO) -> Track: if (lat is not None) and (lng is not None): lat_deg = field_to_deg(lat) lng_deg = field_to_deg(lng) + + alt = record.get_value('enhanced_altitude') + if alt is None: + alt = record.get_value('altitude') + value_tuple = (record_time, lat_deg, lng_deg, + alt or 0, ) positions.append(value_tuple) -- 2.45.2