diff --git a/gpx/src/gpx.ts b/gpx/src/gpx.ts index 96382b99..2d73999c 100644 --- a/gpx/src/gpx.ts +++ b/gpx/src/gpx.ts @@ -668,11 +668,11 @@ export class TrackSegment extends GPXTreeLeaf { _computeSmoothedElevation(): number[] { const points = this.trkpt; - let smoothed = distanceWindowSmoothing(points, 100, (index) => points[index].ele, (accumulated, start, end) => accumulated / (end - start + 1)); + let smoothed = distanceWindowSmoothing(points, 100, (index) => points[index].ele ?? 0, (accumulated, start, end) => accumulated / (end - start + 1)); if (points.length > 0) { - smoothed[0] = points[0].ele; - smoothed[points.length - 1] = points[points.length - 1].ele; + smoothed[0] = points[0].ele ?? 0; + smoothed[points.length - 1] = points[points.length - 1].ele ?? 0; } return smoothed; diff --git a/website/src/lib/components/toolbar/tools/routing/Routing.ts b/website/src/lib/components/toolbar/tools/routing/Routing.ts index c5701658..42ee72fb 100644 --- a/website/src/lib/components/toolbar/tools/routing/Routing.ts +++ b/website/src/lib/components/toolbar/tools/routing/Routing.ts @@ -73,7 +73,7 @@ async function getRoute(points: Coordinates[], brouterProfile: string, privateRo lat: coord[1], lon: coord[0] }, - ele: coord[2] ?? undefined + ele: coord[2] ?? (i > 0 ? route[i - 1].ele : 0) })); route[route.length - 1].setSurface(surface)