Minimum stored in track too

master
José Carlos Cuevas 4 years ago
parent a1772168d7
commit 159b081a49

@ -33,6 +33,8 @@ def parse_gpx(filename, fps=30.0):
prev_elevation = None
max_speed = 0.0
max_elevation = 0.0
min_speed = 9999.0
min_elevation = 9999.0
print("Calculating interpolation at {} fps".format(fps))
for segment in track_data.findall('def:trkseg', ns):
@ -59,6 +61,12 @@ def parse_gpx(filename, fps=30.0):
if km_hour > max_speed:
max_speed = km_hour
if elevation < min_elevation:
min_elevation = elevation
if km_hour < min_speed:
min_speed = km_hour
# Begin interpolation
delta_v = (km_hour - prev_velocity) / fps
delta_e = (elevation - prev_elevation) / fps
@ -74,5 +82,7 @@ def parse_gpx(filename, fps=30.0):
data.set_maximum('speed', max_speed)
data.set_maximum('elevation', max_elevation)
data.set_minimum('speed', min_speed)
data.set_minimum('elevation', min_elevation)
return data

@ -6,6 +6,7 @@ class Track:
def __init__(self):
self.datapoints = []
self.maximums = {}
self.minimums = {}
def add_point(self, speed, elevation):
self.datapoints.append((speed, elevation))
@ -22,5 +23,11 @@ class Track:
def set_maximum(self, key, value):
self.maximums[key] = value
def set_minimum(self, key, value):
self.minimums[key] = value
def get_maximum(self, key):
return self.maximums.get(key, 0)
def get_minimum(self, key):
return self.mininums.get(key, 0)

Loading…
Cancel
Save