Class OsmHighwaySettings
- java.lang.Object
-
- org.goplanit.osm.converter.network.OsmWaySettings
-
- org.goplanit.osm.converter.network.OsmHighwaySettings
-
public class OsmHighwaySettings extends OsmWaySettings
All highway specific settings- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_HIGHWAY_TYPE_WHEN_UNSUPPORTED
Default is OSM highway type when the type is not supported is set to PlanitOsmTags.TERTIARY.static boolean
DEFAULT_HIGHWAYS_PARSER_ACTIVE
by default the highway parser is activatedstatic boolean
DEFAULT_SPEEDLIMIT_BASED_ON_URBAN_AREA
default value whether or not speed limits are based on urban area defaults: trueprotected String
defaultOsmHighwayTypeWhenUnsupported
When the user has activated a highway type for which the reader has no support, this alternative will be used, default is set to PlanitOSMTags.TERTIARY.protected Map<String,Pair<Double,Double>>
overwriteByOsmHighwayType
track overwrite values for OSM highway types where we want different defaults for capacity and max densityprotected boolean
speedLimitDefaultsBasedOnUrbanArea
when speed limit information is missing, use predefined speed limits for highway types mapped to urban area speed limits (or non-urban), default is true-
Fields inherited from class org.goplanit.osm.converter.network.OsmWaySettings
overwriteOsmWayTypeCapacityDensityDefaults
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
OsmHighwaySettings(OsmSpeedLimitDefaultsCategory urbanSpeedLimitDefaults, OsmSpeedLimitDefaultsCategory nonUrbanSpeedLimitDefaults, OsmModeAccessDefaultsCategory osmModeAccessHighwayDefaults)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateAllOsmHighwayTypes()
Activate all known OSM highway typesvoid
activateOsmHighwayType(String osmWayValue)
Choose to add given highway type to parsed types on top of the defaults, e.g.void
activateOsmHighwayTypes(String... osmHighwayValueTypes)
Activate all passed in highway typesvoid
activateOsmHighwayTypes(List<String> osmHighwayValueTypes)
Activate all passed in highway typesvoid
addAllowedHighwayModes(String osmHighwayType, String... osmModes)
add allowed osm modes to highwaytypevoid
addAllowedHighwayModes(String osmHighwayType, List<String> osmModes)
add allowed osm modes to highwaytypeCollection<String>
collectAllowedOsmHighwayModes(String osmHighwayValueType)
Collect all Osm modes that are allowed for the given osmHighway type as configured by the userprotected Collection<String>
collectAllowedOsmWayModes(String osmWayValueType)
collect all allowed modes on the given OSM wayvoid
deactivateAllOsmHighWayTypes()
deactivate all types for highwayvoid
deactivateAllOsmHighwayTypesExcept(String... osmHighwayTypes)
deactivate all types for highway except the ones providesvoid
deactivateAllOsmHighwayTypesExcept(List<String> osmHighwayTypes)
deactivate all types for highway except the ones providesvoid
deactivateAllRoadModesExcept(String... deactivateAllRoadModesExcept)
Remove all road modes from mapping except for the passed in onesvoid
deactivateAllRoadModesExcept(List<String> remainingOsmRoadModes)
remove all road modes from mapping except for the passed in onesvoid
deactivateOsmHighwayType(String osmWayValue)
Choose to not parse the given highway type, e.g.void
deactivateRoadModes(String... osmRoadModes)
deactivate provided road modesvoid
deactivateRoadModes(List<String> osmRoadModes)
deactivate provided road modesString
getDefaultOsmHighwayTypeWhenUnsupported()
When the parsed way has a type that is not supported but also not explicitly excluded, this alternative will be useddouble
getDefaultSpeedLimitByOsmHighwayType(String osmWayValue)
Collect the speed limit for a given highway tag value, e.g.Double
getDefaultSpeedLimitByOsmHighwayType(Map<String,String> tags)
Collect the default speed limit for a given highway tag value, where we extract the key and value from the passed in tags, if availableCollection<String>
getMappedOsmRoadModes(Mode planitMode)
convenience method that collects the currently mapped osm road modes for the given planit modeMode
getMappedPlanitRoadMode(String osmMode)
convenience method that collects the currently mapped PLANit road mode for the given OSM modePair<Double,Double>
getOverwrittenCapacityMaxDensityByOsmHighwayType(String osmWayType)
Collect the overwrite type values that should be usedprotected void
initialiseDefaultMappingFromOsmRoadModes2PlanitModes(Modes planitModes)
Each OSM road mode is mapped to a PLANit mode by default so that the memory model's modes are user configurable yet linked to the original format.boolean
isApplyDefaultWhenOsmHighwayTypeDeactivated()
check if a default type is set when the activate type is not supportedboolean
isDefaultCapacityOrMaxDensityOverwrittenByOsmHighwayType(String osmWayType)
Check if defaults should be overwrittenboolean
isOsmHighwayTypeActivated(String osmWayValue)
Verify if the passed in OSM highway type is explicitly activated.boolean
isOsmHighWayTypeDeactivated(String osmHighwayValue)
Verify if the passed in OSM high way type is explicitly deactivated.boolean
isSpeedLimitDefaultsBasedOnUrbanArea()
collect state of flag indicating to use urban or non-urban default speed limits when speed limit information is missingvoid
logUnsupportedOsmHighwayTypes()
Log all de-activated OSM highwayway typesvoid
overwriteCapacityMaxDensityDefaults(String osmHighwayType, Number capacityPerLanePerHour, Number maxDensityPerLane)
Choose to overwrite the given highway type defaults with the given valuesvoid
removeAllRoadModes()
remove all road modes from the network when parsingvoid
removeOsmHighwayTypeWhenUnsupported()
remove default type in case activate type is not supported by the readervoid
removeOsmRoadModePlanitModeMapping(String osmRoadMode)
remove a mapping from OSM road mode to PLANit mode.void
removeOsmRoadModePlanitModeMapping(List<String> osmRoadModes)
Remove a mapping from OSM road modes to PLANit modes.void
setDefaultWhenOsmHighwayTypeUnsupported(String defaultOsmHighwayValueWhenUnsupported)
set the default to be used when we encounter an unsupported type.void
setOsmRoadMode2PlanitModeMapping(String osmRoadMode, Mode planitMode)
add/overwrite a mapping from OSM road mode to PLANit mode.void
setSpeedLimitDefaultsBasedOnUrbanArea(boolean speedLimitDefaultsBasedOnUrbanArea)
set state of flag indicating to use urban or non-urban default speed limits when speed limit information is missing-
Methods inherited from class org.goplanit.osm.converter.network.OsmWaySettings
activateAllOsmWayTypes, activateOsmWayType, activateOsmWayTypes, activateOsmWayTypes, activateParser, addAllowedOsmWayModes, addOsmMode2PlanitModeMapping, collectAllowedOsmWayModes, deactivateAllModesExcept, deactivateAllOsmWayTypes, deactivateOsmModes, deactivateOsmWayType, excludeOsmWayTypesWithoutActivatedModes, getDefaultSpeedLimitByOsmWayType, getDefaultSpeedLimitByOsmWayType, getMappedOsmModes, getMappedPlanitMode, getOverwrittenCapacityMaxDensityByOsmWayType, getSetOfActivatedOsmWayTypes, hasAnyMappedPlanitModeOtherThan, hasMappedPlanitMode, isDefaultCapacityOrMaxDensityOverwrittenByOsmWayType, isModeAllowedOnOsmWay, isOsmWayTypeActivated, isOsmWayTypeDeactivated, isParserActive, logUnsupportedOsmWayTypes, overwriteOsmWayTypeDefaultCapacityMaxDensity, removeOsmMode2PlanitModeMapping, setModeExternalIdsBasedOnMappedOsmModes, setOsmMode2PlanitModeMapping
-
-
-
-
Field Detail
-
overwriteByOsmHighwayType
protected final Map<String,Pair<Double,Double>> overwriteByOsmHighwayType
track overwrite values for OSM highway types where we want different defaults for capacity and max density
-
defaultOsmHighwayTypeWhenUnsupported
protected String defaultOsmHighwayTypeWhenUnsupported
When the user has activated a highway type for which the reader has no support, this alternative will be used, default is set to PlanitOSMTags.TERTIARY. Note in case this is also not available on the reader, the type will be ignored altogether
-
speedLimitDefaultsBasedOnUrbanArea
protected boolean speedLimitDefaultsBasedOnUrbanArea
when speed limit information is missing, use predefined speed limits for highway types mapped to urban area speed limits (or non-urban), default is true
-
DEFAULT_HIGHWAY_TYPE_WHEN_UNSUPPORTED
public static String DEFAULT_HIGHWAY_TYPE_WHEN_UNSUPPORTED
Default is OSM highway type when the type is not supported is set to PlanitOsmTags.TERTIARY.
-
DEFAULT_SPEEDLIMIT_BASED_ON_URBAN_AREA
public static boolean DEFAULT_SPEEDLIMIT_BASED_ON_URBAN_AREA
default value whether or not speed limits are based on urban area defaults: true
-
DEFAULT_HIGHWAYS_PARSER_ACTIVE
public static boolean DEFAULT_HIGHWAYS_PARSER_ACTIVE
by default the highway parser is activated
-
-
Constructor Detail
-
OsmHighwaySettings
protected OsmHighwaySettings(OsmSpeedLimitDefaultsCategory urbanSpeedLimitDefaults, OsmSpeedLimitDefaultsCategory nonUrbanSpeedLimitDefaults, OsmModeAccessDefaultsCategory osmModeAccessHighwayDefaults)
Constructor- Parameters:
urbanSpeedLimitDefaults
- urban limit defaults to usenonUrbanSpeedLimitDefaults
- non-urban defaults to useosmModeAccessHighwayDefaults
- mode configuration
-
-
Method Detail
-
initialiseDefaultMappingFromOsmRoadModes2PlanitModes
protected void initialiseDefaultMappingFromOsmRoadModes2PlanitModes(Modes planitModes) throws PlanItException
Each OSM road mode is mapped 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. It is important to realise that modes that are marked as N/A have no predefined equivalent in PLANit, as a result they are ignored. One could add them to a known predefined mode, e.g., MOPED to MotorBikeMode, however, this would mean that a restriction on for example mopeds would also be imposed on motor bikes and this is something you likely do not want. If you must include mopeds, then add a custom mapping to a custom mode afterwards, so it is modelled separately. Again, when also persisting using a network converter, make sure the custom mode is also used in the writer to include the mode in the network output.- FOOT to PedestrianMode
- DOG to N/A
- HORSE to N/A
- BICYCLE to BicycleMode
- CARRIAGE to N/A
- TRAILER to N/A
- CARAVAN to N/A
- MOTOR_CYCLE to MotorBike
- MOPED to N/A
- MOFA to N/A
- MOTOR_CAR to CarMode
- MOTOR_HOME to N/A
- TOURIST_BUS to N/A
- COACH to N/A
- AGRICULTURAL to N/A
- GOLF_CART to N/A
- ATV to N/A
- GOODS to GoodsMode
- HEAVY_GOODS to HeavyGoodsMode
- HEAVY_GOODS_ARTICULATED to LargeHeavyGoodsMode
- BUS to BusMode
- TAXI to N/A
- SHARE_TAXI to N/A
- MINI_BUS to N/A
- Parameters:
planitModes
- to populate based on (default) mapping- Throws:
PlanItException
- thrown if error
-
collectAllowedOsmWayModes
protected Collection<String> collectAllowedOsmWayModes(String osmWayValueType)
collect all allowed modes on the given OSM way- Specified by:
collectAllowedOsmWayModes
in classOsmWaySettings
- Parameters:
osmWayValueType
- to collect osm modes for- Returns:
- allowed osm modes
-
getDefaultOsmHighwayTypeWhenUnsupported
public final String getDefaultOsmHighwayTypeWhenUnsupported()
When the parsed way has a type that is not supported but also not explicitly excluded, this alternative will be used- Returns:
- chosen default
-
setDefaultWhenOsmHighwayTypeUnsupported
public void setDefaultWhenOsmHighwayTypeUnsupported(String defaultOsmHighwayValueWhenUnsupported)
set the default to be used when we encounter an unsupported type.- Parameters:
defaultOsmHighwayValueWhenUnsupported
- the default to use, should be a type that is supported.
-
isApplyDefaultWhenOsmHighwayTypeDeactivated
public final boolean isApplyDefaultWhenOsmHighwayTypeDeactivated()
check if a default type is set when the activate type is not supported- Returns:
- true when available false otherwise
-
removeOsmHighwayTypeWhenUnsupported
public final void removeOsmHighwayTypeWhenUnsupported()
remove default type in case activate type is not supported by the reader
-
isOsmHighWayTypeDeactivated
public boolean isOsmHighWayTypeDeactivated(String osmHighwayValue)
Verify if the passed in OSM high way type is explicitly deactivated. Deactivated types will be ignored when processing ways.- Parameters:
osmHighwayValue
- , e.g. primary, road- Returns:
- true when unSupported, false if not (which means it is either supported, or not registered)
-
isOsmHighwayTypeActivated
public boolean isOsmHighwayTypeActivated(String osmWayValue)
Verify if the passed in OSM highway 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)
-
deactivateOsmHighwayType
public void deactivateOsmHighwayType(String osmWayValue)
Choose to not parse the given highway type, e.g. highway=road.- Parameters:
osmWayValue
- to use
-
deactivateAllOsmHighWayTypes
public void deactivateAllOsmHighWayTypes()
deactivate all types for highway
-
deactivateAllOsmHighwayTypesExcept
public void deactivateAllOsmHighwayTypesExcept(String... osmHighwayTypes)
deactivate all types for highway except the ones provides- Parameters:
osmHighwayTypes
- to not deactivate
-
deactivateAllOsmHighwayTypesExcept
public void deactivateAllOsmHighwayTypesExcept(List<String> osmHighwayTypes)
deactivate all types for highway except the ones provides- Parameters:
osmHighwayTypes
- to not deactivate
-
activateOsmHighwayType
public void activateOsmHighwayType(String osmWayValue)
Choose to add given highway type to parsed types on top of the defaults, e.g. highway=road- Parameters:
osmWayValue
- to use
-
activateOsmHighwayTypes
public void activateOsmHighwayTypes(String... osmHighwayValueTypes)
Activate all passed in highway types- Parameters:
osmHighwayValueTypes
- to activate
-
activateOsmHighwayTypes
public void activateOsmHighwayTypes(List<String> osmHighwayValueTypes)
Activate all passed in highway types- Parameters:
osmHighwayValueTypes
- to activate
-
activateAllOsmHighwayTypes
public void activateAllOsmHighwayTypes()
Activate all known OSM highway types
-
overwriteCapacityMaxDensityDefaults
public void overwriteCapacityMaxDensityDefaults(String osmHighwayType, Number capacityPerLanePerHour, Number maxDensityPerLane)
Choose to overwrite the given highway type defaults with the given values- Parameters:
osmHighwayType
- the type to set these values forcapacityPerLanePerHour
- new value in pcu/lane/hmaxDensityPerLane
- new value pcu/km/lane
-
getOverwrittenCapacityMaxDensityByOsmHighwayType
public final Pair<Double,Double> getOverwrittenCapacityMaxDensityByOsmHighwayType(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)
-
isDefaultCapacityOrMaxDensityOverwrittenByOsmHighwayType
public boolean isDefaultCapacityOrMaxDensityOverwrittenByOsmHighwayType(String osmWayType)
Check if defaults should be overwritten- Parameters:
osmWayType
- to check- Returns:
- true when new defaults are provided, false otherwise
-
isSpeedLimitDefaultsBasedOnUrbanArea
public boolean isSpeedLimitDefaultsBasedOnUrbanArea()
collect state of flag indicating to use urban or non-urban default speed limits when speed limit information is missing- Returns:
- flag value
-
setSpeedLimitDefaultsBasedOnUrbanArea
public void setSpeedLimitDefaultsBasedOnUrbanArea(boolean speedLimitDefaultsBasedOnUrbanArea)
set state of flag indicating to use urban or non-urban default speed limits when speed limit information is missing- Parameters:
speedLimitDefaultsBasedOnUrbanArea
- flag value
-
getDefaultSpeedLimitByOsmHighwayType
public double getDefaultSpeedLimitByOsmHighwayType(String osmWayValue) throws PlanItException
Collect the speed limit for a given highway tag value, e.g. highway=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 (for highway types, the outside or inside urban area depending on the setting of the flag setSpeedLimitDefaultsBasedOnUrbanArea is collected)
- Throws:
PlanItException
- thrown if error
-
getDefaultSpeedLimitByOsmHighwayType
public Double getDefaultSpeedLimitByOsmHighwayType(Map<String,String> tags) throws PlanItException
Collect the default speed limit for a given highway 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 (for highway types, the outside or inside urban area depending on the setting of the flag setSpeedLimitDefaultsBasedOnUrbanArea is collected)
- Throws:
PlanItException
- thrown if error
-
setOsmRoadMode2PlanitModeMapping
public void setOsmRoadMode2PlanitModeMapping(String osmRoadMode, Mode planitMode)
add/overwrite a mapping from OSM road mode to PLANit mode. This means that the osmMode will be added to the PLANit network, but also any of its restrictions will be imposed on the PLANit mode that is provided.- Parameters:
osmRoadMode
- to setplanitMode
- to map it to
-
removeOsmRoadModePlanitModeMapping
public void removeOsmRoadModePlanitModeMapping(String osmRoadMode)
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:
osmRoadMode
- to remove
-
removeOsmRoadModePlanitModeMapping
public void removeOsmRoadModePlanitModeMapping(List<String> osmRoadModes)
Remove a mapping from OSM road 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:
osmRoadModes
- to remove
-
deactivateAllRoadModesExcept
public void deactivateAllRoadModesExcept(String... deactivateAllRoadModesExcept)
Remove all road modes from mapping except for the passed in ones- Parameters:
deactivateAllRoadModesExcept
- to explicitly keep if present
-
deactivateAllRoadModesExcept
public void deactivateAllRoadModesExcept(List<String> remainingOsmRoadModes)
remove all road modes from mapping except for the passed in ones- Parameters:
remainingOsmRoadModes
- to explicitly keep if present
-
deactivateRoadModes
public void deactivateRoadModes(String... osmRoadModes)
deactivate provided road modes- Parameters:
osmRoadModes
- to explicitly deactivate
-
deactivateRoadModes
public void deactivateRoadModes(List<String> osmRoadModes)
deactivate provided road modes- Parameters:
osmRoadModes
- to explicitly deactivate
-
removeAllRoadModes
public void removeAllRoadModes()
remove all road modes from the network when parsing
-
getMappedPlanitRoadMode
public Mode getMappedPlanitRoadMode(String osmMode)
convenience method that collects the currently mapped PLANit road 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
-
getMappedOsmRoadModes
public final Collection<String> getMappedOsmRoadModes(Mode planitMode)
convenience method that collects the currently mapped osm road 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
-
collectAllowedOsmHighwayModes
public Collection<String> collectAllowedOsmHighwayModes(String osmHighwayValueType)
Collect all Osm modes that are allowed for the given osmHighway type as configured by the user- Parameters:
osmHighwayValueType
- to use- Returns:
- allowed OsmModes
-
addAllowedHighwayModes
public void addAllowedHighwayModes(String osmHighwayType, String... osmModes)
add allowed osm modes to highwaytype- Parameters:
osmHighwayType
- to useosmModes
- to allow
-
addAllowedHighwayModes
public void addAllowedHighwayModes(String osmHighwayType, List<String> osmModes)
add allowed osm modes to highwaytype- Parameters:
osmHighwayType
- to useosmModes
- to allow
-
logUnsupportedOsmHighwayTypes
public void logUnsupportedOsmHighwayTypes()
Log all de-activated OSM highwayway types
-
-