Class OsmRailwaySettings


  • public class OsmRailwaySettings
    extends OsmWaySettings
    Settings specific to railways when parsing OSM files and converting them to a PLANit memory model
    Author:
    markr
    • Field Detail

      • DEFAULT_RAILWAYS_PARSER_ACTIVE

        public static boolean DEFAULT_RAILWAYS_PARSER_ACTIVE
        by default the railway parser is deactivated
    • Constructor Detail

      • OsmRailwaySettings

        public OsmRailwaySettings​(OsmSpeedLimitDefaultsCategory railwaySpeedLimitDefaults,
                                  OsmModeAccessDefaultsCategory osmModeAccessRailwayDefaults)
        Constructor
        Parameters:
        railwaySpeedLimitDefaults - as they are initially provided
        osmModeAccessRailwayDefaults - configuration
    • Method Detail

      • initialiseDefaultMappingFromOsmRailModes2PlanitModes

        protected void initialiseDefaultMappingFromOsmRailModes2PlanitModes()
        each OSM rail mode is mapped (or not) 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. In contrast to road modes, rail modes do not have specific restrictions. Hence, we can map more exotic OSM rail modes to more common PLANit rail modes, without imposing its restrictions on this common mode.
        • FUNICULAR to TramMode
        • LIGHT_RAIL to LightRailMode
        • MONO_RAIL to TramMode
        • NARROW_GAUGE to TrainMode
        • PRESERVED to TrainMode
        • RAIL to TrainMode
        • SUBWAY to SubWayMode
        • TRAM to TramMode
      • collectAllowedOsmWayModes

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

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

        public boolean isOsmRailwayTypeActivated​(String osmWayValue)
        Verify if the passed in OSM railway 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)
      • deactivateOsmRailwayType

        public void deactivateOsmRailwayType​(String osmWayValue)
        Choose to not parse the given railway type, e.g. railway=rail.
        Parameters:
        osmWayValue - to use
      • deactivateAllOsmRailwayTypesExcept

        public void deactivateAllOsmRailwayTypesExcept​(String... osmRailwayTypes)
        deactivate all types for railway except the ones provides
        Parameters:
        osmRailwayTypes - to not deactivate
      • deactivateAllOsmRailwayTypesExcept

        public void deactivateAllOsmRailwayTypesExcept​(List<String> osmRailwayTypes)
        deactivate all types for railway except the ones provides
        Parameters:
        osmRailwayTypes - to not deactivate
      • activateOsmRailwayType

        public void activateOsmRailwayType​(String osmWayValue)
        Choose to add given railway type to parsed types on top of the defaults, e.g. railway=rail.
        Parameters:
        osmWayValue - to use
      • activateOsmRailwayTypes

        public void activateOsmRailwayTypes​(String... osmRailwayValueTypes)
        activate all passed in railway types
        Parameters:
        osmRailwayValueTypes - to activate
      • activateOsmRailwayTypes

        public void activateOsmRailwayTypes​(List<String> osmRailwayValueTypes)
        activate all passed in railway types
        Parameters:
        osmRailwayValueTypes - to activate
      • activateAllOsmRailwayTypes

        public void activateAllOsmRailwayTypes()
        activate all known OSM railway types
      • deactivateAllOsmRailwayTypes

        public void deactivateAllOsmRailwayTypes()
        deactivate all types for rail
      • logUnsupportedOsmRailwayTypes

        public void logUnsupportedOsmRailwayTypes()
        Log all de-activated OSM railway types
      • overwriteCapacityMaxDensityDefaults

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

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

        public final Pair<Double,​Double> getOverwrittenCapacityMaxDensityByOsmRailwayType​(String osmWayType)
        collect the overwritten 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)
      • getDefaultSpeedLimitByOsmRailwayType

        public double getDefaultSpeedLimitByOsmRailwayType​(String osmWayValue)
        Collect the speed limit for a given railway tag value, e.g. railway=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
      • activateOsmRailMode

        public void activateOsmRailMode​(String osmRailMode)
        activate an OSM rail mode based on its (default) mapping to a PLANit mode. This means that the osmMode will be added to the PLANit network
        Parameters:
        osmRailMode - to activate
      • deactivateOsmRailMode

        public void deactivateOsmRailMode​(String osmRailMode)
        Remove a mapping from OSM road mode to PLANit mode. This means that the osmMode will not be added to the PLANit network You can only remove a mode when it is already added, either manually or through the default mapping
        Parameters:
        osmRailMode - to remove
      • deactivateOsmRailModes

        public void deactivateOsmRailModes​(List<String> osmRailModes)
        remove a mapping from OSM rail 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:
        osmRailModes - to remove
      • deactivateOsmRailModes

        public void deactivateOsmRailModes​(String... osmRailModes)
        deactivate provided rail modes
        Parameters:
        osmRailModes - to explicitly deactivate
      • deactivateAllOsmRailModes

        public void deactivateAllOsmRailModes()
        remove all rail modes from mapping
      • deactivateAllOsmRailModesExcept

        public void deactivateAllOsmRailModesExcept​(String... remainingOsmRailModes)
        remove all rail modes from mapping except for the passed in ones
        Parameters:
        remainingOsmRailModes - to explicitly keep if present
      • deactivateAllOsmRailModesExcept

        public void deactivateAllOsmRailModesExcept​(List<String> remainingOsmRailModes)
        remove all rail modes from mapping except for the passed in ones
        Parameters:
        remainingOsmRailModes - to explicitly keep if present
      • getMappedPlanitRailMode

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

        public final TreeSet<String> getMappedOsmRailModes​(PredefinedModeType planitModeType)
        convenience method that collects the currently mapped osm rail 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
      • collectAllowedOsmRailwayModes

        public Collection<String> collectAllowedOsmRailwayModes​(String osmRailwayValueType)
        Collect all Osm modes that are allowed for the given osmRailway type as configured by the user
        Parameters:
        osmRailwayValueType - to use
        Returns:
        allowed OsmModes found
      • logSettings

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