Package org.goplanit.osm.util
Class OsmModeUtils
- java.lang.Object
-
- org.goplanit.osm.util.OsmModeUtils
-
public class OsmModeUtils extends Object
Utilities in relation to parsing OSM modes when constructing a PLANit model from it. All utility methods are static in that they do not require any additional information regarding the configuration of the OSM reader, i.e., only generic utilities regarding OSM modes are included here.- Author:
- markr
-
-
Constructor Summary
Constructors Constructor Description OsmModeUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Collection<String>
collectEligibleOsmModesOnPtOsmEntity(long osmEntityId, Map<String,String> tags)
Collect the modes that are deemed eligible for this node (platform, station, halt, etc.).static Collection<String>
collectEligibleOsmModesOnPtOsmEntity(long osmPtEntityId, Map<String,String> tags, String defaultOsmMode)
Collect the modes that are deemed eligible for this node (platform, station, halt, etc.).protected static Set<String>
collectEligibleOsmModesOnPtOsmEntity(Map<String,String> tags, Set<String> selectableOsmModes, String defaultOsmMode)
Collect the OSM modes that are deemed eligible for this entity (platform, station, halt, etc.).static TreeSet<String>
collectEligibleOsmPublicTransportModesOnPtOsmEntity(long osmPtEntityId, Map<String,String> tags, String defaultOsmMode)
Collect the public transport modes that are deemed eligible for this node (platform, station, halt, etc.).static Set<String>
collectEligibleOsmRailModesOnPtOsmEntity(Map<String,String> tags, String defaultOsmMode)
Collect the rail modes that are deemed eligible for this node (platform, station, halt, etc.).static Set<String>
collectEligibleOsmRoadModesOnPtOsmEntity(long osmEntityId, Map<String,String> tags, String defaultOsmMode)
Collect the rail modes that are deemed eligible for this entity (platform, station, halt, etc.).static Set<String>
collectEligibleOsmWaterModesOnPtOsmEntity(Map<String,String> tags, String defaultOsmMode)
Collect the water modes that are deemed eligible for this entity (platform, station, halt, etc.).static Collection<String>
extractCompatibleOsmModes(Collection<String> osmModesToCheck, Collection<String> referenceOsmModes, boolean allowPseudoMatches)
Find out if modes to check are compatible with the reference OSM modes.static TreeSet<String>
extractPublicTransportModesFrom(Collection<String> eligibleOsmModes)
Collect all pt modes available from the passed in modes across all major mode types (road, rail, water)protected static Set<String>
getOsmModesWithValueTag(Map<String,String> tags, Collection<String> supportedOsmModes, String... modeAccessValueTags)
Collect all OSM modes withkey=<OSM mode name>
value=the access value tags that are passed in and available from the supported modes (also passed in).static Set<String>
getOsmRailModesWithValueTag(Map<String,String> tags, String... modeAccessValueTags)
collect all OSM rail modes withkey=<OSM mode name> value=the access value tags that are passed in
.static Set<String>
getOsmRoadModesWithValueTag(Map<String,String> tags, String... modeAccessValueTags)
collect all OSM road going modes withkey=<OSM mode name>
value=the access value tags that are passed in.static Set<String>
getPostfixedOsmRoadModesWithValueTag(String postFix, Map<String,String> tags, String... modeAccessValueTags)
collect all OSM modes withkey=<OSM mode name>:postFix=
any of the modeAccessValueTags that are passed in.protected static Set<String>
getPrefixedOrPostfixedOsmRoadModesWithValueTag(boolean isprefix, String alteration, Map<String,String> tags, String... modeAccessValueTags)
Collect all OSM modes with eitherpreFix:<OSM mode name>=
orpostFix:<OSM mode name>= any of the modeAccessValueTags that are passed in
.static Collection<String>
getPrefixedOsmRoadModesWithValueTag(String prefix, Map<String,String> tags, String... modeAccessValueTags)
collect all OSM modes withkey=preFix:<OSM mode name>= any of the modeAccessValueTags
that are passed in.static boolean
hasEligibleOsmMode(Pair<? extends SortedSet<String>,SortedSet<PredefinedModeType>> modeResult)
Check to see if pair with eligible modes contains any eligible OSM modestatic boolean
hasMappedPlanitMode(Pair<? extends SortedSet<String>,SortedSet<PredefinedModeType>> modeResult)
Check to see if pair with eligible modes contains any mapped PLANit modestatic String
identifyPtv1DefaultMode(long osmId, Map<String,String> tags)
Identical toidentifyPtv1DefaultMode(long, Map, boolean)
without suppressing warningsstatic String
identifyPtv1DefaultMode(long osmId, Map<String,String> tags, boolean suppressWarning)
If the tags contain Ptv1 related tagging, we use it to identify the most likely mode that is expected to be supported, highway=bus_stop gives bus highway=station gives bus highway=platform gives bus highway=platform_edge gives bus railway=station gives train railway=platform gives train railway=platform_edge gives train railway=halt gives train railway=stop gives train railway=tram_stop gives tram amenity=ferry_terminal gives ferrystatic String
identifyPtv1DefaultMode(long osmId, Map<String,String> tags, String backupDefaultMode)
Identical toidentifyPtv1DefaultMode(long, Map, String, boolean)
without suppressing warningsstatic String
identifyPtv1DefaultMode(long osmId, Map<String,String> tags, String backupDefaultMode, boolean suppressWarning)
If the tags contain Ptv1 related tagging, we use it to identify the most likely mode that is expected to be supported.
-
-
-
Method Detail
-
getPrefixedOrPostfixedOsmRoadModesWithValueTag
protected static Set<String> getPrefixedOrPostfixedOsmRoadModesWithValueTag(boolean isprefix, String alteration, Map<String,String> tags, String... modeAccessValueTags)
Collect all OSM modes with eitherpreFix:<OSM mode name>=
orpostFix:<OSM mode name>= any of the modeAccessValueTags that are passed in
. Note that the actual value of the tags will be stripped from special characters to make it more universal to match the pre-specified mode access value tags that we expect to be passed in.- Parameters:
isprefix
- when true prefix applied, when false, postfixalteration
- , the post or prefix alteration of the mode keytags
- to find explicitly included/excluded (PLANit) modes frommodeAccessValueTags
- used to filter the modes by- Returns:
- modes found with specified value tag
-
getOsmModesWithValueTag
protected static Set<String> getOsmModesWithValueTag(Map<String,String> tags, Collection<String> supportedOsmModes, String... modeAccessValueTags)
Collect all OSM modes withkey=<OSM mode name>
value=the access value tags that are passed in and available from the supported modes (also passed in). Note that the actual value of the tags will be stripped from special characters to make it more universal to match the pre-specified mode access value tags that we expect to be passed in- Parameters:
tags
- to find explicitly included/excluded (planit) modes fromsupportedOsmModes
- supportedOsmModes to filer onmodeAccessValueTags
- used to filter the modes by (yes/no)- Returns:
- modes found with specified value tag
-
collectEligibleOsmModesOnPtOsmEntity
protected static Set<String> collectEligibleOsmModesOnPtOsmEntity(Map<String,String> tags, Set<String> selectableOsmModes, String defaultOsmMode)
Collect the OSM modes that are deemed eligible for this entity (platform, station, halt, etc.). A mode is eligible when marked as yes, e.g. ferry=yes, or when none are marked explicitly we assume the the default (if provided). When modes are marked as non-accessible, they are removed from the explicitly included modes. We use a selected set of supported modes passed in to select from- Parameters:
tags
- related to the nodeselectableOsmModes
- to choose fromdefaultOsmMode
- used when no explicit modes can be found (can be null)- Returns:
- list of eligible osm modes, can be empty if no modes are found and default is null
-
getOsmRoadModesWithValueTag
public static Set<String> getOsmRoadModesWithValueTag(Map<String,String> tags, String... modeAccessValueTags)
collect all OSM road going modes withkey=<OSM mode name>
value=the access value tags that are passed in. Note that the actual value of the tags will be stripped from special characters to make it more universal to match the pre-specified mode access value tags that we expect to be passed in- Parameters:
tags
- to find explicitly included/excluded (planit) modes frommodeAccessValueTags
- used to filter the modes by (yes/no)- Returns:
- modes found with specified value tag
-
getOsmRailModesWithValueTag
public static Set<String> getOsmRailModesWithValueTag(Map<String,String> tags, String... modeAccessValueTags)
collect all OSM rail modes withkey=<OSM mode name> value=the access value tags that are passed in
. Note that the actual value of the tags will be stripped from special characters to make it more universal to match the pre-specified mode access value tags that we expect to be passed in- Parameters:
tags
- to find explicitly included/excluded (planit) modes frommodeAccessValueTags
- used to filter the modes by (yes/no)- Returns:
- modes found with specified value tag
-
getPostfixedOsmRoadModesWithValueTag
public static Set<String> getPostfixedOsmRoadModesWithValueTag(String postFix, Map<String,String> tags, String... modeAccessValueTags)
collect all OSM modes withkey=<OSM mode name>:postFix=
any of the modeAccessValueTags that are passed in. Note that the actual value of the tags will be stripped from special characters to make it more universal to match the pre-specified mode access value tags that we expect to be passed in- Parameters:
postFix
- to utilisetags
- to find explicitly included/excluded (planit) modes frommodeAccessValueTags
- used to filter the modes by (yes/no)- Returns:
- modes found with specified value tag
-
getPrefixedOsmRoadModesWithValueTag
public static Collection<String> getPrefixedOsmRoadModesWithValueTag(String prefix, Map<String,String> tags, String... modeAccessValueTags)
collect all OSM modes withkey=preFix:<OSM mode name>= any of the modeAccessValueTags
that are passed in. Note that the actual value of the tags will be stripped from special characters to make it more universal to match the pre-specified mode access value tags that we expect to be passed in- Parameters:
prefix
- consideredtags
- to find explicitly included/excluded (planit) modes frommodeAccessValueTags
- used to filter the modes by- Returns:
- modes found with specified value tag
-
collectEligibleOsmWaterModesOnPtOsmEntity
public static Set<String> collectEligibleOsmWaterModesOnPtOsmEntity(Map<String,String> tags, String defaultOsmMode)
Collect the water modes that are deemed eligible for this entity (platform, station, halt, etc.). A mode is eligible when marked as yes, e.g. ferry=yes, or when none are marked explicitly we assume the the default (if provided). When modes are marked as non-accessible, they are removed from the explicitly included modes.- Parameters:
tags
- related to the nodedefaultOsmMode
- used when no explicit modes can be found (can be null)- Returns:
- list of eligible osm modes, can be empty if no modes are found and default is null
-
collectEligibleOsmRailModesOnPtOsmEntity
public static Set<String> collectEligibleOsmRailModesOnPtOsmEntity(Map<String,String> tags, String defaultOsmMode)
Collect the rail modes that are deemed eligible for this node (platform, station, halt, etc.). A mode is eligible when marked as yes, e.g. subway=yes, or when none are marked explicitly we assume the default (if provided)- Parameters:
tags
- related to the nodedefaultOsmMode
- used when no explicit modes can be found (can be null)- Returns:
- list of eligible osm modes, can be empty if no modes are found and default is null
-
collectEligibleOsmRoadModesOnPtOsmEntity
public static Set<String> collectEligibleOsmRoadModesOnPtOsmEntity(long osmEntityId, Map<String,String> tags, String defaultOsmMode)
Collect the rail modes that are deemed eligible for this entity (platform, station, halt, etc.). A mode is eligible when marked as yes, e.g. bus=yes, or when none are marked explicitly we assume the the default (if provided). When modes are marked as non-accessible, they are removed from the explicitly included modes.- Parameters:
osmEntityId
- to usetags
- related to the nodedefaultOsmMode
- used when no explicit modes can be found (can be null)- Returns:
- list of eligible osm modes, can be empty if no modes are found and default is null
-
collectEligibleOsmModesOnPtOsmEntity
public static Collection<String> collectEligibleOsmModesOnPtOsmEntity(long osmEntityId, Map<String,String> tags)
Collect the modes that are deemed eligible for this node (platform, station, halt, etc.). A mode is eligible when marked as yes, e.g. subway=yes.- Parameters:
osmEntityId
- to usetags
- related to the node- Returns:
- list of eligible osm modes, can be empty if no modes are found
-
collectEligibleOsmModesOnPtOsmEntity
public static Collection<String> collectEligibleOsmModesOnPtOsmEntity(long osmPtEntityId, Map<String,String> tags, String defaultOsmMode)
Collect the modes that are deemed eligible for this node (platform, station, halt, etc.). A mode is eligible when marked as yes, e.g. subway=yes, or when none are marked explicitly we assume the default (if provided).- Parameters:
osmPtEntityId
- to usetags
- related to the nodedefaultOsmMode
- used when no explicit modes can be found (can be null)- Returns:
- list of eligible osm modes, can be empty if no modes are found and default is null
-
collectEligibleOsmPublicTransportModesOnPtOsmEntity
public static TreeSet<String> collectEligibleOsmPublicTransportModesOnPtOsmEntity(long osmPtEntityId, Map<String,String> tags, String defaultOsmMode)
Collect the public transport modes that are deemed eligible for this node (platform, station, halt, etc.). A mode is eligible when marked as yes, e.g. subway=yes, or when none are marked explicitly we assume the default (if provided).- Parameters:
osmPtEntityId
- to usetags
- related to the nodedefaultOsmMode
- used when no explicit modes can be found (can be null)- Returns:
- list of eligible osm public transport modes, can be empty if no modes are found and default is null
-
identifyPtv1DefaultMode
public static String identifyPtv1DefaultMode(long osmId, Map<String,String> tags, boolean suppressWarning)
If the tags contain Ptv1 related tagging, we use it to identify the most likely mode that is expected to be supported,- highway=bus_stop gives bus
- highway=station gives bus
- highway=platform gives bus
- highway=platform_edge gives bus
- railway=station gives train
- railway=platform gives train
- railway=platform_edge gives train
- railway=halt gives train
- railway=stop gives train
- railway=tram_stop gives tram
- amenity=ferry_terminal gives ferry
- Parameters:
osmId
- this relates totags
- to extract information fromsuppressWarning
- when true suppress any warnings, do not otherwise- Returns:
- default mode found, null if nothing is found
-
identifyPtv1DefaultMode
public static String identifyPtv1DefaultMode(long osmId, Map<String,String> tags)
Identical toidentifyPtv1DefaultMode(long, Map, boolean)
without suppressing warnings- Parameters:
osmId
- this relates totags
- to extract information from- Returns:
- default mode found, null if nothing is found
-
identifyPtv1DefaultMode
public static String identifyPtv1DefaultMode(long osmId, Map<String,String> tags, String backupDefaultMode, boolean suppressWarning)
If the tags contain Ptv1 related tagging, we use it to identify the most likely mode that is expected to be supported. We are slightly more tolerant to ferries due to their high likelihood of erroneous or incomplete tagging. In those cases we verify a few more tags than one would normally do- highway=bus_stop gives bus
- highway=station gives bus
- highway=platform gives bus
- highway=platform_edge gives bus
- railway=station gives train
- railway=platform gives train
- railway=platform_edge gives train
- railway=halt gives train
- railway=stop gives train
- railway=tram_stop gives tram
- railway=tram_stop gives tram
- amenity=ferry_terminal gives ferry
- ferry=yes gives ferry
- Parameters:
osmId
- this relates totags
- to extract information frombackupDefaultMode
- if none can be found, this mode is used, may be nullsuppressWarning
- when true do not log warning if no match could be found,- Returns:
- default mode, null if no match could be made
-
identifyPtv1DefaultMode
public static String identifyPtv1DefaultMode(long osmId, Map<String,String> tags, String backupDefaultMode)
Identical toidentifyPtv1DefaultMode(long, Map, String, boolean)
without suppressing warnings- Parameters:
osmId
- to usetags
- to extract information frombackupDefaultMode
- if none can be found, this mode is used, may be null- Returns:
- default mode, null if no match could be made
-
extractCompatibleOsmModes
public static Collection<String> extractCompatibleOsmModes(Collection<String> osmModesToCheck, Collection<String> referenceOsmModes, boolean allowPseudoMatches)
Find out if modes to check are compatible with the reference OSM modes. Mode compatible means at least one overlapping OSM mode. When one allows for pseudo compatibility we relax the restrictions such that any rail/road/water mode is considered a match with any other rail/road/water mode. This can be useful when you do not want to make super strict matches but still want to filter out definite non-matches.- Parameters:
osmModesToCheck
- the modes to checkreferenceOsmModes
- modes to check againstallowPseudoMatches
- when true, we consider all road modes compatible, i.e., bus is compatible with car, train is compatible with tram, etc., when false only exact matches are accepted- Returns:
- compatible modes found
-
extractPublicTransportModesFrom
public static TreeSet<String> extractPublicTransportModesFrom(Collection<String> eligibleOsmModes)
Collect all pt modes available from the passed in modes across all major mode types (road, rail, water)- Parameters:
eligibleOsmModes
- to extract from- Returns:
- found public transport based modes, can be null
-
hasEligibleOsmMode
public static boolean hasEligibleOsmMode(Pair<? extends SortedSet<String>,SortedSet<PredefinedModeType>> modeResult)
Check to see if pair with eligible modes contains any eligible OSM mode- Parameters:
modeResult
- of collectEligibleModes on zoning base handler- Returns:
- true when has at least one mapped PLANit mode present
-
hasMappedPlanitMode
public static boolean hasMappedPlanitMode(Pair<? extends SortedSet<String>,SortedSet<PredefinedModeType>> modeResult)
Check to see if pair with eligible modes contains any mapped PLANit mode- Parameters:
modeResult
- of collectEligibleModes on zoning base handler- Returns:
- true when has at least one mapped PLANit mode present
-
-