From 1830bcc609051da6c0b67e4386dc2013739ca367 Mon Sep 17 00:00:00 2001 From: vcoppe Date: Mon, 22 Apr 2024 12:55:01 +0200 Subject: [PATCH] compute speed where possible --- gpx/src/gpx.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gpx/src/gpx.ts b/gpx/src/gpx.ts index b3a80282..1dc1ca3b 100644 --- a/gpx/src/gpx.ts +++ b/gpx/src/gpx.ts @@ -314,8 +314,6 @@ export class TrackSegment extends GPXTreeLeaf { } } - trkptStatistics.speed.push(speed); - // bounds statistics.bounds.southWest.lat = Math.min(statistics.bounds.southWest.lat, points[i].attributes.lat); statistics.bounds.southWest.lon = Math.max(statistics.bounds.southWest.lon, points[i].attributes.lon); @@ -327,7 +325,7 @@ export class TrackSegment extends GPXTreeLeaf { statistics.speed.total = statistics.distance.total / (statistics.time.total / 3600); statistics.speed.moving = statistics.distance.moving / (statistics.time.moving / 3600); - trkptStatistics.speed = distanceWindowSmoothingWithDistanceAccumulator(points, 200, (accumulated, start, end) => 3600 * accumulated / (points[end].time.getTime() - points[start].time.getTime())); + trkptStatistics.speed = distanceWindowSmoothingWithDistanceAccumulator(points, 200, (accumulated, start, end) => (points[start].time && points[end].time) ? 3600 * accumulated / (points[end].time.getTime() - points[start].time.getTime()) : undefined); this.statistics = statistics; this.trkptStatistics = trkptStatistics;