expanded dynamic range

This commit is contained in:
afischerdev 2024-10-06 11:50:13 +02:00
parent 22842f0305
commit a6ba70a786
3 changed files with 16 additions and 10 deletions

View File

@ -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) {

View File

@ -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);
} }
} }

View File

@ -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,9 +127,10 @@ 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
mwp.hasUpdate = true; mwp.hasUpdate = true;