Fix issue where stub end test would throw issues on nodes outside download area.

The nodes were pre-existing, which means that they may or may not be
connected to other ways.

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2020-01-20 09:18:16 -07:00
rodzic ed18321973
commit 16c06e0bd9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
1 zmienionych plików z 18 dodań i 14 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
// License: GPL. For details, see LICENSE file. // License: GPL. For details, see LICENSE file.
package org.openstreetmap.josm.plugins.mapwithai.data.validation.tests; package org.openstreetmap.josm.plugins.mapwithai.data.validation.tests;
import static org.openstreetmap.josm.tools.I18n.marktr;
import static org.openstreetmap.josm.tools.I18n.tr; import static org.openstreetmap.josm.tools.I18n.tr;
import java.util.ArrayList; import java.util.ArrayList;
@ -59,8 +60,8 @@ public class StubEndsTest extends Test {
} }
private TestError createError(Way way, List<Node> nodes, double distance) { private TestError createError(Way way, List<Node> nodes, double distance) {
Builder error = TestError.builder(this, Severity.ERROR, 333300239).message(tr("Stub end ({0}m)", distance)) Builder error = TestError.builder(this, Severity.ERROR, 333300239)
.primitives(way).highlight(nodes); .message(MapWithAIPlugin.NAME, marktr("Stub end ({0}m)"), distance).primitives(way).highlight(nodes);
if (way.isNew()) { if (way.isNew()) {
Way tWay = new Way(way); Way tWay = new Way(way);
List<Node> tNodes = tWay.getNodes(); List<Node> tNodes = tWay.getNodes();
@ -100,6 +101,8 @@ public class StubEndsTest extends Test {
private static double distanceToConnection(Way way, List<Node> nodesToConnection, List<Node> nodeOrder) { private static double distanceToConnection(Way way, List<Node> nodesToConnection, List<Node> nodeOrder) {
double distance = 0; double distance = 0;
Node previous = nodeOrder.get(0); Node previous = nodeOrder.get(0);
// isOutsideDownloadArea returns false if new or undeleted as well
if (!previous.isOutsideDownloadArea()) {
for (Node node : nodeOrder) { for (Node node : nodeOrder) {
List<Way> connectingWays = previous.getReferrers().parallelStream().filter(Way.class::isInstance) List<Way> connectingWays = previous.getReferrers().parallelStream().filter(Way.class::isInstance)
.map(Way.class::cast).filter(tWay -> !tWay.equals(way)) .map(Way.class::cast).filter(tWay -> !tWay.equals(way))
@ -114,6 +117,7 @@ public class StubEndsTest extends Test {
break; break;
} }
} }
}
return distance; return distance;
} }
} }