From ace42e3e34e61226f25f4ca1f4d031ffc1c9d602 Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 24 Jul 2018 14:24:24 +0300 Subject: [PATCH] fix straight lines through buildings to next route location --- .../osmand/plus/routing/RouteProvider.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index a46fae182e..b9142af8f1 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -368,12 +368,19 @@ public class RouteProvider { 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); + if (routeLocations != null && routeLocations.size() >= 1) { + gpxRoute = new ArrayList<>(); + Location trackStart = routeLocations.get(0); + Location realStart = routeParams.start; + if (realStart != null && trackStart != null && realStart.distanceTo(trackStart) > 60) { + LatLon nextRouteLocation = new LatLon(trackStart.getLatitude(), trackStart.getLongitude()); + RouteCalculationResult newRes = findOfflineRouteSegment(routeParams, realStart, nextRouteLocation); + if (newRes != null && newRes.isCalculated()) { + gpxRoute.addAll(0, newRes.getImmutableAllLocations()); + } else { + gpxRoute.add(0, realStart); + } + } gpxRoute.addAll(new ArrayList<>(routeLocations)); endI = new int[]{gpxRoute.size()}; }