Merge branch 'r3.3'

This commit is contained in:
Victor Shcherb 2019-03-15 13:50:10 +01:00
commit 28b69de4ab

View file

@ -95,7 +95,7 @@ public class TransportRoutePlanner {
} else { } else {
travelTime += ctx.cfg.stopTime + segmentDist / ctx.cfg.travelSpeed; travelTime += ctx.cfg.stopTime + segmentDist / ctx.cfg.travelSpeed;
} }
if(travelTime > finishTime + ctx.cfg.finishTimeSeconds) { if(segment.distFromStart + travelTime > finishTime + ctx.cfg.finishTimeSeconds) {
break; break;
} }
sgms.clear(); sgms.clear();
@ -107,31 +107,31 @@ public class TransportRoutePlanner {
if (segment.wasVisited(sgm)) { if (segment.wasVisited(sgm)) {
continue; continue;
} }
TransportRouteSegment rrs = new TransportRouteSegment(sgm); TransportRouteSegment nextSegment = new TransportRouteSegment(sgm);
rrs.parentRoute = segment; nextSegment.parentRoute = segment;
rrs.parentStop = ind; nextSegment.parentStop = ind;
rrs.walkDist = MapUtils.getDistance(rrs.getLocation(), stop.getLocation()); nextSegment.walkDist = MapUtils.getDistance(nextSegment.getLocation(), stop.getLocation());
rrs.parentTravelTime = travelTime; nextSegment.parentTravelTime = travelTime;
rrs.parentTravelDist = travelDist; nextSegment.parentTravelDist = travelDist;
double walkTime = rrs.walkDist / ctx.cfg.walkSpeed double walkTime = nextSegment.walkDist / ctx.cfg.walkSpeed
+ (ctx.cfg.getChangeTime()); + (ctx.cfg.getChangeTime());
rrs.distFromStart = segment.distFromStart + travelTime + walkTime; nextSegment.distFromStart = segment.distFromStart + travelTime + walkTime;
if(ctx.cfg.useSchedule) { if(ctx.cfg.useSchedule) {
int tm = (sgm.departureTime - ctx.cfg.scheduleTimeOfDay) * 10; int tm = (sgm.departureTime - ctx.cfg.scheduleTimeOfDay) * 10;
if(tm >= rrs.distFromStart) { if(tm >= nextSegment.distFromStart) {
rrs.distFromStart = tm; nextSegment.distFromStart = tm;
queue.add(rrs); queue.add(nextSegment);
} }
} else { } else {
queue.add(rrs); queue.add(nextSegment);
} }
} }
TransportRouteSegment f = endSegments.get(segmentId); TransportRouteSegment finalSegment = endSegments.get(segmentId);
double distToEnd = MapUtils.getDistance(stop.getLocation(), end); double distToEnd = MapUtils.getDistance(stop.getLocation(), end);
if (f != null && distToEnd < ctx.cfg.walkRadius) { if (finalSegment != null && distToEnd < ctx.cfg.walkRadius) {
if (finish == null || minDist > distToEnd) { if (finish == null || minDist > distToEnd) {
minDist = distToEnd; minDist = distToEnd;
finish = new TransportRouteSegment(f); finish = new TransportRouteSegment(finalSegment);
finish.parentRoute = segment; finish.parentRoute = segment;
finish.parentStop = ind; finish.parentStop = ind;
finish.walkDist = distToEnd; finish.walkDist = distToEnd;
@ -213,9 +213,15 @@ public class TransportRoutePlanner {
return null; return null;
} }
if (p.parentRoute != null) { if (p.parentRoute != null) {
TransportRouteResultSegment sg = new TransportRouteResultSegment(p.parentRoute.road, TransportRouteResultSegment sg = new TransportRouteResultSegment();
p.parentRoute.segStart, p.parentStop, p.parentRoute.walkDist, sg.route = p.parentRoute.road;
p.departureTime); sg.start = p.parentRoute.segStart;
sg.end = p.parentStop;
sg.walkDist = p.parentRoute.walkDist;
sg.walkTime = sg.walkDist / ctx.cfg.walkSpeed;
sg.depTime = p.departureTime;
sg.travelInaccurateDist = p.parentTravelDist;
sg.travelTime = p.parentTravelTime;
route.segments.add(0, sg); route.segments.add(0, sg);
} }
p = p.parentRoute; p = p.parentRoute;
@ -277,20 +283,19 @@ public class TransportRoutePlanner {
public static class TransportRouteResultSegment { public static class TransportRouteResultSegment {
private static final boolean DISPLAY_FULL_SEGMENT_ROUTE = false; private static final boolean DISPLAY_FULL_SEGMENT_ROUTE = false;
private static final int DISPLAY_SEGMENT_IND = 0; private static final int DISPLAY_SEGMENT_IND = 0;
public final TransportRoute route; public TransportRoute route;
public final int start; public double walkTime;
public final int end; public double travelInaccurateDist;
public final double walkDist ; public double travelTime;
public final int depTime; public int start;
public int end;
public double walkDist ;
public int depTime;
public TransportRouteResultSegment(TransportRoute route, int start, int end, double walkDist, int depTime) { public TransportRouteResultSegment() {
this.route = route;
this.start = start;
this.end = end;
this.walkDist = walkDist;
this.depTime = depTime;
} }
public int getArrivalTime() { public int getArrivalTime() {
@ -533,9 +538,9 @@ public class TransportRoutePlanner {
private static final int SHIFT_DEPTIME = 14; // assume less than 1024 stops private static final int SHIFT_DEPTIME = 14; // assume less than 1024 stops
TransportRouteSegment parentRoute = null; TransportRouteSegment parentRoute = null;
int parentStop; int parentStop; // last stop to exit for parent route
double parentTravelTime; // travel time double parentTravelTime; // travel time for parent route
double parentTravelDist; // inaccurate double parentTravelDist; // travel distance for parent route (inaccurate)
// walk distance to start route location (or finish in case last segment) // walk distance to start route location (or finish in case last segment)
double walkDist = 0; double walkDist = 0;