Skip to content

Commit

Permalink
Average elevation added
Browse files Browse the repository at this point in the history
  • Loading branch information
firefly-cpp committed Dec 30, 2015
1 parent 4c0aeec commit 2bab168
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tcxparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def __init__(self, tcx_file):
def hr_values(self):
return [int(x.text) for x in self.root.xpath('//ns:HeartRateBpm/ns:Value', namespaces={'ns': namespace})]

def altitude_points(self):
return [float(x.text) for x in self.root.xpath('//ns:AltitudeMeters', namespaces={'ns': namespace})]

@property
def latitude(self):
return self.activity.Lap.Track.Trackpoint.Position.LatitudeDegrees.pyval
Expand Down Expand Up @@ -69,4 +72,9 @@ def pace(self):
"""Average pace (mm:ss/km for the workout"""
secs_per_km = self.duration/(self.distance/1000)
return time.strftime('%M:%S', time.gmtime(secs_per_km))


@property
def altitude_avg(self):
"""Average altitude for the workout"""
altitude_data = self.altitude_points()
return sum(altitude_data)/len(altitude_data)

0 comments on commit 2bab168

Please sign in to comment.