Changeset 15316 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2019-08-24T12:44:58+02:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io/remotecontrol
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
r14153 r15316 11 11 import java.awt.event.KeyEvent; 12 12 import java.awt.event.MouseEvent; 13 import java.util.Arrays; 13 14 import java.util.Collection; 14 15 import java.util.HashMap; 15 16 import java.util.HashSet; 16 import java.util.LinkedHashSet;17 17 import java.util.Map; 18 18 import java.util.Map.Entry; 19 19 import java.util.Set; 20 import java.util.stream.Collectors; 20 21 21 22 import javax.swing.AbstractAction; … … 281 282 if (args.containsKey("addtags")) { 282 283 GuiHelper.executeByMainWorkerInEDT(() -> { 283 Set<String> tagSet = new LinkedHashSet<>(); // preserve order, see #15704 284 for (String tag1 : args.get("addtags").split("\\|")) { 285 if (!tag1.trim().isEmpty() && tag1.contains("=")) { 286 tagSet.add(tag1.trim()); 287 } 288 } 289 if (!tagSet.isEmpty()) { 290 String[][] keyValue = new String[tagSet.size()][2]; 291 int i = 0; 292 for (String tag2 : tagSet) { 293 // support a = b===c as "a"="b===c" 294 String[] pair = tag2.split("\\s*=\\s*", 2); 295 keyValue[i][0] = pair[0]; 296 keyValue[i][1] = pair.length < 2 ? "" : pair[1]; 297 i++; 298 } 299 addTags(keyValue, sender, primitives); 300 } 284 addTags(parseUrlTagsToKeyValues(args.get("addtags")), sender, primitives); 301 285 }); 302 286 } 287 } 288 289 /** 290 * Convert a argument from a url to a series of tags 291 * @param urlSection A url section that looks like {@code tag1=value1|tag2=value2} 292 * @return An 2d array in the format of {@code [key][value]} 293 * @since 15316 294 */ 295 public static String[][] parseUrlTagsToKeyValues(String urlSection) { 296 return Arrays.stream(urlSection.split("\\|")) 297 .map(String::trim) 298 .filter(tag -> !tag.isEmpty() && tag.contains("=")) 299 .map(tag -> tag.split("\\s*=\\s*", 2)) 300 .map(pair -> {pair[1] = pair.length < 2 ? "" : pair[1]; return pair;}) 301 .collect(Collectors.toList()).toArray(new String[][] {}); 303 302 } 304 303 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
r14624 r15316 225 225 } 226 226 227 // This comes before the other changeset tags, so that they can be overridden 228 if (args.containsKey("changeset_tags")) { 229 MainApplication.worker.submit(() -> { 230 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 231 if (ds != null) { 232 for (String[] key : AddTagsDialog.parseUrlTagsToKeyValues(args.get("changeset_tags"))) { 233 ds.addChangeSetTag(key[0], key[1]); 234 } 235 } 236 }); 237 } 238 227 239 // add changeset tags after download if necessary 228 240 if (args.containsKey("changeset_comment") || args.containsKey("changeset_source") || args.containsKey("changeset_hashtags")) {
Note:
See TracChangeset
for help on using the changeset viewer.