Skip to content

Commit

Permalink
feat: elevation gain - joyrun
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-29 committed May 26, 2024
1 parent 834db8d commit 67aab83
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions run_page/endomondo_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def parse_run_endomondo_to_nametuple(en_dict):
"average_speed": en_dict.get("distance_km", 0)
/ en_dict.get("duration_s", 1)
* 1000,
"total_elevation_gain": None,
"location_country": "",
}
return namedtuple("x", d.keys())(*d.values())
Expand Down
2 changes: 1 addition & 1 deletion run_page/gpxtrackposter/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def to_namedtuple(self):
int(self.average_heartrate) if self.average_heartrate else None
),
"total_elevation_gain": (
int(self.total_elevation_gain) if self.total_elevation_gain else None
int(self.total_elevation_gain) if self.total_elevation_gain else None
),
"map": run_map(self.polyline_str),
"start_latlng": self.start_latlng,
Expand Down
10 changes: 9 additions & 1 deletion run_page/joyrun_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ def parse_points_to_gpx(
f"""<gpxtpx:TrackPointExtension xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1">
<gpxtpx:hr>{heart_rate_list[i]}</gpxtpx:hr>
</gpxtpx:TrackPointExtension>
""")
"""
)
i += 1
point.extensions.append(gpx_extension_hr)
gpx_segment.points.append(point)
Expand Down Expand Up @@ -304,6 +305,7 @@ def parse_raw_data_to_nametuple(self, run_data, old_gpx_ids, with_gpx=False):
# fix #66
if heart_rate < 0:
heart_rate = None
total_elevation_gain = None
# pass the track no points
if run_points_data:
gpx_data = self.parse_points_to_gpx(
Expand All @@ -314,6 +316,11 @@ def parse_raw_data_to_nametuple(self, run_data, old_gpx_ids, with_gpx=False):
altitude_list,
pause_list,
)
total_elevation_gain = (
gpx_data.get_uphill_downhill().uphill
if gpx_data.has_elevations()
else None
)
if with_gpx:
# pass the track no points
if str(joyrun_id) not in old_gpx_ids:
Expand Down Expand Up @@ -351,6 +358,7 @@ def parse_raw_data_to_nametuple(self, run_data, old_gpx_ids, with_gpx=False):
seconds=int((run_data["endtime"] - run_data["starttime"]))
),
"average_speed": run_data["meter"] / run_data["second"],
"total_elevation_gain": total_elevation_gain,
"location_country": location_country,
}
return namedtuple("x", d.keys())(*d.values())
Expand Down

0 comments on commit 67aab83

Please sign in to comment.