mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-25 22:27:32 +00:00
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:
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user