added a dynamic range check
This commit is contained in:
parent
a55bef904f
commit
9fc21b0fc8
@ -76,6 +76,7 @@ public final class RoutingContext {
|
||||
public double waypointCatchingRange;
|
||||
public boolean correctMisplacedViaPoints;
|
||||
public double correctMisplacedViaPointsDistance;
|
||||
public boolean useDynamicDistance;
|
||||
|
||||
private void setModel(String className) {
|
||||
if (className == null) {
|
||||
@ -168,6 +169,8 @@ public final class RoutingContext {
|
||||
// Constant power of the biker (in W)
|
||||
bikerPower = expctxGlobal.getVariableValue("bikerPower", 100.f);
|
||||
|
||||
useDynamicDistance = expctxGlobal.getVariableValue("use_dynamic_range", 0f) == 1f;
|
||||
|
||||
boolean test = expctxGlobal.getVariableValue("check_start_way", 1f) == 1f;
|
||||
if (!test) expctxGlobal.freeNoWays();
|
||||
|
||||
|
||||
@ -587,7 +587,13 @@ public class RoutingEngine extends Thread {
|
||||
mwp.direct = waypoints.get(i).direct;
|
||||
matchedWaypoints.add(mwp);
|
||||
}
|
||||
int startSize = matchedWaypoints.size();
|
||||
matchWaypointsToNodes(matchedWaypoints);
|
||||
if (startSize < matchedWaypoints.size()) {
|
||||
refTracks = new OsmTrack[matchedWaypoints.size()]; // used ways for alternatives
|
||||
lastTracks = new OsmTrack[matchedWaypoints.size()];
|
||||
hasDirectRouting = true;
|
||||
}
|
||||
|
||||
routingContext.checkMatchedWaypointAgainstNogos(matchedWaypoints);
|
||||
|
||||
@ -968,7 +974,53 @@ public class RoutingEngine extends Thread {
|
||||
// geometric position matching finding the nearest routable way-section
|
||||
private void matchWaypointsToNodes(List<MatchedWaypoint> unmatchedWaypoints) {
|
||||
resetCache(false);
|
||||
nodesCache.matchWaypointsToNodes(unmatchedWaypoints, routingContext.waypointCatchingRange, islandNodePairs);
|
||||
boolean useDynamicDistance = routingContext.useDynamicDistance;
|
||||
double range = routingContext.waypointCatchingRange;
|
||||
boolean ok = nodesCache.matchWaypointsToNodes(unmatchedWaypoints, range, islandNodePairs);
|
||||
if (!ok && useDynamicDistance) {
|
||||
logInfo("second check for way points");
|
||||
resetCache(false);
|
||||
range = -range;
|
||||
List<MatchedWaypoint> tmp = new ArrayList<>();
|
||||
// only first or last checked
|
||||
if (unmatchedWaypoints.get(0).crosspoint == null) tmp.add(unmatchedWaypoints.get(0));
|
||||
if (unmatchedWaypoints.get(unmatchedWaypoints.size()-1).crosspoint == null) tmp.add(unmatchedWaypoints.get(unmatchedWaypoints.size()-1));
|
||||
|
||||
ok = nodesCache.matchWaypointsToNodes(tmp, range, islandNodePairs);
|
||||
}
|
||||
if (!ok) {
|
||||
for (MatchedWaypoint mwp :unmatchedWaypoints) {
|
||||
if (mwp.crosspoint == null) throw new IllegalArgumentException(mwp.name + "-position not mapped in existing datafile");
|
||||
}
|
||||
}
|
||||
if (useDynamicDistance) {
|
||||
List<MatchedWaypoint> waypoints = new ArrayList<>();
|
||||
for (int i = 0; i < unmatchedWaypoints.size(); i++) {
|
||||
MatchedWaypoint wp = unmatchedWaypoints.get(i);
|
||||
if (wp.waypoint.calcDistance(wp.crosspoint) > routingContext.waypointCatchingRange) {
|
||||
MatchedWaypoint nmw = new MatchedWaypoint();
|
||||
if (i==0) {
|
||||
nmw.waypoint = new OsmNode(wp.waypoint.ilon, wp.waypoint.ilat);
|
||||
nmw.crosspoint = new OsmNode(wp.waypoint.ilon, wp.waypoint.ilat);
|
||||
nmw.direct = true;
|
||||
wp.waypoint = new OsmNode(wp.crosspoint.ilon, wp.crosspoint.ilat);
|
||||
} else {
|
||||
nmw.waypoint = new OsmNode(wp.crosspoint.ilon, wp.crosspoint.ilat);
|
||||
nmw.crosspoint = new OsmNode(wp.crosspoint.ilon, wp.crosspoint.ilat);
|
||||
nmw.node1 = new OsmNode(wp.node1.ilon, wp.node1.ilat);
|
||||
nmw.node2 = new OsmNode(wp.node2.ilon, wp.node2.ilat);
|
||||
nmw.direct = true;
|
||||
wp.crosspoint = new OsmNode(wp.waypoint.ilon, wp.waypoint.ilat);
|
||||
}
|
||||
nmw.name = wp.name;
|
||||
waypoints.add(nmw);
|
||||
wp.name = wp.name + "_add";
|
||||
}
|
||||
waypoints.add(wp);
|
||||
}
|
||||
unmatchedWaypoints.clear();
|
||||
unmatchedWaypoints.addAll(waypoints);
|
||||
}
|
||||
}
|
||||
|
||||
private OsmTrack searchTrack(MatchedWaypoint startWp, MatchedWaypoint endWp, OsmTrack nearbyTrack, OsmTrack refTrack) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user