Merge branch 'master' into rework-voicehint

This commit is contained in:
afischerdev 2024-03-08 12:44:22 +01:00 committed by GitHub
commit 7f880a5826
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 3 additions and 77 deletions

View file

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

View file

@ -20,8 +20,6 @@ import btools.mapaccess.OsmLink;
import btools.mapaccess.OsmLinkHolder;
import btools.mapaccess.OsmNode;
import btools.mapaccess.OsmNodePairSet;
import btools.util.CheapAngleMeter;
import btools.util.CheapRuler;
import btools.util.CompactLongMap;
import btools.util.SortedHeap;
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_GETELEV = 2;
public final static int BROUTER_ENGINEMODE_PREPARE_REROUTE = 6;
private NodesCache nodesCache;
private SortedHeap<OsmPath> openSet = new SortedHeap<>();
private boolean finished = false;
@ -162,7 +158,6 @@ 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!");
}
@ -194,9 +189,6 @@ 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) {
@ -583,10 +575,6 @@ 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
@ -599,22 +587,6 @@ public class RoutingEngine extends Thread {
matchedWaypoints.add(mwp);
}
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);
@ -659,8 +631,7 @@ public class RoutingEngine extends Thread {
routingContext.inverseDirection = false;
wptIndex = i + 1;
} 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), nearbyTrack, refTracks[i]);
seg = searchTrack(matchedWaypoints.get(i), matchedWaypoints.get(i + 1), i == matchedWaypoints.size() - 2 ? nearbyTrack : null, refTracks[i]);
wptIndex = i;
}
if (seg == null)
@ -1077,18 +1048,7 @@ public class RoutingEngine extends Thread {
track.nogoChecksums = routingContext.getNogoChecksums();
track.profileTimestamp = routingContext.profileTimestamp;
track.isDirty = isDirty;
if (foundRawTrack == null) {
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
}
foundRawTrack = track;
}
if (!wasClean && isDirty) {

View file

@ -105,29 +105,13 @@ public class BRouter {
if (engineMode == RoutingEngine.BROUTER_ENGINEMODE_GETELEV) {
re = new RoutingEngine("testinfo", null, new File(args[0]), wplist, rc, engineMode);
} else {
// use this to generate a raw track for CLI
// rc.rawTrackPath = "testtrack.raw";
re = new RoutingEngine("testtrack", null, new File(args[0]), wplist, rc, engineMode);
}
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 (rc.rawTrackPath != null && re.getFoundRawTrack() != null) {
try {
re.getFoundRawTrack().writeBinary(rc.rawTrackPath);
} catch (Exception e) {
e.printStackTrace();
}
}
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}

View file

@ -77,21 +77,4 @@ public final class CheapRuler {
double dlat = (ilat1 - ilat2) * kxky[1];
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;
}
}