Class OsmWaySettings

    • Field Detail

      • overwriteOsmWayTypeCapacityDensityDefaults

        protected final Map<String,​Pair<Double,​Double>> overwriteOsmWayTypeCapacityDensityDefaults
        track overwrite values for OSM way types where we want different defaults for capacity and max density
    • Method Detail

      • excludeOsmWayTypesWithoutActivatedModes

        public void excludeOsmWayTypesWithoutActivatedModes()
        explicitly exclude all osmWay types that are included but have no more activated modes due to deactivation of their default assigned modes. Doing so avoids the reader to log warnings that supported way types cannot be injected in the network because they have no viable modes attached
      • isOsmWayTypeDeactivated

        protected boolean isOsmWayTypeDeactivated​(String osmWayValueType)
        Verify if the passed in OSM way type is explicitly deactivated. Deactivated types will be ignored when processing ways.
        Parameters:
        osmWayValueType - railway value type of representing way key (railway, highway, etc)
        Returns:
        true when unSupported, false if not (which means it is either supported, or not registered)
      • isOsmWayTypeActivated

        protected boolean isOsmWayTypeActivated​(String osmWayValue)
        Verify if the passed in OSM way value 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)
      • deactivateOsmWayType

        protected void deactivateOsmWayType​(String osmWayValue)
        Choose to not parse the given way valuetype, e.g. railway=rail, highway=primary, etc.
        Parameters:
        osmWayValue - to use
      • activateOsmWayType

        protected void activateOsmWayType​(String osmWayValue)
        Choose to add given way value type to parsed types on top of the defaults, e.g. railway=rail, highway=primary, etc. Activates parser implicitly as well as it is assumed any activation of a type requires parsing it
        Parameters:
        osmWayValue - to use
      • activateOsmWayTypes

        protected void activateOsmWayTypes​(String... osmWayValueTypes)
        Activate all passed in way types
        Parameters:
        osmWayValueTypes - to activate
      • activateOsmWayTypes

        protected void activateOsmWayTypes​(List<String> osmWayValueTypes)
        Activate all passed in way types
        Parameters:
        osmWayValueTypes - to activate
      • activateAllOsmWayTypes

        protected void activateAllOsmWayTypes()
        Activate all known OSM railway types
      • deactivateAllOsmWayTypes

        protected void deactivateAllOsmWayTypes()
        Deactivate all types for the infrastructure type we represent. Also deactivates the parser since if no types are activate, the parser should not parse anything
      • logUnsupportedOsmWayTypes

        protected void logUnsupportedOsmWayTypes()
        Log all de-activated OSM way types (irrespective of parser being active or not)
      • overwriteOsmWayTypeDefaultCapacityMaxDensity

        protected void overwriteOsmWayTypeDefaultCapacityMaxDensity​(String osmWayKey,
                                                                    String osmWayType,
                                                                    double capacityPerLanePerHour,
                                                                    double maxDensityPerLane)
        Choose to overwrite the given highway type defaults with the given values.
        Parameters:
        osmWayKey - the way key
        osmWayType - the value type to set these values for
        capacityPerLanePerHour - new value in pcu/lane/h
        maxDensityPerLane - new value pcu/km/lane
      • isDefaultCapacityOrMaxDensityOverwrittenByOsmWayType

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

        protected final Pair<Double,​Double> getOverwrittenCapacityMaxDensityByOsmWayType​(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)
      • getDefaultSpeedLimitByOsmTypeValue

        protected double getDefaultSpeedLimitByOsmTypeValue​(String osmWayKey,
                                                            String osmWayValue)
        Collect the speed limit for a given way tag value, e.g. railway=typeValue, based on the defaults provided (typically set by country)
        Parameters:
        osmWayKey - key to use
        osmWayValue - way value type to collect default speed limit for
        Returns:
        speedLimit in km/h
      • getDefaultSpeedLimitByOsmWayType

        protected Double getDefaultSpeedLimitByOsmWayType​(String osmWayKey,
                                                          Map<String,​String> tags)
        Collect the default speed limit for a given way tag value, where we extract the key and value from the passed in tags, if available
        Parameters:
        osmWayKey - that is considered valid and should be used to collect way type value
        tags - to extract way key value pair from (highway,railway keys currently supported)
        Returns:
        speedLimit in km/h
      • addDefaultOsmMode2PlanitPredefinedModeTypeMapping

        protected void addDefaultOsmMode2PlanitPredefinedModeTypeMapping​(String osmMode,
                                                                         PredefinedModeType planitModeType)
        add mapping from osm mode to PLANit mode (only predefined modes supported for now)
        Parameters:
        osmMode - to map from
        planitModeType - mode to map to
      • activateOsmMode

        protected void activateOsmMode​(String osmMode)
        Activate an OSM mode based on its default mapping to a PLANit mode
        Parameters:
        osmMode - to map from
      • setOsmMode2PlanitModeTypeMapping

        protected void setOsmMode2PlanitModeTypeMapping​(String osmMode,
                                                        PredefinedModeType planitModeType)
        Add/overwrite a mapping from OSM mode to PLANit mode type. This means that the osmMode will be added to the PLANit network once parsing commences
        Parameters:
        osmMode - to set
        planitModeType - to map it to
      • deactivateOsmMode

        protected void deactivateOsmMode​(String osmMode)
        Deactivate an OSM 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.
        Parameters:
        osmMode - to remove
      • deactivateOsmModes

        protected void deactivateOsmModes​(Collection<String> osmModes)
        Remove all provided modes from mapping
        Parameters:
        osmModes - to deactivate
      • deactivateAllModesExcept

        protected void deactivateAllModesExcept​(Collection<String> toBeRemovedModes,
                                                List<String> remainingOsmRoadModes)
        remove all road modes from mapping except for the passed in ones
        Parameters:
        toBeRemovedModes - remove all these modes, except...
        remainingOsmRoadModes - to explicitly keep from the osmModesToRemove
      • getPlanitModeTypeIfActivated

        protected PredefinedModeType getPlanitModeTypeIfActivated​(String osmMode)
        Convenience method that collects the currently mapped PLANit mode for the given OSM mode if the parser is active otherwise null is returned
        Parameters:
        osmMode - to collect mapped mode for (if any)
        Returns:
        mapped PLANit mode type, if not available or parser is not active null is returned
      • getAcivatedOsmModes

        protected TreeSet<String> getAcivatedOsmModes​(PredefinedModeType planitModeType)
        convenience method that collects the currently mapped OSM modes for the given PLANit mode
        Parameters:
        planitModeType - to collect mapped OSM modes for this type (if any)
        Returns:
        mapped osm modes, if not available (due to lack of mapping or inactive parser) empty collection is returned
      • isModeAllowedOnOsmWay

        protected boolean isModeAllowedOnOsmWay​(String osmWayKey,
                                                String osmWayTypeValue,
                                                String osmMode)
        verify if a particular osm mode is allowed on the provided osm way type e.g., is train allowed on rail?
        Parameters:
        osmWayKey - to use
        osmWayTypeValue - to use
        osmMode - to check
        Returns:
        true when allowed, false, otherwise
      • collectAllowedOsmWayModes

        protected Set<String> collectAllowedOsmWayModes​(String osmWayKey,
                                                        String osmWayValueType,
                                                        Collection<String> osmModesToCheck)
        Collect all Osm modes from the passed in options that are allowed for the given osmWay type
        Parameters:
        osmWayKey - to use
        osmWayValueType - to use
        osmModesToCheck - modes to select from
        Returns:
        allowed OsmModes found
      • addAllowedOsmWayModes

        protected void addAllowedOsmWayModes​(String osmWayKey,
                                             String osmWayTypeValue,
                                             List<String> osmModes)
        Add allowed osm modes to OSM way type
        Parameters:
        osmWayKey - to use
        osmWayTypeValue - to use
        osmModes - to allow
      • logSettings

        public abstract void logSettings()
        log way specific settings for derived classes
      • activateParser

        public void activateParser​(boolean activate)
        Determine whether or not the ways represented by these settings should be parsed or not. It has no impact on the settings themselves, except that all queries related to whether or not modes or types are activated will respond negatively when the parser is deactived, despite the underlying settings remaining in memory and will be reinstated when the parser is re-activated.
        Parameters:
        activate - parser when true, deactivate otherwise
      • isParserActive

        public boolean isParserActive()
        verifies if the parser for these settings is active or not
        Returns:
        true when active, false otherwise
      • isOsmModeActivated

        public boolean isOsmModeActivated​(String osmMode)
        Verify if the passed in osmMode is mapped to a mode, i.e., if it is actively included when reading the network. When the parser is not active false is returned in all cases
        Parameters:
        osmMode - to verify
        Returns:
        true if mapped and parser is active, false otherwise
      • getAcivatedOsmModes

        public Collection<String> getAcivatedOsmModes()
        convenience method that collects all currently activated OSM modes
        Returns:
        mapped osm modes, if not available (due to lack of mapping or inactive parser) empty collection is returned
      • hasActivatedOsmModeOtherThan

        public boolean hasActivatedOsmModeOtherThan​(String osmMode)
        Verify if any mode other than the passed in OSM mode is active (in case the parser is active)
        Parameters:
        osmMode - to check
        Returns:
        true when other mapped mode is present (and parser is active), false otherwise
      • getSetOfActivatedOsmWayLikeTypes

        public final Map<String,​Set<String>> getSetOfActivatedOsmWayLikeTypes()
        Collect all activated types (by key) as a set (copy) in case the parser is active
        Returns:
        set of currently activated OSM way types (when parser is active), modifications to this set have no effect on configuration, null if not applicable
      • getActivatedPlanitModeTypesStream

        public Stream<PredefinedModeType> getActivatedPlanitModeTypesStream()
        Create a stream of currently activated planit mode types
        Returns:
        activated PLANitModeTypes, i.e., they are mapped and activated