- Timestamp:
- 2020-07-30T12:44:04+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r16784 r16812 39 39 import org.openstreetmap.josm.command.SequenceCommand; 40 40 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 41 import org.openstreetmap.josm.data.osm.Node; 41 42 import org.openstreetmap.josm.data.osm.OsmPrimitive; 42 43 import org.openstreetmap.josm.data.osm.OsmUtils; … … 45 46 import org.openstreetmap.josm.data.osm.TagMap; 46 47 import org.openstreetmap.josm.data.osm.Tagged; 48 import org.openstreetmap.josm.data.osm.Way; 47 49 import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper; 48 50 import org.openstreetmap.josm.data.validation.OsmValidator; … … 922 924 } 923 925 } 924 filterDeprecatedTags(p, key, fixVals);925 926 if (minDist <= MAX_LEVENSHTEIN_DISTANCE && maxPresetValueLen > MAX_LEVENSHTEIN_DISTANCE 926 927 && !fixVals.isEmpty() 927 928 && (harmonizedValue.length() > 3 || minDist < MAX_LEVENSHTEIN_DISTANCE)) { 928 if (fixVals.size() < 2) { 929 fixedValue = fixVals.get(0); 930 } else { 931 Collections.sort(fixVals); 932 // misspelled preset value with multiple good alternatives 933 errors.add(TestError.builder(this, Severity.WARNING, MISSPELLED_VALUE_NO_FIX) 934 .message(tr("Unknown property value"), 935 marktr("Value ''{0}'' for key ''{1}'' is unknown, maybe one of {2} is meant?"), 936 value, key, fixVals) 937 .primitives(p).build()); 938 withErrors.put(p, "WPV"); 939 return; 929 filterDeprecatedTags(p, key, fixVals); 930 if (!fixVals.isEmpty()) { 931 if (fixVals.size() < 2) { 932 fixedValue = fixVals.get(0); 933 } else { 934 Collections.sort(fixVals); 935 // misspelled preset value with multiple good alternatives 936 errors.add(TestError.builder(this, Severity.WARNING, MISSPELLED_VALUE_NO_FIX) 937 .message(tr("Unknown property value"), 938 marktr("Value ''{0}'' for key ''{1}'' is unknown, maybe one of {2} is meant?"), 939 value, key, fixVals) 940 .primitives(p).build()); 941 withErrors.put(p, "WPV"); 942 return; 943 } 940 944 } 941 945 } … … 966 970 return; 967 971 968 String origVal = p.get(key); 969 try { 970 int unchangedDeprecated = countDeprecated(p); 971 Iterator<String> iter = fixVals.iterator(); 972 while (iter.hasNext()) { 973 p.put(key, iter.next()); 974 if (countDeprecated(p) > unchangedDeprecated) 975 iter.remove(); 976 } 977 } finally { 978 // restore original value 979 p.put(key, origVal); 972 int unchangedDeprecated = countDeprecated(p); 973 Iterator<String> iter = fixVals.iterator(); 974 OsmPrimitive clone; 975 if (p instanceof Node) { 976 clone = new Node((Node) p); 977 } else if (p instanceof Way) { 978 clone = new Way((Way) p); 979 } else if (p instanceof Relation) { 980 clone = new Relation((Relation) p); 981 } else { 982 return; // should not happen 983 } 984 while (iter.hasNext()) { 985 clone.put(key, iter.next()); 986 if (countDeprecated(clone) > unchangedDeprecated) 987 iter.remove(); 980 988 } 981 989 }
Note:
See TracChangeset
for help on using the changeset viewer.