Ticket #20514: 20514-2.patch
| File 20514-2.patch, 4.3 KB (added by , 5 years ago) |
|---|
-
src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
60 60 private MapCSSStyleIndex indexData; 61 61 private final Map<MapCSSRule, MapCSSTagCheckerAndRule> ruleToCheckMap = new HashMap<>(); 62 62 private static final Map<IPrimitive, Area> mpAreaCache = new HashMap<>(); 63 private static final Set<IPrimitive> toMatchForSurrounding = new HashSet<>(); 63 64 static final boolean ALL_TESTS = true; 64 65 static final boolean ONLY_SELECTED_TESTS = false; 65 66 … … 160 161 indexData = createMapCSSTagCheckerIndex(checks, includeOtherSeverity, ALL_TESTS); 161 162 } 162 163 163 Environment env = new Environment(p, new MultiCascade(), Environment.DEFAULT_LAYER, null);164 final Environment env = new Environment(p, new MultiCascade(), Environment.DEFAULT_LAYER, null); 164 165 env.mpAreaCache = mpAreaCache; 166 env.toMatchForSurrounding = toMatchForSurrounding; 165 167 166 168 Iterator<MapCSSRule> candidates = indexData.getRuleCandidates(p); 167 169 while (candidates.hasNext()) { … … 219 221 final List<TestError> r = new ArrayList<>(); 220 222 final Environment env = new Environment(p, new MultiCascade(), Environment.DEFAULT_LAYER, null); 221 223 env.mpAreaCache = mpAreaCache; 224 env.toMatchForSurrounding = toMatchForSurrounding; 222 225 for (Set<MapCSSTagCheckerRule> schecks : checksCol) { 223 226 for (MapCSSTagCheckerRule check : schecks) { 224 227 boolean ignoreError = Severity.OTHER == check.getSeverity() && !includeOtherSeverity; … … 368 371 // always clear the cache to make sure that we catch changes in geometry 369 372 mpAreaCache.clear(); 370 373 ruleToCheckMap.clear(); 374 toMatchForSurrounding.clear(); 371 375 super.endTest(); 372 376 } 373 377 … … 387 391 } 388 392 389 393 mpAreaCache.clear(); 394 toMatchForSurrounding.clear(); 390 395 391 396 Set<OsmPrimitive> surrounding = new HashSet<>(); 392 397 for (Entry<String, Set<MapCSSTagCheckerRule>> entry : checks.entrySet()) { … … 467 472 } 468 473 } 469 474 475 toMatchForSurrounding.clear(); 476 toMatchForSurrounding.addAll(tested); 470 477 for (OsmPrimitive p : surrounding) { 471 478 if (tested.contains(p)) 472 479 continue; -
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
377 377 } else { 378 378 toIgnore = null; 379 379 } 380 380 boolean filterWithTested = e.toMatchForSurrounding != null && !e.toMatchForSurrounding.isEmpty(); 381 381 for (IPrimitive p : primitives) { 382 if (filterWithTested && !e.toMatchForSurrounding.contains(p)) 383 continue; 382 384 if (isPrimitiveUsable(p) && Objects.equals(layer, OsmUtils.getLayer(p)) 383 385 && left.matches(new Environment(p).withParent(e.osm)) && isArea(p) 384 386 && (toIgnore == null || !toIgnore.contains(p))) {
