prepare rerouting

This commit is contained in:
afischerdev 2024-01-19 16:37:29 +01:00
parent ae7411d4a0
commit e5ecd14ce1
2 changed files with 16 additions and 1 deletions

View file

@ -32,6 +32,8 @@ public class RoutingEngine extends Thread {
public final static int BROUTER_ENGINEMODE_SEED = 1;
public final static int BROUTER_ENGINEMODE_GETELEV = 2;
public final static int BROUTER_ENGINEMODE_PREPARE_REROUTE = 6;
private NodesCache nodesCache;
private SortedHeap<OsmPath> openSet = new SortedHeap<>();
private boolean finished = false;
@ -160,6 +162,7 @@ public class RoutingEngine extends Thread {
switch (engineMode) {
case BROUTER_ENGINEMODE_ROUTING:
case BROUTER_ENGINEMODE_PREPARE_REROUTE:
if (waypoints.size() < 2) {
throw new IllegalArgumentException("we need two lat/lon points at least!");
}
@ -191,6 +194,9 @@ public class RoutingEngine extends Thread {
ArrayList<String> messageList = new ArrayList<>();
for (int i = 0; ; i++) {
track = findTrack(refTracks, lastTracks);
if (engineMode==BROUTER_ENGINEMODE_PREPARE_REROUTE) break; // no output for rerouting prepare
track.message = "track-length = " + track.distance + " filtered ascend = " + track.ascend
+ " plain-ascend = " + track.plainAscend + " cost=" + track.cost;
if (track.energy != 0) {
@ -577,6 +583,10 @@ public class RoutingEngine extends Thread {
boolean dirty = found && nearbyTrack.isDirty;
logInfo("read referenceTrack, found=" + found + " dirty=" + dirty + " " + debugInfo);
}
if (nearbyTrack != null &&
engineMode==BROUTER_ENGINEMODE_PREPARE_REROUTE) {
return null; // already rerouting prepared
}
}
if (matchedWaypoints == null) { // could exist from the previous alternative level
@ -1067,6 +1077,10 @@ public class RoutingEngine extends Thread {
track.profileTimestamp = routingContext.profileTimestamp;
track.isDirty = isDirty;
foundRawTrack = track;
if (engineMode==BROUTER_ENGINEMODE_PREPARE_REROUTE) {
return null; // rerouting prepared
}
}
if (!wasClean && isDirty) {

View file

@ -110,7 +110,8 @@ public class BRouter {
}
re.doRun(0);
if (engineMode == RoutingEngine.BROUTER_ENGINEMODE_ROUTING) {
if (engineMode == RoutingEngine.BROUTER_ENGINEMODE_ROUTING ||
engineMode == RoutingEngine.BROUTER_ENGINEMODE_PREPARE_REROUTE) {
// store new reference track if any
// (can exist for timed-out search)
if (re.getFoundRawTrack() != null) {