Ticket #19136: 19136.2.patch

File 19136.2.patch, 2.6 KB (added by GerdP, 4 years ago)

Like this?

  • src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java

     
    7373    public static final int RINGS_SHARE_NODES = 1617;
    7474    /** Incomplete multipolygon was modified */
    7575    public static final int MODIFIED_INCOMPLETE = 1618;
     76    /** No further tags for multipolygon */
     77    public static final int NO_TAGS = 1619;
     78    /** No area tag for multipolygon */
     79    public static final int NO_AREA_TAG = 1620;
    7680
    7781    private static final int FOUND_INSIDE = 1;
    7882    private static final int FOUND_OUTSIDE = 2;
     
    130134    private void checkStyleConsistency(Relation r, Multipolygon polygon) {
    131135        ElemStyles styles = MapPaintStyles.getStyles();
    132136        if (styles != null && !r.isBoundary()) {
     137            if (r.getInterestingTags().size() <= 1) {
     138                errors.add(TestError.builder(this, Severity.ERROR, NO_TAGS)
     139                        .message(tr("No further tags for multipolygon"))
     140                        .primitives(r)
     141                        .build());
     142            } else if (!r.concernsArea()) {
     143                errors.add(TestError.builder(this, Severity.WARNING, NO_AREA_TAG)
     144                        .message(tr("No area tag for multipolygon"))
     145                        .primitives(r)
     146                        .build());
     147            }
    133148            AreaElement area = ElemStyles.getAreaElemStyle(r, false);
    134149            boolean areaStyle = area != null;
    135             // If area style was not found for relation then use style of ways
    136             if (area == null) {
    137                 for (Way w : polygon.getOuterWays()) {
    138                     area = ElemStyles.getAreaElemStyle(w, true);
    139                     if (area != null) {
    140                         break;
    141                     }
    142                 }
    143                 if (area == null) {
    144                     errors.add(TestError.builder(this, Severity.OTHER, NO_STYLE)
    145                             .message(tr("No area style for multipolygon"))
    146                             .primitives(r)
    147                             .build());
    148                 }
     150            if (area == null ) {
     151                errors.add(TestError.builder(this, Severity.OTHER, NO_STYLE)
     152                        .message(tr("No area style for multipolygon"))
     153                        .primitives(r)
     154                        .build());
    149155            }
    150156
    151157            if (area != null) {