Ignore:
Timestamp:
2019-05-09T10:13:10+02:00 (5 years ago)
Author:
GerdP
Message:

fix #12627,#14287,#14289,#17695

  • let CrossingFinder and ContainsFinder find all objects instead of stopping at first match
  • if objects are selected, make sure that ContainsFinder is called for enclosing objects which are not in the selection
  • enable corresponding unit tests

Draw back: MapCSSTagChecker is a bit slower.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java

    r14654 r15064  
    77import java.util.Collection;
    88import java.util.Collections;
     9import java.util.LinkedHashSet;
    910import java.util.List;
    1011import java.util.NoSuchElementException;
     
    258259                return !e.osm.equals(p) && p.isUsable();
    259260            }
     261
     262            protected void addToChildren(Environment e, IPrimitive p) {
     263                if (e.children == null) {
     264                    e.children = new LinkedHashSet<>();
     265                }
     266                e.children.add(p);
     267            }
    260268        }
    261269
     
    299307            @Override
    300308            public void visit(IWay<?> w) {
    301                 if (e.child == null && Objects.equals(layer, OsmUtils.getLayer(w))
     309                if (Objects.equals(layer, OsmUtils.getLayer(w))
    302310                    && left.matches(new Environment(w).withParent(e.osm))
    303311                    && e.osm instanceof IWay && Geometry.PolygonIntersection.CROSSING.equals(
    304312                            Geometry.polygonIntersection(w.getNodes(), ((IWay<?>) e.osm).getNodes()))) {
    305                     e.child = w;
     313                    addToChildren(e, w);
    306314                }
    307315            }
     
    316324            @Override
    317325            public void visit(INode n) {
    318                 if (e.child == null && left.matches(new Environment(n).withParent(e.osm))
     326                if (left.matches(new Environment(n).withParent(e.osm))
    319327                    && ((e.osm instanceof IWay && Geometry.nodeInsidePolygon(n, ((IWay<?>) e.osm).getNodes()))
    320328                            || (e.osm instanceof Relation && (
    321329                                    (Relation) e.osm).isMultipolygon() && Geometry.isNodeInsideMultiPolygon(n, (Relation) e.osm, null)))) {
    322                     e.child = n;
     330                    addToChildren(e, n);
    323331                }
    324332            }
     
    326334            @Override
    327335            public void visit(IWay<?> w) {
    328                 if (e.child == null && left.matches(new Environment(w).withParent(e.osm))
     336                if (left.matches(new Environment(w).withParent(e.osm))
    329337                    && ((e.osm instanceof IWay && Geometry.PolygonIntersection.FIRST_INSIDE_SECOND.equals(
    330338                            Geometry.polygonIntersection(w.getNodes(), ((IWay<?>) e.osm).getNodes())))
     
    332340                                    (Relation) e.osm).isMultipolygon()
    333341                                    && Geometry.isPolygonInsideMultiPolygon(w.getNodes(), (Relation) e.osm, null)))) {
    334                     e.child = w;
     342                    addToChildren(e, w);
    335343                }
    336344            }
     
    388396                }
    389397
    390                 return e.child != null;
     398                return e.children != null;
    391399
    392400            } else if (ChildOrParentSelectorType.CROSSING == type && e.osm instanceof IWay) {
    393401                e.parent = e.osm;
    394                 final CrossingFinder crossingFinder = new CrossingFinder(e);
    395402                if (right instanceof OptimizedGeneralSelector
    396403                        && ((OptimizedGeneralSelector) right).matchesBase(OsmPrimitiveType.WAY)) {
     404                    final CrossingFinder crossingFinder = new CrossingFinder(e);
    397405                    crossingFinder.visit(e.osm.getDataSet().searchWays(e.osm.getBBox()));
    398406                }
    399                 return e.child != null;
     407                return e.children != null;
    400408            } else if (ChildOrParentSelectorType.SIBLING == type) {
    401409                if (e.osm instanceof INode) {
Note: See TracChangeset for help on using the changeset viewer.