From 1e819cf5bd099470488dcddb4e2fc458cb0945e7 Mon Sep 17 00:00:00 2001 From: quaelnix <122357328+quaelnix@users.noreply.github.com> Date: Tue, 10 Jan 2023 15:32:17 +0100 Subject: [PATCH 1/2] Fix regression of travel time calculation This fixes a regression in the travel time calculation in the kinematic model caused by combining the following two commits: * https://github.com/abrensch/brouter/commit/bd025875d452ffb8873459d8523bae227bb0806e#diff-59799a4a78f59692f35951f94cd8733f7e34718c2d60a6248685159f637517a4 * https://github.com/abrensch/brouter/commit/57da34d205d26f22b31f667facc99ab7507d468c#diff-59799a4a78f59692f35951f94cd8733f7e34718c2d60a6248685159f637517a4 --- brouter-core/src/main/java/btools/router/StdPath.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brouter-core/src/main/java/btools/router/StdPath.java b/brouter-core/src/main/java/btools/router/StdPath.java index 0d73b40..27bbd4f 100644 --- a/brouter-core/src/main/java/btools/router/StdPath.java +++ b/brouter-core/src/main/java/btools/router/StdPath.java @@ -212,7 +212,7 @@ final class StdPath extends OsmPath { double speed; // Travel speed double f_roll = rc.totalMass * GRAVITY * (rc.defaultC_r + incline); - if (rc.footMode || rc.expctxWay.getCostfactor() > 4.9) { + if (rc.footMode) { // Use Tobler's hiking function for walking sections speed = rc.maxSpeed * 3.6; speed = (speed * FastMath.exp(-3.5 * Math.abs(incline + 0.05))) / 3.6; From a49c43d1efa2332af23ba5ee6916f10af4d22c74 Mon Sep 17 00:00:00 2001 From: quaelnix <122357328+quaelnix@users.noreply.github.com> Date: Tue, 10 Jan 2023 15:34:37 +0100 Subject: [PATCH 2/2] Refactor computeKinematic --- .../src/main/java/btools/router/StdPath.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/StdPath.java b/brouter-core/src/main/java/btools/router/StdPath.java index 27bbd4f..b890c27 100644 --- a/brouter-core/src/main/java/btools/router/StdPath.java +++ b/brouter-core/src/main/java/btools/router/StdPath.java @@ -202,26 +202,20 @@ final class StdPath extends OsmPath { elevation_buffer += delta_h; double incline = calcIncline(dist); - double wayMaxspeed; - - wayMaxspeed = rc.expctxWay.getMaxspeed() / 3.6f; - if (wayMaxspeed == 0) { - wayMaxspeed = rc.maxSpeed; + double maxSpeed = rc.maxSpeed; + double speedLimit = rc.expctxWay.getMaxspeed() / 3.6f; + if (speedLimit > 0) { + maxSpeed = Math.min(maxSpeed, speedLimit); } - wayMaxspeed = Math.min(wayMaxspeed, rc.maxSpeed); - double speed; // Travel speed + double speed = maxSpeed; // Travel speed double f_roll = rc.totalMass * GRAVITY * (rc.defaultC_r + incline); if (rc.footMode) { // Use Tobler's hiking function for walking sections - speed = rc.maxSpeed * 3.6; - speed = (speed * FastMath.exp(-3.5 * Math.abs(incline + 0.05))) / 3.6; + speed = rc.maxSpeed * FastMath.exp(-3.5 * Math.abs(incline + 0.05)); } else if (rc.bikeMode) { speed = solveCubic(rc.S_C_x, f_roll, rc.bikerPower); - speed = Math.min(speed, wayMaxspeed); - } else // all other - { - speed = wayMaxspeed; + speed = Math.min(speed, maxSpeed); } float dt = (float) (dist / speed); totalTime += dt;