fix(tours): elevation model jitter no longer counts as ascent

Ascent and descent were the raw sum of every height difference, so a flat walk across Venice (highest point 16 m) read 121 m of climbing. Heights now count once they move 5 m from the last one that counted; the server's stored figures and the planner's live analysis share the one function.
This commit is contained in:
Maurice
2026-10-25 10:22:03 +01:00
parent e3eec8d6d1
commit 26611b46e4
4 changed files with 68 additions and 19 deletions
+9
View File
@@ -27,6 +27,15 @@ describe('analyzeRouteGeometry', () => {
expect(analysis!.distanceIndexedProfileSamples[2].distanceMeters).toBeCloseTo(3335.85, 1)
})
it('leaves the elevation model jitter of a flat walk out of its ascent', () => {
const analysis = analyzeRouteGeometry(JSON.stringify([
[45.44, 12.32, 2], [45.441, 12.32, 9], [45.442, 12.32, 1], [45.443, 12.32, 4], [45.444, 12.32, 3],
]))
expect(analysis!.maxEle).toBe(9)
expect(analysis!.gain).toBe(7)
expect(analysis!.loss).toBe(8)
})
it('maps route endpoints and interpolates focus between prepared samples', () => {
const samples = [
{ distanceMeters: 0, elevationMeters: 100, lat: 10, lng: 20 },