Changeset 15021 in josm for trunk/src/org


Ignore:
Timestamp:
2019-04-26T16:45:26+02:00 (6 years ago)
Author:
GerdP
Message:

fix #17652: Method Geometry.isPolygonInsideMultiPolygon returns wrong result

  • don't allow polygon to cross the outer way
  • performance improvement: only check if inner is inside outer when polygon is inside inner. Matters for complex mp with many inners.
  • add unit test which shows error #17652 with old code
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r15008 r15021  
    1212import java.util.Collections;
    1313import java.util.Comparator;
    14 import java.util.EnumSet;
    1514import java.util.LinkedHashSet;
    1615import java.util.List;
     
    10031002            if (nodes.size() == 1
    10041003                    ? nodeInsidePolygon(nodes.get(0), out.getNodes())
    1005                     : EnumSet.of(PolygonIntersection.FIRST_INSIDE_SECOND, PolygonIntersection.CROSSING).contains(
    1006                             polygonIntersection(nodes, out.getNodes()))) {
     1004                    : PolygonIntersection.FIRST_INSIDE_SECOND == polygonIntersection(nodes, out.getNodes())) {
    10071005                boolean insideInner = false;
    10081006                // If inside an outer, check it is not inside an inner
    10091007                for (JoinedPolygon in : outerInner.b) {
    1010                     if (polygonIntersection(in.getNodes(), out.getNodes()) == PolygonIntersection.FIRST_INSIDE_SECOND
    1011                             && (nodes.size() == 1
    1012                             ? nodeInsidePolygon(nodes.get(0), in.getNodes())
    1013                             : polygonIntersection(nodes, in.getNodes()) == PolygonIntersection.FIRST_INSIDE_SECOND)) {
     1008                    if (nodes.size() == 1 ? nodeInsidePolygon(nodes.get(0), in.getNodes())
     1009                            : polygonIntersection(nodes, in.getNodes()) == PolygonIntersection.FIRST_INSIDE_SECOND
     1010                                    && polygonIntersection(in.getNodes(),
     1011                                            out.getNodes()) == PolygonIntersection.FIRST_INSIDE_SECOND) {
    10141012                        insideInner = true;
    10151013                        break;
Note: See TracChangeset for help on using the changeset viewer.