From 159b081a49ca6ce774d235123272cc8adf4206b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Cuevas?= Date: Tue, 17 Mar 2020 16:25:57 +0100 Subject: [PATCH] Minimum stored in track too --- src/parser.py | 10 ++++++++++ src/track.py | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/parser.py b/src/parser.py index 8ca4743..a028e76 100644 --- a/src/parser.py +++ b/src/parser.py @@ -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 diff --git a/src/track.py b/src/track.py index e7e7433..a2d510a 100644 --- a/src/track.py +++ b/src/track.py @@ -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)