Changeset 12356 in josm


Ignore:
Timestamp:
2017-06-09T11:40:32+02:00 (6 months ago)
Author:
michael2402
Message:

CombineWayAction: Allow merging ways that are not in the current edit data set.

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java

    r12314 r12356  
    2020import java.util.Set;
    2121import java.util.Stack;
     22import java.util.stream.Collectors;
    2223
    2324import javax.swing.JOptionPane;
     
    112113        ways = new LinkedHashSet<>(ways);
    113114
     115        List<DataSet> dataSets = ways.stream().map(Way::getDataSet).distinct().collect(Collectors.toList());
     116        if (dataSets.size() != 1) {
     117            throw new IllegalArgumentException("Cannot combine ways of multiple data sets.");
     118        }
     119
    114120        // try to build a new way which includes all the combined ways
    115         //
    116121        NodeGraph graph = NodeGraph.createNearlyUndirectedGraphFromNodeWays(ways);
    117122        List<Node> path = graph.buildSpanningPath();
     
    194199        deletedWays.remove(targetWay);
    195200
    196         cmds.add(new ChangeCommand(targetWay, modifiedTargetWay));
     201        cmds.add(new ChangeCommand(dataSets.get(0), targetWay, modifiedTargetWay));
    197202        cmds.addAll(reverseWayTagCommands);
    198203        cmds.addAll(resolution);
    199         cmds.add(new DeleteCommand(deletedWays));
     204        cmds.add(new DeleteCommand(dataSets.get(0), deletedWays));
    200205        final Command sequenceCommand = new SequenceCommand(/* for correct i18n of plural forms - see #9110 */
    201206                trn("Combine {0} way", "Combine {0} ways", ways.size(), ways.size()), cmds);
  • trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java

    r12210 r12356  
    153153            corrCmds = (new ReverseWayTagCorrector()).execute(w, wnew);
    154154        }
    155         return new ReverseWayResult(wnew, corrCmds, new ChangeCommand(w, wnew));
     155        return new ReverseWayResult(wnew, corrCmds, new ChangeCommand(w.getDataSet(), w, wnew));
    156156    }
    157157
  • trunk/src/org/openstreetmap/josm/command/ChangeRelationMemberRoleCommand.java

    r12288 r12356  
    99import javax.swing.Icon;
    1010
     11import org.openstreetmap.josm.data.osm.DataSet;
    1112import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1213import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     
    4142     */
    4243    public ChangeRelationMemberRoleCommand(Relation relation, int position, String newRole) {
     44        this.relation = relation;
     45        this.position = position;
     46        this.newRole = newRole;
     47    }
     48
     49    /**
     50     * Constructs a new {@code ChangeRelationMemberRoleCommand}.
     51     * @param dataSet The data set the role is in
     52     * @param relation The relation to be changed
     53     * @param position Member position
     54     * @param newRole New role
     55     * @since 12355
     56     */
     57    public ChangeRelationMemberRoleCommand(DataSet dataSet, Relation relation, int position, String newRole) {
     58        super(dataSet);
    4359        this.relation = relation;
    4460        this.position = position;
  • trunk/src/org/openstreetmap/josm/corrector/TagCorrector.java

    r10308 r12356  
    175175                    // save the clone
    176176                    if (!keysChanged.isEmpty()) {
    177                         commands.add(new ChangeCommand(primitive, clone));
     177                        commands.add(new ChangeCommand(primitive.getDataSet(), primitive, clone));
    178178                    }
    179179                }
     
    185185                        RoleCorrection roleCorrection = roleCorrections.get(i);
    186186                        if (roleTableMap.get(primitive).getCorrectionTableModel().getApply(i)) {
    187                             commands.add(new ChangeRelationMemberRoleCommand(
     187                            commands.add(new ChangeRelationMemberRoleCommand(roleCorrection.relation.getDataSet(),
    188188                                    roleCorrection.relation, roleCorrection.position, roleCorrection.newRole));
    189189                        }
Note: See TracChangeset for help on using the changeset viewer.