Ticket #20514: 20514.patch
| File 20514.patch, 4.3 KB (added by , 5 years ago) |
|---|
-
src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
79 79 private MapCSSStyleIndex indexData; 80 80 private final Map<MapCSSRule, MapCSSTagCheckerAndRule> ruleToCheckMap = new HashMap<>(); 81 81 private static final Map<IPrimitive, Area> mpAreaCache = new HashMap<>(); 82 private static final Set<IPrimitive> toMatchForSurrounding = new HashSet<>(); 82 83 static final boolean ALL_TESTS = true; 83 84 static final boolean ONLY_SELECTED_TESTS = false; 84 85 … … 651 652 652 653 Environment env = new Environment(p, new MultiCascade(), Environment.DEFAULT_LAYER, null); 653 654 env.mpAreaCache = mpAreaCache; 655 env.toMatchForSurrounding = toMatchForSurrounding; 654 656 655 657 Iterator<MapCSSRule> candidates = indexData.getRuleCandidates(p); 656 658 while (candidates.hasNext()) { … … 728 730 final List<TestError> r = new ArrayList<>(); 729 731 final Environment env = new Environment(p, new MultiCascade(), Environment.DEFAULT_LAYER, null); 730 732 env.mpAreaCache = mpAreaCache; 733 env.toMatchForSurrounding = toMatchForSurrounding; 731 734 for (Set<TagCheck> schecks : checksCol) { 732 735 for (TagCheck check : schecks) { 733 736 boolean ignoreError = Severity.OTHER == check.getSeverity() && !includeOtherSeverity; … … 877 880 // always clear the cache to make sure that we catch changes in geometry 878 881 mpAreaCache.clear(); 879 882 ruleToCheckMap.clear(); 883 toMatchForSurrounding.clear(); 880 884 super.endTest(); 881 885 } 882 886 … … 887 891 } 888 892 889 893 mpAreaCache.clear(); 894 toMatchForSurrounding.clear(); 890 895 891 896 Set<OsmPrimitive> surrounding = new HashSet<>(); 892 897 for (Entry<String, Set<TagCheck>> entry : checks.entrySet()) { … … 966 971 } 967 972 } 968 973 974 toMatchForSurrounding.clear(); 975 toMatchForSurrounding.addAll(tested); 969 976 for (OsmPrimitive p : surrounding) { 970 977 if (tested.contains(p)) 971 978 continue; … … 986 993 */ 987 994 public void runOnly(String ruleFile, Collection<OsmPrimitive> selection) { 988 995 mpAreaCache.clear(); 996 toMatchForSurrounding.clear(); 989 997 990 998 Set<OsmPrimitive> surrounding = new HashSet<>(); 991 999 for (Entry<String, Set<TagCheck>> entry : checks.entrySet()) { -
src/org/openstreetmap/josm/gui/mappaint/Environment.java
88 88 public Map<IPrimitive, Area> mpAreaCache; 89 89 90 90 /** 91 * Can be null, may contain primitives when surrounding objects of the primitives are tested 92 */ 93 public Set<IPrimitive> toMatchForSurrounding; 94 95 /** 91 96 * Creates a new uninitialized environment. 92 97 */ 93 98 public Environment() { … … 140 145 this.intersections = other.intersections; 141 146 this.crossingWaysMap = other.crossingWaysMap; 142 147 this.mpAreaCache = other.mpAreaCache; 148 this.toMatchForSurrounding = other.toMatchForSurrounding; 143 149 } 144 150 145 151 /** -
src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
368 368 } else { 369 369 toIgnore = null; 370 370 } 371 371 boolean filterWithTested = e.toMatchForSurrounding != null && !e.toMatchForSurrounding.isEmpty(); 372 372 for (IPrimitive p : primitives) { 373 if (filterWithTested && !e.toMatchForSurrounding.contains(p)) 374 continue; 373 375 if (isPrimitiveUsable(p) && Objects.equals(layer, OsmUtils.getLayer(p)) 374 376 && left.matches(new Environment(p).withParent(e.osm)) && isArea(p) 375 377 && (toIgnore == null || !toIgnore.contains(p))) {
