Ticket #17501: detect_wrong_oneway_relation.patch
File detect_wrong_oneway_relation.patch, 6.1 KB (added by , 6 years ago) |
---|
-
src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableLinkedCellRenderer.java
66 66 int y2; 67 67 68 68 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 } 70 74 if (value.isOnewayHead) { 71 75 g.fillRect(xoff - 1, 0, 3, 1); 72 76 } else { … … 92 96 } 93 97 94 98 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 } 96 104 if (value.isOnewayTail) { 97 105 g.fillRect(xoff - 1, ymax, 3, 1); 98 106 } else { … … 119 127 } 120 128 121 129 /* 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 } 123 135 if (value.isLoop) { 124 136 g.drawLine(xoff+xloop, y1, xoff+xloop, y2); 125 137 } -
src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionType.java
21 21 * direction is FORWARD if the first node of this way is connected to the previous way 22 22 * and / or the last node of this way is connected to the next way. 23 23 * 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 24 28 * direction has a ROUNDABOUT value, if it is tagged as such and it is somehow 25 29 * connected to the previous / next member. 26 30 * If there is no connection to the previous or next member, then … … 44 48 public boolean isOnewayHead; 45 49 public boolean isOnewayTail; 46 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; 55 47 56 public WayConnectionType(boolean linkPrev, boolean linkNext, Direction direction) { 48 57 this.linkPrev = linkPrev; 49 58 this.linkNext = linkNext; … … 82 91 * @since 10248 83 92 */ 84 93 public String getTooltip() { 94 boolean onewayGood = onewayFollowsPrevious && onewayFollowsNext; 85 95 if (!isValid()) 86 96 return ""; 87 else if (linkPrev && linkNext )97 else if (linkPrev && linkNext && onewayGood) 88 98 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) 90 102 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) 92 106 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"); 93 109 else 94 110 return tr("way is not connected to previous or next relation member"); 95 111 } -
src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java
13 13 import org.openstreetmap.josm.data.osm.Way; 14 14 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType.Direction; 15 15 import org.openstreetmap.josm.tools.JosmRuntimeException; 16 import org.openstreetmap.josm.tools.Logging; 16 17 import org.openstreetmap.josm.tools.bugreport.BugReport; 17 18 18 19 /** … … 119 120 if (lastWct != null) { 120 121 lastWct.linkNext = wct.linkPrev; 121 122 } 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 } 122 140 con.set(i, wct); 123 141 return wct; 124 142 }