Ticket #21038: 21038.patch

File 21038.patch, 3.1 KB (added by GerdP, 3 years ago)
  • src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

     
    111111    public static class UnconnectedRailways extends UnconnectedWays {
    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);
    118118        }
     
    119119
    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    }
    131148
     
    238255        middlenodes = new HashSet<>();
    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();
    243262        dsArea = ds == null ? null : ds.getDataSourceArea();
     
    321340     * @param endnode the node which is known to be an end node of the wanted way
    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))
    327346                return w;