Update transport route planner #8986
This commit is contained in:
parent
9a7fcbd7b8
commit
500cd84903
2 changed files with 20 additions and 4 deletions
|
@ -42,6 +42,7 @@ public class TransportRoutePlanner {
|
||||||
|
|
||||||
public List<TransportRouteResult> buildRoute(TransportRoutingContext ctx, LatLon start, LatLon end) throws IOException, InterruptedException {
|
public List<TransportRouteResult> buildRoute(TransportRoutingContext ctx, LatLon start, LatLon end) throws IOException, InterruptedException {
|
||||||
ctx.startCalcTime = System.currentTimeMillis();
|
ctx.startCalcTime = System.currentTimeMillis();
|
||||||
|
double totalDistance = MapUtils.getDistance(start, end);
|
||||||
List<TransportRouteSegment> startStops = ctx.getTransportStops(start);
|
List<TransportRouteSegment> startStops = ctx.getTransportStops(start);
|
||||||
List<TransportRouteSegment> endStops = ctx.getTransportStops(end);
|
List<TransportRouteSegment> endStops = ctx.getTransportStops(end);
|
||||||
|
|
||||||
|
@ -60,7 +61,14 @@ public class TransportRoutePlanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
double finishTime = ctx.cfg.maxRouteTime;
|
double finishTime = ctx.cfg.maxRouteTime;
|
||||||
double maxTravelTimeCmpToWalk = MapUtils.getDistance(start, end) / ctx.cfg.walkSpeed - ctx.cfg.changeTime / 2;
|
ctx.finishTimeSeconds = ctx.cfg.finishTimeSeconds;
|
||||||
|
if (totalDistance > ctx.cfg.maxRouteDistance && ctx.cfg.maxRouteIncreaseSpeed > 0) {
|
||||||
|
int increaseTime = (int) ((totalDistance - ctx.cfg.maxRouteDistance)
|
||||||
|
* 3.6 / ctx.cfg.maxRouteIncreaseSpeed);
|
||||||
|
finishTime += increaseTime;
|
||||||
|
ctx.finishTimeSeconds += increaseTime / 6;
|
||||||
|
}
|
||||||
|
double maxTravelTimeCmpToWalk = totalDistance / ctx.cfg.walkSpeed - ctx.cfg.changeTime / 2;
|
||||||
List<TransportRouteSegment> results = new ArrayList<TransportRouteSegment>();
|
List<TransportRouteSegment> results = new ArrayList<TransportRouteSegment>();
|
||||||
initProgressBar(ctx, start, end);
|
initProgressBar(ctx, start, end);
|
||||||
while (!queue.isEmpty()) {
|
while (!queue.isEmpty()) {
|
||||||
|
@ -82,7 +90,7 @@ public class TransportRoutePlanner {
|
||||||
if (segment.getDepth() > ctx.cfg.maxNumberOfChanges + 1) {
|
if (segment.getDepth() > ctx.cfg.maxNumberOfChanges + 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (segment.distFromStart > finishTime + ctx.cfg.finishTimeSeconds ||
|
if (segment.distFromStart > finishTime + ctx.finishTimeSeconds ||
|
||||||
segment.distFromStart > maxTravelTimeCmpToWalk) {
|
segment.distFromStart > maxTravelTimeCmpToWalk) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +122,7 @@ public class TransportRoutePlanner {
|
||||||
} else {
|
} else {
|
||||||
travelTime += ctx.cfg.stopTime + segmentDist / routeTravelSpeed;
|
travelTime += ctx.cfg.stopTime + segmentDist / routeTravelSpeed;
|
||||||
}
|
}
|
||||||
if(segment.distFromStart + travelTime > finishTime + ctx.cfg.finishTimeSeconds) {
|
if(segment.distFromStart + travelTime > finishTime + ctx.finishTimeSeconds) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sgms.clear();
|
sgms.clear();
|
||||||
|
@ -169,7 +177,7 @@ public class TransportRoutePlanner {
|
||||||
if (finishTime > finish.distFromStart) {
|
if (finishTime > finish.distFromStart) {
|
||||||
finishTime = finish.distFromStart;
|
finishTime = finish.distFromStart;
|
||||||
}
|
}
|
||||||
if(finish.distFromStart < finishTime + ctx.cfg.finishTimeSeconds &&
|
if(finish.distFromStart < finishTime + ctx.finishTimeSeconds &&
|
||||||
(finish.distFromStart < maxTravelTimeCmpToWalk || results.size() == 0)) {
|
(finish.distFromStart < maxTravelTimeCmpToWalk || results.size() == 0)) {
|
||||||
results.add(finish);
|
results.add(finish);
|
||||||
}
|
}
|
||||||
|
@ -732,6 +740,7 @@ public class TransportRoutePlanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TransportRoutingContext {
|
public static class TransportRoutingContext {
|
||||||
|
|
||||||
public NativeLibrary library;
|
public NativeLibrary library;
|
||||||
public RouteCalculationProgress calculationProgress;
|
public RouteCalculationProgress calculationProgress;
|
||||||
public TLongObjectHashMap<TransportRouteSegment> visitedSegments = new TLongObjectHashMap<TransportRouteSegment>();
|
public TLongObjectHashMap<TransportRouteSegment> visitedSegments = new TLongObjectHashMap<TransportRouteSegment>();
|
||||||
|
@ -746,6 +755,7 @@ public class TransportRoutePlanner {
|
||||||
public final Map<BinaryMapIndexReader, TIntObjectHashMap<TransportRoute>> routeMap =
|
public final Map<BinaryMapIndexReader, TIntObjectHashMap<TransportRoute>> routeMap =
|
||||||
new LinkedHashMap<BinaryMapIndexReader, TIntObjectHashMap<TransportRoute>>();
|
new LinkedHashMap<BinaryMapIndexReader, TIntObjectHashMap<TransportRoute>>();
|
||||||
|
|
||||||
|
public int finishTimeSeconds;
|
||||||
|
|
||||||
// stats
|
// stats
|
||||||
public long startCalcTime;
|
public long startCalcTime;
|
||||||
|
|
|
@ -23,6 +23,10 @@ public class TransportRoutingConfiguration {
|
||||||
public int finishTimeSeconds = 1200;
|
public int finishTimeSeconds = 1200;
|
||||||
|
|
||||||
public int maxRouteTime = 60 * 60 * 10; // 10 hours
|
public int maxRouteTime = 60 * 60 * 10; // 10 hours
|
||||||
|
public int maxRouteDistance = 0; // distance for maxRouteTime
|
||||||
|
public int maxRouteIncreaseSpeed = 30; // speed to increase route time
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public GeneralRouter router;
|
public GeneralRouter router;
|
||||||
// cache values from router for fast access
|
// cache values from router for fast access
|
||||||
|
@ -85,6 +89,8 @@ public class TransportRoutingConfiguration {
|
||||||
ZOOM_TO_LOAD_TILES = router.getIntAttribute("zoomToLoadTiles", ZOOM_TO_LOAD_TILES);
|
ZOOM_TO_LOAD_TILES = router.getIntAttribute("zoomToLoadTiles", ZOOM_TO_LOAD_TILES);
|
||||||
maxNumberOfChanges = router.getIntAttribute("maxNumberOfChanges", maxNumberOfChanges);
|
maxNumberOfChanges = router.getIntAttribute("maxNumberOfChanges", maxNumberOfChanges);
|
||||||
maxRouteTime = router.getIntAttribute("maxRouteTime", maxRouteTime);
|
maxRouteTime = router.getIntAttribute("maxRouteTime", maxRouteTime);
|
||||||
|
maxRouteIncreaseSpeed = router.getIntAttribute("maxRouteIncreaseSpeed", maxRouteIncreaseSpeed);
|
||||||
|
maxRouteDistance = router.getIntAttribute("maxRouteDistance", maxRouteDistance);
|
||||||
finishTimeSeconds = router.getIntAttribute("delayForAlternativesRoutes", finishTimeSeconds);
|
finishTimeSeconds = router.getIntAttribute("delayForAlternativesRoutes", finishTimeSeconds);
|
||||||
String mn = params.get("max_num_changes");
|
String mn = params.get("max_num_changes");
|
||||||
maxNumberOfChanges = (int) RoutingConfiguration.parseSilentFloat(mn, maxNumberOfChanges);
|
maxNumberOfChanges = (int) RoutingConfiguration.parseSilentFloat(mn, maxNumberOfChanges);
|
||||||
|
|
Loading…
Reference in a new issue