fixed bug 95
This commit is contained in:
parent
a5e87ebd43
commit
e1177cf3ce
2 changed files with 53 additions and 50 deletions
|
@ -213,60 +213,63 @@ public class RoutePlannerFrontEnd {
|
||||||
|
|
||||||
private List<RouteSegmentResult> searchRoute(final RoutingContext ctx, List<RouteSegment> points, PrecalculatedRouteDirection routeDirection)
|
private List<RouteSegmentResult> searchRoute(final RoutingContext ctx, List<RouteSegment> points, PrecalculatedRouteDirection routeDirection)
|
||||||
throws IOException, InterruptedException {
|
throws IOException, InterruptedException {
|
||||||
if(points.size() > 2) {
|
if (points.size() <= 2) {
|
||||||
ArrayList<RouteSegmentResult> firstPartRecalculatedRoute = null;
|
ctx.previouslyCalculatedRoute = null;
|
||||||
ArrayList<RouteSegmentResult> restPartRecalculatedRoute = null;
|
return searchRoute(ctx, points.get(0), points.get(1), routeDirection);
|
||||||
if (ctx.previouslyCalculatedRoute != null) {
|
}
|
||||||
List<RouteSegmentResult> prev = ctx.previouslyCalculatedRoute;
|
|
||||||
long id = points.get(1).getRoad().id;
|
|
||||||
int ss = points.get(1).getSegmentStart();
|
|
||||||
for (int i = 0; i < prev.size(); i++) {
|
|
||||||
RouteSegmentResult rsr = prev.get(i);
|
|
||||||
if (id == rsr.getObject().getId() && ss == rsr.getEndPointIndex()) {
|
|
||||||
firstPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(i + 1);
|
|
||||||
restPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(prev.size() - i);
|
|
||||||
for(int k = 0; k < prev.size(); k++) {
|
|
||||||
if(k <= i) {
|
|
||||||
firstPartRecalculatedRoute.add(prev.get(k));
|
|
||||||
} else {
|
|
||||||
restPartRecalculatedRoute.add(prev.get(k));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<RouteSegmentResult> results = new ArrayList<RouteSegmentResult>();
|
|
||||||
for (int i = 0; i < points.size() - 1; i++) {
|
|
||||||
RoutingContext local = new RoutingContext(ctx);
|
|
||||||
if(i == 0) {
|
|
||||||
local.previouslyCalculatedRoute = firstPartRecalculatedRoute;
|
|
||||||
}
|
|
||||||
local.visitor = ctx.visitor;
|
|
||||||
local.calculationProgress = ctx.calculationProgress;
|
|
||||||
List<RouteSegmentResult> res = searchRouteInternalPrepare(local, points.get(i), points.get(i + 1), routeDirection);
|
|
||||||
|
|
||||||
results.addAll(res);
|
ArrayList<RouteSegmentResult> firstPartRecalculatedRoute = null;
|
||||||
ctx.distinctLoadedTiles += local.distinctLoadedTiles;
|
ArrayList<RouteSegmentResult> restPartRecalculatedRoute = null;
|
||||||
ctx.loadedTiles += local.loadedTiles;
|
if (ctx.previouslyCalculatedRoute != null) {
|
||||||
ctx.visitedSegments += local.visitedSegments;
|
List<RouteSegmentResult> prev = ctx.previouslyCalculatedRoute;
|
||||||
ctx.loadedPrevUnloadedTiles += local.loadedPrevUnloadedTiles;
|
long id = points.get(1).getRoad().id;
|
||||||
ctx.timeToCalculate += local.timeToCalculate;
|
int ss = points.get(1).getSegmentStart();
|
||||||
ctx.timeToLoad += local.timeToLoad;
|
for (int i = 0; i < prev.size(); i++) {
|
||||||
ctx.timeToLoadHeaders += local.timeToLoadHeaders;
|
RouteSegmentResult rsr = prev.get(i);
|
||||||
ctx.relaxedSegments += local.relaxedSegments;
|
if (id == rsr.getObject().getId() && ss == rsr.getEndPointIndex()) {
|
||||||
ctx.routingTime += local.routingTime;
|
firstPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(i + 1);
|
||||||
|
restPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(prev.size() - i);
|
||||||
local.unloadAllData(ctx);
|
for (int k = 0; k < prev.size(); k++) {
|
||||||
if(restPartRecalculatedRoute != null) {
|
if (k <= i) {
|
||||||
results.addAll(restPartRecalculatedRoute);
|
firstPartRecalculatedRoute.add(prev.get(k));
|
||||||
|
} else {
|
||||||
|
restPartRecalculatedRoute.add(prev.get(k));
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.unloadAllData();
|
|
||||||
return results;
|
|
||||||
}
|
}
|
||||||
return searchRoute(ctx, points.get(0), points.get(1), routeDirection);
|
List<RouteSegmentResult> results = new ArrayList<RouteSegmentResult>();
|
||||||
|
for (int i = 0; i < points.size() - 1; i++) {
|
||||||
|
RoutingContext local = new RoutingContext(ctx);
|
||||||
|
if (i == 0) {
|
||||||
|
//local.previouslyCalculatedRoute = firstPartRecalculatedRoute;
|
||||||
|
}
|
||||||
|
local.visitor = ctx.visitor;
|
||||||
|
local.calculationProgress = ctx.calculationProgress;
|
||||||
|
List<RouteSegmentResult> res = searchRouteInternalPrepare(local, points.get(i), points.get(i + 1), routeDirection);
|
||||||
|
|
||||||
|
results.addAll(res);
|
||||||
|
ctx.distinctLoadedTiles += local.distinctLoadedTiles;
|
||||||
|
ctx.loadedTiles += local.loadedTiles;
|
||||||
|
ctx.visitedSegments += local.visitedSegments;
|
||||||
|
ctx.loadedPrevUnloadedTiles += local.loadedPrevUnloadedTiles;
|
||||||
|
ctx.timeToCalculate += local.timeToCalculate;
|
||||||
|
ctx.timeToLoad += local.timeToLoad;
|
||||||
|
ctx.timeToLoadHeaders += local.timeToLoadHeaders;
|
||||||
|
ctx.relaxedSegments += local.relaxedSegments;
|
||||||
|
ctx.routingTime += local.routingTime;
|
||||||
|
|
||||||
|
local.unloadAllData(ctx);
|
||||||
|
if (restPartRecalculatedRoute != null) {
|
||||||
|
results.addAll(restPartRecalculatedRoute);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.unloadAllData();
|
||||||
|
return results;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
|
|
|
@ -670,7 +670,7 @@ public class RouteProvider {
|
||||||
ctx.calculationProgress = params.calculationProgress;
|
ctx.calculationProgress = params.calculationProgress;
|
||||||
if(params.previousToRecalculate != null) {
|
if(params.previousToRecalculate != null) {
|
||||||
// not used any more
|
// not used any more
|
||||||
// ctx.previouslyCalculatedRoute = params.previousToRecalculate.getOriginalRoute();
|
ctx.previouslyCalculatedRoute = params.previousToRecalculate.getOriginalRoute();
|
||||||
}
|
}
|
||||||
LatLon st = new LatLon(params.start.getLatitude(), params.start.getLongitude());
|
LatLon st = new LatLon(params.start.getLatitude(), params.start.getLongitude());
|
||||||
LatLon en = new LatLon(params.end.getLatitude(), params.end.getLongitude());
|
LatLon en = new LatLon(params.end.getLatitude(), params.end.getLongitude());
|
||||||
|
|
Loading…
Reference in a new issue