expanded dynamic range
This commit is contained in:
parent
22842f0305
commit
a6ba70a786
@ -981,11 +981,16 @@ public class RoutingEngine extends Thread {
|
|||||||
logInfo("second check for way points");
|
logInfo("second check for way points");
|
||||||
resetCache(false);
|
resetCache(false);
|
||||||
range = -range;
|
range = -range;
|
||||||
ok = nodesCache.matchWaypointsToNodes(unmatchedWaypoints, range, islandNodePairs);
|
List<MatchedWaypoint> tmp = new ArrayList<>();
|
||||||
|
for (MatchedWaypoint mwp : unmatchedWaypoints) {
|
||||||
|
if (mwp.crosspoint == null) tmp.add(mwp);
|
||||||
|
}
|
||||||
|
ok = nodesCache.matchWaypointsToNodes(tmp, range, islandNodePairs);
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
for (MatchedWaypoint mwp :unmatchedWaypoints) {
|
for (MatchedWaypoint mwp : unmatchedWaypoints) {
|
||||||
if (mwp.crosspoint == null) throw new IllegalArgumentException(mwp.name + "-position not mapped in existing datafile");
|
if (mwp.crosspoint == null)
|
||||||
|
throw new IllegalArgumentException(mwp.name + "-position not mapped in existing datafile");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (useDynamicDistance) {
|
if (useDynamicDistance) {
|
||||||
@ -994,7 +999,7 @@ public class RoutingEngine extends Thread {
|
|||||||
MatchedWaypoint wp = unmatchedWaypoints.get(i);
|
MatchedWaypoint wp = unmatchedWaypoints.get(i);
|
||||||
if (wp.waypoint.calcDistance(wp.crosspoint) > routingContext.waypointCatchingRange) {
|
if (wp.waypoint.calcDistance(wp.crosspoint) > routingContext.waypointCatchingRange) {
|
||||||
MatchedWaypoint nmw = new MatchedWaypoint();
|
MatchedWaypoint nmw = new MatchedWaypoint();
|
||||||
if (i==0) {
|
if (i == 0) {
|
||||||
nmw.waypoint = new OsmNode(wp.waypoint.ilon, wp.waypoint.ilat);
|
nmw.waypoint = new OsmNode(wp.waypoint.ilon, wp.waypoint.ilat);
|
||||||
nmw.crosspoint = new OsmNode(wp.waypoint.ilon, wp.waypoint.ilat);
|
nmw.crosspoint = new OsmNode(wp.waypoint.ilon, wp.waypoint.ilat);
|
||||||
nmw.direct = true;
|
nmw.direct = true;
|
||||||
|
|||||||
@ -289,9 +289,9 @@ public final class NodesCache {
|
|||||||
int cellsize = 12500;
|
int cellsize = 12500;
|
||||||
preloadPosition(mwp.waypoint, cellsize, 1);
|
preloadPosition(mwp.waypoint, cellsize, 1);
|
||||||
// get a second chance
|
// get a second chance
|
||||||
if (mwp.crosspoint == null) {
|
if (mwp.crosspoint == null || mwp.radius > Math.abs(maxDistance)) {
|
||||||
cellsize = 1000000 / 32;
|
cellsize = 1000000 / 32;
|
||||||
preloadPosition(mwp.waypoint, cellsize, maxDistance < 0 ? 5 : 2);
|
preloadPosition(mwp.waypoint, cellsize, maxDistance < 0 ? 15 : 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,7 @@ public final class WaypointMatcherImpl implements WaypointMatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (MatchedWaypoint mwp : waypoints) {
|
for (MatchedWaypoint mwp : waypoints) {
|
||||||
mwp.radius = maxDistance;
|
mwp.radius = useDynamicRange ? mwp.radius != maxDistance ? mwp.radius : -1 : maxDistance;
|
||||||
if (last != null && mwp.directionToNext == -1) {
|
if (last != null && mwp.directionToNext == -1) {
|
||||||
last.directionToNext = CheapAngleMeter.getDirection(last.waypoint.ilon, last.waypoint.ilat, mwp.waypoint.ilon, mwp.waypoint.ilat);
|
last.directionToNext = CheapAngleMeter.getDirection(last.waypoint.ilon, last.waypoint.ilat, mwp.waypoint.ilon, mwp.waypoint.ilat);
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ public final class WaypointMatcherImpl implements WaypointMatcher {
|
|||||||
double r22 = x2 * x2 + y2 * y2;
|
double r22 = x2 * x2 + y2 * y2;
|
||||||
double radius = Math.abs(r12 < r22 ? y1 * dx - x1 * dy : y2 * dx - x2 * dy) / d;
|
double radius = Math.abs(r12 < r22 ? y1 * dx - x1 * dy : y2 * dx - x2 * dy) / d;
|
||||||
|
|
||||||
if (radius <= mwp.radius || (this.maxDistance == -1d && (i == 0 || i == maxWptIdx))) {
|
if (radius < mwp.radius || (this.maxDistance == -1d)) {
|
||||||
double s1 = x1 * dx + y1 * dy;
|
double s1 = x1 * dx + y1 * dy;
|
||||||
double s2 = x2 * dx + y2 * dy;
|
double s2 = x2 * dx + y2 * dy;
|
||||||
|
|
||||||
@ -127,8 +127,9 @@ public final class WaypointMatcherImpl implements WaypointMatcher {
|
|||||||
if (s2 > 0.) {
|
if (s2 > 0.) {
|
||||||
radius = Math.sqrt(s1 < s2 ? r12 : r22);
|
radius = Math.sqrt(s1 < s2 ? r12 : r22);
|
||||||
|
|
||||||
if (radius > mwp.radius && this.maxDistance != -1)
|
if (radius > mwp.radius && mwp.radius != -1) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// new match for that waypoint
|
// new match for that waypoint
|
||||||
mwp.radius = radius; // shortest distance to way
|
mwp.radius = radius; // shortest distance to way
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user