Merge pull request #679 from abrensch/revert-674-rerouting

Revert "App: Rerouting"
This commit is contained in:
afischerdev 2024-03-08 12:24:03 +01:00 committed by GitHub
commit aa393ab7dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 3 additions and 76 deletions

View file

@ -285,7 +285,6 @@ public final class OsmTrack {
} }
dis.close(); dis.close();
} catch (Exception e) { } catch (Exception e) {
t = null;
if (debugInfo != null) { if (debugInfo != null) {
debugInfo.append("Error reading rawTrack: " + e); debugInfo.append("Error reading rawTrack: " + e);
} }

View file

@ -20,8 +20,6 @@ import btools.mapaccess.OsmLink;
import btools.mapaccess.OsmLinkHolder; import btools.mapaccess.OsmLinkHolder;
import btools.mapaccess.OsmNode; import btools.mapaccess.OsmNode;
import btools.mapaccess.OsmNodePairSet; import btools.mapaccess.OsmNodePairSet;
import btools.util.CheapAngleMeter;
import btools.util.CheapRuler;
import btools.util.CompactLongMap; import btools.util.CompactLongMap;
import btools.util.SortedHeap; import btools.util.SortedHeap;
import btools.util.StackSampler; import btools.util.StackSampler;
@ -32,8 +30,6 @@ public class RoutingEngine extends Thread {
public final static int BROUTER_ENGINEMODE_SEED = 1; public final static int BROUTER_ENGINEMODE_SEED = 1;
public final static int BROUTER_ENGINEMODE_GETELEV = 2; public final static int BROUTER_ENGINEMODE_GETELEV = 2;
public final static int BROUTER_ENGINEMODE_PREPARE_REROUTE = 6;
private NodesCache nodesCache; private NodesCache nodesCache;
private SortedHeap<OsmPath> openSet = new SortedHeap<>(); private SortedHeap<OsmPath> openSet = new SortedHeap<>();
private boolean finished = false; private boolean finished = false;
@ -162,7 +158,6 @@ public class RoutingEngine extends Thread {
switch (engineMode) { switch (engineMode) {
case BROUTER_ENGINEMODE_ROUTING: case BROUTER_ENGINEMODE_ROUTING:
case BROUTER_ENGINEMODE_PREPARE_REROUTE:
if (waypoints.size() < 2) { if (waypoints.size() < 2) {
throw new IllegalArgumentException("we need two lat/lon points at least!"); throw new IllegalArgumentException("we need two lat/lon points at least!");
} }
@ -194,9 +189,6 @@ public class RoutingEngine extends Thread {
ArrayList<String> messageList = new ArrayList<>(); ArrayList<String> messageList = new ArrayList<>();
for (int i = 0; ; i++) { for (int i = 0; ; i++) {
track = findTrack(refTracks, lastTracks); 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 track.message = "track-length = " + track.distance + " filtered ascend = " + track.ascend
+ " plain-ascend = " + track.plainAscend + " cost=" + track.cost; + " plain-ascend = " + track.plainAscend + " cost=" + track.cost;
if (track.energy != 0) { if (track.energy != 0) {
@ -583,10 +575,6 @@ public class RoutingEngine extends Thread {
boolean dirty = found && nearbyTrack.isDirty; boolean dirty = found && nearbyTrack.isDirty;
logInfo("read referenceTrack, found=" + found + " dirty=" + dirty + " " + debugInfo); 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 if (matchedWaypoints == null) { // could exist from the previous alternative level
@ -599,22 +587,6 @@ public class RoutingEngine extends Thread {
matchedWaypoints.add(mwp); matchedWaypoints.add(mwp);
} }
matchWaypointsToNodes(matchedWaypoints); matchWaypointsToNodes(matchedWaypoints);
if (routingContext.startDirection != null) {
// add a nogo not to turn back
double angle = CheapAngleMeter.normalize(180 + routingContext.startDirection);
int[] np = CheapRuler.destination(matchedWaypoints.get(0).crosspoint.ilon, matchedWaypoints.get(0).crosspoint.ilat, 10, angle);
OsmNodeNamed n = new OsmNodeNamed();
n.name = "nogo8";
n.ilon = np[0];
n.ilat = np[1];
n.isNogo = true;
n.radius = 8;
n.nogoWeight = 9999;
if (routingContext.nogopoints == null) {
routingContext.nogopoints = new ArrayList<>();
}
routingContext.nogopoints.add(n);
}
routingContext.checkMatchedWaypointAgainstNogos(matchedWaypoints); routingContext.checkMatchedWaypointAgainstNogos(matchedWaypoints);
@ -659,8 +631,7 @@ public class RoutingEngine extends Thread {
routingContext.inverseDirection = false; routingContext.inverseDirection = false;
wptIndex = i + 1; wptIndex = i + 1;
} else { } else {
//seg = searchTrack(matchedWaypoints.get(i), matchedWaypoints.get(i + 1), i == matchedWaypoints.size() - 2 ? nearbyTrack : null, refTracks[i]); seg = searchTrack(matchedWaypoints.get(i), matchedWaypoints.get(i + 1), i == matchedWaypoints.size() - 2 ? nearbyTrack : null, refTracks[i]);
seg = searchTrack(matchedWaypoints.get(i), matchedWaypoints.get(i + 1), nearbyTrack, refTracks[i]);
wptIndex = i; wptIndex = i;
} }
if (seg == null) if (seg == null)
@ -1077,18 +1048,7 @@ public class RoutingEngine extends Thread {
track.nogoChecksums = routingContext.getNogoChecksums(); track.nogoChecksums = routingContext.getNogoChecksums();
track.profileTimestamp = routingContext.profileTimestamp; track.profileTimestamp = routingContext.profileTimestamp;
track.isDirty = isDirty; track.isDirty = isDirty;
if (foundRawTrack == null) {
foundRawTrack = track; foundRawTrack = track;
} else {
for (OsmPathElement n : track.nodes) {
foundRawTrack.nodes.add(n);
}
foundRawTrack.endPoint = endWp;
}
if (engineMode==BROUTER_ENGINEMODE_PREPARE_REROUTE) {
return null; // rerouting prepared
}
} }
if (!wasClean && isDirty) { if (!wasClean && isDirty) {

View file

@ -105,24 +105,9 @@ public class BRouter {
if (engineMode == RoutingEngine.BROUTER_ENGINEMODE_GETELEV) { if (engineMode == RoutingEngine.BROUTER_ENGINEMODE_GETELEV) {
re = new RoutingEngine("testinfo", null, new File(args[0]), wplist, rc, engineMode); re = new RoutingEngine("testinfo", null, new File(args[0]), wplist, rc, engineMode);
} else { } else {
rc.rawTrackPath = "testtrack.raw";
re = new RoutingEngine("testtrack", null, new File(args[0]), wplist, rc, engineMode); re = new RoutingEngine("testtrack", null, new File(args[0]), wplist, rc, engineMode);
} }
re.doRun(0); re.doRun(0);
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) {
try {
re.getFoundRawTrack().writeBinary(rc.rawTrackPath);
} catch (Exception e) {
e.printStackTrace();
}
}
}
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }

View file

@ -77,21 +77,4 @@ public final class CheapRuler {
double dlat = (ilat1 - ilat2) * kxky[1]; double dlat = (ilat1 - ilat2) * kxky[1];
return Math.sqrt(dlat * dlat + dlon * dlon); // in m return Math.sqrt(dlat * dlat + dlon * dlon); // in m
} }
public static int[] destination(int lon1, int lat1, double distance, double angle) {
double[] lonlat2m = CheapRuler.getLonLatToMeterScales(lat1);
double lon2m = lonlat2m[0];
double lat2m = lonlat2m[1];
angle = 90. - angle;
double st = Math.sin(angle * Math.PI / 180.);
double ct = Math.cos(angle * Math.PI / 180.);
int lon2 = (int) (0.5 + lon1 + ct * distance / lon2m);
int lat2 = (int) (0.5 + lat1 + st * distance / lat2m);
int[] ret = new int[2];
ret[0] = lon2;
ret[1] = lat2;
return ret;
}
} }