mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 23:53:25 +00:00
fallback elevation value for smoothing and after routing
This commit is contained in:
@@ -668,11 +668,11 @@ export class TrackSegment extends GPXTreeLeaf {
|
|||||||
_computeSmoothedElevation(): number[] {
|
_computeSmoothedElevation(): number[] {
|
||||||
const points = this.trkpt;
|
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) {
|
if (points.length > 0) {
|
||||||
smoothed[0] = points[0].ele;
|
smoothed[0] = points[0].ele ?? 0;
|
||||||
smoothed[points.length - 1] = points[points.length - 1].ele;
|
smoothed[points.length - 1] = points[points.length - 1].ele ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return smoothed;
|
return smoothed;
|
||||||
|
@@ -73,7 +73,7 @@ async function getRoute(points: Coordinates[], brouterProfile: string, privateRo
|
|||||||
lat: coord[1],
|
lat: coord[1],
|
||||||
lon: coord[0]
|
lon: coord[0]
|
||||||
},
|
},
|
||||||
ele: coord[2] ?? undefined
|
ele: coord[2] ?? (i > 0 ? route[i - 1].ele : 0)
|
||||||
}));
|
}));
|
||||||
route[route.length - 1].setSurface(surface)
|
route[route.length - 1].setSurface(surface)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user