From d7c756e471e67e0797f56c5dc0397610046d7144 Mon Sep 17 00:00:00 2001 From: vcoppe Date: Wed, 7 Aug 2024 16:22:22 +0200 Subject: [PATCH] time management improvements for routing tool --- gpx/src/gpx.ts | 2 +- .../lib/components/toolbar/tools/routing/RoutingControls.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gpx/src/gpx.ts b/gpx/src/gpx.ts index 049616f7..a69a07ac 100644 --- a/gpx/src/gpx.ts +++ b/gpx/src/gpx.ts @@ -682,7 +682,7 @@ export class TrackSegment extends GPXTreeLeaf { const time = (points[i].time.getTime() - points[i - 1].time.getTime()) / 1000; speed = dist / (time / 3600); - if (speed >= 0.5) { + if (speed >= 0.5 && speed <= 1500) { statistics.global.distance.moving += dist; statistics.global.time.moving += time; } diff --git a/website/src/lib/components/toolbar/tools/routing/RoutingControls.ts b/website/src/lib/components/toolbar/tools/routing/RoutingControls.ts index 3c8b44eb..d0b630f2 100644 --- a/website/src/lib/components/toolbar/tools/routing/RoutingControls.ts +++ b/website/src/lib/components/toolbar/tools/routing/RoutingControls.ts @@ -569,6 +569,10 @@ export class RoutingControls { let remainingTime = stats.global.time.moving - (stats.local.time.moving[anchors[anchors.length - 1].point._data.index] - stats.local.time.moving[anchors[0].point._data.index]); let replacingTime = newTime - remainingTime; + if (replacingTime <= 0) { // Fallback to simple time difference + replacingTime = stats.local.time.total[anchors[anchors.length - 1].point._data.index] - stats.local.time.total[anchors[0].point._data.index]; + } + speed = replacingDistance / replacingTime * 3600; if (startTime === undefined) { // Replacing the first point