Ticket #17898: 17898.4.patch
| File 17898.4.patch, 30.4 KB (added by , 6 years ago) |
|---|
-
src/org/openstreetmap/josm/actions/CombineWayAction.java
8 8 import java.awt.event.ActionEvent; 9 9 import java.awt.event.KeyEvent; 10 10 import java.util.ArrayList; 11 import java.util.Arrays; 11 12 import java.util.Collection; 12 13 import java.util.Collections; 13 import java.util.HashSet;14 14 import java.util.LinkedHashSet; 15 15 import java.util.LinkedList; 16 16 import java.util.List; … … 22 22 import javax.swing.JOptionPane; 23 23 24 24 import org.openstreetmap.josm.actions.corrector.ReverseWayTagCorrector; 25 import org.openstreetmap.josm.actions.downloadtasks.DownloadReferrersTask; 25 26 import org.openstreetmap.josm.command.ChangeCommand; 26 27 import org.openstreetmap.josm.command.Command; 27 28 import org.openstreetmap.josm.command.DeleteCommand; 29 import org.openstreetmap.josm.command.MissingDataHelper; 30 import org.openstreetmap.josm.command.MissingDataHelper.MissingDataStrategy; 31 import org.openstreetmap.josm.command.MissingDataHelper.WhenRelationOrderUncertain; 28 32 import org.openstreetmap.josm.command.SequenceCommand; 29 33 import org.openstreetmap.josm.data.UndoRedoHandler; 30 34 import org.openstreetmap.josm.data.osm.DataSet; … … 279 283 .show(); 280 284 return; 281 285 } 286 List<Node> path = tryJoin(selectedWays); 287 if (path.isEmpty()) { 288 warnCombiningImpossible(); 289 return; 290 } 282 291 283 292 // see #18083: check if we will combine ways at nodes outside of the download area 284 Set<Node> endNodesOutside = new HashSet<>(); 285 for (Way w : selectedWays) { 286 final Node[] endnodes = {w.firstNode(), w.lastNode()}; 287 for (Node n : endnodes) { 288 if (!n.isNew() && n.isOutsideDownloadArea() && !endNodesOutside.add(n)) { 289 new Notification(tr("Combine ways refused<br>" + "(A shared node is outside of the download area)")) 290 .setIcon(JOptionPane.INFORMATION_MESSAGE).show(); 291 return; 292 293 } 293 Set<Way> unsureParents = selectedWays.stream().filter( 294 w -> (Command.checkOutlyingOrIncompleteOperation(Arrays.asList(w.firstNode(), w.lastNode()), null) 295 & Command.IS_OUTSIDE) != 0) 296 .collect(Collectors.toSet()); 297 if (!unsureParents.isEmpty()) { 298 MissingDataStrategy missingDataStrategy = MissingDataHelper 299 .getUserDecision(WhenRelationOrderUncertain.ASK_USER_FOR_CONSENT_TO_DOWNLOAD); 300 switch (missingDataStrategy) { 301 case GO_AHEAD_WITH_DOWNLOADS: 302 MainApplication.worker.submit(new DownloadReferrersTask(getLayerManager().getEditLayer(), unsureParents)); 303 break; 304 case GO_AHEAD_WITHOUT_DOWNLOADS: 305 // Proceed with the split with the information we have. 306 // This can mean that we break relations. 307 break; 308 case USER_ABORTED: 309 default: 310 return; 294 311 } 295 312 } 296 313 297 314 // combine and update gui 298 Pair<Way, Command> combineResult; 299 try { 300 combineResult = combineWaysWorker(selectedWays); 301 } catch (UserCancelException ex) { 302 Logging.trace(ex); 303 return; 304 } 315 GuiHelper.executeByMainWorkerInEDT(() -> { 316 Pair<Way, Command> combineResult; 317 try { 318 combineResult = combineWaysWorker(selectedWays); 319 } catch (UserCancelException ex) { 320 Logging.trace(ex); 321 return; 322 } 305 323 306 if (combineResult == null)307 return;324 if (combineResult == null) 325 return; 308 326 309 final Way selectedWay = combineResult.a; 310 UndoRedoHandler.getInstance().add(combineResult.b); 311 Test test = new OverlappingWays(); 312 test.startTest(null); 313 test.visit(combineResult.a); 314 test.endTest(); 315 if (test.getErrors().isEmpty()) { 316 test = new SelfIntersectingWay(); 327 final Way selectedWay = combineResult.a; 328 UndoRedoHandler.getInstance().add(combineResult.b); 329 Test test = new OverlappingWays(); 317 330 test.startTest(null); 318 331 test.visit(combineResult.a); 319 332 test.endTest(); 320 } 321 if (!test.getErrors().isEmpty()) { 322 new Notification(test.getErrors().get(0).getMessage()) 323 .setIcon(JOptionPane.WARNING_MESSAGE) 324 .setDuration(Notification.TIME_SHORT) 325 .show(); 326 } 327 if (selectedWay != null) { 328 GuiHelper.runInEDT(() -> ds.setSelected(selectedWay)); 329 } 333 if (test.getErrors().isEmpty()) { 334 test = new SelfIntersectingWay(); 335 test.startTest(null); 336 test.visit(combineResult.a); 337 test.endTest(); 338 } 339 if (!test.getErrors().isEmpty()) { 340 new Notification(test.getErrors().get(0).getMessage()) 341 .setIcon(JOptionPane.WARNING_MESSAGE) 342 .setDuration(Notification.TIME_SHORT) 343 .show(); 344 } 345 if (selectedWay != null) { 346 ds.setSelected(selectedWay); 347 } 348 }); 330 349 } 331 350 332 351 @Override -
src/org/openstreetmap/josm/actions/SplitWayAction.java
25 25 import javax.swing.JPanel; 26 26 import javax.swing.ListSelectionModel; 27 27 28 import org.openstreetmap.josm.command.MissingDataHelper; 28 29 import org.openstreetmap.josm.command.SplitWayCommand; 29 30 import org.openstreetmap.josm.data.UndoRedoHandler; 30 31 import org.openstreetmap.josm.data.osm.DataSet; … … 293 294 wayToKeep, 294 295 newWays, 295 296 !isMapModeDraw ? newSelection : null, 296 SplitWayCommand.WhenRelationOrderUncertain.ASK_USER_FOR_CONSENT_TO_DOWNLOAD297 MissingDataHelper.WhenRelationOrderUncertain.ASK_USER_FOR_CONSENT_TO_DOWNLOAD 297 298 ); 298 299 299 300 splitWayCommand.ifPresent(result -> { -
src/org/openstreetmap/josm/command/MissingDataHelper.java
1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.command; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import javax.swing.JOptionPane; 7 8 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 9 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 10 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 11 import org.openstreetmap.josm.gui.MainApplication; 12 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; 13 import org.openstreetmap.josm.tools.ImageProvider; 14 15 /** 16 * Methods for actions which may corrupt relations. They should make sure that possible membership in relations is known 17 * and that relations are not corrupted by the modification of the member. 18 * @since xxx 19 */ 20 public final class MissingDataHelper { 21 22 private MissingDataHelper() { 23 // Hide default constructor for utils classes 24 } 25 26 /** 27 * What to do when the action might modify a member of a relation and either the parents 28 * of the object are not known for certain or the action might need to add members in a specific order and that 29 * order cannot be determined with the available information. 30 * This can be used for unit tests. 31 */ 32 public enum WhenRelationOrderUncertain { 33 /** 34 * Ask the user to consent to downloading the missing information. The user can abort the action or choose to 35 * proceed without downloading anything. 36 */ 37 ASK_USER_FOR_CONSENT_TO_DOWNLOAD, 38 /** 39 * If needed information is missing, abort the action. 40 */ 41 ABORT, 42 /** 43 * Perform the action even when needed information is missing, without downloading anything and risk to corrupt relations. 44 */ 45 PERFORM_ANYWAY, 46 /** 47 * If needed information is missing, automatically download these without prompting the user. 48 */ 49 DOWNLOAD_MISSING 50 } 51 52 /** 53 * What to do if needed data is missing. 54 */ 55 public enum MissingDataStrategy { 56 /** continue, download needed data */ 57 GO_AHEAD_WITH_DOWNLOADS, 58 /** continue, don't download needed data and risk to break relations */ 59 GO_AHEAD_WITHOUT_DOWNLOADS, 60 /** aboort action */ 61 USER_ABORTED 62 } 63 64 /** 65 * Check given preference key and optionally show dialog to ask user for confirmation regarding the download of missing data. 66 * @param whenRelationOrderUncertain What to do when the action might corrupt relations and additional data is needed 67 * @return the strategy to use 68 */ 69 public static MissingDataStrategy getUserDecision(WhenRelationOrderUncertain whenRelationOrderUncertain) { 70 final String prefKey = "download_relation_data"; 71 switch (whenRelationOrderUncertain) { 72 case ASK_USER_FOR_CONSENT_TO_DOWNLOAD: 73 // Only ask the user about downloading missing data when they haven't consented to this before. 74 if (ConditionalOptionPaneUtil.getDialogReturnValue(prefKey) == Integer.MAX_VALUE) { 75 // User has previously told us downloading missing relation members is fine. 76 return MissingDataStrategy.GO_AHEAD_WITH_DOWNLOADS; 77 } 78 // Ask the user. 79 return offerToDownloadMissingDataIfNeeded(prefKey); 80 case PERFORM_ANYWAY: 81 return MissingDataStrategy.GO_AHEAD_WITHOUT_DOWNLOADS; 82 case DOWNLOAD_MISSING: 83 return MissingDataStrategy.GO_AHEAD_WITH_DOWNLOADS; 84 case ABORT: 85 default: 86 return MissingDataStrategy.USER_ABORTED; 87 } 88 } 89 90 static MissingDataStrategy offerToDownloadMissingDataIfNeeded(String preferenceKey) { 91 92 JMultilineLabel msg = new JMultilineLabel( 93 tr("Relations might be corrupted by this action." + "<br>" 94 + "Download information about parent relations or incomplete members from server?")); 95 96 ButtonSpec[] options = { 97 new ButtonSpec( 98 tr("Yes, download"), 99 new ImageProvider("ok"), 100 tr("Click to download possibly missing relation data"), 101 null /* no specific help topic */ 102 ), 103 new ButtonSpec( 104 tr("No, perform the action without downloading"), 105 new ImageProvider("cancel"), 106 tr("Click to perform the action with the currently loaded data"), 107 null /* no specific help topic */ 108 ), 109 new ButtonSpec( 110 tr("No, cancel"), 111 new ImageProvider("cancel"), 112 tr("Click to cancel the action"), 113 null /* no specific help topic */ 114 ), 115 }; 116 117 int ret = HelpAwareOptionPane.showOptionDialog( 118 MainApplication.getMainFrame(), 119 msg, 120 tr("Download relation data from server?"), 121 JOptionPane.WARNING_MESSAGE, 122 null, 123 options, 124 options[0], // OK is default, 125 "/Dialog/Actions#MissingRelationData" 126 ); 127 128 switch (ret) { 129 case JOptionPane.OK_OPTION: 130 // Ask the user if they want to do this automatically from now on. We only ask this for the download 131 // action, because automatically cancelling is confusing (the user can't tell why this happened), and 132 // automatically performing the split without downloading missing parent relations is 133 // likely to break relations. 134 ConditionalOptionPaneUtil.showMessageDialog( 135 preferenceKey, 136 MainApplication.getMainFrame(), 137 tr("Missing information about relations will be downloaded. " 138 + "Should this be done automatically from now on?"), 139 tr("Download missing information about relations"), 140 JOptionPane.INFORMATION_MESSAGE 141 ); 142 return MissingDataStrategy.GO_AHEAD_WITH_DOWNLOADS; 143 case JOptionPane.NO_OPTION: 144 return MissingDataStrategy.GO_AHEAD_WITHOUT_DOWNLOADS; 145 default: 146 return MissingDataStrategy.USER_ABORTED; 147 } 148 } 149 150 } -
src/org/openstreetmap/josm/command/SplitWayCommand.java
1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.command; 3 3 4 import static org.openstreetmap.josm.command.SplitWayCommand.MissingMemberStrategy.GO_AHEAD_WITHOUT_DOWNLOADS;5 import static org.openstreetmap.josm.command.SplitWayCommand.MissingMemberStrategy.GO_AHEAD_WITH_DOWNLOADS;6 import static org.openstreetmap.josm.command.SplitWayCommand.MissingMemberStrategy.USER_ABORTED;7 import static org.openstreetmap.josm.command.SplitWayCommand.WhenRelationOrderUncertain.ASK_USER_FOR_CONSENT_TO_DOWNLOAD;8 4 import static org.openstreetmap.josm.tools.I18n.tr; 9 5 import static org.openstreetmap.josm.tools.I18n.trn; 10 6 … … 24 20 import java.util.Set; 25 21 import java.util.function.Consumer; 26 22 27 import javax.swing.JOptionPane;28 23 import org.openstreetmap.josm.command.MissingDataHelper.MissingDataStrategy; 24 import org.openstreetmap.josm.command.MissingDataHelper.WhenRelationOrderUncertain; 29 25 import org.openstreetmap.josm.data.osm.DataSet; 30 26 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 31 27 import org.openstreetmap.josm.data.osm.Node; … … 34 30 import org.openstreetmap.josm.data.osm.Relation; 35 31 import org.openstreetmap.josm.data.osm.RelationMember; 36 32 import org.openstreetmap.josm.data.osm.Way; 37 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;38 33 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 39 34 import org.openstreetmap.josm.gui.MainApplication; 40 35 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 41 import org.openstreetmap.josm.gui.widgets.JMultilineLabel;42 36 import org.openstreetmap.josm.io.MultiFetchServerObjectReader; 37 import org.openstreetmap.josm.io.OsmServerBackreferenceReader; 43 38 import org.openstreetmap.josm.io.OsmTransferException; 44 39 import org.openstreetmap.josm.spi.preferences.Config; 45 40 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 55 50 public class SplitWayCommand extends SequenceCommand { 56 51 57 52 private static volatile Consumer<String> warningNotifier = Logging::warn; 58 private static final String DOWNLOAD_MISSING_PREF_KEY = "split_way_download_missing_members";59 53 60 54 private static final class RelationInformation { 61 55 boolean warnme; … … 285 279 286 280 // This method could be refactored to use an Optional in the future, but would need to be deprecated first 287 281 // to phase out use by plugins. 288 return splitWay(way, wayChunks, selection, splitStrategy, ASK_USER_FOR_CONSENT_TO_DOWNLOAD).orElse(null); 282 return splitWay(way, wayChunks, selection, splitStrategy, 283 WhenRelationOrderUncertain.ASK_USER_FOR_CONSENT_TO_DOWNLOAD).orElse(null); 289 284 } 290 285 291 286 /** … … 344 339 List<Way> newWays, 345 340 List<OsmPrimitive> newSelection, 346 341 WhenRelationOrderUncertain whenRelationOrderUncertain) { 347 if (whenRelationOrderUncertain == null) whenRelationOrderUncertain = ASK_USER_FOR_CONSENT_TO_DOWNLOAD;342 if (whenRelationOrderUncertain == null) whenRelationOrderUncertain = WhenRelationOrderUncertain.ASK_USER_FOR_CONSENT_TO_DOWNLOAD; 348 343 349 344 final int indexOfWayToKeep = newWays.indexOf(wayToKeep); 350 345 newWays.remove(wayToKeep); 351 346 347 348 MissingDataStrategy missingDataStrategy = null; 349 if (!way.isNew() && (way.getDataSet().getDataSourceBounds().isEmpty() 350 || way.getNodes().stream().allMatch(Node::isOutsideDownloadArea))) { 351 missingDataStrategy = MissingDataHelper.getUserDecision(whenRelationOrderUncertain); 352 switch (missingDataStrategy) { 353 case GO_AHEAD_WITH_DOWNLOADS: 354 try { 355 downloadParents(way); 356 } catch (OsmTransferException e) { 357 ExceptionDialogUtil.explainException(e); 358 return Optional.empty(); 359 } 360 break; 361 case GO_AHEAD_WITHOUT_DOWNLOADS: 362 // Proceed with the split with the information we have. 363 // This can mean that we break relations. 364 break; 365 case USER_ABORTED: 366 default: 367 return Optional.empty(); 368 } 369 } 370 352 371 // Figure out the order of relation members (if any). 353 372 Analysis analysis = analyseSplit(way, wayToKeep, newWays, indexOfWayToKeep); 354 373 … … 380 399 } 381 400 } 382 401 383 MissingMemberStrategy missingMemberStrategy;384 402 if (relationsNeedingMoreMembers.isEmpty()) { 385 403 // The split can be performed without any extra downloads. 386 missing MemberStrategy =GO_AHEAD_WITHOUT_DOWNLOADS;404 missingDataStrategy = MissingDataStrategy.GO_AHEAD_WITHOUT_DOWNLOADS; 387 405 } else { 388 switch (whenRelationOrderUncertain) { 389 case ASK_USER_FOR_CONSENT_TO_DOWNLOAD: 390 // If the analysis shows that for some relations missing members should be downloaded, offer the user the 391 // chance to consent to this. 392 393 // Only ask the user about downloading missing members when they haven't consented to this before. 394 if (ConditionalOptionPaneUtil.getDialogReturnValue(DOWNLOAD_MISSING_PREF_KEY) == Integer.MAX_VALUE) { 395 // User has previously told us downloading missing relation members is fine. 396 missingMemberStrategy = GO_AHEAD_WITH_DOWNLOADS; 397 } else { 398 // Ask the user. 399 missingMemberStrategy = offerToDownloadMissingMembersIfNeeded(analysis, relationsNeedingMoreMembers); 400 } 401 break; 402 case SPLIT_ANYWAY: 403 missingMemberStrategy = GO_AHEAD_WITHOUT_DOWNLOADS; 404 break; 405 case DOWNLOAD_MISSING_MEMBERS: 406 missingMemberStrategy = GO_AHEAD_WITH_DOWNLOADS; 407 break; 408 case ABORT: 409 default: 410 missingMemberStrategy = USER_ABORTED; 411 break; 406 if (missingDataStrategy == null) { 407 missingDataStrategy = MissingDataHelper.getUserDecision(whenRelationOrderUncertain); 412 408 } 413 409 } 414 415 switch (missingMemberStrategy) { 416 case GO_AHEAD_WITH_DOWNLOADS: 417 try { 418 downloadMissingMembers(incompleteMembers); 419 } catch (OsmTransferException e) { 420 ExceptionDialogUtil.explainException(e); 421 return Optional.empty(); 422 } 423 // If missing relation members were downloaded, perform the analysis again to find the relation 424 // member order for all relations. 425 analysis = analyseSplit(way, wayToKeep, newWays, indexOfWayToKeep); 426 return Optional.of(splitBasedOnAnalyses(way, newWays, newSelection, analysis, indexOfWayToKeep)); 427 case GO_AHEAD_WITHOUT_DOWNLOADS: 428 // Proceed with the split with the information we have. 429 // This can mean that there are no missing members we want, or that the user chooses to continue 430 // the split without downloading them. 431 return Optional.of(splitBasedOnAnalyses(way, newWays, newSelection, analysis, indexOfWayToKeep)); 432 case USER_ABORTED: 433 default: 410 if (missingDataStrategy == MissingDataStrategy.USER_ABORTED) 411 return Optional.empty(); 412 if (missingDataStrategy == MissingDataStrategy.GO_AHEAD_WITH_DOWNLOADS) { 413 try { 414 downloadMissingMembers(incompleteMembers); 415 } catch (OsmTransferException e) { 416 ExceptionDialogUtil.explainException(e); 434 417 return Optional.empty(); 418 } 419 // If missing relation members were downloaded, perform the analysis again to find the relation 420 // member order for all relations. 421 analysis = analyseSplit(way, wayToKeep, newWays, indexOfWayToKeep); 435 422 } 423 return Optional.of(splitBasedOnAnalyses(way, newWays, newSelection, analysis, indexOfWayToKeep)); 436 424 } 437 425 438 426 static Analysis analyseSplit(Way way, … … 633 621 } 634 622 } 635 623 636 static MissingMemberStrategy offerToDownloadMissingMembersIfNeeded(Analysis analysis,637 List<Relation> relationsNeedingMoreMembers) {638 String[] options = {639 tr("Yes, download the missing members"),640 tr("No, abort the split operation"),641 tr("No, perform the split without downloading")642 };643 644 String msgMemberOfRelations = trn(645 "This way is part of a relation.",646 "This way is part of {0} relations.",647 analysis.getNumberOfRelations(),648 analysis.getNumberOfRelations()649 );650 651 String msgReferToRelations;652 if (analysis.getNumberOfRelations() == 1) {653 msgReferToRelations = tr("this relation");654 } else if (analysis.getNumberOfRelations() == relationsNeedingMoreMembers.size()) {655 msgReferToRelations = tr("these relations");656 } else {657 msgReferToRelations = trn(658 "one relation",659 "{0} relations",660 relationsNeedingMoreMembers.size(),661 relationsNeedingMoreMembers.size()662 );663 }664 665 String msgRelationsMissingData = tr(666 "For {0} the correct order of the new way parts could not be determined. " +667 "To fix this, some missing relation members should be downloaded first.",668 msgReferToRelations669 );670 671 JMultilineLabel msg = new JMultilineLabel(msgMemberOfRelations + " " + msgRelationsMissingData);672 msg.setMaxWidth(600);673 674 int ret = JOptionPane.showOptionDialog(675 MainApplication.getMainFrame(),676 msg,677 tr("Download missing relation members?"),678 JOptionPane.OK_CANCEL_OPTION,679 JOptionPane.QUESTION_MESSAGE,680 null,681 options,682 options[0]683 );684 685 switch (ret) {686 case JOptionPane.OK_OPTION:687 // Ask the user if they want to do this automatically from now on. We only ask this for the download688 // action, because automatically cancelling is confusing (the user can't tell why this happened), and689 // automatically performing the split without downloading missing members despite needing them is690 // likely to break a lot of routes. The user also can't tell the difference between a split that needs691 // no downloads at all, and this special case where downloading missing relation members will prevent692 // broken relations.693 ConditionalOptionPaneUtil.showMessageDialog(694 DOWNLOAD_MISSING_PREF_KEY,695 MainApplication.getMainFrame(),696 tr("Missing relation members will be downloaded. Should this be done automatically from now on?"),697 tr("Downloading missing relation members"),698 JOptionPane.INFORMATION_MESSAGE699 );700 return GO_AHEAD_WITH_DOWNLOADS;701 case JOptionPane.CANCEL_OPTION:702 return GO_AHEAD_WITHOUT_DOWNLOADS;703 default:704 return USER_ABORTED;705 }706 }707 708 624 static void downloadMissingMembers(Set<OsmPrimitive> incompleteMembers) throws OsmTransferException { 709 625 // Download the missing members. 710 626 MultiFetchServerObjectReader reader = MultiFetchServerObjectReader.create(); … … 714 630 MainApplication.getLayerManager().getEditLayer().mergeFrom(ds); 715 631 } 716 632 633 private static void downloadParents(Way way) throws OsmTransferException { 634 // Download possible parent relations 635 OsmServerBackreferenceReader reader = new OsmServerBackreferenceReader(way); 636 DataSet ds = reader.parseOsm(NullProgressMonitor.INSTANCE); 637 MainApplication.getLayerManager().getEditLayer().mergeFrom(ds); 638 } 639 717 640 static SplitWayCommand splitBasedOnAnalyses(Way way, 718 641 List<Way> newWays, 719 642 List<OsmPrimitive> newSelection, … … 885 808 return relationSpecialTypes; 886 809 } 887 810 888 /**889 * What to do when the split way is part of relations, and the order of the new parts in the relation cannot be890 * determined without downloading missing relation members.891 */892 public enum WhenRelationOrderUncertain {893 /**894 * Ask the user to consent to downloading the missing members. The user can abort the operation or choose to895 * proceed without downloading anything.896 */897 ASK_USER_FOR_CONSENT_TO_DOWNLOAD,898 /**899 * If there are relation members missing, and these are needed to determine the order of the new parts in900 * that relation, abort the split operation.901 */902 ABORT,903 /**904 * If there are relation members missing, and these are needed to determine the order of the new parts in905 * that relation, continue with the split operation anyway, without downloading anything. Caution: use this906 * option with care.907 */908 SPLIT_ANYWAY,909 /**910 * If there are relation members missing, and these are needed to determine the order of the new parts in911 * that relation, automatically download these without prompting the user.912 */913 DOWNLOAD_MISSING_MEMBERS914 }915 916 811 static class RelationAnalysis { 917 812 private final Relation relation; 918 813 private final RelationMember relationMember; … … 965 860 ROLE 966 861 } 967 862 968 enum MissingMemberStrategy {969 GO_AHEAD_WITH_DOWNLOADS,970 GO_AHEAD_WITHOUT_DOWNLOADS,971 USER_ABORTED972 }973 863 } -
test/data/regress/18596/data.osm
1 1 <?xml version='1.0' encoding='UTF-8'?> 2 2 <osm version='0.6' generator='JOSM' upload='never' download='never'> 3 <bounds minlat='53.1855593' minlon='5.786497' maxlat='53.1912994' maxlon='5.799107' origin='fake bounds' /> 3 4 <node id='1001' version='1' visible='true' lat='53.18916486972' lon='5.79536381868' /> 4 5 <node id='1002' version='1' visible='true' lat='53.19109032103' lon='5.79066925796' /> 5 6 <node id='1003' version='1' visible='true' lat='53.18576597652' lon='5.79492806044' /> -
test/unit/org/openstreetmap/josm/command/SplitWayCommandTest.java
17 17 import org.junit.Test; 18 18 import org.openstreetmap.josm.TestUtils; 19 19 import org.openstreetmap.josm.command.SplitWayCommand.Strategy; 20 import org.openstreetmap.josm.data.Bounds; 21 import org.openstreetmap.josm.data.DataSource; 20 22 import org.openstreetmap.josm.data.UndoRedoHandler; 21 23 import org.openstreetmap.josm.data.coor.LatLon; 22 24 import org.openstreetmap.josm.data.osm.DataSet; … … 150 152 @Test 151 153 public void testOneMemberOrderedRelationShowsWarningTest() { 152 154 final DataSet dataSet = new DataSet(); 155 dataSet.addDataSource(new DataSource(new Bounds(-180, -90, 180, 90), "Test")); 153 156 154 157 // Positive IDs to mark that these ways are incomplete (i.e., no nodes loaded). 155 158 final Way w1 = new Way(1); … … 180 183 SplitWayCommand.buildSplitChunks(w2, Collections.singletonList(n2)), 181 184 new ArrayList<>(), 182 185 Strategy.keepLongestChunk(), 183 SplitWayCommand.WhenRelationOrderUncertain.ABORT186 MissingDataHelper.WhenRelationOrderUncertain.ABORT 184 187 ); 185 188 186 189 assertFalse(result.isPresent()); … … 311 314 new ArrayList<>(), 312 315 Strategy.keepLongestChunk(), 313 316 // This split requires no additional downloads. 314 SplitWayCommand.WhenRelationOrderUncertain.ABORT317 MissingDataHelper.WhenRelationOrderUncertain.ABORT 315 318 ); 316 319 317 320 assertTrue(result.isPresent()); … … 359 362 new ArrayList<>(), 360 363 Strategy.keepLongestChunk(), 361 364 // This split requires no additional downloads. If any are needed, this command will fail. 362 SplitWayCommand.WhenRelationOrderUncertain.ABORT365 MissingDataHelper.WhenRelationOrderUncertain.ABORT 363 366 ); 364 367 365 368 // Should not result in aborting the split.
