Ticket #17501: detect_wrong_oneway_relation.patch

File detect_wrong_oneway_relation.patch, 6.1 KB (added by taylor.smock, 6 years ago)

Initial patch for showing oneways in the wrong direction of a relation.

  • src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableLinkedCellRenderer.java

     
    6666        int y2;
    6767
    6868        if (value.linkPrev) {
    69             g.setColor(Color.black);
     69            if (value.onewayFollowsPrevious) {
     70                g.setColor(Color.black);
     71            } else {
     72                g.setColor(Color.lightGray);
     73            }
    7074            if (value.isOnewayHead) {
    7175                g.fillRect(xoff - 1, 0, 3, 1);
    7276            } else {
     
    9296        }
    9397
    9498        if (value.linkNext) {
    95             g.setColor(Color.black);
     99            if (value.onewayFollowsNext) {
     100                g.setColor(Color.black);
     101            } else {
     102                g.setColor(Color.lightGray);
     103            }
    96104            if (value.isOnewayTail) {
    97105                g.fillRect(xoff - 1, ymax, 3, 1);
    98106            } else {
     
    119127        }
    120128
    121129        /* vertical lines */
    122         g.setColor(Color.black);
     130        if (value.onewayFollowsNext && value.onewayFollowsPrevious) {
     131            g.setColor(Color.black);
     132        } else {
     133            g.setColor(Color.lightGray);
     134        }
    123135        if (value.isLoop) {
    124136            g.drawLine(xoff+xloop, y1, xoff+xloop, y2);
    125137        }
  • src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionType.java

     
    2121     * direction is FORWARD if the first node of this way is connected to the previous way
    2222     * and / or the last node of this way is connected to the next way.
    2323     * direction is BACKWARD if it is the other way around.
     24     * direction has a ONEWAY value, if it is tagged as such and it is connected
     25     * to the previous / next member.
     26     * ONEWAY_FORWARD == the first node of the oneway is the last node of the previous way
     27     * ONEWAY_BACKWARD == the last node of the oneway is the last node of the previous way
    2428     * direction has a ROUNDABOUT value, if it is tagged as such and it is somehow
    2529     * connected to the previous / next member.
    2630     * If there is no connection to the previous or next member, then
     
    4448    public boolean isOnewayHead;
    4549    public boolean isOnewayTail;
    4650
     51    /** False, if the way is oneway and it doesn't follow the flow of the previous member */
     52    public boolean onewayFollowsPrevious = true;
     53    /** True, if the way is oneway and it doesn't follow the flow of the next member */
     54    public boolean onewayFollowsNext = true;
     55
    4756    public WayConnectionType(boolean linkPrev, boolean linkNext, Direction direction) {
    4857        this.linkPrev = linkPrev;
    4958        this.linkNext = linkNext;
     
    8291     * @since 10248
    8392     */
    8493    public String getTooltip() {
     94        boolean onewayGood = onewayFollowsPrevious && onewayFollowsNext;
    8595        if (!isValid())
    8696            return "";
    87         else if (linkPrev && linkNext)
     97        else if (linkPrev && linkNext && onewayGood)
    8898            return tr("way is connected");
    89         else if (linkPrev)
     99        else if (linkPrev && linkNext && !onewayGood)
     100            return tr("way is connected but has a wrong oneway direction");
     101        else if (linkPrev && onewayGood)
    90102            return tr("way is connected to previous relation member");
    91         else if (linkNext)
     103        else if (linkPrev && !onewayGood)
     104            return tr("way is connected to previous relation member but has a wrong oneway direction");
     105        else if (linkNext && onewayGood)
    92106            return tr("way is connected to next relation member");
     107        else if (linkNext && !onewayGood)
     108            return tr("way is connected to next relation member but has a wrong oneway direction");
    93109        else
    94110            return tr("way is not connected to previous or next relation member");
    95111    }
  • src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java

     
    1313import org.openstreetmap.josm.data.osm.Way;
    1414import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType.Direction;
    1515import org.openstreetmap.josm.tools.JosmRuntimeException;
     16import org.openstreetmap.josm.tools.Logging;
    1617import org.openstreetmap.josm.tools.bugreport.BugReport;
    1718
    1819/**
     
    119120        if (lastWct != null) {
    120121            lastWct.linkNext = wct.linkPrev;
    121122        }
     123
     124        if (lastWct != null && i > 0 && m.getMember() instanceof Way && members.get(i - 1).getMember() instanceof Way
     125                && (m.getWay().isOneway() != 0 || members.get(i - 1).getWay().isOneway() != 0)) {
     126            Way way = m.getWay();
     127            Way previousWay = members.get(i - 1).getWay();
     128            Logging.setLogLevel(Logging.LEVEL_INFO);
     129            if (way.isOneway() != 0 && ((!previousWay.isFirstLastNode(way.firstNode(true))) ||
     130                    (previousWay.isOneway() != 0 && !way.firstNode(true).equals(previousWay.lastNode(true))))) {
     131                Logging.info("{0} is doesn't follow the previous way", way);
     132                wct.onewayFollowsPrevious = false;
     133            }
     134            if (previousWay.isOneway() != 0 && ((!way.isFirstLastNode(previousWay.lastNode(true))) ||
     135                    (way.isOneway() != 0 && !previousWay.lastNode(true).equals(way.firstNode())))) {
     136                Logging.info("{0} is doesn't follow the next way", previousWay);
     137                lastWct.onewayFollowsNext = false;
     138            }
     139        }
    122140        con.set(i, wct);
    123141        return wct;
    124142    }