Ticket #20663: 20663-2.patch

File 20663-2.patch, 9.3 KB (added by GerdP, 5 years ago)

reverts also the changes from r17501

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

     
    5656    public static final int INNER_WAY_OUTSIDE = 1605;
    5757    /** Intersection between multipolygon ways */
    5858    public static final int CROSSING_WAYS = 1606;
    59     /** Style for outer way mismatches / With the currently used mappaint style(s) the style for outer way mismatches the area style */
    60     public static final int OUTER_STYLE_MISMATCH = 1607;
     59    // 1607 is no longer used: With the currently used mappaint style(s) the style for outer way mismatches the area style
    6160    /** With the currently used mappaint style the style for inner way equals the multipolygon style */
    6261    public static final int INNER_STYLE_MISMATCH = 1608;
    63     // no longer used: Area style way is not closed NOT_CLOSED = 1609
     62    // 1609 is no longer used: Area style way is not closed
    6463    /** No area style for multipolygon */
    6564    public static final int NO_STYLE = 1610;
    66     // no longer used: Multipolygon relation should be tagged with area tags and not the outer way(s) NO_STYLE_POLYGON = 1611;
     65    // 1611 is no longer used: Multipolygon relation should be tagged with area tags and not the outer way(s)
    6766    /** Area style on outer way */
    6867    public static final int OUTER_STYLE = 1613;
    6968    /** Multipolygon member repeated (same primitive, same role */
     
    125124     * Various style-related checks:<ul>
    126125     * <li>{@link #NO_STYLE}: No area style for multipolygon</li>
    127126     * <li>{@link #INNER_STYLE_MISMATCH}: With the currently used mappaint style the style for inner way equals the multipolygon style</li>
    128      * <li>{@link #OUTER_STYLE_MISMATCH}: With the currently used mappaint style the style for outer way mismatches the area style</li>
    129127     * <li>{@link #OUTER_STYLE}: Area style on outer way</li>
    130128     * </ul>
    131129     * @param r relation
     
    154152                        continue;
    155153                    AreaElement areaOuter = ElemStyles.getAreaElemStyle(wOuter, false);
    156154                    if (areaOuter != null) {
    157                         if (!area.equals(areaOuter)) {
    158                             errors.add(TestError.builder(this, Severity.OTHER, OUTER_STYLE_MISMATCH)
    159                                     .message(tr("With the currently used mappaint style the style for outer way mismatches the area style"))
    160                                     .primitives(Arrays.asList(r, wOuter))
    161                                     .highlight(wOuter)
    162                                     .build());
    163                         } else { /* style on outer way of multipolygon, but equal to polygon */
    164                             errors.add(TestError.builder(this, Severity.WARNING, OUTER_STYLE)
    165                                     .message(tr("Area style on outer way"))
    166                                     .primitives(Arrays.asList(r, wOuter))
    167                                     .highlight(wOuter)
    168                                     .build());
    169                         }
     155                        errors.add(TestError.builder(this, Severity.WARNING, OUTER_STYLE)
     156                                .message(tr("Area style on outer way"))
     157                                .primitives(Arrays.asList(r, wOuter))
     158                                .highlight(wOuter)
     159                                .build());
    170160                    }
    171161                }
    172162            }
  • src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

     
    4242import org.openstreetmap.josm.data.osm.OsmPrimitive;
    4343import org.openstreetmap.josm.data.osm.OsmUtils;
    4444import org.openstreetmap.josm.data.osm.Relation;
    45 import org.openstreetmap.josm.data.osm.RelationMember;
    4645import org.openstreetmap.josm.data.osm.Tag;
    4746import org.openstreetmap.josm.data.osm.TagMap;
    4847import org.openstreetmap.josm.data.osm.Tagged;
    49 import org.openstreetmap.josm.data.osm.Way;
    5048import org.openstreetmap.josm.data.osm.visitor.MergeSourceBuildingVisitor;
    5149import org.openstreetmap.josm.data.preferences.sources.ValidatorPrefHelper;
    5250import org.openstreetmap.josm.data.validation.OsmValidator;
     
    103101    /** tag keys that have only numerical values in the presets */
    104102    private static final Set<String> ignoreForLevenshtein = new HashSet<>();
    105103
    106     /** tag keys that are allowed to be the same on a multipolygon and an outer way */
    107     private static final Set<String> ignoreForOuterMPSameTagCheck = new HashSet<>();
    108 
    109104    /** The preferences prefix */
    110105    protected static final String PREFIX = ValidatorPrefHelper.PREFIX + "." + TagChecker.class.getSimpleName();
    111106
     
    160155     */
    161156    public static final String PREF_CHECK_PRESETS_TYPES_BEFORE_UPLOAD = PREF_CHECK_PRESETS_TYPES + BEFORE_UPLOAD;
    162157
    163     /**
    164      * The preference key for the list of tag keys that are allowed to be the same on a multipolygon and an outer way
    165      */
    166     public static final String PREF_KEYS_IGNORE_OUTER_MP_SAME_TAG = PREFIX + ".ignore-keys-outer-mp-same-tag";
    167 
    168158    private static final int MAX_LEVENSHTEIN_DISTANCE = 2;
    169159
    170160    protected boolean includeOtherSeverity;
     
    209199    protected static final int MULTIPOLYGON_NO_AREA             = 1218;
    210200    protected static final int MULTIPOLYGON_INCOMPLETE          = 1219;
    211201    protected static final int MULTIPOLYGON_MAYBE_NO_AREA       = 1220;
    212     protected static final int MULTIPOLYGON_SAME_TAG_ON_OUTER   = 1221;
    213202    // CHECKSTYLE.ON: SingleSpaceSeparator
    214203
    215204    protected EditableList sourcesList;
     
    264253        ignoreForLevenshtein.clear();
    265254        oftenUsedTags.clear();
    266255        presetIndex.clear();
    267         ignoreForOuterMPSameTagCheck.clear();
    268256
    269257        StringBuilder errorSources = new StringBuilder();
    270258        for (String source : Config.getPref().getList(PREF_SOURCES, DEFAULT_SOURCES)) {
     
    649637        }
    650638
    651639        if (p instanceof Relation && p.hasTag("type", "multipolygon")) {
    652         checkMultipolygonTags(p);
     640            checkMultipolygonTags(p);
    653641        }
    654642
    655643        if (checkPresetsTypes) {
     
    694682                .anyMatch(k -> k.matches("^(abandoned|construction|demolished|disused|planned|razed|removed|was).*")))
    695683            return;
    696684
    697         checkOuterWaysOfRelation((Relation) p);
    698 
    699685        if (hasAcceptedPrimaryTagForMultipolygon(p))
    700686            return;
    701687        TestError.Builder builder = null;
     
    724710    }
    725711
    726712    /**
    727      * Check if an outer way of the relation has the same tag as the relation.
    728      * @param rel the relation
    729      */
    730     private void checkOuterWaysOfRelation(Relation rel) {
    731         for (Entry<String, String> tag : rel.getInterestingTags().entrySet()) {
    732             if (ignoreForOuterMPSameTagCheck.contains(tag.getKey()))
    733                 continue;
    734 
    735             Set<Way> sameOuters = rel.getMembers().stream()
    736                     .filter(rm -> rm.isWay() && rm.getWay().isArea() && "outer".equals(rm.getRole())
    737                             && tag.getValue().equals(rm.getWay().get(tag.getKey())))
    738                     .map(RelationMember::getWay).collect(Collectors.toSet());
    739             if (!sameOuters.isEmpty()) {
    740                 List<OsmPrimitive> primitives = new ArrayList<>(sameOuters.size() + 1);
    741                 primitives.add(rel);
    742                 primitives.addAll(sameOuters);
    743                 Way w = new Way();
    744                 w.put(tag.getKey(), tag.getValue());
    745                 if (hasAcceptedPrimaryTagForMultipolygon(w)) {
    746                     errors.add(TestError.builder(this, Severity.WARNING, MULTIPOLYGON_SAME_TAG_ON_OUTER)
    747                             .message(tr("Multipolygon outer way repeats major tag of relation"),
    748                                     marktr("Same tag:''{0}''=''{1}''"), tag.getKey(), tag.getValue())
    749                             .primitives(primitives)
    750                             .build());
    751                 } else {
    752                     errors.add(TestError.builder(this, Severity.OTHER, MULTIPOLYGON_SAME_TAG_ON_OUTER)
    753                             .message(tr("Multipolygon outer way repeats tag of relation"),
    754                                     marktr("Same tag:''{0}''=''{1}''"), tag.getKey(), tag.getValue())
    755                             .primitives(primitives)
    756                             .build());
    757                 }
    758             }
    759         }
    760     }
    761 
    762     /**
    763713     * Check if a multipolygon has a main tag that describes the type of area. Accepts also some deprecated tags and typos.
    764714     * @param p the multipolygon
    765715     * @return true if the multipolygon has a main tag that (likely) describes the type of area.
     
    10981048            checkPresetsTypes = checkPresetsTypes && Config.getPref().getBoolean(PREF_CHECK_PRESETS_TYPES_BEFORE_UPLOAD, true);
    10991049        }
    11001050        deprecatedChecker = OsmValidator.getTest(MapCSSTagChecker.class);
    1101         ignoreForOuterMPSameTagCheck.addAll(Config.getPref().getList(PREF_KEYS_IGNORE_OUTER_MP_SAME_TAG, Collections.emptyList()));
    11021051    }
    11031052
    11041053    @Override