Changeset 6605 in josm


Ignore:
Timestamp:
2014-01-03T10:22:49+01:00 (11 years ago)
Author:
simon04
Message:

fix #9350 - Validator: test for the correct usage of :conditional tags, deprecate day|date|hour_on|off tags

This validates the correct syntax of :conditional keys and values (for the latter, only <restriction-value> @ <condition> and opening_hours are checked).

For more tests a preciser specification for allowed conditions is required (such as occupants>1).

Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/data/validator/deprecated.mapcss

    r6548 r6605  
    177177  fixChangeKey: "monitoring:river_level => monitoring:water_level";
    178178}
     179
     180/* from http://wiki.openstreetmap.org/wiki/Conditional_restrictions#Deprecated_tags */
     181*[/(day|date|hour)_(on|off)/] {
     182  throwWarning: tr("{0} is deprecated", "{0.key}");
     183  suggestAlternative: "*:conditional";
     184  assertMatch: "node day_on=0-12";
     185}
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r6593 r6605  
    1717import java.util.Map;
    1818import java.util.TreeSet;
    19 import java.util.regex.Matcher;
    20 import java.util.regex.Pattern;
    2119
    2220import javax.swing.JOptionPane;
     
    2826import org.openstreetmap.josm.data.validation.tests.BuildingInBuilding;
    2927import org.openstreetmap.josm.data.validation.tests.Coastlines;
     28import org.openstreetmap.josm.data.validation.tests.ConditionalKeys;
    3029import org.openstreetmap.josm.data.validation.tests.CrossingWays;
    3130import org.openstreetmap.josm.data.validation.tests.DuplicateNode;
     
    123122        MapCSSTagChecker.class, // 3000 .. 3099
    124123        Lanes.class, // 3100 .. 3199
     124        ConditionalKeys.class, // 3200 .. 3299
    125125    };
    126126   
     
    133133            } catch (Exception e) {
    134134                Main.error(e);
    135                 continue;
    136135            }
    137136        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java

    r6591 r6605  
    177177     */
    178178    public List<OpeningHoursTestError> checkOpeningHourSyntax(final String key, final String value, CheckMode mode) {
     179        return checkOpeningHourSyntax(key, value, mode, false);
     180    }
     181
     182    /**
     183     * Checks for a correct usage of the opening hour syntax of the {@code value} given according to
     184     * <a href="https://github.com/ypid/opening_hours.js">opening_hours.js</a> and returns a list containing
     185     * validation errors or an empty list. Null values result in an empty list.
     186     * @param key the OSM key (should be "opening_hours", "collection_times" or "service_times").
     187     * @param value the opening hour value to be checked.
     188     * @param mode whether to validate {@code value} as a time range, or points in time, or both.
     189     * @param ignoreOtherSeverity whether to ignore errors with {@link Severity#OTHER}.
     190     * @return a list of {@link TestError} or an empty list
     191     */
     192    public List<OpeningHoursTestError> checkOpeningHourSyntax(final String key, final String value, CheckMode mode, boolean ignoreOtherSeverity) {
    179193        if (ENGINE == null || value == null || value.trim().isEmpty()) {
    180194            return Collections.emptyList();
     
    195209                errors.add(new OpeningHoursTestError(i.toString().trim(), Severity.WARNING, prettifiedValue));
    196210            }
    197             if (errors.isEmpty() && prettifiedValue != null && !value.equals(prettifiedValue)) {
     211            if (!ignoreOtherSeverity && errors.isEmpty() && prettifiedValue != null && !value.equals(prettifiedValue)) {
    198212                errors.add(new OpeningHoursTestError(tr("opening_hours value can be prettified"), Severity.OTHER, prettifiedValue));
    199213            }
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreference.java

    r6529 r6605  
    274274    }
    275275
    276     /**
    277      * Initialize the tagging presets (load and may display error)
    278      */
     276    public static void readFromPreferences() {
     277        taggingPresets = TaggingPresetReader.readFromPreferences(false);
     278    }
     279
     280        /**
     281         * Initialize the tagging presets (load and may display error)
     282         */
    279283    public static void initialize() {
    280         taggingPresets = TaggingPresetReader.readFromPreferences(false);
     284        readFromPreferences();
    281285        for (TaggingPreset tp: taggingPresets) {
    282286            if (!(tp instanceof TaggingPresetSeparator)) {
Note: See TracChangeset for help on using the changeset viewer.