error on dynamic range

This commit is contained in:
afischerdev 2024-10-04 11:06:33 +02:00
parent 57726a36ce
commit 22842f0305
2 changed files with 12 additions and 14 deletions

View File

@ -981,13 +981,7 @@ 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;
List<MatchedWaypoint> tmp = new ArrayList<>(); ok = nodesCache.matchWaypointsToNodes(unmatchedWaypoints, range, islandNodePairs);
// only w/o crosspoint check
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) {

View File

@ -1,12 +1,12 @@
package btools.mapaccess; package btools.mapaccess;
import java.util.List;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List;
import btools.codec.WaypointMatcher; import btools.codec.WaypointMatcher;
import btools.util.CheapRuler;
import btools.util.CheapAngleMeter; import btools.util.CheapAngleMeter;
import btools.util.CheapRuler;
/** /**
* the WaypointMatcher is feeded by the decoder with geoemtries of ways that are * the WaypointMatcher is feeded by the decoder with geoemtries of ways that are
@ -29,8 +29,9 @@ public final class WaypointMatcherImpl implements WaypointMatcher {
private int lonLast; private int lonLast;
private int latLast; private int latLast;
boolean useAsStartWay = true; boolean useAsStartWay = true;
public boolean useDynamicRange;
private int maxWptIdx; private int maxWptIdx;
private double maxDistance;
public boolean useDynamicRange = false;
private Comparator<MatchedWaypoint> comparator; private Comparator<MatchedWaypoint> comparator;
@ -38,9 +39,11 @@ public final class WaypointMatcherImpl implements WaypointMatcher {
this.waypoints = waypoints; this.waypoints = waypoints;
this.islandPairs = islandPairs; this.islandPairs = islandPairs;
MatchedWaypoint last = null; MatchedWaypoint last = null;
this.useDynamicRange = maxDistance < 0; this.maxDistance = maxDistance;
if (maxDistance < 0.) { if (maxDistance < 0.) {
this.maxDistance = -1;
maxDistance *= -1; maxDistance *= -1;
useDynamicRange = true;
} }
for (MatchedWaypoint mwp : waypoints) { for (MatchedWaypoint mwp : waypoints) {
@ -87,7 +90,7 @@ public final class WaypointMatcherImpl implements WaypointMatcher {
//for ( MatchedWaypoint mwp : waypoints ) //for ( MatchedWaypoint mwp : waypoints )
for (int i = 0; i < waypoints.size(); i++) { for (int i = 0; i < waypoints.size(); i++) {
if (!useAsStartWay && i==0) continue; if (!useAsStartWay && i == 0) continue;
MatchedWaypoint mwp = waypoints.get(i); MatchedWaypoint mwp = waypoints.get(i);
if (mwp.direct && if (mwp.direct &&
@ -113,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.useDynamicRange) { if (radius <= mwp.radius || (this.maxDistance == -1d && (i == 0 || i == maxWptIdx))) {
double s1 = x1 * dx + y1 * dy; double s1 = x1 * dx + y1 * dy;
double s2 = x2 * dx + y2 * dy; double s2 = x2 * dx + y2 * dy;
@ -123,7 +126,8 @@ 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)
if (radius > mwp.radius && this.maxDistance != -1)
continue; continue;
} }
// new match for that waypoint // new match for that waypoint