Fix #9787
This commit is contained in:
parent
bb65803201
commit
a814e21207
1 changed files with 14 additions and 1 deletions
|
@ -469,7 +469,9 @@ public class RouteProvider {
|
||||||
List<Location> gpxRouteLocations = result.getImmutableAllLocations();
|
List<Location> gpxRouteLocations = result.getImmutableAllLocations();
|
||||||
int gpxNextIndex = calcWholeRoute ? 0 : findStartIndexFromRoute(gpxRouteLocations, routeParams.start, calculateOsmAndRouteParts);
|
int gpxNextIndex = calcWholeRoute ? 0 : findStartIndexFromRoute(gpxRouteLocations, routeParams.start, calculateOsmAndRouteParts);
|
||||||
Location gpxNextLocation = null;
|
Location gpxNextLocation = null;
|
||||||
|
Location gpxLastLocation = !gpxRouteLocations.isEmpty() ? gpxRouteLocations.get(gpxRouteLocations.size() - 1) : null;
|
||||||
List<RouteSegmentResult> firstSegmentRoute = null;
|
List<RouteSegmentResult> firstSegmentRoute = null;
|
||||||
|
List<RouteSegmentResult> lastSegmentRoute = null;
|
||||||
List<RouteSegmentResult> gpxRoute;
|
List<RouteSegmentResult> gpxRoute;
|
||||||
if (gpxNextIndex > 0) {
|
if (gpxNextIndex > 0) {
|
||||||
gpxNextLocation = gpxRouteLocations.get(gpxNextIndex);
|
gpxNextLocation = gpxRouteLocations.get(gpxNextIndex);
|
||||||
|
@ -486,14 +488,25 @@ public class RouteProvider {
|
||||||
if (calculateOsmAndRouteParts
|
if (calculateOsmAndRouteParts
|
||||||
&& routeParams.start != null && gpxNextLocation != null
|
&& routeParams.start != null && gpxNextLocation != null
|
||||||
&& gpxNextLocation.distanceTo(routeParams.start) > MIN_DISTANCE_FOR_INSERTING_ROUTE_SEGMENT) {
|
&& gpxNextLocation.distanceTo(routeParams.start) > MIN_DISTANCE_FOR_INSERTING_ROUTE_SEGMENT) {
|
||||||
RouteCalculationResult firstSegmentResult = findOfflineRouteSegment(routeParams, routeParams.start, new LatLon(gpxNextLocation.getLatitude(), gpxNextLocation.getLongitude()));
|
RouteCalculationResult firstSegmentResult = findOfflineRouteSegment(
|
||||||
|
routeParams, routeParams.start, new LatLon(gpxNextLocation.getLatitude(), gpxNextLocation.getLongitude()));
|
||||||
firstSegmentRoute = firstSegmentResult.getOriginalRoute();
|
firstSegmentRoute = firstSegmentResult.getOriginalRoute();
|
||||||
}
|
}
|
||||||
|
if (calculateOsmAndRouteParts
|
||||||
|
&& routeParams.end != null && gpxLastLocation != null
|
||||||
|
&& MapUtils.getDistance(gpxLastLocation.getLatitude(), gpxLastLocation.getLongitude(),
|
||||||
|
routeParams.end.getLatitude(), routeParams.end.getLongitude()) > MIN_DISTANCE_FOR_INSERTING_ROUTE_SEGMENT) {
|
||||||
|
RouteCalculationResult lastSegmentResult = findOfflineRouteSegment(routeParams, gpxLastLocation, routeParams.end);
|
||||||
|
lastSegmentRoute = lastSegmentResult.getOriginalRoute();
|
||||||
|
}
|
||||||
List<RouteSegmentResult> newGpxRoute = new ArrayList<>();
|
List<RouteSegmentResult> newGpxRoute = new ArrayList<>();
|
||||||
if (firstSegmentRoute != null && !firstSegmentRoute.isEmpty()) {
|
if (firstSegmentRoute != null && !firstSegmentRoute.isEmpty()) {
|
||||||
newGpxRoute.addAll(firstSegmentRoute);
|
newGpxRoute.addAll(firstSegmentRoute);
|
||||||
}
|
}
|
||||||
newGpxRoute.addAll(gpxRoute);
|
newGpxRoute.addAll(gpxRoute);
|
||||||
|
if (lastSegmentRoute != null && !lastSegmentRoute.isEmpty()) {
|
||||||
|
newGpxRoute.addAll(lastSegmentRoute);
|
||||||
|
}
|
||||||
return new RouteCalculationResult(newGpxRoute, routeParams.start, routeParams.end,
|
return new RouteCalculationResult(newGpxRoute, routeParams.start, routeParams.end,
|
||||||
routeParams.intermediates, routeParams.ctx, routeParams.leftSide, null, null, routeParams.mode, true);
|
routeParams.intermediates, routeParams.ctx, routeParams.leftSide, null, null, routeParams.mode, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue