Ticket #19885: 19885-splitway.patch
File 19885-splitway.patch, 5.9 KB (added by , 4 years ago) |
---|
-
src/org/openstreetmap/josm/actions/SplitWayAction.java
222 222 } else { 223 223 setHighlightedWaySegments(Collections.emptyList()); 224 224 DISPLAY_COUNT.decrementAndGet(); 225 if (getValue() != 1) { 226 newWays.forEach(w -> w.setNodes(null)); // see 19885 227 } 225 228 } 226 229 } 227 230 … … 303 306 way.getDataSet().setSelected(newSel); 304 307 } 305 308 }); 309 if (!splitWayCommand.isPresent()) { 310 newWays.forEach(w -> w.setNodes(null)); // see 19885 311 } 306 312 } 307 313 308 314 @Override -
src/org/openstreetmap/josm/command/SplitWayCommand.java
16 16 import java.util.HashMap; 17 17 import java.util.HashSet; 18 18 import java.util.Iterator; 19 import java.util.LinkedHashSet; 19 20 import java.util.LinkedList; 20 21 import java.util.List; 21 22 import java.util.Map; … … 89 90 * @param commandList The sequence of commands that should be executed. 90 91 * @param newSelection The new list of selected primitives ids (which is saved for later retrieval with {@link #getNewSelection}) 91 92 * @param originalWay The original way being split (which is saved for later retrieval with {@link #getOriginalWay}) 92 * @param newWays The resulting new ways (which is saved for later retrieval with {@link #get OriginalWay})93 * @param newWays The resulting new ways (which is saved for later retrieval with {@link #getNewWays}) 93 94 */ 94 95 public SplitWayCommand(String name, Collection<Command> commandList, 95 96 List<? extends PrimitiveId> newSelection, Way originalWay, List<Way> newWays) { … … 395 396 } 396 397 } 397 398 398 switch (missingMemberStrategy) { 399 try { 400 switch (missingMemberStrategy) { 399 401 case GO_AHEAD_WITH_DOWNLOADS: 400 402 try { 401 403 downloadMissingMembers(incompleteMembers); … … 405 407 } 406 408 // If missing relation members were downloaded, perform the analysis again to find the relation 407 409 // member order for all relations. 410 analysis.cleanup(); 408 411 analysis = analyseSplit(way, wayToKeep, newWays); 409 return Optional.of(splitBasedOnAnalyses(way, newWays, newSelection, analysis, indexOfWayToKeep));412 break; 410 413 case GO_AHEAD_WITHOUT_DOWNLOADS: 411 414 // Proceed with the split with the information we have. 412 415 // This can mean that there are no missing members we want, or that the user chooses to continue 413 416 // the split without downloading them. 414 return Optional.of(splitBasedOnAnalyses(way, newWays, newSelection, analysis, indexOfWayToKeep));417 break; 415 418 case USER_ABORTED: 416 419 default: 417 420 return Optional.empty(); 421 } 422 return Optional.of(splitBasedOnAnalyses(way, newWays, newSelection, analysis, indexOfWayToKeep)); 423 } finally { 424 // see #19885 425 wayToKeep.setNodes(null); 426 analysis.cleanup(); 418 427 } 419 428 } 420 429 … … 441 450 if (!r.isUsable()) { 442 451 continue; 443 452 } 444 445 453 numberOfRelations++; 454 boolean isSimpleCase = true; 446 455 447 456 Relation c = null; 448 457 String type = Optional.ofNullable(r.get("type")).orElse(""); … … 548 557 missingWays = Collections.emptySet(); 549 558 } 550 559 relationAnalyses.add(new RelationAnalysis(c, rm, direction, missingWays)); 560 isSimpleCase = false; 551 561 } 552 562 } 553 563 } 554 555 if (c != null) {556 c ommandList.add(new ChangeCommand(r.getDataSet(), r, c));564 if (c != null && isSimpleCase && !r.getMembers().equals(c.getMembers())) { 565 commandList.add(new ChangeMembersCommand(r, new ArrayList<>(c.getMembers()))); 566 c.setMembers(null); // see #19885 557 567 } 558 568 } 559 569 changedWay.setNodes(null); // see #19885 … … 576 586 this.numberOfRelations = numberOfRelations; 577 587 } 578 588 589 /** 590 * Unlink temporary copies of relations. See #19885 591 */ 592 void cleanup() { 593 for (RelationAnalysis ra : relationAnalyses) { 594 if (ra.relation.getDataSet() == null) 595 ra.relation.setMembers(null); 596 } 597 } 598 579 599 List<RelationAnalysis> getRelationAnalyses() { 580 600 return relationAnalyses; 581 601 } … … 687 707 newSelection.addAll(newWays); 688 708 } 689 709 710 Set<Relation> modifiedRelations = new LinkedHashSet<>(); 690 711 // Perform the split. 691 712 for (RelationAnalysis relationAnalysis : analysis.getRelationAnalyses()) { 692 713 RelationMember rm = relationAnalysis.getRelationMember(); … … 728 749 relation.addMember(j, em); 729 750 } 730 751 } 752 modifiedRelations.add(relation); 731 753 } 754 for (Relation r : modifiedRelations) { 755 DataSet ds = way.getDataSet(); 756 Relation orig = (Relation) ds.getPrimitiveById(r); 757 analysis.getCommands().add(new ChangeMembersCommand(orig, new ArrayList<>(r.getMembers()))); 758 r.setMembers(null); // see #19885 759 } 732 760 733 761 EnumSet<WarningType> warnings = analysis.getWarningTypes(); 734 762