Ticket #20680: 20680-2.patch
| File 20680-2.patch, 4.6 KB (added by , 5 years ago) |
|---|
-
actions/upload/ValidateUploadHook.java
54 54 if (tests.isEmpty()) 55 55 return true; 56 56 57 AggregatePrimitivesVisitor v = new AggregatePrimitivesVisitor( );57 AggregatePrimitivesVisitor v = new AggregatePrimitivesVisitor(true); 58 58 v.visit(apiDataSet.getPrimitivesToAdd()); 59 59 Collection<OsmPrimitive> selection = v.visit(apiDataSet.getPrimitivesToUpdate()); 60 60 -
actions/ValidateAction.java
70 70 selection = getLayerManager().getActiveDataSet().allNonDeletedPrimitives(); 71 71 lastSelection = null; 72 72 } else { 73 AggregatePrimitivesVisitor v = new AggregatePrimitivesVisitor( );73 AggregatePrimitivesVisitor v = new AggregatePrimitivesVisitor(true); 74 74 selection = v.visit(selection); 75 75 lastSelection = selection; 76 76 } -
data/validation/tests/CrossingWays.java
15 15 import java.util.stream.Collectors; 16 16 17 17 import org.openstreetmap.josm.data.coor.EastNorth; 18 import org.openstreetmap.josm.data.osm.DataSet; 19 import org.openstreetmap.josm.data.osm.OsmDataManager; 18 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 21 import org.openstreetmap.josm.data.osm.OsmUtils; 20 22 import org.openstreetmap.josm.data.osm.Relation; … … 80 82 private final Map<Point2D, List<WaySegment>> cellSegments = new HashMap<>(1000); 81 83 /** The already detected ways in error */ 82 84 private final Map<List<Way>, List<WaySegment>> seenWays = new HashMap<>(50); 85 protected boolean isSurroundingTest; 83 86 84 87 protected final int code; 85 88 … … 298 301 @Override 299 302 public void startTest(ProgressMonitor monitor) { 300 303 super.startTest(monitor); 304 isSurroundingTest = false; 301 305 cellSegments.clear(); 302 306 seenWays.clear(); 303 307 } … … 304 308 305 309 @Override 306 310 public void endTest() { 311 // see #20680: if only a selection was tested, test it also against the other suitable ways 312 if (partialSelection && !cellSegments.isEmpty() && !(this instanceof SelfCrossing)) { 313 isSurroundingTest = true; // don't add more ways to the spatial index 314 DataSet ds = OsmDataManager.getInstance().getActiveDataSet(); 315 for (Way w : ds.getWays()) { 316 if (isPrimitiveUsable(w)) 317 visit(w); 318 } 319 } 307 320 super.endTest(); 308 321 cellSegments.clear(); 309 322 seenWays.clear(); … … 390 403 highlight.add(es2); 391 404 } 392 405 } 393 segments.add(es1); 406 if (!isSurroundingTest) 407 segments.add(es1); 394 408 } 395 409 } 396 410 } -
data/validation/util/AggregatePrimitivesVisitor.java
21 21 public class AggregatePrimitivesVisitor implements OsmPrimitiveVisitor { 22 22 /** Aggregated data */ 23 23 private final Collection<OsmPrimitive> aggregatedData = new HashSet<>(); 24 private final boolean collectParentWays; 24 25 25 26 /** 27 * create new AggregatePrimitivesVisitor. 28 */ 29 public AggregatePrimitivesVisitor() { 30 this(false); 31 } 32 33 /** 34 * create new AggregatePrimitivesVisitor. 35 * @param collectParentWays if true, parent ways of modified nodes are also collected 36 */ 37 public AggregatePrimitivesVisitor(boolean collectParentWays) { 38 this.collectParentWays = collectParentWays; 39 } 40 41 /** 26 42 * Visits a collection of primitives 27 43 * @param data The collection of primitives 28 44 * @return The aggregated primitives … … 40 56 if (!aggregatedData.contains(n)) { 41 57 aggregatedData.add(n); 42 58 } 59 if (collectParentWays && n.isModified()) { 60 n.referrers(Way.class).filter(Way::isUsable).forEach(this::visit); 61 } 43 62 } 44 63 45 64 @Override
