Changeset 9583 in josm for trunk/src


Ignore:
Timestamp:
2016-01-23T15:09:55+01:00 (4 years ago)
Author:
Don-vip
Message:

see #12377 - simplify multipolygon geometry checks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java

    r9582 r9583  
    300300            primitives.add(r);
    301301            primitives.addAll(openNodes);
    302             Arrays.asList(openNodes, r);
    303302            addError(r, new TestError(this, Severity.WARNING, tr("Multipolygon is not closed"), NON_CLOSED_WAY,
    304303                    primitives, openNodes));
     
    309308        for (Multipolygon.PolyData pdInner : polygon.getInnerPolygons()) {
    310309            boolean outside = true;
    311             boolean crossing = false;
    312             Multipolygon.PolyData outerWay = null;
    313310            for (int i = 0; i < polygon.getOuterPolygons().size(); i++) {
    314                 GeneralPath outer = outerPolygons.get(i);
    315                 Intersection intersection = getPolygonIntersection(outer, pdInner.getNodes());
     311                Intersection intersection = getPolygonIntersection(outerPolygons.get(i), pdInner.getNodes());
    316312                outside = outside & intersection == Intersection.OUTSIDE;
    317313                if (intersection == Intersection.CROSSING) {
    318                     crossing = true;
    319                     outerWay = polygon.getOuterPolygons().get(i);
    320                 }
    321             }
    322             if (outside || crossing) {
    323                 List<List<Node>> highlights = new ArrayList<>();
    324                 highlights.add(pdInner.getNodes());
    325                 if (outside) {
    326                     addError(r, new TestError(this, Severity.WARNING, tr("Multipolygon inner way is outside"),
    327                             INNER_WAY_OUTSIDE, Collections.singletonList(r), highlights));
    328                 } else if (outerWay != null) {
    329                     highlights.add(outerWay.getNodes());
    330                     addError(r, new TestError(this, Severity.WARNING, tr("Intersection between multipolygon ways"),
    331                             CROSSING_WAYS, Collections.singletonList(r), highlights));
    332                 }
     314                    Multipolygon.PolyData outerWay = polygon.getOuterPolygons().get(i);
     315                    if (outerWay != null) {
     316                        addError(r, new TestError(this, Severity.WARNING, tr("Intersection between multipolygon ways"),
     317                                CROSSING_WAYS, Collections.singletonList(r), Arrays.asList(pdInner.getNodes(), outerWay.getNodes())));
     318                    }
     319                }
     320            }
     321            if (outside) {
     322                addError(r, new TestError(this, Severity.WARNING, tr("Multipolygon inner way is outside"),
     323                        INNER_WAY_OUTSIDE, Collections.singletonList(r), Arrays.asList(pdInner.getNodes())));
    333324            }
    334325        }
Note: See TracChangeset for help on using the changeset viewer.