Changeset 15132 in josm
- Timestamp:
- 2019-05-28T19:53:19+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/MultipolygonTest.java
r15008 r15132 30 30 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon; 31 31 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.PolyData; 32 import org.openstreetmap.josm.data.validation.OsmValidator;33 32 import org.openstreetmap.josm.data.validation.Severity; 34 33 import org.openstreetmap.josm.data.validation.Test; … … 37 36 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 38 37 import org.openstreetmap.josm.gui.mappaint.styleelement.AreaElement; 39 import org.openstreetmap.josm.gui.progress.ProgressMonitor;40 38 import org.openstreetmap.josm.tools.Geometry; 41 39 import org.openstreetmap.josm.tools.Geometry.PolygonIntersection; … … 62 60 /** With the currently used mappaint style the style for inner way equals the multipolygon style */ 63 61 public static final int INNER_STYLE_MISMATCH = 1608; 64 /** Area style way is not closed */ 65 public static final int NOT_CLOSED = 1609; 62 // no longer used: Area style way is not closed NOT_CLOSED = 1609 66 63 /** No area style for multipolygon */ 67 64 public static final int NO_STYLE = 1610; … … 82 79 private static final int FOUND_OUTSIDE = 2; 83 80 84 private final Set<String> keysCheckedByAnotherTest = new HashSet<>();85 86 81 /** 87 82 * Constructs a new {@code MultipolygonTest}. … … 90 85 super(tr("Multipolygon"), 91 86 tr("This test checks if multipolygons are valid.")); 92 }93 94 @Override95 public void startTest(ProgressMonitor progressMonitor) {96 super.startTest(progressMonitor);97 keysCheckedByAnotherTest.clear();98 for (Test t : OsmValidator.getEnabledTests(false)) {99 if (t instanceof UnclosedWays) {100 keysCheckedByAnotherTest.addAll(((UnclosedWays) t).getCheckedKeys());101 break;102 }103 }104 }105 106 @Override107 public void endTest() {108 keysCheckedByAnotherTest.clear();109 super.endTest();110 }111 112 @Override113 public void visit(Way w) {114 if (!w.isArea() && ElemStyles.hasOnlyAreaElements(w)) {115 List<Node> nodes = w.getNodes();116 if (nodes.isEmpty()) return; // fix zero nodes bug117 for (String key : keysCheckedByAnotherTest) {118 if (w.hasKey(key)) {119 return;120 }121 }122 errors.add(TestError.builder(this, Severity.WARNING, NOT_CLOSED)123 .message(tr("Area style way is not closed"))124 .primitives(w)125 .highlight(Arrays.asList(nodes.get(0), nodes.get(nodes.size() - 1)))126 .build());127 }128 87 } 129 88 -
trunk/src/org/openstreetmap/josm/data/validation/tests/UnclosedWays.java
r15093 r15132 8 8 import java.util.Collections; 9 9 import java.util.HashSet; 10 import java.util.List; 10 11 import java.util.Set; 11 12 13 import org.openstreetmap.josm.data.osm.Node; 12 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 13 15 import org.openstreetmap.josm.data.osm.OsmUtils; … … 17 19 import org.openstreetmap.josm.data.validation.Test; 18 20 import org.openstreetmap.josm.data.validation.TestError; 21 import org.openstreetmap.josm.gui.mappaint.ElemStyles; 19 22 20 23 /** … … 156 159 new UnclosedWaysBooleanCheck(1120, "building", marktr("building")), 157 160 new UnclosedWaysBooleanCheck(1130, "area", marktr("area")), 161 // 1131: Area style way is not closed 158 162 // CHECKSTYLE.ON: SingleSpaceSeparator 159 163 }; … … 190 194 } 191 195 } 196 // code 1131: other area style ways 197 if (ElemStyles.hasOnlyAreaElements(w)) { 198 List<Node> nodes = w.getNodes(); 199 if (nodes.isEmpty()) return; // fix zero nodes bug 200 errors.add(TestError.builder(this, Severity.WARNING, 1131) 201 .message(tr("Unclosed way"), marktr("Area style way is not closed"), new Object()) 202 .primitives(w) 203 .highlight(Arrays.asList(w.firstNode(), w.lastNode())) 204 .build()); 205 } 192 206 } 193 207 }
Note:
See TracChangeset
for help on using the changeset viewer.