diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index ef847f7d8b..a46fae182e 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -366,6 +366,18 @@ public class RouteProvider { int[] endI = new int[]{gpxParams.points.size()}; if(routeParams.gpxRoute.passWholeRoute) { gpxRoute = gpxParams.points; + if (routeParams.previousToRecalculate != null && routeParams.onlyStartPointChanged) { + List routeLocations = routeParams.previousToRecalculate.getRouteLocations(); + if (routeLocations != null) { + Location loc = routeParams.previousToRecalculate.getNextRouteLocation(); + LatLon nextRouteLocation = new LatLon(loc.getLatitude(), loc.getLongitude()); + List routeToNextRouteLocation = findStartAndEndLocationsFromRoute(routeLocations, + routeParams.start, nextRouteLocation, null, null); + gpxRoute = new ArrayList<>(routeToNextRouteLocation); + gpxRoute.addAll(new ArrayList<>(routeLocations)); + endI = new int[]{gpxRoute.size()}; + } + } } else { gpxRoute = findStartAndEndLocationsFromRoute(gpxParams.points, routeParams.start, routeParams.end, startI, endI); diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 689777d5b3..fa15b79b5d 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -957,7 +957,8 @@ public class RoutingHelper { params.intermediates = intermediates; params.gpxRoute = gpxRoute == null ? null : gpxRoute.build(start, settings); params.onlyStartPointChanged = onlyStartPointChanged; - if(recalculateCountInInterval < RECALCULATE_THRESHOLD_COUNT_CAUSING_FULL_RECALCULATE) { + if (recalculateCountInInterval < RECALCULATE_THRESHOLD_COUNT_CAUSING_FULL_RECALCULATE + || (gpxRoute != null && gpxRoute.isPassWholeRoute() && isDeviatedFromRoute)) { params.previousToRecalculate = previousRoute; } else { recalculateCountInInterval = 0;