Merge pull request #583 from afischerdev/find-points
Find matching points in areas with longer distance between way points
This commit is contained in:
commit
565cdde223
2 changed files with 15 additions and 5 deletions
|
@ -64,6 +64,8 @@ public class RoutingEngine extends Thread {
|
||||||
protected RoutingContext routingContext;
|
protected RoutingContext routingContext;
|
||||||
|
|
||||||
public double airDistanceCostFactor;
|
public double airDistanceCostFactor;
|
||||||
|
public double lastAirDistanceCostFactor;
|
||||||
|
|
||||||
private OsmTrack guideTrack;
|
private OsmTrack guideTrack;
|
||||||
|
|
||||||
private OsmPathElement matchPath;
|
private OsmPathElement matchPath;
|
||||||
|
@ -933,6 +935,7 @@ public class RoutingEngine extends Thread {
|
||||||
|
|
||||||
if (track == null) {
|
if (track == null) {
|
||||||
for (int cfi = 0; cfi < airDistanceCostFactors.length; cfi++) {
|
for (int cfi = 0; cfi < airDistanceCostFactors.length; cfi++) {
|
||||||
|
if (cfi > 0) lastAirDistanceCostFactor = airDistanceCostFactors[cfi-1];
|
||||||
airDistanceCostFactor = airDistanceCostFactors[cfi];
|
airDistanceCostFactor = airDistanceCostFactors[cfi];
|
||||||
|
|
||||||
if (airDistanceCostFactor < 0.) {
|
if (airDistanceCostFactor < 0.) {
|
||||||
|
@ -986,6 +989,7 @@ public class RoutingEngine extends Thread {
|
||||||
|
|
||||||
// final run for verbose log info and detail nodes
|
// final run for verbose log info and detail nodes
|
||||||
airDistanceCostFactor = 0.;
|
airDistanceCostFactor = 0.;
|
||||||
|
lastAirDistanceCostFactor = 0.;
|
||||||
guideTrack = track;
|
guideTrack = track;
|
||||||
startTime = System.currentTimeMillis(); // reset timeout...
|
startTime = System.currentTimeMillis(); // reset timeout...
|
||||||
try {
|
try {
|
||||||
|
@ -1328,7 +1332,8 @@ public class RoutingEngine extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
// recheck cutoff before doing expensive stuff
|
// recheck cutoff before doing expensive stuff
|
||||||
if (path.cost + path.airdistance > maxTotalCost + 100) {
|
int addDiff = 100;
|
||||||
|
if (path.cost + path.airdistance > maxTotalCost + addDiff) {
|
||||||
path.unregisterUpTree(routingContext);
|
path.unregisterUpTree(routingContext);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1426,7 +1431,7 @@ public class RoutingEngine extends Thread {
|
||||||
|
|
||||||
boolean inRadius = boundary == null || boundary.isInBoundary(nextNode, bestPath.cost);
|
boolean inRadius = boundary == null || boundary.isInBoundary(nextNode, bestPath.cost);
|
||||||
|
|
||||||
if (inRadius && (isFinalLink || bestPath.cost + bestPath.airdistance <= maxTotalCost + 100)) {
|
if (inRadius && (isFinalLink || bestPath.cost + bestPath.airdistance <= (lastAirDistanceCostFactor != 0. ? maxTotalCost*lastAirDistanceCostFactor : maxTotalCost) + addDiff)) {
|
||||||
// add only if this may beat an existing path for that link
|
// add only if this may beat an existing path for that link
|
||||||
OsmLinkHolder dominator = link.getFirstLinkHolder(currentNode);
|
OsmLinkHolder dominator = link.getFirstLinkHolder(currentNode);
|
||||||
while (!trafficSim && dominator != null) {
|
while (!trafficSim && dominator != null) {
|
||||||
|
|
|
@ -285,7 +285,13 @@ public final class NodesCache {
|
||||||
public void matchWaypointsToNodes(List<MatchedWaypoint> unmatchedWaypoints, double maxDistance, OsmNodePairSet islandNodePairs) {
|
public void matchWaypointsToNodes(List<MatchedWaypoint> unmatchedWaypoints, double maxDistance, OsmNodePairSet islandNodePairs) {
|
||||||
waypointMatcher = new WaypointMatcherImpl(unmatchedWaypoints, maxDistance, islandNodePairs);
|
waypointMatcher = new WaypointMatcherImpl(unmatchedWaypoints, maxDistance, islandNodePairs);
|
||||||
for (MatchedWaypoint mwp : unmatchedWaypoints) {
|
for (MatchedWaypoint mwp : unmatchedWaypoints) {
|
||||||
preloadPosition(mwp.waypoint);
|
int cellsize = 12500;
|
||||||
|
preloadPosition(mwp.waypoint, cellsize);
|
||||||
|
// get a second chance
|
||||||
|
if (mwp.crosspoint == null) {
|
||||||
|
cellsize = 1000000 / 32;
|
||||||
|
preloadPosition(mwp.waypoint, cellsize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first_file_access_failed) {
|
if (first_file_access_failed) {
|
||||||
|
@ -309,8 +315,7 @@ public final class NodesCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void preloadPosition(OsmNode n) {
|
private void preloadPosition(OsmNode n, int d) {
|
||||||
int d = 12500;
|
|
||||||
first_file_access_failed = false;
|
first_file_access_failed = false;
|
||||||
first_file_access_name = null;
|
first_file_access_name = null;
|
||||||
loadSegmentFor(n.ilon, n.ilat);
|
loadSegmentFor(n.ilon, n.ilat);
|
||||||
|
|
Loading…
Reference in a new issue