Changeset 15107 in josm for trunk/src


Ignore:
Timestamp:
2019-05-25T07:23:25+02:00 (6 years ago)
Author:
GerdP
Message:

see #17745: ignore unclosed ways and multipolygons with unclosed outer rings in methods Geometry.filterInsidePolygon() and Geometry.filterInsideMultipolygon()
TODO: implement correct algorithm for unclosed ways

File:
1 edited

Legend:

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

    r15069 r15107  
    10431043    /**
    10441044     * Find all primitives in the given collection which are inside the given polygon.
     1045     * Unclosed ways and multipolygon relations with unclosed outer rings are ignored.
    10451046     * @param primitives the primitives
    10461047     * @param polygon the polygon
     
    10611062                }
    10621063            } else if (p instanceof IWay) {
    1063                 if (polygonArea == null) {
    1064                     polygonArea = getArea(polygon.getNodes());
    1065                 }
    1066                 if (PolygonIntersection.FIRST_INSIDE_SECOND == polygonIntersection(getArea(((IWay<?>) p).getNodes()),
    1067                         polygonArea)) {
    1068                     res.add(p);
     1064                if (((IWay<?>) p).isClosed()) {
     1065                    if (polygonArea == null) {
     1066                        polygonArea = getArea(polygon.getNodes());
     1067                    }
     1068                    if (PolygonIntersection.FIRST_INSIDE_SECOND == polygonIntersection(getArea(((IWay<?>) p).getNodes()),
     1069                            polygonArea)) {
     1070                        res.add(p);
     1071                    }
    10691072                }
    10701073            } else if (p.isMultipolygon()) {
     
    10761079                // a (valid) multipolygon is inside the polygon if all outer rings are inside
    10771080                for (PolyData outer : mp.getOuterPolygons()) {
    1078                     if (PolygonIntersection.FIRST_INSIDE_SECOND != polygonIntersection(getArea(outer.getNodes()),
    1079                             polygonArea)) {
     1081                    if (!outer.isClosed()
     1082                            || PolygonIntersection.FIRST_INSIDE_SECOND != polygonIntersection(getArea(outer.getNodes()),
     1083                                    polygonArea)) {
    10801084                        inside = false;
    10811085                        break;
     
    10921096    /**
    10931097     * Find all primitives in the given collection which are inside the given multipolygon. Members of the multipolygon are
    1094      * ignored.
     1098     * ignored. Unclosed ways and multipolygon relations with unclosed outer rings are ignored.
    10951099     * @param primitives the primitives
    10961100     * @param multiPolygon the multipolygon relation
     
    11211125                }
    11221126            } else if (p instanceof Way) {
    1123                 if (isPolygonInsideMultiPolygon(((Way) p).getNodes(), outerInner, null)) {
     1127                if (((IWay<?>) p).isClosed() && isPolygonInsideMultiPolygon(((Way) p).getNodes(), outerInner, null)) {
    11241128                    res.add(p);
    11251129                }
     
    11291133                // a (valid) multipolygon is inside multiPolygon if all outer rings are inside
    11301134                for (PolyData outer : mp.getOuterPolygons()) {
    1131                     if (!isPolygonInsideMultiPolygon(outer.getNodes(), outerInner, null)) {
     1135                    if (!outer.isClosed() || !isPolygonInsideMultiPolygon(outer.getNodes(), outerInner, null)) {
    11321136                        inside = false;
    11331137                        break;
Note: See TracChangeset for help on using the changeset viewer.