Changeset 14468 in josm
- Timestamp:
- 2018-11-30T09:45:11+01: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/CrossingWays.java
r14452 r14468 38 38 static final String LANDUSE = "landuse"; 39 39 40 private static final class MessageHelper { 41 final String message; 42 final int code; 43 44 MessageHelper(String message, int code) { 45 this.message = message; 46 this.code = code; 47 } 48 } 49 40 50 /** 41 51 * Type of way. Entries have to be declared in alphabetical order, see sort below. … … 65 75 private final Map<List<Way>, List<WaySegment>> seenWays = new HashMap<>(50); 66 76 67 pr ivatefinal int code;77 protected final int code; 68 78 69 79 /** … … 120 130 121 131 @Override 122 StringcreateMessage(Way w1, Way w2) {132 MessageHelper createMessage(Way w1, Way w2) { 123 133 WayType[] types = {WayType.of(w1), WayType.of(w2)}; 124 134 Arrays.sort(types); … … 127 137 switch(types[0]) { 128 138 case BUILDING: 129 return tr("Crossing buildings");139 return new MessageHelper(tr("Crossing buildings"), 610); 130 140 case HIGHWAY: 131 return tr("Crossing highways");141 return new MessageHelper(tr("Crossing highways"), 620); 132 142 case RAILWAY: 133 return tr("Crossing railways");143 return new MessageHelper(tr("Crossing railways"), 630); 134 144 case RESIDENTIAL_AREA: 135 return tr("Crossing residential areas");145 return new MessageHelper(tr("Crossing residential areas"), 640); 136 146 case WATERWAY: 137 return tr("Crossing waterways");147 return new MessageHelper(tr("Crossing waterways"), 650); 138 148 case WAY: 139 149 default: 140 return tr("Crossing ways");150 return new MessageHelper(tr("Crossing ways"), CROSSING_WAYS); 141 151 } 142 152 } else { … … 145 155 switch (types[1]) { 146 156 case HIGHWAY: 147 return tr("Crossing building/highway");157 return new MessageHelper(tr("Crossing building/highway"), 612); 148 158 case RAILWAY: 149 return tr("Crossing building/railway");159 return new MessageHelper(tr("Crossing building/railway"), 613); 150 160 case RESIDENTIAL_AREA: 151 return tr("Crossing building/residential area");161 return new MessageHelper(tr("Crossing building/residential area"), 614); 152 162 case WATERWAY: 153 return tr("Crossing building/waterway");163 return new MessageHelper(tr("Crossing building/waterway"), 615); 154 164 case WAY: 155 165 default: 156 return tr("Crossing building/way");166 return new MessageHelper(tr("Crossing building/way"), 611); 157 167 } 158 168 case HIGHWAY: 159 169 switch (types[1]) { 160 170 case RAILWAY: 161 return tr("Crossing highway/railway");171 return new MessageHelper(tr("Crossing highway/railway"), 622); 162 172 case WATERWAY: 163 return tr("Crossing highway/waterway");173 return new MessageHelper(tr("Crossing highway/waterway"), 623); 164 174 case WAY: 165 175 default: 166 return tr("Crossing highway/way");176 return new MessageHelper(tr("Crossing highway/way"), 621); 167 177 } 168 178 case RAILWAY: 169 179 switch (types[1]) { 170 180 case WATERWAY: 171 return tr("Crossing railway/waterway");181 return new MessageHelper(tr("Crossing railway/waterway"), 632); 172 182 case WAY: 173 183 default: 174 return tr("Crossing railway/way");184 return new MessageHelper(tr("Crossing railway/way"), 631); 175 185 } 176 186 case RESIDENTIAL_AREA: … … 178 188 case WAY: 179 189 default: 180 return tr("Crossing residential area/way");190 return new MessageHelper(tr("Crossing residential area/way"), 641); 181 191 } 182 192 case WATERWAY: 183 193 default: 184 return tr("Crossing waterway/way");194 return new MessageHelper(tr("Crossing waterway/way"), 651); 185 195 } 186 196 } … … 214 224 215 225 @Override 216 StringcreateMessage(Way w1, Way w2) {217 return tr("Crossing boundaries");226 MessageHelper createMessage(Way w1, Way w2) { 227 return new MessageHelper(tr("Crossing boundaries"), CROSSING_BOUNDARIES); 218 228 } 219 229 … … 251 261 252 262 @Override 253 StringcreateMessage(Way w1, Way w2) {254 return tr("Crossing barriers");263 MessageHelper createMessage(Way w1, Way w2) { 264 return new MessageHelper(tr("Crossing barriers"), CROSSING_BARRIERS); 255 265 } 256 266 } … … 286 296 287 297 @Override 288 StringcreateMessage(Way w1, Way w2) {289 return tr("Self-crossing ways");298 MessageHelper createMessage(Way w1, Way w2) { 299 return new MessageHelper(tr("Self-crossing ways"), CROSSING_SELF); 290 300 } 291 301 } … … 341 351 abstract boolean ignoreWaySegmentCombination(Way w1, Way w2); 342 352 343 abstract StringcreateMessage(Way w1, Way w2);353 abstract MessageHelper createMessage(Way w1, Way w2); 344 354 345 355 @Override … … 357 367 final EastNorth en2 = es1.getSecondNode().getEastNorth(); 358 368 if (en1 == null || en2 == null) { 359 Logging.warn("Crossing ways test skipped " +es1);369 Logging.warn("Crossing ways test skipped " + es1); 360 370 continue; 361 371 } … … 378 388 highlight.add(es2); 379 389 380 final Stringmessage = createMessage(es1.way, es2.way);381 errors.add(TestError.builder(this, Severity.WARNING, code)382 .message(message )390 final MessageHelper message = createMessage(es1.way, es2.way); 391 errors.add(TestError.builder(this, Severity.WARNING, message.code) 392 .message(message.message) 383 393 .primitives(prims) 384 394 .highlightWaySegments(highlight) -
trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java
r14305 r14468 46 46 */ 47 47 public abstract class UnconnectedWays extends Test { 48 private final int code; 48 49 49 50 /** … … 51 52 */ 52 53 public static class UnconnectedHighways extends UnconnectedWays { 54 static final int UNCONNECTED_HIGHWAYS = 1311; 53 55 54 56 /** … … 56 58 */ 57 59 public UnconnectedHighways() { 58 super(tr("Unconnected highways") );60 super(tr("Unconnected highways"), UNCONNECTED_HIGHWAYS); 59 61 } 60 62 … … 69 71 */ 70 72 public static class UnconnectedRailways extends UnconnectedWays { 71 73 static final int UNCONNECTED_RAILWAYS = 1321; 72 74 /** 73 75 * Constructs a new {@code UnconnectedRailways} test. 74 76 */ 75 77 public UnconnectedRailways() { 76 super(tr("Unconnected railways") );78 super(tr("Unconnected railways"), UNCONNECTED_RAILWAYS); 77 79 } 78 80 … … 87 89 */ 88 90 public static class UnconnectedWaterways extends UnconnectedWays { 89 91 static final int UNCONNECTED_WATERWAYS = 1331; 90 92 /** 91 93 * Constructs a new {@code UnconnectedWaterways} test. 92 94 */ 93 95 public UnconnectedWaterways() { 94 super(tr("Unconnected waterways") );96 super(tr("Unconnected waterways"), UNCONNECTED_WATERWAYS); 95 97 } 96 98 … … 105 107 */ 106 108 public static class UnconnectedNaturalOrLanduse extends UnconnectedWays { 107 109 static final int UNCONNECTED_NATURAL_OR_LANDUSE = 1341; 108 110 /** 109 111 * Constructs a new {@code UnconnectedNaturalOrLanduse} test. 110 112 */ 111 113 public UnconnectedNaturalOrLanduse() { 112 super(tr("Unconnected natural lands and landuses") );114 super(tr("Unconnected natural lands and landuses"), UNCONNECTED_NATURAL_OR_LANDUSE); 113 115 } 114 116 … … 123 125 */ 124 126 public static class UnconnectedPower extends UnconnectedWays { 125 127 static final int UNCONNECTED_POWER = 1351; 126 128 /** 127 129 * Constructs a new {@code UnconnectedPower} test. 128 130 */ 129 131 public UnconnectedPower() { 130 super(tr("Unconnected power ways") );132 super(tr("Unconnected power ways"), UNCONNECTED_POWER); 131 133 } 132 134 … … 156 158 */ 157 159 public UnconnectedWays(String title) { 160 this(title, UNCONNECTED_WAYS); 161 162 } 163 164 /** 165 * Constructs a new {@code UnconnectedWays} test with the given code. 166 * @param title The test title 167 * @param code The test code 168 * @since 14468 169 */ 170 public UnconnectedWays(String title, int code) { 158 171 super(title, tr("This test checks if a way has an endpoint very near to another way.")); 172 this.code = code; 159 173 } 160 174 … … 268 282 protected final void addErrors(Severity severity, Map<Node, Way> errorMap, String message) { 269 283 for (Map.Entry<Node, Way> error : errorMap.entrySet()) { 270 errors.add(TestError.builder(this, severity, UNCONNECTED_WAYS)284 errors.add(TestError.builder(this, severity, code) 271 285 .message(message) 272 286 .primitives(error.getKey(), error.getValue())
Note:
See TracChangeset
for help on using the changeset viewer.