kopia lustrzana https://github.com/JOSM/MapWithAI
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
rodzic
ed18321973
commit
16c06e0bd9
|
@ -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,18 +101,21 @@ 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);
|
||||||
for (Node node : nodeOrder) {
|
// isOutsideDownloadArea returns false if new or undeleted as well
|
||||||
List<Way> connectingWays = previous.getReferrers().parallelStream().filter(Way.class::isInstance)
|
if (!previous.isOutsideDownloadArea()) {
|
||||||
.map(Way.class::cast).filter(tWay -> !tWay.equals(way))
|
for (Node node : nodeOrder) {
|
||||||
.filter(tWay -> tWay.hasTag(HIGHWAY) && !BAD_HIGHWAYS.contains(tWay.get(HIGHWAY)))
|
List<Way> connectingWays = previous.getReferrers().parallelStream().filter(Way.class::isInstance)
|
||||||
.collect(Collectors.toList());
|
.map(Way.class::cast).filter(tWay -> !tWay.equals(way))
|
||||||
if (!node.equals(previous) && connectingWays.isEmpty()) {
|
.filter(tWay -> tWay.hasTag(HIGHWAY) && !BAD_HIGHWAYS.contains(tWay.get(HIGHWAY)))
|
||||||
nodesToConnection.add(previous);
|
.collect(Collectors.toList());
|
||||||
distance += node.getCoor().greatCircleDistance(previous.getCoor());
|
if (!node.equals(previous) && connectingWays.isEmpty()) {
|
||||||
previous = node;
|
nodesToConnection.add(previous);
|
||||||
}
|
distance += node.getCoor().greatCircleDistance(previous.getCoor());
|
||||||
if (!connectingWays.isEmpty()) {
|
previous = node;
|
||||||
break;
|
}
|
||||||
|
if (!connectingWays.isEmpty()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return distance;
|
return distance;
|
||||||
|
|
Ładowanie…
Reference in New Issue