From 51a4ad04e400696e9203a5da68faf5e76d133952 Mon Sep 17 00:00:00 2001 From: frederic wagner Date: Fri, 16 Sep 2022 13:45:19 +0200 Subject: [PATCH] small bugfix in avg speed --- apps/gipy/app.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/gipy/app.js b/apps/gipy/app.js index 3d48a8f50..dc1b1b35e 100644 --- a/apps/gipy/app.js +++ b/apps/gipy/app.js @@ -165,7 +165,7 @@ class Status { ); // record start if needed - if (this.on_path) { + if (this.on_path && this.old_points.length > 1) { if (this.starting_times[orientation] === null) { this.starting_times[orientation] = this.old_times[this.old_times.length - 1]; @@ -294,7 +294,9 @@ class Status { let done_distance = this.remaining_distances_at_start[orientation] - remaining_distance; let done_in = point_time - this.starting_times[orientation]; - approximate_speed = Math.round((done_distance * 3.6) / done_in); + if (done_in != 0) { + approximate_speed = Math.round((done_distance * 3.6) / done_in); + } } let approximate_instant_speed = Math.round(this.instant_speed * 3.6);