Ticket #12493: 12493_v1.patch

File 12493_v1.patch, 2.5 KB (added by reichg, 3 years ago)

Categorizes warning by end node's parent way highway tag.

  • src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

     
    2020import java.util.Objects;
    2121import java.util.Set;
    2222import java.util.stream.Collectors;
     23import java.util.stream.Stream;
    2324
    2425import org.openstreetmap.josm.data.coor.EastNorth;
    2526import org.openstreetmap.josm.data.coor.LatLon;
     
    5758
    5859    static final double DETOUR_FACTOR = 4;
    5960
     61    private final Set<String> priorityHighwayTags = Stream.of("MOTORWAY", "MOTORWAY_LINK", "TRUNK", "TRUNK_LINK", "PRIMARY",
     62                    "PRIMARY_LINK", "SECONDARY", "SECONDARY_LINK", "TERTIARY", "TERTIARY_LINK", "RESIDENTIAL", "UNCLASSIFIED")
     63            .collect(Collectors.toCollection(HashSet::new));
     64
    6065    protected abstract boolean isCandidate(OsmPrimitive p);
    6166
    6267    protected boolean isWantedWay(Way w) {
     
    349354        for (Entry<Node, MyWaySegment> error : errorMap.entrySet()) {
    350355            Node node = error.getKey();
    351356            MyWaySegment ws = error.getValue();
     357
     358            // Get parent way from nearby end node and extract highway tag.
     359            Way parentWay = getWantedParentWay(node);
     360            String parentWayHighwayTag = parentWay.get(HIGHWAY);
     361
     362            // Check if highway tag is Unclassified or above (Residential - Motorway)
     363            // New message for warning categories.
     364            // #12493 - Categorize 'Way end node near other highway' warnings.
     365            if (priorityHighwayTags.contains(parentWayHighwayTag.toUpperCase())) {
     366                message = tr("Way end node near other highway - Major");
     367            }
    352368            errors.add(TestError.builder(this, severity, code)
    353369                    .message(message)
    354370                    .primitives(node, ws.w)
     
    373389        if (!searchNodes.isEmpty()) {
    374390            maxLen = DETOUR_FACTOR * mindist;
    375391            if (isHighwayTest) {
    376                 addErrors(Severity.WARNING, getHighwayEndNodesNearOtherHighway(), tr("Way end node near other highway"));
     392                addErrors(Severity.WARNING, getHighwayEndNodesNearOtherHighway(), tr("Way end node near other highway - Minor"));
    377393            } else {
    378394                addErrors(Severity.WARNING, getWayEndNodesNearOtherWay(), tr("Way end node near other way"));
    379395            }