Changeset 17241 in josm
- Timestamp:
- 2020-10-19T11:35:13+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/corrector/TagCorrector.java
r16628 r17241 20 20 import javax.swing.JScrollPane; 21 21 22 import org.openstreetmap.josm.command.Change Command;22 import org.openstreetmap.josm.command.ChangePropertyCommand; 23 23 import org.openstreetmap.josm.command.ChangeRelationMemberRoleCommand; 24 24 import org.openstreetmap.josm.command.Command; … … 27 27 import org.openstreetmap.josm.data.osm.DataSet; 28 28 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 29 import org.openstreetmap.josm.data.osm.Node;30 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; 31 import org.openstreetmap.josm.data.osm.Relation;32 import org.openstreetmap.josm.data.osm.Way;33 30 import org.openstreetmap.josm.gui.MainApplication; 34 31 import org.openstreetmap.josm.gui.correction.RoleCorrectionTable; … … 38 35 import org.openstreetmap.josm.tools.ImageProvider; 39 36 import org.openstreetmap.josm.tools.UserCancelException; 37 import org.openstreetmap.josm.tools.Utils; 40 38 41 39 /** … … 164 162 OsmPrimitive primitive = entry.getKey(); 165 163 166 // create the clone167 OsmPrimitive clone;168 if (primitive instanceof Way) {169 clone = new Way((Way) primitive);170 } else if (primitive instanceof Node) {171 clone = new Node((Node) primitive);172 } else if (primitive instanceof Relation) {173 clone = new Relation((Relation) primitive);174 } else175 throw new AssertionError();176 177 164 // use this structure to remember keys that have been set already so that 178 165 // they're not dropped by a later step 179 166 Set<String> keysChanged = new HashSet<>(); 180 167 181 // apply all changes to this clone 168 // the map for the change command 169 Map<String, String> tagMap = new HashMap<>(); 170 182 171 List<TagCorrection> tagCorrections = entry.getValue(); 183 172 for (int i = 0; i < tagCorrections.size(); i++) { … … 185 174 TagCorrection tagCorrection = tagCorrections.get(i); 186 175 if (tagCorrection.isKeyChanged() && !keysChanged.contains(tagCorrection.oldKey)) { 187 clone.remove(tagCorrection.oldKey);176 tagMap.put(tagCorrection.oldKey, null); 188 177 } 189 clone.put(tagCorrection.newKey, tagCorrection.newValue);178 tagMap.put(tagCorrection.newKey, tagCorrection.newValue); 190 179 keysChanged.add(tagCorrection.newKey); 191 180 } 192 181 } 193 182 194 // save the clone195 183 if (!keysChanged.isEmpty()) { 196 commands.add(new ChangeCommand(dataSet, primitive, clone)); 184 // change the properties of this object 185 commands.add(new ChangePropertyCommand(dataSet, Collections.singleton(primitive), 186 Utils.toUnmodifiableMap(tagMap))); 197 187 } 198 188 }
Note:
See TracChangeset
for help on using the changeset viewer.