Changeset 15076 in josm for trunk/src


Ignore:
Timestamp:
2019-05-15T22:28:07+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #17501 - Detect if a oneway in a relation may be going in the wrong direction (patch by taylor.smock)

Location:
trunk/src/org/openstreetmap/josm/gui/dialogs/relation
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableLinkedCellRenderer.java

    r12657 r15076  
    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);
     
    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);
     
    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);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionType.java

    r14030 r15076  
    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.
     
    4448    public boolean isOnewayHead;
    4549    public boolean isOnewayTail;
     50
     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;
    4655
    4756    public WayConnectionType(boolean linkPrev, boolean linkNext, Direction direction) {
     
    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");
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java

    r14473 r15076  
    119119        if (lastWct != null) {
    120120            lastWct.linkNext = wct.linkPrev;
     121        }
     122
     123        if (lastWct != null && i > 0 && m.getMember() instanceof Way && members.get(i - 1).getMember() instanceof Way
     124                && (m.getWay().isOneway() != 0 || members.get(i - 1).getWay().isOneway() != 0)) {
     125            Way way = m.getWay();
     126            Way previousWay = members.get(i - 1).getWay();
     127            if (way.isOneway() != 0 && previousWay.isOneway() != 0 &&
     128                    (way.firstNode(true) != previousWay.lastNode(true) &&
     129                        way.lastNode(true) != previousWay.firstNode(true))) {
     130                wct.onewayFollowsPrevious = false;
     131                lastWct.onewayFollowsNext = false;
     132            } else if (way.isOneway() != 0 && previousWay.isOneway() == 0 &&
     133                    previousWay.isFirstLastNode(way.lastNode(true))) {
     134                wct.onewayFollowsPrevious = false;
     135            }
    121136        }
    122137        con.set(i, wct);
Note: See TracChangeset for help on using the changeset viewer.