Changeset 14966 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2019-04-07T07:54:49+02:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/validation/tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java
r14501 r14966 64 64 public static final String ROLE_VERIF_PROBLEM_MSG = tr("Role verification problem"); 65 65 private boolean ignoreMultiPolygons; 66 private boolean ignoreTurnRestrictions; 66 67 67 68 /** … … 109 110 if (t instanceof MultipolygonTest) { 110 111 ignoreMultiPolygons = true; 111 break; 112 } 113 if (t instanceof TurnrestrictionTest) { 114 ignoreTurnRestrictions = true; 112 115 } 113 116 } … … 125 128 if (ignoreMultiPolygons && n.isMultipolygon()) { 126 129 // see #17010: don't report same problem twice 130 return; 131 } 132 if (ignoreTurnRestrictions && n.hasTag("type","restriction")) { 133 // see #17561: don't report same problem twice 127 134 return; 128 135 } … … 321 328 if (!key.isEmpty()) { 322 329 errors.add(TestError.builder(this, Severity.WARNING, ROLE_UNKNOWN) 323 .message(ROLE_VERIF_PROBLEM_MSG, marktr("Role ''{0}'' unknownin templates ''{1}''"), key, templates)330 .message(ROLE_VERIF_PROBLEM_MSG, marktr("Role ''{0}'' is not in templates ''{1}''"), key, templates) 324 331 .primitives(n) 325 332 .build()); -
trunk/src/org/openstreetmap/josm/data/validation/tests/TurnrestrictionTest.java
r14501 r14966 5 5 6 6 import java.util.ArrayList; 7 import java.util.Arrays; 7 8 import java.util.List; 8 9 … … 38 39 protected static final int SUPERFLUOUS = 1815; 39 40 protected static final int FROM_EQUALS_TO = 1816; 41 protected static final int UNKNOWN_RESTRICTION = 1817; 42 protected static final int TO_CLOSED_WAY = 1818; 43 protected static final int FROM_CLOSED_WAY = 1819; 44 45 private static final List<String> SUPPORTED_RESTRICTIONS = Arrays.asList( 46 "no_right_turn", "no_left_turn", "no_u_turn", "no_straight_on", 47 "only_right_turn", "only_left_turn", "only_straight_on", 48 "no_entry", "no_exit" 49 ); 40 50 41 51 /** … … 50 60 if (!r.hasTag("type", "restriction")) 51 61 return; 62 63 if (!r.hasTag("restriction", SUPPORTED_RESTRICTIONS)) { 64 errors.add(TestError.builder(this, Severity.ERROR, UNKNOWN_RESTRICTION) 65 .message(tr("Unknown restriction")) 66 .primitives(r) 67 .build()); 68 return; 69 } 52 70 53 71 Way fromWay = null; … … 98 116 default: 99 117 errors.add(TestError.builder(this, Severity.WARNING, UNKNOWN_ROLE) 100 .message(tr("Unknown role "))118 .message(tr("Unknown role in restriction")) 101 119 .primitives(l) 102 120 .highlight(m.getMember()) … … 105 123 } else if (m.isNode()) { 106 124 Node n = m.getNode(); 107 if ("via".equals(m.getRole())) { 125 switch (m.getRole()) { 126 case "via": 108 127 if (!via.isEmpty()) { 109 128 if (via.get(0) instanceof Node) { … … 115 134 via.add(n); 116 135 } 117 } else { 136 break; 137 case "location_hint": 118 138 errors.add(TestError.builder(this, Severity.WARNING, UNKNOWN_ROLE) 119 .message(tr("Unknown role")) 139 .message(tr("Role location_hint in not in templates")) 140 .primitives(l) 141 .highlight(m.getMember()) 142 .build()); 143 break; 144 default: 145 errors.add(TestError.builder(this, Severity.WARNING, UNKNOWN_ROLE) 146 .message(tr("Unknown role in restriction")) 120 147 .primitives(l) 121 148 .highlight(m.getMember()) … … 135 162 .primitives(r) 136 163 .build()); 164 return; 137 165 } 138 166 if (moreto) { … … 141 169 .primitives(r) 142 170 .build()); 171 return; 143 172 } 144 173 if (morevia) { … … 147 176 .primitives(r) 148 177 .build()); 178 return; 149 179 } 150 180 if (mixvia) { … … 153 183 .primitives(r) 154 184 .build()); 185 return; 155 186 } 156 187 … … 161 192 .build()); 162 193 return; 163 } 194 } else if (fromWay.isClosed()) { 195 errors.add(TestError.builder(this, Severity.ERROR, FROM_CLOSED_WAY) 196 .message(tr("\"from\" way is a closed way")) 197 .primitives(r) 198 .highlight(fromWay) 199 .build()); 200 return; 201 } 202 164 203 if (toWay == null) { 165 204 errors.add(TestError.builder(this, Severity.ERROR, NO_TO) 166 205 .message(tr("No \"to\" way found")) 167 206 .primitives(r) 207 .build()); 208 return; 209 } else if (toWay.isClosed()) { 210 errors.add(TestError.builder(this, Severity.ERROR, TO_CLOSED_WAY) 211 .message(tr("\"to\" way is a closed way")) 212 .primitives(r) 213 .highlight(toWay) 168 214 .build()); 169 215 return; … … 186 232 if (via.get(0) instanceof Node) { 187 233 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))) { 234 if (isFullOneway(toWay) && viaNode.equals(toWay.lastNode(true))) { 193 235 errors.add(TestError.builder(this, Severity.WARNING, SUPERFLUOUS) 194 236 .message(tr("Superfluous turnrestriction as \"to\" way is oneway")) 195 237 .primitives(r) 196 .build()); 197 return; 198 } 199 checkIfConnected(viaPseudoWay, toWay, 238 .highlight(toWay) 239 .build()); 240 return; 241 } 242 if (isFullOneway(fromWay) && viaNode.equals(fromWay.firstNode(true))) { 243 errors.add(TestError.builder(this, Severity.WARNING, SUPERFLUOUS) 244 .message(tr("Superfluous turnrestriction as \"from\" way is oneway")) 245 .primitives(r) 246 .highlight(fromWay) 247 .build()); 248 return; 249 } 250 final Way viaPseudoWay = new Way(); 251 viaPseudoWay.addNode(viaNode); 252 checkIfConnected(r, fromWay, viaPseudoWay, 253 tr("The \"from\" way does not start or end at a \"via\" node."), FROM_VIA_NODE); 254 checkIfConnected(r, viaPseudoWay, toWay, 200 255 tr("The \"to\" way does not start or end at a \"via\" node."), TO_VIA_NODE); 201 256 } else { 257 if (isFullOneway(toWay) && ((Way) via.get(via.size() - 1)).isFirstLastNode(toWay.lastNode(true))) { 258 errors.add(TestError.builder(this, Severity.WARNING, SUPERFLUOUS) 259 .message(tr("Superfluous turnrestriction as \"to\" way is oneway")) 260 .primitives(r) 261 .highlight(toWay) 262 .build()); 263 return; 264 } 265 if (isFullOneway(fromWay) && ((Way) via.get(0)).isFirstLastNode(fromWay.firstNode(true))) { 266 errors.add(TestError.builder(this, Severity.WARNING, SUPERFLUOUS) 267 .message(tr("Superfluous turnrestriction as \"from\" way is oneway")) 268 .primitives(r) 269 .highlight(fromWay) 270 .build()); 271 return; 272 } 202 273 // check if consecutive ways are connected: from/via[0], via[i-1]/via[i], via[last]/to 203 checkIfConnected( fromWay, (Way) via.get(0),274 checkIfConnected(r, fromWay, (Way) via.get(0), 204 275 tr("The \"from\" and the first \"via\" way are not connected."), FROM_VIA_WAY); 205 276 if (via.size() > 1) { … … 207 278 Way previous = (Way) via.get(i - 1); 208 279 Way current = (Way) via.get(i); 209 checkIfConnected( previous, current,280 checkIfConnected(r, previous, current, 210 281 tr("The \"via\" ways are not connected."), UNCONNECTED_VIA); 211 282 } 212 283 } 213 if (toWay.isOneway() != 0 && ((Way) via.get(via.size() - 1)).isFirstLastNode(toWay.lastNode(true))) { 214 errors.add(TestError.builder(this, Severity.WARNING, SUPERFLUOUS) 215 .message(tr("Superfluous turnrestriction as \"to\" way is oneway")) 216 .primitives(r) 217 .build()); 218 return; 219 } 220 checkIfConnected((Way) via.get(via.size() - 1), toWay, 284 checkIfConnected(r, (Way) via.get(via.size() - 1), toWay, 221 285 tr("The last \"via\" and the \"to\" way are not connected."), TO_VIA_WAY); 222 286 } … … 227 291 } 228 292 229 private void checkIfConnected( Way previous, Way current, String msg, int code) {293 private void checkIfConnected(Relation r, Way previous, Way current, String msg, int code) { 230 294 boolean c; 231 295 if (isFullOneway(previous) && isFullOneway(current)) { … … 243 307 } 244 308 if (!c) { 309 List<OsmPrimitive> hilite = new ArrayList<>(); 310 if (previous.getNodesCount() == 1 && previous.isNew()) 311 hilite.add(previous.firstNode()); 312 else 313 hilite.add(previous); 314 if (current.getNodesCount() == 1 && current.isNew()) 315 hilite.add(current.firstNode()); 316 else 317 hilite.add(current); 318 List<OsmPrimitive> primitives = new ArrayList<>(); 319 primitives.add(r); 320 primitives.addAll(hilite); 245 321 errors.add(TestError.builder(this, Severity.ERROR, code) 246 322 .message(msg) 247 .primitives(previous, current) 323 .primitives(primitives) 324 .highlight(hilite) 248 325 .build()); 249 326 }
Note:
See TracChangeset
for help on using the changeset viewer.