Ignore:
Timestamp:
2020-04-14T07:14:38+02:00 (4 years ago)
Author:
GerdP
Message:

fix #19053:Validator does not find overlapping buildings anymore

  • improve handling of ignore action for messages produced by MapCSSTagCheckerTest. This requires a change in the entries stored in preferences.xml.
  • partly revert r16247 to re-enable ignore button for groups
  • add code to recognize and remove ignore list entries produced with older version of JOSM. Users have to re-add those items by ignoring the errors again.
Location:
trunk/src/org/openstreetmap/josm/data/validation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r16295 r16296  
    1919import java.util.Enumeration;
    2020import java.util.HashMap;
     21import java.util.HashSet;
    2122import java.util.Iterator;
    2223import java.util.List;
    2324import java.util.Map;
    2425import java.util.Map.Entry;
     26import java.util.Set;
    2527import java.util.SortedMap;
    2628import java.util.TreeMap;
     
    224226                        treeSet.addAll(Files.readAllLines(path, StandardCharsets.UTF_8));
    225227                        treeSet.forEach(ignore -> ignoredErrors.putIfAbsent(ignore, ""));
     228                        removeLegacyEntries(true);
    226229
    227230                        saveIgnoredErrors();
     
    237240                Logging.log(Logging.LEVEL_ERROR, "Unable to load ignored errors", e);
    238241            }
    239             // see #19053: remove invalid entry
    240             ignoredErrors.remove("3000");
     242            removeLegacyEntries(Config.getPref().get(ValidatorPrefHelper.PREF_IGNORELIST_FORMAT).isEmpty());
     243        }
     244    }
     245
     246    private static void removeLegacyEntries(boolean force) {
     247        // see #19053:
     248        boolean wasChanged = false;
     249        if (force) {
     250            Iterator<Entry<String, String>> iter = ignoredErrors.entrySet().iterator();
     251            while (iter.hasNext()) {
     252                Entry<String, String> entry = iter.next();
     253                if (entry.getKey().startsWith("3000_")) {
     254                    Logging.warn(tr("Cannot handle ignore list entry {0}", entry));
     255                    iter.remove();
     256                    wasChanged = true;
     257                }
     258            }
     259        }
     260        String legacyEntry = ignoredErrors.remove("3000");
     261        if (legacyEntry != null) {
     262            if (!legacyEntry.isEmpty()) {
     263                addIgnoredError("3000_" + legacyEntry, legacyEntry);
     264            }
     265            wasChanged = true;
     266        }
     267        if (wasChanged) {
     268            saveIgnoredErrors();
    241269        }
    242270    }
     
    268296     */
    269297    static void cleanupIgnoredErrors() {
     298        cleanup3000();
    270299        if (ignoredErrors.size() > 1) {
    271300            List<String> toRemove = new ArrayList<>();
     
    289318            ignoredErrors.putAll(tmap);
    290319        }
     320    }
     321
     322    private static void cleanup3000() {
     323        // see #19053
     324        Set<String> toRemove = new HashSet<>();
     325        for (Entry<String, String> entry : ignoredErrors.entrySet()) {
     326            if (entry.getKey().equals("3000_" + entry.getValue()))
     327                toRemove.add(entry.getValue());
     328        }
     329        ignoredErrors.entrySet()
     330                .removeIf(e -> toRemove.contains(e.getValue()) && !e.getKey().equals("3000_" + e.getValue()));
     331
    291332    }
    292333
     
    485526        if (list.isEmpty()) list = null;
    486527        Config.getPref().putListOfMaps(ValidatorPrefHelper.PREF_IGNORELIST, list);
     528        Config.getPref().put(ValidatorPrefHelper.PREF_IGNORELIST_FORMAT, "2");
    487529    }
    488530
  • trunk/src/org/openstreetmap/josm/data/validation/TestError.java

    r16178 r16296  
    339339     */
    340340    public String getIgnoreSubGroup() {
     341        if (code == 3000) {
     342            // see #19053
     343            return "3000_" + (description == null ? message : description);
     344        }
    341345        String ignorestring = getIgnoreGroup();
    342346        if (descriptionEn != null) {
     
    352356     */
    353357    public String getIgnoreGroup() {
     358        if (code == 3000) {
     359            // see #19053
     360            return "3000_" + getMessage();
     361        }
    354362        return Integer.toString(code);
    355363    }
     
    525533        return "TestError [tester=" + tester + ", code=" + code + ", message=" + message + ']';
    526534    }
     535
    527536}
Note: See TracChangeset for help on using the changeset viewer.