Changeset 5688 in josm for trunk/src/org
- Timestamp:
- 2013-01-29T01:25:27+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java
r5490 r5688 140 140 } 141 141 if (!hasOuterWay) { 142 errors.add(new TestError(this, Severity.WARNING, tr("No outer way for multipolygon"), MISSING_OUTER_WAY, r));142 addError(r, new TestError(this, Severity.WARNING, tr("No outer way for multipolygon"), MISSING_OUTER_WAY, r)); 143 143 } 144 144 … … 163 163 } 164 164 if(area == null) 165 errors.add(new TestError(this, Severity.OTHER, tr("No style for multipolygon"), NO_STYLE, r));165 addError(r, new TestError(this, Severity.OTHER, tr("No style for multipolygon"), NO_STYLE, r)); 166 166 else 167 errors.add(new TestError(this, Severity.OTHER, tr("No style in multipolygon relation"),167 addError(r, new TestError(this, Severity.OTHER, tr("No style in multipolygon relation"), 168 168 NO_STYLE_POLYGON, r)); 169 169 } … … 177 177 l.add(r); 178 178 l.add(wInner); 179 errors.add(new TestError(this, Severity.WARNING, tr("Style for inner way equals multipolygon"),179 addError(r, new TestError(this, Severity.WARNING, tr("Style for inner way equals multipolygon"), 180 180 INNER_STYLE_MISMATCH, l, Collections.singletonList(wInner))); 181 181 } … … 188 188 l.add(r); 189 189 l.add(wOuter); 190 errors.add(new TestError(this, Severity.WARNING, tr("Style for outer way mismatches"),190 addError(r, new TestError(this, Severity.WARNING, tr("Style for outer way mismatches"), 191 191 OUTER_STYLE_MISMATCH, l, Collections.singletonList(wOuter))); 192 192 } … … 207 207 primitives.addAll(openNodes); 208 208 Arrays.asList(openNodes, r); 209 errors.add(new TestError(this, Severity.WARNING, tr("Multipolygon is not closed"), NON_CLOSED_WAY,209 addError(r, new TestError(this, Severity.WARNING, tr("Multipolygon is not closed"), NON_CLOSED_WAY, 210 210 primitives, openNodes)); 211 211 } … … 230 230 highlights.add(pdInner); 231 231 if (outside) { 232 errors.add(new TestError(this, Severity.WARNING, tr("Multipolygon inner way is outside"), INNER_WAY_OUTSIDE, Collections.singletonList(r), highlights));232 addError(r, new TestError(this, Severity.WARNING, tr("Multipolygon inner way is outside"), INNER_WAY_OUTSIDE, Collections.singletonList(r), highlights)); 233 233 } else if (crossing) { 234 234 highlights.add(outerWay); 235 errors.add(new TestError(this, Severity.WARNING, tr("Intersection between multipolygon ways"), CROSSING_WAYS, Collections.singletonList(r), highlights));235 addError(r, new TestError(this, Severity.WARNING, tr("Intersection between multipolygon ways"), CROSSING_WAYS, Collections.singletonList(r), highlights)); 236 236 } 237 237 } … … 244 244 if (rm.isWay()) { 245 245 if (!("inner".equals(rm.getRole()) || "outer".equals(rm.getRole()) || !rm.hasRole())) { 246 errors.add(new TestError(this, Severity.WARNING, tr("No useful role for multipolygon member"), WRONG_MEMBER_ROLE, rm.getMember()));246 addError(r, new TestError(this, Severity.WARNING, tr("No useful role for multipolygon member"), WRONG_MEMBER_ROLE, rm.getMember())); 247 247 } 248 248 } else { 249 249 if(!"admin_centre".equals(rm.getRole())) 250 errors.add(new TestError(this, Severity.WARNING, tr("Non-Way in multipolygon"), WRONG_MEMBER_TYPE, rm.getMember())); 251 } 252 } 250 addError(r, new TestError(this, Severity.WARNING, tr("Non-Way in multipolygon"), WRONG_MEMBER_TYPE, rm.getMember())); 251 } 252 } 253 } 254 255 private void addRelationIfNeeded(TestError error, Relation r) { 256 // Fix #8212 : if the error references only incomplete primitives, 257 // add multipolygon in order to let user select something and fix the error 258 Collection<? extends OsmPrimitive> primitives = error.getPrimitives(); 259 if (!primitives.contains(r)) { 260 for (OsmPrimitive p : primitives) { 261 if (!p.isIncomplete()) { 262 return; 263 } 264 } 265 List<OsmPrimitive> newPrimitives = new ArrayList<OsmPrimitive>(primitives); 266 newPrimitives.add(0, r); 267 error.setPrimitives(newPrimitives); 268 } 269 } 270 271 private void addError(Relation r, TestError error) { 272 addRelationIfNeeded(error, r); 273 errors.add(error); 253 274 } 254 275 }
Note:
See TracChangeset
for help on using the changeset viewer.