Class OsmModeAccessDefaultsCategory


  • public class OsmModeAccessDefaultsCategory
    extends Object
    Class representing the default mode access restrictions/allowance for modes for a given category of OSM ways, e.g. highway, railway etc., although the class itself is agnostic to what category it belongs Disallowed modes take precedence over any other setting, allowed modes take precedence over mode category settings and mode category settings define groups of allowed modes (when not present, it is assumed the category is not allowed as a whole)
    Author:
    markr
    • Constructor Detail

      • OsmModeAccessDefaultsCategory

        public OsmModeAccessDefaultsCategory()
        Default constructor
      • OsmModeAccessDefaultsCategory

        public OsmModeAccessDefaultsCategory​(String countryName)
        Default constructor
        Parameters:
        countryName - to use
      • OsmModeAccessDefaultsCategory

        public OsmModeAccessDefaultsCategory​(OsmModeAccessDefaultsCategory other)
        Copy constructor
        Parameters:
        other - to copy from
    • Method Detail

      • addAllowedModes

        protected void addAllowedModes​(String key,
                                       String type,
                                       boolean logChanges,
                                       List<String> osmModes)
        Add the passed in modes as modes that are explicitly allowed access regardless of the mode category, i.e., this takes precedence over the categories.

        We must use key and type, because type alone does not uniquely define a situation, e.g., ferry=primary and highway=primary both exist, but ref;ect different road/waterway types

        Parameters:
        key - to use
        type - to use
        logChanges - when true changes are logged, otherwise not
        osmModes - to add
      • setAllowedModes

        protected void setAllowedModes​(String key,
                                       String type,
                                       boolean logChanges,
                                       List<String> osmModes)
        Set the passed in modes as the only modes that are explicitly allowed access regardless of the mode category,
        Parameters:
        key - to use
        type - to use
        logChanges - when true changes are logged, otherwise not
        osmModes - to add
      • addAllowedModeCategories

        protected void addAllowedModeCategories​(String key,
                                                String type,
                                                boolean logChanges,
                                                String... osmModeCategories)
        Add the passed in mode categories as allowed for all its child modes (currently only road modes have categories)
        Parameters:
        key - to use
        type - to use
        logChanges - when true changes are logged, otherwise not
        osmModeCategories - to add
      • removeAllowedModeCategories

        protected void removeAllowedModeCategories​(String key,
                                                   String type,
                                                   boolean logChanges,
                                                   String... osmModeCategories)
        remove the passed in mode categories as allowed for all its child modes
        Parameters:
        key - to use
        type - to use
        logChanges - when true changes are logged, otherwise not
        osmModeCategories - to remove
      • removeAllowedModes

        protected void removeAllowedModes​(String key,
                                          String wayType,
                                          boolean logChanges,
                                          String... osmModes)
        remove the passed in modes as modes that are no longer allowed access for the given way type
        Parameters:
        key - to use
        wayType - to use
        logChanges - when true changes are logged, otherwise not
        osmModes - to remove
      • addDisallowedModes

        protected void addDisallowedModes​(String key,
                                          String wayType,
                                          boolean logChanges,
                                          String... osmModes)
        Add the passed in modes as modes that are explicitly NOT allowed access regardless of the mode category or allowed modes, i.e., this takes precedence over all other settings. Note that rail modes are by definition disallowed unless explicitly allowed, so they need never be added as disallowed modes.
        Parameters:
        key - to use
        wayType - to use
        logChanges - when true changes are logged, otherwise not
        osmModes - to disallow
      • removeDisallowedModes

        protected void removeDisallowedModes​(String key,
                                             String wayType,
                                             boolean logChanges,
                                             String... osmModes)
        remove the passed in modes as modes that are NOT allowed access for the given highway type
        Parameters:
        key - to use
        wayType - to use
        logChanges - when true changes are logged, otherwise not
        osmModes - to remove from disallowing
      • getCountry

        public String getCountry()
        The country for which these defaults hold. In absence of a country, it should return CountryNames.GLOBAL
        Returns:
        country name
      • setCountry

        public void setCountry​(String countryName)
        Set the country name that represents these defaults
        Parameters:
        countryName - to set
      • addAllowedModeCategories

        public void addAllowedModeCategories​(Pair<String,​String> osmKeyValueType,
                                             String... osmModeCategories)
        add the passed in mode categories as allowed for all its child modes
        Parameters:
        osmKeyValueType - key value combination to use
        osmModeCategories - to add
      • removeAllowedModeCategories

        public void removeAllowedModeCategories​(Pair<String,​String> osmKeyValueType,
                                                String... osmModeCategories)
        remove the passed in mode categories as allowed for all its child modes
        Parameters:
        osmKeyValueType - key value combination to use
        osmModeCategories - to remove
      • addAllowedModes

        public void addAllowedModes​(Pair<String,​String> osmKeyValueType,
                                    String... osmModes)
        add the passed in modes as modes that are explicitly allowed access regardless of the mode category, i.e., this takes precedence over the categories. Note that rail modes can be explicitly allowed onto roads, e.g. tram, lightrail, indicating a track embedded in the road.
        Parameters:
        osmKeyValueType - key value combination to use
        osmModes - to add
      • addAllowedModes

        public void addAllowedModes​(String key,
                                    String wayType,
                                    List<String> osmModes)
        add the passed in modes as modes that are explicitly allowed access regardless of the mode category, i.e., this takes precedence over the categories. Note that rail modes can be explicitly allowed onto roads, e.g. tram, lightrail, indicating a track embedded in the road.
        Parameters:
        key - to use
        wayType - to use
        osmModes - to add
      • setAllowedModes

        public void setAllowedModes​(String key,
                                    String wayType,
                                    List<String> osmModes)
        set the passed in modes as the only modes that are explicitly allowed access and remove all categories
        Parameters:
        key - to use
        wayType - to use
        osmModes - to add
      • removeAllowedModes

        public void removeAllowedModes​(Pair<String,​String> osmKeyValueType,
                                       String... osmModes)
        remove the passed in modes as modes that are no longer allowed access for the given highway type
        Parameters:
        osmKeyValueType - key value combination to use
        osmModes - to remove
      • addDisallowedModes

        public void addDisallowedModes​(Pair<String,​String> osmKeyValueType,
                                       String... osmModes)
        add the passed in modes as modes that are explicitly NOT allowed access regardless of the mode category or allowed modes, i.e., this takes precedence over all other settings. Note that rail modes are by definition disallowed unless explicitly allowed, so they need never be added as disallowed modes.
        Parameters:
        osmKeyValueType - key value combination to use
        osmModes - to disallow
      • removeDisallowedModes

        public void removeDisallowedModes​(Pair<String,​String> osmKeyValueType,
                                          String... osmModes)
        Remove the passed in modes as modes that are NOT allowed access for the given highway type
        Parameters:
        osmKeyValueType - key value combination to use
        osmModes - to remove from disallowing
      • isAllowed

        public boolean isAllowed​(String key,
                                 String osmWayValue,
                                 String osmMode)
        Verify if mode is allowed for given way type. If none of the allowed/disallowed configuration options includes the passed in mode it is assumed the mode is not allowed
        Parameters:
        key - to use
        osmWayValue - to check for
        osmMode - to verify
        Returns:
        true when allowed, false when disallowed, false if unknown