Concatenate total track

+ handle server voicehint time removed, times with 3 digits
This commit is contained in:
Norbert Renner 2021-03-12 21:20:35 +01:00
parent 954812cf52
commit 25f8828ae7
10 changed files with 412 additions and 47 deletions

View file

@ -49,14 +49,25 @@ BR.Gpx = {
comment += ' energy=' + (props['total-energy'] / 3600000).toFixed(1) + 'kwh';
}
if (props['total-time']) {
// TODO format, e.g. total-time=14833 -> time=4h 7m 13s
// see brouter OsmTrack.getFormattedTime2
comment += ' time=' + props['total-time'] + 's';
comment += ' time=' + BR.Gpx.formatTime(props['total-time']);
}
comment += ' -->';
return comment;
},
// 14833 -> 4h 7m 13s
// see BRouter OsmTrack.getFormattedTime2
formatTime(seconds) {
const hours = Math.trunc(seconds / 3600);
const minutes = Math.trunc((seconds - hours * 3600) / 60);
seconds = seconds - hours * 3600 - minutes * 60;
let time = '';
if (hours != 0) time += hours + 'h ';
if (minutes != 0) time += minutes + 'm ';
if (seconds != 0) time += seconds + 's';
return time;
},
// modified version of
// https://gist.github.com/sente/1083506#gistcomment-2254622
// MIT License, Copyright (c) 2016 Stuart Powers, ES6 version by Jonathan Gruber