gpx_parser: Fix crash if gpx doesn't contain timings
Signed-off-by: Thomas Klaehn <thomas.klaehn@u-blox.com>
This commit is contained in:
parent
dbae0584c4
commit
538be61afd
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
|||||||
data/
|
data/
|
||||||
|
.vscode/settings.json
|
||||||
|
gpx_parser/__init__.pyc
|
||||||
|
@ -24,7 +24,7 @@ def main():
|
|||||||
max_day = (datetime.date(year + 1, 1, 1) - datetime.timedelta(days=1)).day
|
max_day = (datetime.date(year + 1, 1, 1) - datetime.timedelta(days=1)).day
|
||||||
else:
|
else:
|
||||||
max_day = (datetime.date(year, month + 1, 1) - datetime.timedelta(days=1)).day
|
max_day = (datetime.date(year, month + 1, 1) - datetime.timedelta(days=1)).day
|
||||||
for day in range(1, max_day):
|
for day in range(1, max_day + 1):
|
||||||
date_tracks = tracks.get(year, month, day)
|
date_tracks = tracks.get(year, month, day)
|
||||||
date_date = datetime.datetime(year, month, day)
|
date_date = datetime.datetime(year, month, day)
|
||||||
date_dist = 0.0
|
date_dist = 0.0
|
||||||
|
2
gpx2html
2
gpx2html
@ -67,7 +67,7 @@ def main():
|
|||||||
max_day = (datetime.date(year + 1, 1, 1) - datetime.timedelta(days=1)).day
|
max_day = (datetime.date(year + 1, 1, 1) - datetime.timedelta(days=1)).day
|
||||||
else:
|
else:
|
||||||
max_day = (datetime.date(year, month + 1, 1) - datetime.timedelta(days=1)).day
|
max_day = (datetime.date(year, month + 1, 1) - datetime.timedelta(days=1)).day
|
||||||
for day in range(1, max_day):
|
for day in range(1, max_day + 1):
|
||||||
date_tracks = tracks.get(year, month, day)
|
date_tracks = tracks.get(year, month, day)
|
||||||
for track in date_tracks:
|
for track in date_tracks:
|
||||||
month_distance[month] += (track.distance / 1000) # km
|
month_distance[month] += (track.distance / 1000) # km
|
||||||
|
@ -34,10 +34,14 @@ class Track(object):
|
|||||||
' ' + str(segment.points[i].longitude))
|
' ' + str(segment.points[i].longitude))
|
||||||
seg.distance += distance.distance(point1, point2).meters
|
seg.distance += distance.distance(point1, point2).meters
|
||||||
|
|
||||||
|
try:
|
||||||
if self.duration is None:
|
if self.duration is None:
|
||||||
self.duration = seg.end_time - seg.start_time
|
self.duration = seg.end_time - seg.start_time
|
||||||
else:
|
else:
|
||||||
self.duration += seg.end_time - seg.start_time
|
self.duration += seg.end_time - seg.start_time
|
||||||
|
except Exception:
|
||||||
|
# TODO: Add logging mechanism.
|
||||||
|
pass
|
||||||
self.end_time = seg.end_time
|
self.end_time = seg.end_time
|
||||||
self.distance += seg.distance
|
self.distance += seg.distance
|
||||||
self.avg_speed = self.distance / self.duration.total_seconds() * 3.6
|
self.avg_speed = self.distance / self.duration.total_seconds() * 3.6
|
||||||
|
2
setup.py
2
setup.py
@ -3,7 +3,7 @@
|
|||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
|
|
||||||
NAME = 'gpx_parser'
|
NAME = 'gpx_parser'
|
||||||
VERSION = '0.2.0'
|
VERSION = '0.2.1'
|
||||||
AUTHOR = 'Thomas Klaehn'
|
AUTHOR = 'Thomas Klaehn'
|
||||||
EMAIL = 'tkl@blackfinn.de'
|
EMAIL = 'tkl@blackfinn.de'
|
||||||
PACKAGES = [NAME]
|
PACKAGES = [NAME]
|
||||||
|
Loading…
Reference in New Issue
Block a user