Fix regression in elevation filter logic

25e506d changed the order in which the elevation deltas are passed through the elevation filter, which can lead to the undesirable behavior that appending segments to the end of a route can decrease the calculated total ascent. This fixes the bug by adjusting the elevation filter accordingly.
This commit is contained in:
quaelnix 2023-01-24 23:38:11 +01:00 committed by GitHub
parent 2387513a1f
commit c3508c2adc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -772,16 +772,15 @@ public class RoutingEngine extends Thread {
if (ele_last != Short.MIN_VALUE) { if (ele_last != Short.MIN_VALUE) {
ehb = ehb + (ele_last - ele) * eleFactor; ehb = ehb + (ele_last - ele) * eleFactor;
} }
if (ehb > 10.) { if (ehb > 0) {
ascend += ehb - 10.; ascend += ehb;
ehb = 10.; ehb = 0;
} else if (ehb < 0.) { } else if (ehb < -10) {
ehb = 0.; ehb = -10;
} }
} }
} }
ascend += ehb;
t.ascend = (int) ascend; t.ascend = (int) ascend;
t.plainAscend = (int) ((ele_start - ele_end) * eleFactor + 0.5); t.plainAscend = (int) ((ele_start - ele_end) * eleFactor + 0.5);