Changeset 15852 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
r15627 r15852 183 183 Objects.equals(way, that.way); 184 184 } 185 186 @Override 187 public String toString() { 188 return "w" + way.getUniqueId() + " " + way.getNodesCount() + " nodes"; 189 } 185 190 } 186 191 … … 254 259 */ 255 260 WayTraverser(Collection<WayInPolygon> ways) { 256 availableWays = new HashSet<>(ways); 261 availableWays = new LinkedHashSet<>(ways); 257 262 lastWay = null; 258 263 } … … 482 487 */ 483 488 public void join(Collection<Way> ways) { 489 cmdsCount = 0; 484 490 addedRelations.clear(); 485 491 … … 548 554 commitCommands(tr("Move tags from ways to relations")); 549 555 556 makeCommitsOneAction(marktr("Joined overlapping areas")); 557 550 558 if (result.polygons != null && ds != null) { 551 559 List<Way> allWays = new ArrayList<>(); … … 569 577 if (addUndoRedo) { 570 578 UndoRedoHandler.getInstance().undo(); 571 UndoRedoHandler.getInstance().getRedoCommands().clear(); 579 // add no-change commands to the stack to remove the half-done commands 580 Way w = ways.iterator().next(); 581 cmds.add(new ChangeCommand(w, w)); 582 cmds.add(new ChangeCommand(w, w)); 583 commitCommands(tr("Reverting changes")); 584 UndoRedoHandler.getInstance().undo(); 572 585 } 573 586 } … … 597 610 * @return new area formed. 598 611 * @throws UserCancelException if user cancels the operation 599 */ 600 public JoinAreasResult joinAreas(List<Multipolygon> areas) throws UserCancelException { 612 * @since xxx : visibility changed from public to private 613 */ 614 private JoinAreasResult joinAreas(List<Multipolygon> areas) throws UserCancelException { 601 615 602 616 // see #11026 - Because <ways> is a dynamic filtered (on ways) of a filtered (on selected objects) collection, … … 705 719 } 706 720 } 707 708 makeCommitsOneAction(marktr("Joined overlapping areas"));709 721 710 722 if (warnAboutRelations) { … … 1008 1020 } 1009 1021 1022 revertDuplicateTwoNodeWays(result); 1023 1010 1024 return result; 1025 } 1026 1027 /** 1028 * Correct possible error in markWayInsideSide result when splitting a self-intersecting way. 1029 * If we have two ways with the same two nodes and the same direction there must be a self intersection. 1030 * Change the direction flag for the latter of the two ways. The result is that difference between the number 1031 * of ways with insideToTheRight = {@code true} and those with insideToTheRight = {@code false} 1032 * differs by 0 or 1, not more. 1033 * <p>See #10511 1034 * @param parts the parts of a single closed way 1035 */ 1036 private static void revertDuplicateTwoNodeWays(List<WayInPolygon> parts) { 1037 for (int i = 0; i < parts.size(); i++) { 1038 WayInPolygon w1 = parts.get(i); 1039 if (w1.way.getNodesCount() != 2) 1040 continue; 1041 for (int j = i + 1; j < parts.size(); j++) { 1042 WayInPolygon w2 = parts.get(j); 1043 if (w2.way.getNodesCount() == 2 && w1.insideToTheRight == w2.insideToTheRight 1044 && w1.way.firstNode() == w2.way.firstNode() && w1.way.lastNode() == w2.way.lastNode()) { 1045 w2.insideToTheRight = !w2.insideToTheRight; 1046 } 1047 } 1048 } 1011 1049 } 1012 1050 … … 1162 1200 cleanMultigonWays.add(way); 1163 1201 } 1164 1165 1202 WayTraverser traverser = new WayTraverser(cleanMultigonWays); 1166 1203 List<AssembledPolygon> result = new ArrayList<>(); -
trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java
r15034 r15852 15 15 import java.util.Set; 16 16 17 import org.junit.Ignore;18 17 import org.junit.Rule; 19 18 import org.junit.Test; … … 50 49 @Rule 51 50 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 52 public JOSMTestRules test = new JOSMTestRules().main().projection(); 51 public JOSMTestRules test = new JOSMTestRules().main().projection().preferences(); 53 52 54 53 /** … … 58 57 */ 59 58 @Test 60 @Ignore("disable this test, needs further working") // XXX61 59 public void testTicket10511() throws IOException, IllegalDataException { 62 60 try (InputStream is = TestUtils.getRegressionDataStream(10511, "10511_mini.osm")) { … … 66 64 try { 67 65 new JoinAreasAction(false).join(ds.getWays()); 66 Collection<IPrimitive> found = SearchAction.searchAndReturn("type:way", SearchMode.replace); 67 assertEquals(1, found.size()); 68 68 } finally { 69 69 // Ensure we clean the place before leaving, even if test fails.
Note:
See TracChangeset
for help on using the changeset viewer.