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​(Modes planitModes)
                                                                     throws PlanItException
        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
        Parameters:
        planitModes - to populate based on (default) mapping
        Throws:
        PlanItException - thrown if error
      • 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 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)
      • getDefaultSpeedLimitByOsmRailwayType

        public double getDefaultSpeedLimitByOsmRailwayType​(String osmWayValue)
                                                    throws PlanItException
        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
        Throws:
        PlanItException - thrown if error
      • getDefaultSpeedLimitByOsmRailwayType

        public Double getDefaultSpeedLimitByOsmRailwayType​(Map<String,​String> tags)
                                                    throws PlanItException
        Collect the default speed limit for a given railway tag value, where we extract the key and value from the passed in tags, if available
        Parameters:
        tags - to extract way key value pair from (highway,railway keys currently supported)
        Returns:
        speedLimit in km/h
        Throws:
        PlanItException - thrown if error
      • setOsmRailMode2PlanitModeMapping

        public void setOsmRailMode2PlanitModeMapping​(String osmRailMode,
                                                     Mode planitMode)
        add/overwrite a mapping from OSM rail mode to PLANit mode. This means that the osmMode will be added to the PLANit network
        Parameters:
        osmRailMode - to set
        planitMode - to map it to
      • removeOsmRailModePlanitModeMapping

        public void removeOsmRailModePlanitModeMapping​(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
      • removeOsmRailModePlanitModeMapping

        public void removeOsmRailModePlanitModeMapping​(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
      • deactivateAllRailModes

        public void deactivateAllRailModes()
        remove all rail modes from mapping
      • deactivateAllRailModesExcept

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

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

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

        public void deactivateRailModes​(List<String> osmRailModes)
        deactivate provided rail modes
        Parameters:
        osmRailModes - to explicitly deactivate
      • getMappedPlanitRailMode

        public Mode getMappedPlanitRailMode​(String osmMode)
        convenience method that collects the currently mapped PLANit 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
      • getMappedOsmRailModes

        public final Collection<String> getMappedOsmRailModes​(Mode planitMode)
        convenience method that collects the currently mapped osm rail modes for the given planit mode
        Parameters:
        planitMode - 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