Class OsmWaySettings
- java.lang.Object
-
- org.goplanit.osm.converter.network.OsmWaySettings
-
- Direct Known Subclasses:
OsmHighwaySettings
,OsmRailwaySettings
,OsmWaterwaySettings
public abstract class OsmWaySettings extends Object
Base class with shared settings across different types of Osm ways (highway, railway)- Author:
- markr
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
OsmWaySettings(OsmInfrastructureConfiguration infrastructureTypeConfiguration, OsmSpeedLimitDefaultsCategory speedLimitDefaults, OsmModeAccessDefaultsCategory osmModeAccessDefaults)
Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
activateAllOsmWayTypes()
Activate all known OSM railway typesprotected void
activateOsmMode(String osmMode)
Activate an OSM mode based on its default mapping to a PLANit modeprotected void
activateOsmWayType(String osmWayValue)
Choose to add given way value type to parsed types on top of the defaults, e.g.protected void
activateOsmWayTypes(String... osmWayValueTypes)
Activate all passed in way typesprotected void
activateOsmWayTypes(List<String> osmWayValueTypes)
Activate all passed in way typesvoid
activateParser(boolean activate)
Determine whether or not the ways represented by these settings should be parsed or not.protected void
addAllowedOsmWayModes(String osmWayKey, String osmWayTypeValue, List<String> osmModes)
Add allowed osm modes to OSM way typeprotected void
addDefaultOsmMode2PlanitPredefinedModeTypeMapping(String osmMode, PredefinedModeType planitModeType)
add mapping from osm mode to PLANit mode (only predefined modes supported for now)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 typeprotected void
deactivateAllModesExcept(Collection<String> toBeRemovedModes, List<String> remainingOsmRoadModes)
remove all road modes from mapping except for the passed in onesprotected void
deactivateAllOsmWayTypes()
Deactivate all types for the infrastructure type we represent.protected void
deactivateOsmMode(String osmMode)
Deactivate an OSM mode.protected void
deactivateOsmModes(Collection<String> osmModes)
Remove all provided modes from mappingprotected void
deactivateOsmWayType(String osmWayValue)
Choose to not parse the given way valuetype, e.g.void
excludeOsmWayTypesWithoutActivatedModes()
explicitly exclude all osmWay types that are included but have no more activated modes due to deactivation of their default assigned modes.Collection<String>
getAcivatedOsmModes()
convenience method that collects all currently activated OSM modesprotected TreeSet<String>
getAcivatedOsmModes(PredefinedModeType planitModeType)
convenience method that collects the currently mapped OSM modes for the given PLANit modeStream<PredefinedModeType>
getActivatedPlanitModeTypesStream()
Create a stream of currently activated planit mode typesprotected double
getDefaultSpeedLimitByOsmTypeValue(String osmWayKey, String osmWayValue)
Collect the speed limit for a given way tag value, e.g.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 availableprotected Pair<Double,Double>
getOverwrittenCapacityMaxDensityByOsmWayType(String osmWayType)
collect the overwrite type values that should be usedprotected 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 returnedMap<String,Set<String>>
getSetOfActivatedOsmWayLikeTypes()
Collect all activated types (by key) as a set (copy) in case the parser is activeboolean
hasActivatedOsmModeOtherThan(String osmMode)
Verify if any mode other than the passed in OSM mode is active (in case the parser is active)protected boolean
isDefaultCapacityOrMaxDensityOverwrittenByOsmWayType(String osmWayType)
Check if defaults should be overwrittenprotected 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?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.protected boolean
isOsmWayTypeActivated(String osmWayValue)
Verify if the passed in OSM way value type is explicitly activated.protected boolean
isOsmWayTypeDeactivated(String osmWayValueType)
Verify if the passed in OSM way type is explicitly deactivated.boolean
isParserActive()
verifies if the parser for these settings is active or notabstract void
logSettings()
log way specific settings for derived classesprotected void
logUnsupportedOsmWayTypes()
Log all de-activated OSM way types (irrespective of parser being active or not)protected void
overwriteOsmWayTypeDefaultCapacityMaxDensity(String osmWayKey, String osmWayType, double capacityPerLanePerHour, double maxDensityPerLane)
Choose to overwrite the given highway type defaults with the given values.protected void
setOsmMode2PlanitModeTypeMapping(String osmMode, PredefinedModeType planitModeType)
Add/overwrite a mapping from OSM mode to PLANit mode type.
-
-
-
Constructor Detail
-
OsmWaySettings
protected OsmWaySettings(OsmInfrastructureConfiguration infrastructureTypeConfiguration, OsmSpeedLimitDefaultsCategory speedLimitDefaults, OsmModeAccessDefaultsCategory osmModeAccessDefaults)
Constructor- Parameters:
infrastructureTypeConfiguration
- to usespeedLimitDefaults
- to useosmModeAccessDefaults
- to use
-
-
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 keyosmWayType
- the value type to set these values forcapacityPerLanePerHour
- new value in pcu/lane/hmaxDensityPerLane
- 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 useosmWayValue
- 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 valuetags
- 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 fromplanitModeType
- 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 setplanitModeType
- 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 useosmWayTypeValue
- to useosmMode
- 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 useosmWayValueType
- to useosmModesToCheck
- 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 useosmWayTypeValue
- to useosmModes
- 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
-
-