Class OsmWaySettings
- java.lang.Object
-
- org.goplanit.osm.converter.network.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
-
-
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
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)
set the flag whether or not the ways represented by these settings should be parsed or notprotected void
addAllowedOsmWayModes(String osmWayTypeValue, List<String> osmModes)
add allowed osm modes to osm way typeprotected void
addOsmMode2PlanitModeMapping(String osmMode, Mode planitMode)
add mapping from osm mode to PLANit modeprotected abstract Collection<String>
collectAllowedOsmWayModes(String osmWayValueType)
collect all allowed modes on the given OSM wayprotected Set<String>
collectAllowedOsmWayModes(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 representprotected 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.protected double
getDefaultSpeedLimitByOsmWayType(String osmWayValue)
Collect the speed limit for a given railway 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 Collection<String>
getMappedOsmModes(Mode planitMode)
convenience method that collects the currently mapped Osm modes for the given planit modeprotected Mode
getMappedPlanitMode(String osmMode)
convenience method that collects the currently mapped PLANit mode for the given OSM modeprotected Pair<Double,Double>
getOverwrittenCapacityMaxDensityByOsmWayType(String osmWayType)
collect the overwrite type values that should be usedSet<String>
getSetOfActivatedOsmWayTypes()
collect all activated types as a set (copy)boolean
hasAnyMappedPlanitModeOtherThan(String osmMode)
Verify if any mode other than the passed in osm mode is activeboolean
hasMappedPlanitMode(String osmMode)
Verify if the passed in osmMode is mapped to a mode, i.e., if it is actively included when reading the networkprotected boolean
isDefaultCapacityOrMaxDensityOverwrittenByOsmWayType(String osmWayType)
Check if defaults should be overwrittenprotected boolean
isModeAllowedOnOsmWay(String osmWayTypeValue, String osmMode)
verify if a particular osm mode is allowed on the provided osm way type e.g.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 notprotected void
logUnsupportedOsmWayTypes()
Log all de-activated OSM way typesprotected void
overwriteOsmWayTypeDefaultCapacityMaxDensity(String osmWayKey, String osmWayType, double capacityPerLanePerHour, double maxDensityPerLane)
Choose to overwrite the given highway type defaults with the given valuesprotected void
removeOsmMode2PlanitModeMapping(String osmMode)
Remove a mapping from OSM road mode to PLANit mode.protected void
setModeExternalIdsBasedOnMappedOsmModes()
set osmModeId's to planit external id (accounting for the possibility multiple osm modes are mapped to the same planit mode).protected void
setOsmMode2PlanitModeMapping(String osmMode, Mode planitMode)
Add/overwrite a mapping from OSM mode to PLANit mode.
-
-
-
Constructor Detail
-
OsmWaySettings
protected OsmWaySettings(OsmInfrastructureConfiguration infrastructureTypeConfiguration, OsmSpeedLimitDefaultsCategory speedLimitDefaults, OsmModeAccessDefaultsCategory osmModeAccessDefaults)
Constructor- Parameters:
infrastructureTypeConfiguration
- to usespeedLimitDefaults
- to useosmModeAccessDefaults
- to use
-
-
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 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)
-
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 valuetags
- 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 fromplanitMode
- 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 setplanitMode
- 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 useosmMode
- 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 useosmModesToCheck
- 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 useosmModes
- 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
-
-