Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
r18960 r18961 317 317 DataSet ds = OsmDataManager.getInstance().getActiveDataSet(); 318 318 if (ds != null) { 319 for (Way w: waysToTest) { 320 selection.addAll(ds.searchWays(w.getBBox())); 319 for (Way wt : waysToTest) { 320 selection.addAll(ds.searchWays(wt.getBBox()).stream() 321 .filter(w -> !w.isDeleted() && isPrimitiveUsable(w)).collect(Collectors.toList())); 322 if (this instanceof CrossingWays.Boundaries) { 323 List<Relation> relations = ds.searchRelations(wt.getBBox()).stream() 324 .filter(p -> isPrimitiveUsable(p)).collect(Collectors.toList()); 325 for (Relation r: relations) { 326 for (Way w : r.getMemberPrimitives(Way.class)) { 327 if (!w.isIncomplete()) 328 selection.add(w); 329 } 330 } 331 } 321 332 } 322 333 } 323 334 } 324 335 for (Way w : selection) { 325 if (!w.isDeleted() && isPrimitiveUsable(w)) { 326 testWay(w); 327 } 336 testWay(w); 328 337 } 329 338 // free storage 330 339 cellSegments.clear(); 331 340 seenWays.clear(); 332 waysToTest.clear();333 341 if (partialSelection) 334 342 removeIrrelevantErrors(waysToTest); 343 waysToTest.clear(); 335 344 super.endTest(); 336 345 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/CrossingWaysTest.java
r18870 r18961 10 10 import java.util.HashMap; 11 11 import java.util.List; 12 import java.util.stream.Collectors; 12 13 13 14 import org.junit.jupiter.api.Test; … … 17 18 import org.openstreetmap.josm.data.osm.DataSet; 18 19 import org.openstreetmap.josm.data.osm.Node; 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 21 import org.openstreetmap.josm.data.osm.Way; 20 22 import org.openstreetmap.josm.data.osm.WaySegment; … … 23 25 import org.openstreetmap.josm.data.validation.tests.CrossingWays.SelfCrossing; 24 26 import org.openstreetmap.josm.data.validation.tests.CrossingWays.Ways; 27 import org.openstreetmap.josm.gui.MainApplication; 28 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 25 29 import org.openstreetmap.josm.io.OsmReader; 26 30 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; … … 200 204 crossingWays.endTest(); 201 205 206 assertEquals(109, crossingWays.getErrors().size()); 202 207 for (TestError e : crossingWays.getErrors()) { 203 208 // we don't report self crossing ways in this test … … 220 225 } 221 226 227 /** 228 * Check if partial selection find crossings with unselected objects. 229 * @throws Exception if an error occurs 230 */ 231 @Test 232 void testPartial() throws Exception { 233 234 DataSet ds = OsmReader.parseDataSet( 235 Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "crossingWays.osm")), null); 236 MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, null, null)); 237 238 CrossingWays crossingWays = new CrossingWays.Ways(); 239 List<OsmPrimitive> partialSelection = ds.getWays().stream().filter(w -> w.hasTag("testsel", "horizontal")) 240 .collect(Collectors.toList()); 241 242 crossingWays.setPartialSelection(true); 243 crossingWays.startTest(null); 244 crossingWays.visit(partialSelection); 245 crossingWays.endTest(); 246 247 assertEquals(109, crossingWays.getErrors().size()); 248 for (TestError e : crossingWays.getErrors()) { 249 // we don't report self crossing ways in this test 250 assertEquals(2, e.getPrimitives().size(), e.getPrimitives().toString()); 251 // see #20121: crossing water areas should not be reported 252 assertFalse(e.getPrimitives().stream().filter(Way.class::isInstance).allMatch(CrossingWays::isWaterArea)); 253 } 254 255 CrossingWays crossingBoundaries = new CrossingWays.Boundaries(); 256 crossingBoundaries.setPartialSelection(true); 257 crossingBoundaries.startTest(null); 258 crossingBoundaries.visit(ds.allPrimitives()); 259 crossingBoundaries.endTest(); 260 assertEquals(2, crossingBoundaries.getErrors().size()); 261 } 222 262 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/DuplicateWayTest.java
r18853 r18961 35 35 private static void doTest(int code, String tags1, String tags2, boolean fixable) { 36 36 performTest(code, buildDataSet(tags1, tags2), fixable); 37 performPartialTest(code, buildDataSet(tags1, tags2), fixable); 37 38 } 38 39 39 40 private static void performTest(int code, DataSet ds, boolean fixable) { 41 TEST.setPartialSelection(false); 40 42 TEST.startTest(NullProgressMonitor.INSTANCE); 41 43 TEST.visit(ds.allPrimitives()); 44 TEST.endTest(); 45 46 assertEquals(1, TEST.getErrors().size()); 47 TestError error = TEST.getErrors().iterator().next(); 48 assertEquals(code, error.getCode()); 49 assertEquals(fixable, error.isFixable()); 50 } 51 52 private static void performPartialTest(int code, DataSet ds, boolean fixable) { 53 ds.setSelected(ds.getWays().iterator().next()); 54 TEST.setPartialSelection(true); 55 TEST.startTest(NullProgressMonitor.INSTANCE); 56 TEST.visit(ds.getSelectedWays().iterator().next()); 42 57 TEST.endTest(); 43 58
Note:
See TracChangeset
for help on using the changeset viewer.