Fix be attentive with route recalculation

This commit is contained in:
Victor Shcherb 2014-10-26 23:48:47 +01:00
parent 9e87ec17e9
commit a410e2b565

View file

@ -336,20 +336,25 @@ public class RoutePlannerFrontEnd {
List<RouteSegmentResult> prev = ctx.previouslyCalculatedRoute; List<RouteSegmentResult> prev = ctx.previouslyCalculatedRoute;
long id = points.get(1).getRoad().id; long id = points.get(1).getRoad().id;
int ss = points.get(1).getSegmentStart(); int ss = points.get(1).getSegmentStart();
int px = points.get(1).getRoad().getPoint31XTile(ss);
int py = points.get(1).getRoad().getPoint31YTile(ss);
for (int i = 0; i < prev.size(); i++) { for (int i = 0; i < prev.size(); i++) {
RouteSegmentResult rsr = prev.get(i); RouteSegmentResult rsr = prev.get(i);
if (id == rsr.getObject().getId() && ss == rsr.getEndPointIndex()) { if (id == rsr.getObject().getId()) {
firstPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(i + 1); if (MapUtils.getDistance(rsr.getPoint(rsr.getEndPointIndex()), MapUtils.get31LatitudeY(py),
restPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(prev.size() - i); MapUtils.get31LongitudeX(px)) < 50) {
for (int k = 0; k < prev.size(); k++) { firstPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(i + 1);
if (k <= i) { restPartRecalculatedRoute = new ArrayList<RouteSegmentResult>(prev.size() - i);
firstPartRecalculatedRoute.add(prev.get(k)); for (int k = 0; k < prev.size(); k++) {
} else { if (k <= i) {
restPartRecalculatedRoute.add(prev.get(k)); firstPartRecalculatedRoute.add(prev.get(k));
} else {
restPartRecalculatedRoute.add(prev.get(k));
}
} }
System.out.println("Recalculate only first part of the route");
break;
} }
System.out.println("Recalculate only first part of the route");
break;
} }
} }
} }