Ticket #21154: 21154-core.patch
File 21154-core.patch, 6.0 KB (added by , 3 years ago) |
---|
-
src/org/openstreetmap/josm/actions/AlignInCircleAction.java
31 31 import org.openstreetmap.josm.data.osm.Way; 32 32 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon; 33 33 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.JoinedWay; 34 import org.openstreetmap.josm.data.validation.tests.CrossingWays; 35 import org.openstreetmap.josm.data.validation.tests.SelfIntersectingWay; 34 import org.openstreetmap.josm.data.validation.OsmValidator; 36 35 import org.openstreetmap.josm.gui.Notification; 37 36 import org.openstreetmap.josm.tools.Geometry; 38 37 import org.openstreetmap.josm.tools.Logging; … … 327 326 } 328 327 329 328 try { 330 if (CrossingWays.isSelfCrossing(test)) 331 return false; 332 return !SelfIntersectingWay.isSelfIntersecting(test); 329 return OsmValidator.validateGeometry(test, false); 333 330 } finally { 334 331 test.setNodes(null); // see #19855 335 332 } -
src/org/openstreetmap/josm/actions/CombineWayAction.java
37 37 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon; 38 38 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.JoinedWay; 39 39 import org.openstreetmap.josm.data.preferences.BooleanProperty; 40 import org.openstreetmap.josm.data.validation.Test; 41 import org.openstreetmap.josm.data.validation.tests.OverlappingWays; 42 import org.openstreetmap.josm.data.validation.tests.SelfIntersectingWay; 40 import org.openstreetmap.josm.data.validation.OsmValidator; 43 41 import org.openstreetmap.josm.gui.ExtendedDialog; 44 42 import org.openstreetmap.josm.gui.MainApplication; 45 43 import org.openstreetmap.josm.gui.Notification; … … 307 305 308 306 final Way selectedWay = combineResult.a; 309 307 UndoRedoHandler.getInstance().add(combineResult.b); 310 Test test = new OverlappingWays(); 311 test.startTest(null); 312 test.visit(combineResult.a); 313 test.endTest(); 314 if (test.getErrors().isEmpty()) { 315 test = new SelfIntersectingWay(); 316 test.startTest(null); 317 test.visit(combineResult.a); 318 test.endTest(); 319 } 320 if (!test.getErrors().isEmpty()) { 321 new Notification(test.getErrors().get(0).getMessage()) 322 .setIcon(JOptionPane.WARNING_MESSAGE) 323 .setDuration(Notification.TIME_SHORT) 324 .show(); 325 } 308 OsmValidator.validateGeometry(selectedWay, true); 326 309 if (selectedWay != null) { 327 310 GuiHelper.runInEDT(() -> ds.setSelected(selectedWay)); 328 311 } -
src/org/openstreetmap/josm/data/validation/OsmValidator.java
35 35 import javax.swing.tree.TreeModel; 36 36 import javax.swing.tree.TreeNode; 37 37 38 import org.openstreetmap.josm.data.osm.Way; 38 39 import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper; 39 40 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 40 41 import org.openstreetmap.josm.data.validation.tests.Addresses; … … 44 45 import org.openstreetmap.josm.data.validation.tests.ConditionalKeys; 45 46 import org.openstreetmap.josm.data.validation.tests.ConnectivityRelations; 46 47 import org.openstreetmap.josm.data.validation.tests.CrossingWays; 48 import org.openstreetmap.josm.data.validation.tests.CrossingWays.SelfCrossing; 47 49 import org.openstreetmap.josm.data.validation.tests.DirectionNodes; 48 50 import org.openstreetmap.josm.data.validation.tests.DuplicateNode; 49 51 import org.openstreetmap.josm.data.validation.tests.DuplicateRelation; … … 74 76 import org.openstreetmap.josm.data.validation.tests.WayConnectedToArea; 75 77 import org.openstreetmap.josm.data.validation.tests.WronglyOrderedWays; 76 78 import org.openstreetmap.josm.gui.MainApplication; 79 import org.openstreetmap.josm.gui.Notification; 77 80 import org.openstreetmap.josm.gui.layer.ValidatorLayer; 78 81 import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference; 79 82 import org.openstreetmap.josm.gui.util.GuiHelper; … … 695 698 static void clearIgnoredErrors() { 696 699 ignoredErrors.clear(); 697 700 } 701 702 /** 703 * Execute geometry tests {@link OverlappingWays}, {@link SelfCrossing}, 704 * and {@link SelfIntersectingWay} on a given way. 705 * @param way the way to test 706 * @param showNotification if set to {@code true} and an error was found show the corresponding message 707 * @return {@code true} if no error was found, else {@code false} 708 * @since xxx 709 */ 710 public static boolean validateGeometry(Way way, boolean showNotification) { 711 Test test = new OverlappingWays(); 712 test.startTest(null); 713 test.visit(way); 714 test.endTest(); 715 if (test.getErrors().isEmpty()) { 716 test = new SelfCrossing(); 717 test.startTest(null); 718 test.visit(way); 719 test.endTest(); 720 } 721 if (test.getErrors().isEmpty()) { 722 test = new SelfIntersectingWay(); 723 test.startTest(null); 724 test.visit(way); 725 test.endTest(); 726 } 727 if (!test.getErrors().isEmpty()) { 728 if (showNotification) { 729 new Notification(test.getErrors().get(0).getMessage()) 730 .setIcon(JOptionPane.WARNING_MESSAGE) 731 .setDuration(Notification.TIME_SHORT) 732 .show(); 733 } 734 return false; 735 } 736 return true; 737 } 698 738 }