From 2f8ddfa9e7c209ad8213ab1d674fc9c42773b084 Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Wed, 6 Apr 2022 11:51:20 +0200 Subject: [PATCH] Interpolate ascend stats --- js/plugin/Routing.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/plugin/Routing.js b/js/plugin/Routing.js index c9318f9..e7272ef 100644 --- a/js/plugin/Routing.js +++ b/js/plugin/Routing.js @@ -519,6 +519,14 @@ BR.Routing = L.Routing.extend({ const stdPath = this._computeKinematic(distance, deltaHeight); props['total-energy'] = stdPath.getTotalEnergy(); props['total-time'] = stdPath.getTotalTime(); + + // match BRouter/Java rounding where `(int)` cast truncates decimals + // https://github.com/abrensch/brouter/blob/14d5a2c4e6b101a2eab711e70151142881df95c6/brouter-core/src/main/java/btools/router/RoutingEngine.java#L1216-L1217 + if (deltaHeight > 0) { + // no filtering for simplicity for now + props['filtered ascend'] = Math.trunc(deltaHeight); + } + props['plain-ascend'] = Math.trunc(deltaHeight + 0.5); // do not set interpolated alt value, to explicitly show missing data, e.g. in height graph } },