fallback elevation value for smoothing and after routing

This commit is contained in:
vcoppe
2024-07-18 00:12:59 +02:00
parent 2bcbf1eada
commit 3f6f9a8844
2 changed files with 4 additions and 4 deletions

View File

@@ -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;