Changeset 17358 in josm for trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java
- Timestamp:
- 2020-11-25T11:50:22+01:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java
r17333 r17358 18 18 import org.openstreetmap.josm.actions.corrector.ReverseWayNoTagCorrector; 19 19 import org.openstreetmap.josm.actions.corrector.ReverseWayTagCorrector; 20 import org.openstreetmap.josm.command.Change Command;20 import org.openstreetmap.josm.command.ChangeNodesCommand; 21 21 import org.openstreetmap.josm.command.Command; 22 22 import org.openstreetmap.josm.command.SequenceCommand; … … 41 41 */ 42 42 public static class ReverseWayResult { 43 private final Way newWay;44 43 private final Collection<Command> tagCorrectionCommands; 45 44 private final Command reverseCommand; … … 47 46 /** 48 47 * Create a new {@link ReverseWayResult} 49 * @param newWay The new way primitive50 48 * @param tagCorrectionCommands The commands to correct the tags 51 49 * @param reverseCommand The command to reverse the way 52 50 */ 53 public ReverseWayResult(Way newWay, Collection<Command> tagCorrectionCommands, Command reverseCommand) { 54 this.newWay = newWay; 51 public ReverseWayResult(Collection<Command> tagCorrectionCommands, Command reverseCommand) { 55 52 this.tagCorrectionCommands = tagCorrectionCommands; 56 53 this.reverseCommand = reverseCommand; 57 }58 59 /**60 * Gets the new way object61 * @return The new, reversed way62 */63 public Way getNewWay() {64 return newWay;65 54 } 66 55 … … 150 139 public static ReverseWayResult reverseWay(Way w) throws UserCancelException { 151 140 ReverseWayNoTagCorrector.checkAndConfirmReverseWay(w); 152 Way wnew = new Way(w); 153 List<Node> nodesCopy = wnew.getNodes(); 141 List<Node> nodesCopy = w.getNodes(); 154 142 Collections.reverse(nodesCopy); 155 wnew.setNodes(nodesCopy);156 143 157 144 Collection<Command> corrCmds = Collections.<Command>emptyList(); 158 145 if (Config.getPref().getBoolean("tag-correction.reverse-way", true)) { 159 corrCmds = new ReverseWayTagCorrector().execute(w, w new);146 corrCmds = new ReverseWayTagCorrector().execute(w, w); 160 147 } 161 return new ReverseWayResult( wnew, corrCmds, new ChangeCommand(w, wnew));148 return new ReverseWayResult(corrCmds, new ChangeNodesCommand(w, new ArrayList<>(nodesCopy))); 162 149 } 163 150
Note:
See TracChangeset
for help on using the changeset viewer.