diff --git a/OsmAnd-java/src/net/osmand/router/RouteCalculationProgress.java b/OsmAnd-java/src/net/osmand/router/RouteCalculationProgress.java index 720d92603b..a875f1b8b3 100644 --- a/OsmAnd-java/src/net/osmand/router/RouteCalculationProgress.java +++ b/OsmAnd-java/src/net/osmand/router/RouteCalculationProgress.java @@ -20,4 +20,22 @@ public class RouteCalculationProgress { public boolean isCancelled; public boolean requestPrivateAccessRouting; + + private static final float FIRST_ITERATION = 0.75f; + public float getLinearProgress() { + float p = Math.max(distanceFromBegin, distanceFromEnd); + float all = totalEstimatedDistance * 1.25f; + float pr = 0; + if (all > 0) { + pr = Math.min(p * p / (all * all) * 100f, 99); + } + if(totalIterations > 1) { + if(iteration <= 0) { + return pr * FIRST_ITERATION; + } else { + return Math.min(FIRST_ITERATION * 100 + pr * (1 - FIRST_ITERATION), 99); + } + } + return pr; + } } diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 0bf319b8ea..2b86ec6b35 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -1006,14 +1006,8 @@ public class RoutingHelper { public void run() { RouteCalculationProgress calculationProgress = params.calculationProgress; if (isRouteBeingCalculated()) { - float p = Math.max(calculationProgress.distanceFromBegin, calculationProgress.distanceFromEnd); - float all = calculationProgress.totalEstimatedDistance * 1.25f; - if (all > 0) { - int t = (int) Math.min(p * p / (all * all) * 100f, 99); - progressRoute.updateProgress(t); - } else { - progressRoute.updateProgress(0); - } + float pr = calculationProgress.getLinearProgress(); + progressRoute.updateProgress((int) pr); Thread t = currentRunningJob; if(t instanceof RouteRecalculationThread && ((RouteRecalculationThread) t).params != params) { // different calculation started