added engineMode roundtrip
This commit is contained in:
parent
4fb19df4d5
commit
a5fca2d8f2
@ -191,6 +191,9 @@ public final class RoutingContext {
|
|||||||
public Integer startDirection;
|
public Integer startDirection;
|
||||||
public boolean startDirectionValid;
|
public boolean startDirectionValid;
|
||||||
public boolean forceUseStartDirection;
|
public boolean forceUseStartDirection;
|
||||||
|
public Integer roundtripDistance;
|
||||||
|
public Integer roundtripDirectionAdd;
|
||||||
|
public boolean allowSamewayback;
|
||||||
|
|
||||||
public CheapAngleMeter anglemeter = new CheapAngleMeter();
|
public CheapAngleMeter anglemeter = new CheapAngleMeter();
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import btools.mapaccess.OsmLinkHolder;
|
|||||||
import btools.mapaccess.OsmNode;
|
import btools.mapaccess.OsmNode;
|
||||||
import btools.mapaccess.OsmNodePairSet;
|
import btools.mapaccess.OsmNodePairSet;
|
||||||
import btools.mapaccess.OsmPos;
|
import btools.mapaccess.OsmPos;
|
||||||
|
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;
|
||||||
@ -31,6 +32,7 @@ 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_GETINFO = 3;
|
public final static int BROUTER_ENGINEMODE_GETINFO = 3;
|
||||||
|
public final static int BROUTER_ENGINEMODE_ROUNDTRIP = 4;
|
||||||
|
|
||||||
private NodesCache nodesCache;
|
private NodesCache nodesCache;
|
||||||
private SortedHeap<OsmPath> openSet = new SortedHeap<>();
|
private SortedHeap<OsmPath> openSet = new SortedHeap<>();
|
||||||
@ -48,7 +50,7 @@ public class RoutingEngine extends Thread {
|
|||||||
|
|
||||||
private int engineMode = 0;
|
private int engineMode = 0;
|
||||||
|
|
||||||
private int MAX_STEPS_CHECK = 10;
|
private int MAX_STEPS_CHECK = 20;
|
||||||
|
|
||||||
private int MAX_DYNAMIC_RANGE = 60000;
|
private int MAX_DYNAMIC_RANGE = 60000;
|
||||||
|
|
||||||
@ -178,6 +180,11 @@ public class RoutingEngine extends Thread {
|
|||||||
}
|
}
|
||||||
doGetInfo();
|
doGetInfo();
|
||||||
break;
|
break;
|
||||||
|
case BROUTER_ENGINEMODE_ROUNDTRIP:
|
||||||
|
if (waypoints.size() < 1)
|
||||||
|
throw new IllegalArgumentException("we need one lat/lon point at least!");
|
||||||
|
doRoundTrip();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("not a valid engine mode");
|
throw new IllegalArgumentException("not a valid engine mode");
|
||||||
}
|
}
|
||||||
@ -447,6 +454,69 @@ public class RoutingEngine extends Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void doRoundTrip() {
|
||||||
|
try {
|
||||||
|
startTime = System.currentTimeMillis();
|
||||||
|
MatchedWaypoint wpt1 = new MatchedWaypoint();
|
||||||
|
wpt1.waypoint = waypoints.get(0);
|
||||||
|
wpt1.name = "roundtrip";
|
||||||
|
|
||||||
|
routingContext.useDynamicDistance = true;
|
||||||
|
double searchRadius = (routingContext.roundtripDistance == null ? 1500 :routingContext.roundtripDistance);
|
||||||
|
double direction = (routingContext.startDirection == null ? -1 :routingContext.startDirection);
|
||||||
|
if (direction == -1) direction = (int) (Math.random()*360);
|
||||||
|
double directionAdd = (routingContext.roundtripDirectionAdd == null ? 20 :routingContext.roundtripDirectionAdd);
|
||||||
|
|
||||||
|
//direction = 59;
|
||||||
|
if (routingContext.allowSamewayback) {
|
||||||
|
int[] pos = CheapRuler.destination(waypoints.get(0).ilon, waypoints.get(0).ilat, searchRadius, direction);
|
||||||
|
MatchedWaypoint wpt2 = new MatchedWaypoint();
|
||||||
|
wpt2.waypoint = new OsmNode(pos[0], pos[1]);
|
||||||
|
wpt2.name = "rt1_" + (direction);
|
||||||
|
|
||||||
|
OsmNodeNamed onn = new OsmNodeNamed(new OsmNode(pos[0], pos[1]));
|
||||||
|
onn.name = "via1";
|
||||||
|
onn.radius = 1000;
|
||||||
|
waypoints.add(onn);
|
||||||
|
} else {
|
||||||
|
int[] pos = CheapRuler.destination(waypoints.get(0).ilon, waypoints.get(0).ilat, searchRadius, direction-directionAdd);
|
||||||
|
MatchedWaypoint wpt2 = new MatchedWaypoint();
|
||||||
|
wpt2.waypoint = new OsmNode(pos[0], pos[1]);
|
||||||
|
wpt2.name = "rt1_" + (direction);
|
||||||
|
|
||||||
|
OsmNodeNamed onn = new OsmNodeNamed(new OsmNode(pos[0], pos[1]));
|
||||||
|
onn.name = "via1";
|
||||||
|
onn.radius = 1000;
|
||||||
|
waypoints.add(onn);
|
||||||
|
|
||||||
|
|
||||||
|
pos = CheapRuler.destination(waypoints.get(0).ilon, waypoints.get(0).ilat, searchRadius, direction+directionAdd);
|
||||||
|
MatchedWaypoint wpt3 = new MatchedWaypoint();
|
||||||
|
wpt3.waypoint = new OsmNode(pos[0], pos[1]);
|
||||||
|
wpt3.name = "rt2_" + (direction);
|
||||||
|
|
||||||
|
onn = new OsmNodeNamed(new OsmNode(pos[0], pos[1]));
|
||||||
|
onn.name = "via2";
|
||||||
|
onn.radius = 1000;
|
||||||
|
waypoints.add(onn);
|
||||||
|
}
|
||||||
|
OsmNodeNamed onn = new OsmNodeNamed(waypoints.get(0));
|
||||||
|
onn.name = "rt_end";
|
||||||
|
waypoints.add(onn);
|
||||||
|
|
||||||
|
routingContext.waypointCatchingRange = 1000;
|
||||||
|
|
||||||
|
doRouting(0);
|
||||||
|
|
||||||
|
long endTime = System.currentTimeMillis();
|
||||||
|
logInfo("execution time = " + (endTime - startTime) / 1000. + " seconds");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.getStackTrace();
|
||||||
|
logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void postElevationCheck(OsmTrack track) {
|
private void postElevationCheck(OsmTrack track) {
|
||||||
OsmPathElement lastPt = null;
|
OsmPathElement lastPt = null;
|
||||||
OsmPathElement startPt = null;
|
OsmPathElement startPt = null;
|
||||||
|
|||||||
@ -202,6 +202,12 @@ public class RoutingParamCollector {
|
|||||||
rctx.forceUseStartDirection = true;
|
rctx.forceUseStartDirection = true;
|
||||||
} else if (key.equals("direction")) {
|
} else if (key.equals("direction")) {
|
||||||
rctx.startDirection = Integer.valueOf(value);
|
rctx.startDirection = Integer.valueOf(value);
|
||||||
|
} else if (key.equals("roundtripDistance")) {
|
||||||
|
rctx.roundtripDistance = Integer.valueOf(value);
|
||||||
|
} else if (key.equals("roundtripDirectionAdd")) {
|
||||||
|
rctx.roundtripDirectionAdd = Integer.valueOf(value);
|
||||||
|
} else if (key.equals("allowSamewayback")) {
|
||||||
|
rctx.allowSamewayback = Integer.parseInt(value)==1;
|
||||||
} else if (key.equals("alternativeidx")) {
|
} else if (key.equals("alternativeidx")) {
|
||||||
rctx.setAlternativeIdx(Integer.parseInt(value));
|
rctx.setAlternativeIdx(Integer.parseInt(value));
|
||||||
} else if (key.equals("turnInstructionMode")) {
|
} else if (key.equals("turnInstructionMode")) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user