From 4bb2ed28aef13377f94bc65f3bfb698604fdc16b Mon Sep 17 00:00:00 2001 From: cepprice Date: Wed, 17 Feb 2021 18:14:44 +0500 Subject: [PATCH] Fix #10872 --- .../src/net/osmand/plus/routing/RouteProvider.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index b3b2a11ab6..1d991a7ef1 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -407,16 +407,13 @@ public class RouteProvider { if (gpxParams.reverse && gpxParams.routePoints.size() > 1) { List gpxRouteLocations = new ArrayList<>(); List gpxRoute = new ArrayList<>(); - Location start = null; - for (int i = 0; i < gpxParams.routePoints.size(); i++) { + WptPt firstGpxPoint = gpxParams.routePoints.get(0); + Location start = new Location("", firstGpxPoint.getLatitude(), firstGpxPoint.getLongitude()); + + for (int i = 1; i < gpxParams.routePoints.size(); i++) { WptPt pt = gpxParams.routePoints.get(i); ApplicationMode appMode = ApplicationMode.valueOfStringKey(pt.getProfileType(), ApplicationMode.DEFAULT); LatLon end = new LatLon(pt.getLatitude(), pt.getLongitude()); - if (start == null) { - start = new Location(""); - start.setLatitude(routeParams.start.getLatitude()); - start.setLongitude(routeParams.start.getLongitude()); - } RouteCalculationParams params = new RouteCalculationParams(); params.inSnapToRoadMode = true; @@ -440,7 +437,7 @@ public class RouteProvider { routeParams.mode.getDefaultSpeed(), new LocationsHolder(locations).getLatLonList())); } gpxRouteLocations.addAll(locations); - if (i > 0 && !gpxRouteLocations.isEmpty()) { + if (!gpxRouteLocations.isEmpty()) { gpxRouteLocations.remove(gpxRouteLocations.size() - 1); } gpxRoute.addAll(route);