Ignore:
Timestamp:
2020-02-26T17:16:35+01:00 (4 years ago)
Author:
GerdP
Message:

see #16707: improve highlighting of overlapping areas and "zoom to error"

  • store the overlapping area with the TestError
  • return also the intersection area in Geometry.polygonIntersectionResult()
File:
1 edited

Legend:

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

    r15925 r15938  
    44import static org.openstreetmap.josm.data.projection.Ellipsoid.WGS84;
    55
     6import java.awt.geom.Area;
    67import java.text.MessageFormat;
    78import java.util.ArrayList;
    89import java.util.Collection;
    910import java.util.Collections;
     11import java.util.HashMap;
    1012import java.util.LinkedHashSet;
    1113import java.util.List;
     
    3133import org.openstreetmap.josm.tools.CheckParameterUtil;
    3234import org.openstreetmap.josm.tools.Geometry;
     35import org.openstreetmap.josm.tools.Geometry.PolygonIntersection;
    3336import org.openstreetmap.josm.tools.Logging;
     37import org.openstreetmap.josm.tools.Pair;
    3438import org.openstreetmap.josm.tools.Utils;
    3539
     
    298302
    299303            private final String layer;
     304            private Area area;
    300305
    301306            private CrossingFinder(Environment e) {
     
    309314                if (Objects.equals(layer, OsmUtils.getLayer(w))
    310315                    && left.matches(new Environment(w).withParent(e.osm))
    311                     && e.osm instanceof IWay && Geometry.PolygonIntersection.CROSSING.equals(
    312                             Geometry.polygonIntersection(w.getNodes(), ((IWay<?>) e.osm).getNodes()))) {
    313                     addToChildren(e, w);
     316                    && e.osm instanceof IWay) {
     317                    if (area == null) {
     318                        area = Geometry.getAreaEastNorth(e.osm);
     319                    }
     320                    Pair<PolygonIntersection, Area> is = Geometry.polygonIntersectionResult(
     321                            Geometry.getAreaEastNorth(w), area, Geometry.INTERSECTION_EPS_EAST_NORTH);
     322                    if (Geometry.PolygonIntersection.CROSSING == is.a) {
     323                        addToChildren(e, w);
     324                        // store intersection area to improve highlight and zoom to problem
     325                        if (e.intersections == null) {
     326                            e.intersections = new HashMap<>();
     327                        }
     328                        e.intersections.put(w, is.b);
     329                    }
    314330                }
    315331            }
Note: See TracChangeset for help on using the changeset viewer.