Changeset 16784 in josm for trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
- Timestamp:
- 2020-07-17T17:12:54+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r16445 r16784 939 939 940 940 if (partialSelection && !tested.isEmpty()) { 941 // #14287: see https://josm.openstreetmap.de/ticket/14287#comment:15 942 // execute tests for objects which might contain or cross previously tested elements 943 944 // rebuild index with a reduced set of rules (those that use ChildOrParentSelector) and thus may have left selectors 945 // matching the previously tested elements 946 indexData = createMapCSSTagCheckerIndex(currentCheck, includeOtherSeverityChecks(), ONLY_SELECTED_TESTS); 947 948 if (surrounding.isEmpty()) { 949 for (OsmPrimitive p : tested) { 950 if (p.getDataSet() != null) { 951 surrounding.addAll(p.getDataSet().searchWays(p.getBBox())); 952 surrounding.addAll(p.getDataSet().searchRelations(p.getBBox())); 953 } 954 } 955 } 956 957 final boolean includeOtherSeverity = includeOtherSeverityChecks(); 958 for (OsmPrimitive p : surrounding) { 959 if (tested.contains(p)) 960 continue; 961 Collection<TestError> additionalErrors = getErrorsForPrimitive(p, includeOtherSeverity); 962 for (TestError e : additionalErrors) { 963 if (e.getPrimitives().stream().anyMatch(tested::contains)) 964 addIfNotSimilar(e, errors); 965 } 966 } 967 } 941 testPartial(currentCheck, tested, surrounding); 942 } 943 } 944 945 private void testPartial(MultiMap<String, TagCheck> currentCheck, Set<OsmPrimitive> tested, 946 Set<OsmPrimitive> surrounding) { 947 948 // #14287: see https://josm.openstreetmap.de/ticket/14287#comment:15 949 // execute tests for objects which might contain or cross previously tested elements 950 951 final boolean includeOtherSeverity = includeOtherSeverityChecks(); 952 // rebuild index with a reduced set of rules (those that use ChildOrParentSelector) and thus may have left selectors 953 // matching the previously tested elements 954 indexData = createMapCSSTagCheckerIndex(currentCheck, includeOtherSeverity, ONLY_SELECTED_TESTS); 955 if (indexData.isEmpty()) 956 return; // performance: some *.mapcss rule files don't use ChildOrParentSelector 957 958 if (surrounding.isEmpty()) { 959 for (OsmPrimitive p : tested) { 960 if (p.getDataSet() != null) { 961 surrounding.addAll(p.getDataSet().searchWays(p.getBBox())); 962 surrounding.addAll(p.getDataSet().searchRelations(p.getBBox())); 963 } 964 } 965 } 966 967 for (OsmPrimitive p : surrounding) { 968 if (tested.contains(p)) 969 continue; 970 Collection<TestError> additionalErrors = getErrorsForPrimitive(p, includeOtherSeverity); 971 for (TestError e : additionalErrors) { 972 if (e.getPrimitives().stream().anyMatch(tested::contains)) 973 addIfNotSimilar(e, errors); 974 } 975 } 976 977 } 978 979 /** 980 * Execute only the rules for the rules matching the given file name. See #19180 981 * @param ruleFile the name of the mapcss file, e.g. deprecated.mapcss 982 * @param selection collection of primitives 983 * @since 16784 984 */ 985 public void runOnly(String ruleFile, Collection<OsmPrimitive> selection) { 986 mpAreaCache.clear(); 987 988 Set<OsmPrimitive> surrounding = new HashSet<>(); 989 for (Entry<String, Set<TagCheck>> entry : checks.entrySet()) { 990 if (isCanceled()) { 991 break; 992 } 993 if (entry.getKey().endsWith(ruleFile)) { 994 visit(entry.getKey(), entry.getValue(), selection, surrounding); 995 } 996 } 997 968 998 } 969 999 }
Note:
See TracChangeset
for help on using the changeset viewer.