Class OsmHighwaySettings


  • public class OsmHighwaySettings
    extends OsmWaySettings
    All highway specific settings
    Author:
    markr
    • Field Detail

      • overwriteByOsmHighwayType

        protected final Map<String,​Pair<Double,​Double>> overwriteByOsmHighwayType
        track overwrite values for OSM highway types where we want different defaults for capacity and max density
      • defaultOsmHighwayTypeWhenUnsupported

        protected String defaultOsmHighwayTypeWhenUnsupported
        When the user has activated a highway type for which the reader has no support, this alternative will be used, default is set to PlanitOSMTags.TERTIARY. Note in case this is also not available on the reader, the type will be ignored altogether
      • speedLimitDefaultsBasedOnUrbanArea

        protected boolean speedLimitDefaultsBasedOnUrbanArea
        when speed limit information is missing, use predefined speed limits for highway types mapped to urban area speed limits (or non-urban), default is true
      • DEFAULT_HIGHWAY_TYPE_WHEN_UNSUPPORTED

        public static String DEFAULT_HIGHWAY_TYPE_WHEN_UNSUPPORTED
        Default is OSM highway type when the type is not supported is set to PlanitOsmTags.TERTIARY.
      • DEFAULT_SPEEDLIMIT_BASED_ON_URBAN_AREA

        public static boolean DEFAULT_SPEEDLIMIT_BASED_ON_URBAN_AREA
        default value whether or not speed limits are based on urban area defaults: true
      • DEFAULT_HIGHWAYS_PARSER_ACTIVE

        public static boolean DEFAULT_HIGHWAYS_PARSER_ACTIVE
        by default the highway parser is activated
    • Method Detail

      • initialiseDefaultMappingFromOsmRoadModes2PlanitModes

        protected void initialiseDefaultMappingFromOsmRoadModes2PlanitModes()
        Each OSM road mode is mapped to a PLANit mode by default so that the memory model's modes are user configurable yet linked to the original format. Note that when the reader is used i.c.w. a network writer to convert one network to the other. It is paramount that the PLANit modes that are mapped here are also mapped by the writer to the output format to ensure a correct I/O mapping of modes The default mapping is provided below. It is important to realise that modes that are marked as N/A have no predefined equivalent in PLANit, as a result they are ignored. One could add them to a known predefined mode, e.g., MOPED to MotorBikeMode, however, this would mean that a restriction on for example mopeds would also be imposed on motor bikes and this is something you likely do not want. If you must include mopeds, then add a custom mapping to a custom mode afterwards, so it is modelled separately. Again, when also persisting using a network converter, make sure the custom mode is also used in the writer to include the mode in the network output.
        • FOOT to PedestrianMode
        • DOG to N/A
        • HORSE to N/A
        • BICYCLE to BicycleMode
        • CARRIAGE to N/A
        • TRAILER to N/A
        • CARAVAN to N/A
        • MOTOR_CYCLE to MotorBike
        • MOPED to N/A
        • MOFA to N/A
        • MOTOR_CAR to CarMode
        • MOTOR_HOME to N/A
        • TOURIST_BUS to N/A
        • COACH to N/A
        • AGRICULTURAL to N/A
        • GOLF_CART to N/A
        • ATV to N/A
        • GOODS to GoodsMode
        • HEAVY_GOODS to HeavyGoodsMode
        • HEAVY_GOODS_ARTICULATED to LargeHeavyGoodsMode
        • BUS to BusMode
        • TAXI to N/A
        • SHARE_TAXI to N/A
        • MINI_BUS to N/A
      • collectAllowedOsmWayModes

        protected Collection<String> collectAllowedOsmWayModes​(String osmWayValueType)
        Collect all OSM modes from the passed in OSM way value for highways
        Parameters:
        osmWayValueType - to use
        Returns:
        allowed OsmModes found
      • getDefaultOsmHighwayTypeWhenUnsupported

        public final String getDefaultOsmHighwayTypeWhenUnsupported()
        When the parsed way has a type that is not supported but also not explicitly excluded, this alternative will be used
        Returns:
        chosen default
      • setDefaultWhenOsmHighwayTypeUnsupported

        public void setDefaultWhenOsmHighwayTypeUnsupported​(String defaultOsmHighwayValueWhenUnsupported)
        set the default to be used when we encounter an unsupported type.
        Parameters:
        defaultOsmHighwayValueWhenUnsupported - the default to use, should be a type that is supported.
      • isApplyDefaultWhenOsmHighwayTypeDeactivated

        public final boolean isApplyDefaultWhenOsmHighwayTypeDeactivated()
        check if a default type is set when the activate type is not supported
        Returns:
        true when available false otherwise
      • removeOsmHighwayTypeWhenUnsupported

        public final void removeOsmHighwayTypeWhenUnsupported()
        remove default type in case activate type is not supported by the reader
      • isOsmHighwayTypeDeactivated

        public boolean isOsmHighwayTypeDeactivated​(String osmHighwayValue)
        Verify if the passed in OSM high way type is explicitly deactivated. Deactivated types will be ignored when processing ways.
        Parameters:
        osmHighwayValue - , e.g. primary, road
        Returns:
        true when unSupported, false if not (which means it is either supported, or not registered)
      • isOsmHighwayTypeActivated

        public boolean isOsmHighwayTypeActivated​(String osmWayValue)
        Verify if the passed in OSM highway type is explicitly activated. Activated types will be processed and converted into link(segments).
        Parameters:
        osmWayValue - , e.g. primary, road
        Returns:
        true when supported, false if not (which means it is unsupported, or not registered)
      • deactivateOsmHighwayType

        public void deactivateOsmHighwayType​(String osmWayValue)
        Choose to not parse the given highway type, e.g. highway=road.
        Parameters:
        osmWayValue - to use
      • deactivateAllOsmHighwayTypes

        public void deactivateAllOsmHighwayTypes()
        deactivate all types for highway
      • deactivateAllOsmHighwayTypesExcept

        public void deactivateAllOsmHighwayTypesExcept​(String... osmHighwayTypes)
        deactivate all types for highway except the ones provides
        Parameters:
        osmHighwayTypes - to not deactivate
      • deactivateAllOsmHighwayTypesExcept

        public void deactivateAllOsmHighwayTypesExcept​(List<String> osmHighwayTypes)
        deactivate all types for highway except the ones provides
        Parameters:
        osmHighwayTypes - to not deactivate
      • activateOsmHighwayType

        public void activateOsmHighwayType​(String osmWayValue)
        Choose to add given highway type to parsed types on top of the defaults, e.g. highway=road
        Parameters:
        osmWayValue - to use
      • activateOsmHighwayTypes

        public void activateOsmHighwayTypes​(String... osmHighwayValueTypes)
        Activate all passed in highway types
        Parameters:
        osmHighwayValueTypes - to activate
      • activateOsmHighwayTypes

        public void activateOsmHighwayTypes​(List<String> osmHighwayValueTypes)
        Activate all passed in highway types
        Parameters:
        osmHighwayValueTypes - to activate
      • activateAllOsmHighwayTypes

        public void activateAllOsmHighwayTypes()
        Activate all known OSM highway types
      • overwriteCapacityMaxDensityDefaults

        public void overwriteCapacityMaxDensityDefaults​(String osmHighwayType,
                                                        Number capacityPerLanePerHour,
                                                        Number maxDensityPerLane)
        Choose to overwrite the given highway type defaults with the given values
        Parameters:
        osmHighwayType - the type to set these values for
        capacityPerLanePerHour - new value in pcu/lane/h
        maxDensityPerLane - new value pcu/km/lane
      • getOverwrittenCapacityMaxDensityByOsmHighwayType

        public final Pair<Double,​Double> getOverwrittenCapacityMaxDensityByOsmHighwayType​(String osmWayType)
        Collect the overwrite type values that should be used
        Parameters:
        osmWayType - to collect overwrite values for
        Returns:
        the new values capacity (pcu/lane/h) and maxDensity (pcu/km/lane)
      • isDefaultCapacityOrMaxDensityOverwrittenByOsmHighwayType

        public boolean isDefaultCapacityOrMaxDensityOverwrittenByOsmHighwayType​(String osmWayType)
        Check if defaults should be overwritten
        Parameters:
        osmWayType - to check
        Returns:
        true when new defaults are provided, false otherwise
      • isSpeedLimitDefaultsBasedOnUrbanArea

        public boolean isSpeedLimitDefaultsBasedOnUrbanArea()
        collect state of flag indicating to use urban or non-urban default speed limits when speed limit information is missing
        Returns:
        flag value
      • setSpeedLimitDefaultsBasedOnUrbanArea

        public void setSpeedLimitDefaultsBasedOnUrbanArea​(boolean speedLimitDefaultsBasedOnUrbanArea)
        set state of flag indicating to use urban or non-urban default speed limits when speed limit information is missing
        Parameters:
        speedLimitDefaultsBasedOnUrbanArea - flag value
      • getDefaultSpeedLimitByOsmHighwayType

        public double getDefaultSpeedLimitByOsmHighwayType​(String osmWayValue)
        Collect the speed limit for a given highway tag value, e.g. highway=typeValue, based on the defaults provided (typically set by country)
        Parameters:
        osmWayValue - way value type to collect default speed limit for
        Returns:
        speedLimit in km/h (for highway types, the outside or inside urban area depending on the setting of the flag setSpeedLimitDefaultsBasedOnUrbanArea is collected)
      • activateOsmRoadMode

        public void activateOsmRoadMode​(String osmRoadMode)
        activate OSM road mode based on its default mapping to PLANit mode. This means that the osmMode will be added to the PLANit network, but also any of its restrictions will be imposed on the PLANit mode that is provided.
        Parameters:
        osmRoadMode - to set
      • deactivateOsmRoadMode

        public void deactivateOsmRoadMode​(String osmRoadMode)
        deactivate an OSM road mode from parsing. This means that the osmMode will not be added to the PLANit network You can only remove a mode when it is already added.
        Parameters:
        osmRoadMode - to remove
      • deactivateOsmRoadModes

        public void deactivateOsmRoadModes​(List<String> osmRoadModes)
        Remove a mapping from OSM road modes to PLANit modes. This means that the osmModes will not be added to the PLANit network. You can only remove modes when they are already added, either manually or through the default mapping
        Parameters:
        osmRoadModes - to remove
      • deactivateAllOsmRoadModesExcept

        public void deactivateAllOsmRoadModesExcept​(String... deactivateAllRoadModesExcept)
        Remove all road modes from mapping except for the passed in ones
        Parameters:
        deactivateAllRoadModesExcept - to explicitly keep if present
      • deactivateAllOsmRoadModesExcept

        public void deactivateAllOsmRoadModesExcept​(List<String> remainingOsmRoadModes)
        remove all road modes from mapping except for the passed in ones
        Parameters:
        remainingOsmRoadModes - to explicitly keep if present
      • deactivateOsmRoadModes

        public void deactivateOsmRoadModes​(String... osmRoadModes)
        deactivate provided road modes
        Parameters:
        osmRoadModes - to explicitly deactivate
      • removeAllRoadModes

        public void removeAllRoadModes()
        remove all road modes from the network when parsing
      • getMappedPlanitRoadMode

        public PredefinedModeType getMappedPlanitRoadMode​(String osmMode)
        convenience method that collects the currently mapped PLANit road mode for the given OSM mode
        Parameters:
        osmMode - to collect mapped mode for (if any)
        Returns:
        mapped PLANit mode, if not available null is returned
      • getMappedOsmRoadModes

        public final TreeSet<String> getMappedOsmRoadModes​(PredefinedModeType planitModeType)
        convenience method that collects the currently mapped osm road modes for the given planit mode
        Parameters:
        planitModeType - to collect mapped mode for (if any)
        Returns:
        mapped osm modes, if not available empty collection is returned
      • collectAllowedOsmHighwayModes

        public Collection<String> collectAllowedOsmHighwayModes​(String osmHighwayValueType)
        Collect all Osm modes that are allowed for the given osmHighway type as configured by the user
        Parameters:
        osmHighwayValueType - to use
        Returns:
        allowed OsmModes
      • addAllowedOsmHighwayModes

        public void addAllowedOsmHighwayModes​(String osmHighwayType,
                                              String... osmModes)
        add allowed osm modes to highwaytype
        Parameters:
        osmHighwayType - to use
        osmModes - to allow
      • addAllowedOsmHighwayModes

        public void addAllowedOsmHighwayModes​(String osmHighwayType,
                                              List<String> osmModes)
        add allowed osm modes to highwaytype
        Parameters:
        osmHighwayType - to use
        osmModes - to allow
      • logUnsupportedOsmHighwayTypes

        public void logUnsupportedOsmHighwayTypes()
        Log all de-activated OSM highwayway types
      • logSettings

        public void logSettings()
        log way specific settings for derived classes
        Specified by:
        logSettings in class OsmWaySettings