Changeset 15852 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2020-02-15T11:15:05+01:00 (5 years ago)
- File:
-
- 1 edited
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<>();
Note:
See TracChangeset
for help on using the changeset viewer.