- Timestamp:
- 2012-03-08T21:59:15+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/Tag.java
r3479 r5058 79 79 } 80 80 81 /**82 * Normalizes the key and the value of the tag by83 * <ul>84 * <li>removing leading and trailing white space</li>85 * <ul>86 *87 */88 public void normalize() {89 key = key.trim();90 value = value.trim();91 }92 93 81 @Override 94 82 public int hashCode() { -
trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java
r4749 r5058 7 7 import java.util.Arrays; 8 8 import java.util.Collection; 9 import java.util.Collections;10 9 import java.util.HashMap; 11 10 import java.util.HashSet; 12 11 import java.util.Iterator; 12 import java.util.LinkedHashMap; 13 import java.util.LinkedHashSet; 13 14 import java.util.List; 14 15 import java.util.Map; 15 16 import java.util.Map.Entry; 16 17 import java.util.Set; 18 import org.openstreetmap.josm.tools.Utils; 17 19 18 20 /** … … 712 714 // See #7201 combining ways screws up the order of ref tags 713 715 Set<String> originalValues = getValues(key); 714 if (originalValues.size() == 1) 716 if (originalValues.size() == 1) { 715 717 return originalValues.iterator().next(); 716 717 StringBuilder buffer = new StringBuilder(); 718 Set<String> valSet = new HashSet<String>(); 719 for (String vs : originalValues) { 720 valSet.addAll(Arrays.asList(vs.split(";"))); 721 } 722 List<String> values = new ArrayList<String>(valSet); 718 } 719 720 Set<String> values = new LinkedHashSet<String>(); 721 Map<String, Collection<String>> originalSplitValues = new LinkedHashMap<String, Collection<String>>(); 722 for (String v : originalValues) { 723 List<String> vs = Arrays.asList(v.split(";\\s*")); 724 originalSplitValues.put(v, vs); 725 values.addAll(vs); 726 } 723 727 values.remove(""); 724 Collections.sort(values); 725 Iterator<String> iter = values.iterator(); 726 while (iter.hasNext()) { 727 buffer.append(iter.next()); 728 if (iter.hasNext()) { 729 buffer.append(";"); 730 } 731 } 732 return buffer.toString(); 728 // try to retain an already existing key if it contains all needed values (remove this if it causes performance problems) 729 for (Entry<String, Collection<String>> i : originalSplitValues.entrySet()) { 730 if (i.getValue().containsAll(values)) { 731 return i.getKey(); 732 } 733 } 734 return Utils.join(";", values); 733 735 } 734 736
Note:
See TracChangeset
for help on using the changeset viewer.