Changeset 17411 in josm for trunk/src/org


Ignore:
Timestamp:
2020-12-17T08:27:26+01:00 (4 years ago)
Author:
GerdP
Message:

fix #20019: Warn about direction=forward/backward on invalid nodes.

  • show error for unconnected node Unconnected node with {0}. Use angle or cardinal direction
  • show warning for node that is connected, but not to a suitable way Node with {0} should be connected to a linear way
  • show information for Node with {0} on end of way and Node with {0} on a connection of multiple ways, both in group Disputed usage of direction on node
  • special handling for highways: if there is a major highway as defined in Highways.CLASSIFIED_HIGHWAYS, ignore minor ways like footway, path to reduce false positives at traffic lights.
Location:
trunk/src/org/openstreetmap/josm/data/validation/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DirectionNodes.java

    r17368 r17411  
    88import java.util.List;
    99import java.util.Map.Entry;
     10import java.util.stream.Collectors;
    1011
    1112import org.openstreetmap.josm.data.osm.Node;
     
    2526    private static final int END_NODE_CODE = 4001;
    2627    private static final int NO_WAY_CODE = 4002;
     28    private static final int NO_SUITABLE_WAY = 4003;
    2729
    28     private static final String DIR_VERIF_PROBLEM_MSG = tr("Invalid usage of direction on node");
     30    private static final String INVALID_USE_MSG = tr("Invalid usage of direction on node");
     31    private static final String DISPUTED_USE_MSG = tr("Disputed usage of direction on node");
    2932
    3033    /**
     
    5457        final List<Way> ways = new ArrayList<>();
    5558        int count = 0;
     59        int countHighWays = 0;
    5660        for (Way w : n.getParentWays()) {
    5761            if (isSuitableParentWay(w)) {
    5862                ways.add(w);
     63                if (w.hasKey("highway"))
     64                    countHighWays++;
    5965            }
    6066            count++;
    6167        }
    62         boolean needsParentWays = n.isNew() || (!n.isOutsideDownloadArea() && n.getDataSet().getDataSourceArea() != null);
     68
     69        // ignore minor highways (footway, path etc) if a major highway is found
     70        if (countHighWays > 1 && (n.hasKey("highway") || n.hasTag("traffic_sign", "city_limit"))) {
     71            List<Way> minor = ways.stream().filter(w -> !w.hasTag("highway", Highways.CLASSIFIED_HIGHWAYS))
     72                    .collect(Collectors.toList());
     73            if (minor.size() != countHighWays) {
     74                ways.removeAll(minor);
     75            }
     76        }
     77        boolean needsParentWays = n.isNew()
     78                || (!n.isOutsideDownloadArea() && n.getDataSet().getDataSourceArea() != null);
    6379        TestError.Builder builder = null;
    6480        if (ways.isEmpty() && needsParentWays) {
    6581            if (count == 0) {
    66                 builder = TestError.builder(this, Severity.WARNING, NO_WAY_CODE).message(DIR_VERIF_PROBLEM_MSG,
    67                         marktr("Unconnected node with {0}"), tag);
     82                builder = TestError.builder(this, Severity.ERROR, NO_WAY_CODE).message(INVALID_USE_MSG,
     83                        marktr("Unconnected node with {0}. Use angle or cardinal direction"), tag);
     84            } else {
     85                builder = TestError.builder(this, Severity.WARNING, NO_SUITABLE_WAY).message(INVALID_USE_MSG,
     86                        marktr("Node with {0} should be connected to a linear way"), tag);
    6887            }
    69 
    7088        } else if (ways.size() == 1) {
    7189            Way w = ways.get(0);
    7290            if (w.firstNode() == n || w.lastNode() == n) {
    73                 builder = TestError.builder(this, Severity.WARNING, END_NODE_CODE).message(DIR_VERIF_PROBLEM_MSG,
     91                builder = TestError.builder(this, Severity.OTHER, END_NODE_CODE).message(DISPUTED_USE_MSG,
    7492                        marktr("Node with {0} on end of way"), tag);
    7593            }
    7694        } else if (ways.size() > 1) {
    77             builder = TestError.builder(this, Severity.WARNING, MULTIPLE_WAYS_CODE).message(DIR_VERIF_PROBLEM_MSG,
     95            builder = TestError.builder(this, Severity.OTHER, MULTIPLE_WAYS_CODE).message(DISPUTED_USE_MSG,
    7896                    marktr("Node with {0} on a connection of multiple ways"), tag);
    7997        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java

    r16382 r17411  
    4646     */
    4747    // CHECKSTYLE.OFF: SingleSpaceSeparator
    48     private static final List<String> CLASSIFIED_HIGHWAYS = Arrays.asList(
     48    static final List<String> CLASSIFIED_HIGHWAYS = Arrays.asList(
    4949            "motorway",  "motorway_link",
    5050            "trunk",     "trunk_link",
Note: See TracChangeset for help on using the changeset viewer.