Changeset 18272 in josm for trunk


Ignore:
Timestamp:
2021-10-13T11:04:07+02:00 (3 years ago)
Author:
GerdP
Message:

fix #21038: Test "Way end node near other way" is too aggressive for railroads

  • new preference validator.UnconnectedWays.node_way_distance_railway with a default dist of 1.0 m
  • additional check if end node is next to a buffer_stop
  • improved include/exclude lists to ignore planned or proposed railway and some objects which are buildings.
File:
1 edited

Legend:

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

    r17927 r18272  
    112112        static final int UNCONNECTED_RAILWAYS = 1321;
    113113        /**
    114          * Constructs a new {@code UnconnectedRailways} test.
    115          */
     114        * Constructs a new {@code UnconnectedRailways} test.
     115        */
    116116        public UnconnectedRailways() {
    117117            super(tr("Unconnected railways"), UNCONNECTED_RAILWAYS, false);
     
    120120        @Override
    121121        protected boolean isCandidate(OsmPrimitive p) {
    122             return p.hasTagDifferent(RAILWAY, "abandoned", "platform", "razed");
     122            if (p.hasTag(RAILWAY, "construction") && p.hasKey("construction"))
     123                return p.hasTagDifferent("construction", "platform", "platform_edge", "service_station", "station");
     124            return p.hasTagDifferent(RAILWAY, "proposed", "planned", "abandoned", "razed", "disused", "no",
     125                    "platform", "platform_edge", "service_station", "station");
    123126        }
    124127
    125128        @Override
    126129        protected boolean ignoreUnconnectedEndNode(Node n) {
    127             return n.hasTag(RAILWAY, "buffer_stop")
    128                 || n.isKeyTrue("noexit");
     130            if (n.hasTag(RAILWAY, "buffer_stop") || n.isKeyTrue("noexit"))
     131                return true;
     132            // See #21038. Check also if next node to end node is a buffer stop.
     133            Way parent = getWantedParentWay(n);
     134            if (parent != null && parent.getNodesCount() > 1) {
     135                Node next = null;
     136                if (n == parent.firstNode())
     137                    next = parent.getNode(1);
     138                else if (n == parent.lastNode()) {
     139                    next = parent.getNode(parent.getNodesCount() - 2);
     140                }
     141                if (next != null)
     142                    return next.hasTag(RAILWAY, "buffer_stop");
     143            }
     144            return false;
     145
    129146        }
    130147    }
     
    239256        othernodes = new HashSet<>();
    240257        mindist = Config.getPref().getDouble(PREFIX + ".node_way_distance", 10.0);
     258        if (this instanceof UnconnectedRailways)
     259            mindist = Config.getPref().getDouble(PREFIX + ".node_way_distance_railway", 1.0);
    241260        minmiddledist = Config.getPref().getDouble(PREFIX + ".way_way_distance", 0.0);
    242261        ds = OsmDataManager.getInstance().getActiveDataSet();
     
    322341     * @return the wanted way
    323342     */
    324     private Way getWantedParentWay(Node endnode) {
     343    protected Way getWantedParentWay(Node endnode) {
    325344        for (Way w : endnode.getParentWays()) {
    326345            if (isWantedWay(w))
Note: See TracChangeset for help on using the changeset viewer.