From aae6a4af30f70afa84631a224fa43d1fffde095a Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 10 Jun 2019 11:58:14 +0200 Subject: [PATCH] Make code more documented --- .../net/osmand/router/RouteResultPreparation.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java index 9d068fc78f..94522fc57c 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java @@ -222,6 +222,11 @@ public class RouteResultPreparation { } } + // decrease speed proportionally from 15ms (50kmh) + private static final double SLOW_DOWN_SPEED_THRESHOLD = 15; + // reference speed 30ms (108kmh) - 2ms (7kmh) + private static final double SLOW_DOWN_SPEED = 2; + private void calculateTimeSpeed(RoutingContext ctx, List result) throws IOException { //for Naismith boolean usePedestrianHeight = ((((GeneralRouter) ctx.getRouter()).getProfile() == GeneralRouterProfile.PEDESTRIAN) && ((GeneralRouter) ctx.getRouter()).getHeightObstacles()); @@ -234,10 +239,8 @@ public class RouteResultPreparation { if (speed == 0) { speed = ctx.getRouter().getMinDefaultSpeed(); } else { - if(speed > 15) { - // decrease speed proportionally from 15ms=50kmh - - // reference speed 30ms=108kmh - 7kmh - speed = speed - ((speed - 15f) / (30f - 15f) * 2f); + if (speed > SLOW_DOWN_SPEED_THRESHOLD) { + speed = speed - (speed / SLOW_DOWN_SPEED_THRESHOLD - 1) * SLOW_DOWN_SPEED; } } boolean plus = rr.getStartPointIndex() < rr.getEndPointIndex();