Changeset 15068 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2019-05-11T09:56:38+02:00 (6 years ago)
Author:
GerdP
Message:

see #17695: Fix ContainsFinder by removing wrong code

  • did not work because the results in the newly created environment were not transferred into the original environment
  • if that transfer is implemented false positives are produced for the examples in the lower row once you add another building inside the mp but outside of the inner way.

TODO: add code to support mp and improve performance of Geometry tests

File:
1 edited

Legend:

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

    r15064 r15068  
    99import java.util.LinkedHashSet;
    1010import java.util.List;
    11 import java.util.NoSuchElementException;
    1211import java.util.Objects;
    13 import java.util.Set;
    1412import java.util.function.IntFunction;
    1513import java.util.function.IntSupplier;
     
    2119import org.openstreetmap.josm.data.osm.IRelationMember;
    2220import org.openstreetmap.josm.data.osm.IWay;
    23 import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2421import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    2522import org.openstreetmap.josm.data.osm.OsmUtils;
    2623import org.openstreetmap.josm.data.osm.Relation;
    27 import org.openstreetmap.josm.data.osm.Way;
    2824import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
    2925import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache;
     
    358354                }
    359355
    360                 ContainsFinder containsFinder;
    361                 try {
    362                     // if right selector also matches relations and if matched primitive is a way which is part of a multipolygon,
    363                     // use the multipolygon for further analysis
    364                     if (!(e.osm instanceof Way)
    365                             || (right instanceof OptimizedGeneralSelector
    366                             && !((OptimizedGeneralSelector) right).matchesBase(OsmPrimitiveType.RELATION))) {
    367                         throw new NoSuchElementException();
    368                     }
    369                     final Relation multipolygon = ((Way) e.osm).referrers(Relation.class)
    370                             .filter(p -> p.hasTag("type", "multipolygon"))
    371                             .findFirst()
    372                             .orElseThrow(NoSuchElementException::new);
    373                     final Set<OsmPrimitive> members = multipolygon.getMemberPrimitives();
    374                     containsFinder = new ContainsFinder(new Environment(multipolygon)) {
    375                         @Override
    376                         public boolean isPrimitiveUsable(IPrimitive p) {
    377                             return super.isPrimitiveUsable(p) && !members.contains(p);
    378                         }
    379                     };
    380                 } catch (NoSuchElementException ignore) {
    381                     Logging.trace(ignore);
    382                     containsFinder = new ContainsFinder(e);
    383                 }
     356                ContainsFinder containsFinder = new ContainsFinder(e);
    384357                e.parent = e.osm;
    385358
Note: See TracChangeset for help on using the changeset viewer.