Ticket #20514: 20514-2.patch

File 20514-2.patch, 4.3 KB (added by GerdP, 5 years ago)

patch adapted for r18225, to be applied after next release

  • src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

     
    6060    private MapCSSStyleIndex indexData;
    6161    private final Map<MapCSSRule, MapCSSTagCheckerAndRule> ruleToCheckMap = new HashMap<>();
    6262    private static final Map<IPrimitive, Area> mpAreaCache = new HashMap<>();
     63    private static final Set<IPrimitive> toMatchForSurrounding = new HashSet<>();
    6364    static final boolean ALL_TESTS = true;
    6465    static final boolean ONLY_SELECTED_TESTS = false;
    6566
     
    160161            indexData = createMapCSSTagCheckerIndex(checks, includeOtherSeverity, ALL_TESTS);
    161162        }
    162163
    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);
    164165        env.mpAreaCache = mpAreaCache;
     166        env.toMatchForSurrounding = toMatchForSurrounding;
    165167
    166168        Iterator<MapCSSRule> candidates = indexData.getRuleCandidates(p);
    167169        while (candidates.hasNext()) {
     
    219221        final List<TestError> r = new ArrayList<>();
    220222        final Environment env = new Environment(p, new MultiCascade(), Environment.DEFAULT_LAYER, null);
    221223        env.mpAreaCache = mpAreaCache;
     224        env.toMatchForSurrounding = toMatchForSurrounding;
    222225        for (Set<MapCSSTagCheckerRule> schecks : checksCol) {
    223226            for (MapCSSTagCheckerRule check : schecks) {
    224227                boolean ignoreError = Severity.OTHER == check.getSeverity() && !includeOtherSeverity;
     
    368371        // always clear the cache to make sure that we catch changes in geometry
    369372        mpAreaCache.clear();
    370373        ruleToCheckMap.clear();
     374        toMatchForSurrounding.clear();
    371375        super.endTest();
    372376    }
    373377
     
    387391        }
    388392
    389393        mpAreaCache.clear();
     394        toMatchForSurrounding.clear();
    390395
    391396        Set<OsmPrimitive> surrounding = new HashSet<>();
    392397        for (Entry<String, Set<MapCSSTagCheckerRule>> entry : checks.entrySet()) {
     
    467472            }
    468473        }
    469474
     475        toMatchForSurrounding.clear();
     476        toMatchForSurrounding.addAll(tested);
    470477        for (OsmPrimitive p : surrounding) {
    471478            if (tested.contains(p))
    472479                continue;
  • src/org/openstreetmap/josm/gui/mappaint/Environment.java

     
    8888    public Map<IPrimitive, Area> mpAreaCache;
    8989
    9090    /**
     91     * Can be null, may contain primitives when surrounding objects of the primitives are tested
     92     */
     93    public Set<IPrimitive> toMatchForSurrounding;
     94
     95    /**
    9196     * Creates a new uninitialized environment.
    9297     */
    9398    public Environment() {
     
    140145        this.intersections = other.intersections;
    141146        this.crossingWaysMap = other.crossingWaysMap;
    142147        this.mpAreaCache = other.mpAreaCache;
     148        this.toMatchForSurrounding = other.toMatchForSurrounding;
    143149    }
    144150
    145151    /**
  • src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java

     
    377377                } else {
    378378                    toIgnore = null;
    379379                }
    380 
     380                boolean filterWithTested = e.toMatchForSurrounding != null && !e.toMatchForSurrounding.isEmpty();
    381381                for (IPrimitive p : primitives) {
     382                    if (filterWithTested && !e.toMatchForSurrounding.contains(p))
     383                        continue;
    382384                    if (isPrimitiveUsable(p) && Objects.equals(layer, OsmUtils.getLayer(p))
    383385                            && left.matches(new Environment(p).withParent(e.osm)) && isArea(p)
    384386                            && (toIgnore == null || !toIgnore.contains(p))) {