introducing engineMode for future use
This commit is contained in:
parent
0c32770cfd
commit
3dffea1753
5 changed files with 48 additions and 3 deletions
|
@ -25,6 +25,11 @@ import btools.util.SortedHeap;
|
||||||
import btools.util.StackSampler;
|
import btools.util.StackSampler;
|
||||||
|
|
||||||
public class RoutingEngine extends Thread {
|
public class RoutingEngine extends Thread {
|
||||||
|
|
||||||
|
public final static int BROUTER_ENGINEMODE_ROUTING = 0;
|
||||||
|
public final static int BROUTER_ENGINEMODE_SEED = 1;
|
||||||
|
public final static int BROUTER_ENGINEMODE_OTHER = 2;
|
||||||
|
|
||||||
private NodesCache nodesCache;
|
private NodesCache nodesCache;
|
||||||
private SortedHeap<OsmPath> openSet = new SortedHeap<OsmPath>();
|
private SortedHeap<OsmPath> openSet = new SortedHeap<OsmPath>();
|
||||||
private boolean finished = false;
|
private boolean finished = false;
|
||||||
|
@ -37,6 +42,8 @@ public class RoutingEngine extends Thread {
|
||||||
private int MAXNODES_ISLAND_CHECK = 500;
|
private int MAXNODES_ISLAND_CHECK = 500;
|
||||||
private OsmNodePairSet islandNodePairs = new OsmNodePairSet(MAXNODES_ISLAND_CHECK);
|
private OsmNodePairSet islandNodePairs = new OsmNodePairSet(MAXNODES_ISLAND_CHECK);
|
||||||
|
|
||||||
|
private int engineMode = 0;
|
||||||
|
|
||||||
private int MAX_STEPS_CHECK = 10;
|
private int MAX_STEPS_CHECK = 10;
|
||||||
|
|
||||||
protected OsmTrack foundTrack = new OsmTrack();
|
protected OsmTrack foundTrack = new OsmTrack();
|
||||||
|
@ -73,12 +80,20 @@ public class RoutingEngine extends Thread {
|
||||||
|
|
||||||
public RoutingEngine(String outfileBase, String logfileBase, File segmentDir,
|
public RoutingEngine(String outfileBase, String logfileBase, File segmentDir,
|
||||||
List<OsmNodeNamed> waypoints, RoutingContext rc) {
|
List<OsmNodeNamed> waypoints, RoutingContext rc) {
|
||||||
|
this(0, outfileBase, logfileBase, segmentDir,
|
||||||
|
waypoints, rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoutingEngine(int engineMode, String outfileBase, String logfileBase, File segmentDir,
|
||||||
|
List<OsmNodeNamed> waypoints, RoutingContext rc) {
|
||||||
this.segmentDir = segmentDir;
|
this.segmentDir = segmentDir;
|
||||||
this.outfileBase = outfileBase;
|
this.outfileBase = outfileBase;
|
||||||
this.logfileBase = logfileBase;
|
this.logfileBase = logfileBase;
|
||||||
this.waypoints = waypoints;
|
this.waypoints = waypoints;
|
||||||
this.infoLogEnabled = outfileBase != null;
|
this.infoLogEnabled = outfileBase != null;
|
||||||
this.routingContext = rc;
|
this.routingContext = rc;
|
||||||
|
this.engineMode = engineMode;
|
||||||
|
|
||||||
|
|
||||||
File baseFolder = new File(routingContext.localFunction).getParentFile();
|
File baseFolder = new File(routingContext.localFunction).getParentFile();
|
||||||
baseFolder = baseFolder == null ? null : baseFolder.getParentFile();
|
baseFolder = baseFolder == null ? null : baseFolder.getParentFile();
|
||||||
|
@ -138,6 +153,16 @@ public class RoutingEngine extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doRun(long maxRunningTime) {
|
public void doRun(long maxRunningTime) {
|
||||||
|
switch (engineMode) {
|
||||||
|
case BROUTER_ENGINEMODE_ROUTING: doRouting(maxRunningTime); break;
|
||||||
|
case BROUTER_ENGINEMODE_SEED: /* do nothing, handled the old way */ break;
|
||||||
|
case BROUTER_ENGINEMODE_OTHER: /* call others */ break;
|
||||||
|
default: doRouting(maxRunningTime); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void doRouting(long maxRunningTime) {
|
||||||
try {
|
try {
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
long startTime0 = startTime;
|
long startTime0 = startTime;
|
||||||
|
|
|
@ -34,6 +34,7 @@ interface IBRouterService {
|
||||||
// "timode" = turnInstructionMode [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies-style, 6=orux-style, 7=locus-old-style] default 0
|
// "timode" = turnInstructionMode [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies-style, 6=orux-style, 7=locus-old-style] default 0
|
||||||
// "heading" = angle (optional to give a route a start direction)
|
// "heading" = angle (optional to give a route a start direction)
|
||||||
// "direction" = angle (optional, used like "heading" on a recalculation request by Locus as start direction)
|
// "direction" = angle (optional, used like "heading" on a recalculation request by Locus as start direction)
|
||||||
|
// "engineMode" = 0 (optional, no more modes defined at the moment)
|
||||||
|
|
||||||
// return null if all ok and no path given, the track if ok and path given, an error message if it was wrong
|
// return null if all ok and no path given, the track if ok and path given, an error message if it was wrong
|
||||||
// the resultas string when 'pathToFileResult' is null, this should be default when Android Q or later
|
// the resultas string when 'pathToFileResult' is null, this should be default when Android Q or later
|
||||||
|
|
|
@ -141,13 +141,17 @@ public class BRouterWorker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int engineMode = 0;
|
||||||
|
if (params.containsKey("engineMode")) {
|
||||||
|
engineMode = params.getInt("engineMode", 0);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
writeTimeoutData(rc);
|
writeTimeoutData(rc);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RoutingEngine cr = new RoutingEngine(null, null, segmentDir, waypoints, rc);
|
RoutingEngine cr = new RoutingEngine(engineMode, null, null, segmentDir, waypoints, rc);
|
||||||
cr.quite = true;
|
cr.quite = true;
|
||||||
cr.doRun(maxRunningTime);
|
cr.doRun(maxRunningTime);
|
||||||
|
|
||||||
|
|
|
@ -191,8 +191,11 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
|
||||||
if (wplist.size() < 10) {
|
if (wplist.size() < 10) {
|
||||||
SuspectManager.nearRecentWps.add(wplist);
|
SuspectManager.nearRecentWps.add(wplist);
|
||||||
}
|
}
|
||||||
|
int engineMode = 0;
|
||||||
for (Map.Entry<String, String> e : params.entrySet()) {
|
for (Map.Entry<String, String> e : params.entrySet()) {
|
||||||
if ("timode".equals(e.getKey())) {
|
if ("engineMode".equals(e.getKey())) {
|
||||||
|
engineMode = Integer.parseInt(e.getValue());
|
||||||
|
} else if ("timode".equals(e.getKey())) {
|
||||||
rc.turnInstructionMode = Integer.parseInt(e.getValue());
|
rc.turnInstructionMode = Integer.parseInt(e.getValue());
|
||||||
} else if ("heading".equals(e.getKey())) {
|
} else if ("heading".equals(e.getKey())) {
|
||||||
rc.startDirection = Integer.valueOf(Integer.parseInt(e.getValue()));
|
rc.startDirection = Integer.valueOf(Integer.parseInt(e.getValue()));
|
||||||
|
@ -210,7 +213,7 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cr = new RoutingEngine(null, null, serviceContext.segmentDir, wplist, rc);
|
cr = new RoutingEngine(engineMode, null, null, serviceContext.segmentDir, wplist, rc);
|
||||||
cr.quite = true;
|
cr.quite = true;
|
||||||
cr.doRun(maxRunningTime);
|
cr.doRun(maxRunningTime);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,18 @@
|
||||||
|
|
||||||
(ZIP-Archives including APK, readme + profiles)
|
(ZIP-Archives including APK, readme + profiles)
|
||||||
|
|
||||||
|
### New last version
|
||||||
|
|
||||||
|
Android
|
||||||
|
|
||||||
|
- Add parameter dialog for profile
|
||||||
|
|
||||||
|
Library
|
||||||
|
|
||||||
|
- Add engineMode for future use
|
||||||
|
- Minor bug fixes
|
||||||
|
|
||||||
|
|
||||||
### [brouter-1.7.0.zip](../brouter_bin/brouter-1.7.0.zip) (current revision, 29.04.2023)
|
### [brouter-1.7.0.zip](../brouter_bin/brouter-1.7.0.zip) (current revision, 29.04.2023)
|
||||||
|
|
||||||
Android
|
Android
|
||||||
|
|
Loading…
Reference in a new issue