Ticket #17561: 17561.diff
File 17561.diff, 4.5 KB (added by , 5 years ago) |
---|
-
src/org/openstreetmap/josm/data/validation/tests/TurnrestrictionTest.java
185 185 186 186 if (via.get(0) instanceof Node) { 187 187 final Node viaNode = (Node) via.get(0); 188 final Way viaPseudoWay = new Way(); 189 viaPseudoWay.addNode(viaNode); 190 checkIfConnected(fromWay, viaPseudoWay, 191 tr("The \"from\" way does not start or end at a \"via\" node."), FROM_VIA_NODE); 192 if (toWay.isOneway() != 0 && viaNode.equals(toWay.lastNode(true))) { 188 if (isFullOneway(toWay) && viaNode.equals(toWay.lastNode(true))) { 193 189 errors.add(TestError.builder(this, Severity.WARNING, SUPERFLUOUS) 194 190 .message(tr("Superfluous turnrestriction as \"to\" way is oneway")) 195 191 .primitives(r) 192 .highlight(toWay) 196 193 .build()); 197 194 return; 198 195 } 199 checkIfConnected(viaPseudoWay, toWay, 196 if (isFullOneway(fromWay) && viaNode.equals(fromWay.firstNode(true))) { 197 errors.add(TestError.builder(this, Severity.WARNING, SUPERFLUOUS) 198 .message(tr("Superfluous turnrestriction as \"from\" way is oneway")) 199 .primitives(r) 200 .highlight(fromWay) 201 .build()); 202 return; 203 } 204 final Way viaPseudoWay = new Way(); 205 viaPseudoWay.addNode(viaNode); 206 checkIfConnected(r, fromWay, viaPseudoWay, 207 tr("The \"from\" way does not start or end at a \"via\" node."), FROM_VIA_NODE); 208 checkIfConnected(r, viaPseudoWay, toWay, 200 209 tr("The \"to\" way does not start or end at a \"via\" node."), TO_VIA_NODE); 201 210 } else { 202 211 // check if consecutive ways are connected: from/via[0], via[i-1]/via[i], via[last]/to 203 checkIfConnected( fromWay, (Way) via.get(0),212 checkIfConnected(r, fromWay, (Way) via.get(0), 204 213 tr("The \"from\" and the first \"via\" way are not connected."), FROM_VIA_WAY); 205 214 if (via.size() > 1) { 206 215 for (int i = 1; i < via.size(); i++) { 207 216 Way previous = (Way) via.get(i - 1); 208 217 Way current = (Way) via.get(i); 209 checkIfConnected( previous, current,218 checkIfConnected(r, previous, current, 210 219 tr("The \"via\" ways are not connected."), UNCONNECTED_VIA); 211 220 } 212 221 } … … 217 226 .build()); 218 227 return; 219 228 } 220 checkIfConnected( (Way) via.get(via.size() - 1), toWay,229 checkIfConnected(r, (Way) via.get(via.size() - 1), toWay, 221 230 tr("The last \"via\" and the \"to\" way are not connected."), TO_VIA_WAY); 222 231 } 223 232 } … … 226 235 return w.isOneway() != 0 && !w.hasTag("oneway:bicycle", "no"); 227 236 } 228 237 229 private void checkIfConnected( Way previous, Way current, String msg, int code) {238 private void checkIfConnected(Relation r, Way previous, Way current, String msg, int code) { 230 239 boolean c; 231 240 if (isFullOneway(previous) && isFullOneway(current)) { 232 241 // both oneways: end/start node must be equal … … 242 251 c = current.isFirstLastNode(previous.firstNode()) || current.isFirstLastNode(previous.lastNode()); 243 252 } 244 253 if (!c) { 254 List<OsmPrimitive> hilite = new ArrayList<>(); 255 if (previous.getNodesCount() == 1 && previous.isNew()) 256 hilite.add(previous.firstNode()); 257 else 258 hilite.add(previous); 259 if (current.getNodesCount() == 1 && current.isNew()) 260 hilite.add(current.firstNode()); 261 else 262 hilite.add(current); 263 List<OsmPrimitive> primitives = new ArrayList<>(); 264 primitives.add(r); 265 primitives.addAll(hilite); 245 266 errors.add(TestError.builder(this, Severity.ERROR, code) 246 267 .message(msg) 247 .primitives(previous, current) 268 .primitives(primitives) 269 .highlight(hilite) 248 270 .build()); 249 271 } 250 272 }