Ticket #20514: 20514.patch

File 20514.patch, 4.3 KB (added by GerdP, 5 years ago)
  • src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

     
    7979    private MapCSSStyleIndex indexData;
    8080    private final Map<MapCSSRule, MapCSSTagCheckerAndRule> ruleToCheckMap = new HashMap<>();
    8181    private static final Map<IPrimitive, Area> mpAreaCache = new HashMap<>();
     82    private static final Set<IPrimitive> toMatchForSurrounding = new HashSet<>();
    8283    static final boolean ALL_TESTS = true;
    8384    static final boolean ONLY_SELECTED_TESTS = false;
    8485
     
    651652
    652653        Environment env = new Environment(p, new MultiCascade(), Environment.DEFAULT_LAYER, null);
    653654        env.mpAreaCache = mpAreaCache;
     655        env.toMatchForSurrounding = toMatchForSurrounding;
    654656
    655657        Iterator<MapCSSRule> candidates = indexData.getRuleCandidates(p);
    656658        while (candidates.hasNext()) {
     
    728730        final List<TestError> r = new ArrayList<>();
    729731        final Environment env = new Environment(p, new MultiCascade(), Environment.DEFAULT_LAYER, null);
    730732        env.mpAreaCache = mpAreaCache;
     733        env.toMatchForSurrounding = toMatchForSurrounding;
    731734        for (Set<TagCheck> schecks : checksCol) {
    732735            for (TagCheck check : schecks) {
    733736                boolean ignoreError = Severity.OTHER == check.getSeverity() && !includeOtherSeverity;
     
    877880        // always clear the cache to make sure that we catch changes in geometry
    878881        mpAreaCache.clear();
    879882        ruleToCheckMap.clear();
     883        toMatchForSurrounding.clear();
    880884        super.endTest();
    881885    }
    882886
     
    887891        }
    888892
    889893        mpAreaCache.clear();
     894        toMatchForSurrounding.clear();
    890895
    891896        Set<OsmPrimitive> surrounding = new HashSet<>();
    892897        for (Entry<String, Set<TagCheck>> entry : checks.entrySet()) {
     
    966971            }
    967972        }
    968973
     974        toMatchForSurrounding.clear();
     975        toMatchForSurrounding.addAll(tested);
    969976        for (OsmPrimitive p : surrounding) {
    970977            if (tested.contains(p))
    971978                continue;
     
    986993     */
    987994    public void runOnly(String ruleFile, Collection<OsmPrimitive> selection) {
    988995        mpAreaCache.clear();
     996        toMatchForSurrounding.clear();
    989997
    990998        Set<OsmPrimitive> surrounding = new HashSet<>();
    991999        for (Entry<String, Set<TagCheck>> entry : checks.entrySet()) {
  • 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

     
    368368                } else {
    369369                    toIgnore = null;
    370370                }
    371 
     371                boolean filterWithTested = e.toMatchForSurrounding != null && !e.toMatchForSurrounding.isEmpty();
    372372                for (IPrimitive p : primitives) {
     373                    if (filterWithTested && !e.toMatchForSurrounding.contains(p))
     374                        continue;
    373375                    if (isPrimitiveUsable(p) && Objects.equals(layer, OsmUtils.getLayer(p))
    374376                            && left.matches(new Environment(p).withParent(e.osm)) && isArea(p)
    375377                            && (toIgnore == null || !toIgnore.contains(p))) {