Class OsmWaySettings

  • Direct Known Subclasses:
    OsmHighwaySettings, OsmRailwaySettings

    public abstract class OsmWaySettings
    extends Object
    Base class with shared settings across different types of Osm ways (highway, railway)
    Author:
    markr
    • 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

      • setModeExternalIdsBasedOnMappedOsmModes

        protected void setModeExternalIdsBasedOnMappedOsmModes()
        set osmModeId's to planit external id (accounting for the possibility multiple osm modes are mapped to the same planit mode). We do this based on the existing mapping of osmModes to planitmodes
      • 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.
        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
      • logUnsupportedOsmWayTypes

        protected void logUnsupportedOsmWayTypes()
        Log all de-activated OSM way types
      • 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)
      • getDefaultSpeedLimitByOsmWayType

        protected double getDefaultSpeedLimitByOsmWayType​(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
      • getDefaultSpeedLimitByOsmWayType

        protected Double getDefaultSpeedLimitByOsmWayType​(String osmWayKey,
                                                          Map<String,​String> tags)
                                                   throws PlanItException
        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
        Throws:
        PlanItException - thrown if error
      • addOsmMode2PlanitModeMapping

        protected void addOsmMode2PlanitModeMapping​(String osmMode,
                                                    Mode planitMode)
        add mapping from osm mode to PLANit mode
        Parameters:
        osmMode - to map from
        planitMode - mode to map to
      • setOsmMode2PlanitModeMapping

        protected void setOsmMode2PlanitModeMapping​(String osmMode,
                                                    Mode planitMode)
        Add/overwrite a mapping from OSM mode to PLANit mode. This means that the osmMode will be added to the PLANit network
        Parameters:
        osmMode - to set
        planitMode - to map it to
      • removeOsmMode2PlanitModeMapping

        protected void removeOsmMode2PlanitModeMapping​(String osmMode)
        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:
        osmMode - to remove
      • deactivateOsmModes

        protected void deactivateOsmModes​(Collection<String> osmModes)
        Remove all provided modes from mapping
        Parameters:
        osmModes - to deactive
      • 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
      • getMappedPlanitMode

        protected Mode getMappedPlanitMode​(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
      • getMappedOsmModes

        protected Collection<String> getMappedOsmModes​(Mode planitMode)
        convenience method that collects the currently mapped Osm 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
      • isModeAllowedOnOsmWay

        protected boolean isModeAllowedOnOsmWay​(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:
        osmWayTypeValue - to use
        osmMode - to check
        Returns:
        true when allowed, falseo otherwise
      • collectAllowedOsmWayModes

        protected abstract Collection<String> collectAllowedOsmWayModes​(String osmWayValueType)
        collect all allowed modes on the given OSM way
        Parameters:
        osmWayValueType - to collect osm modes for
        Returns:
        allowed osm modes
      • collectAllowedOsmWayModes

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

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

        public void activateParser​(boolean activate)
        set the flag whether or not the ways represented by these settings should be parsed or not
        Parameters:
        activate - actate 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
      • hasMappedPlanitMode

        public boolean hasMappedPlanitMode​(String osmMode)
        Verify if the passed in osmMode is mapped to a mode, i.e., if it is actively included when reading the network
        Parameters:
        osmMode - to verify
        Returns:
        true if mapped, false otherwise
      • hasAnyMappedPlanitModeOtherThan

        public boolean hasAnyMappedPlanitModeOtherThan​(String osmMode)
        Verify if any mode other than the passed in osm mode is active
        Parameters:
        osmMode - to check
        Returns:
        true when other mapped mode is present false otherwise
      • getSetOfActivatedOsmWayTypes

        public final Set<String> getSetOfActivatedOsmWayTypes()
        collect all activated types as a set (copy)
        Returns:
        set of currently activated osm way types, modifications to this set have no effect on configuration