Package org.goplanit.osm.util
Class OsmTagUtils
- java.lang.Object
-
- org.goplanit.osm.util.OsmTagUtils
-
public class OsmTagUtils extends Object
Class with some general convenience methods for dealing with OSM tags- Author:
- markr
-
-
Field Summary
Fields Modifier and Type Field Description static StringVALUETAG_SPECIALCHAR_STRIP_REGEXregular expression used to identify non-word characters (a-z any case, 0-9 or _) or whitespace
-
Constructor Summary
Constructors Constructor Description OsmTagUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleananyKeyMatchesAnyValueTag(Map<String,String> tags, String[] keyTags, String... valueTags)Verify if any of the passed in keys matches and of the passed in values in the tags provided, all value tags are filtered by applyingVALUETAG_SPECIALCHAR_STRIP_REGEXstatic booleananyKeyMatchesAnyValueTag(Map<String,String> tags, String regEx, String[] keyTags, String... valueTags)Verify if any of the passed in keys matches and of the passed in values in the tags providedstatic booleancontainsAnyKey(Map<String,String> tags, String... potentialKeys)Determine if any of the potential keys is listed in the passed in tagsstatic StringcreateCompositeOsmKey(String currentKey, String... subTagConditions)Construct composite key "currentKey:subTag1:subTag2:etc."static IntegergetValueAsInt(Map<String,String> tags, String tagKey)Parse value for key as Integer, return null and log warning if not possible to perform conversionstatic List<String>getValuesForSupportedRefKeys(Map<String,String> tags)Collect the values for any "ref" related key tag that we support.static booleankeyMatchesAnyValueTag(Map<String,String> tags, String keyTag, String... valueTags)Verify if the passed in key matches and of the passed in values in the tags provided, all value tags are filtered by applyingVALUETAG_SPECIALCHAR_STRIP_REGEXstatic booleanmatchesAnyValueTag(String valueTag, String... valueTags)Verify if the passed in value tag is present in the list of value tags providedstatic StringtoConcatEqualsString(String key, String value)Combine two string and add '=' in betweenstatic StringtoConcatWithSep(String key, String value, String sep)Combine two string and add separator, e.g, '=' in between
-
-
-
Field Detail
-
VALUETAG_SPECIALCHAR_STRIP_REGEX
public static final String VALUETAG_SPECIALCHAR_STRIP_REGEX
regular expression used to identify non-word characters (a-z any case, 0-9 or _) or whitespace- See Also:
- Constant Field Values
-
-
Method Detail
-
matchesAnyValueTag
public static boolean matchesAnyValueTag(String valueTag, String... valueTags)
Verify if the passed in value tag is present in the list of value tags provided- Parameters:
valueTag- to checkvalueTags- to check against- Returns:
- true when present, false otherwise
-
keyMatchesAnyValueTag
public static boolean keyMatchesAnyValueTag(Map<String,String> tags, String keyTag, String... valueTags)
Verify if the passed in key matches and of the passed in values in the tags provided, all value tags are filtered by applyingVALUETAG_SPECIALCHAR_STRIP_REGEX- Parameters:
tags- to check existence fromkeyTag- to checkvalueTags- to check- Returns:
- true when match is present, false otherwise
-
anyKeyMatchesAnyValueTag
public static boolean anyKeyMatchesAnyValueTag(Map<String,String> tags, String[] keyTags, String... valueTags)
Verify if any of the passed in keys matches and of the passed in values in the tags provided, all value tags are filtered by applyingVALUETAG_SPECIALCHAR_STRIP_REGEX- Parameters:
tags- to check existence fromkeyTags- to checkvalueTags- to check- Returns:
- true when match is present, false otherwise
-
anyKeyMatchesAnyValueTag
public static boolean anyKeyMatchesAnyValueTag(Map<String,String> tags, String regEx, String[] keyTags, String... valueTags)
Verify if any of the passed in keys matches and of the passed in values in the tags provided- Parameters:
tags- to check existence fromregEx- filter each value tag in tags by applying this regular expressions and replace matches with "", can be used to strip whitespaces or unwanted characters that cause a mistmachkeyTags- to checkvalueTags- to check- Returns:
- true when match is present, false otherwise
-
createCompositeOsmKey
public static String createCompositeOsmKey(String currentKey, String... subTagConditions)
Construct composite key "currentKey:subTag1:subTag2:etc."- Parameters:
currentKey- the currentKeysubTagConditions- to add- Returns:
- composite version separated by colons
-
containsAnyKey
public static boolean containsAnyKey(Map<String,String> tags, String... potentialKeys)
Determine if any of the potential keys is listed in the passed in tags- Parameters:
tags- to checkpotentialKeys- to check- Returns:
- true when present, false otherwise
-
getValuesForSupportedRefKeys
public static List<String> getValuesForSupportedRefKeys(Map<String,String> tags)
Collect the values for any "ref" related key tag that we support. We currently support the following ref key tags- ref
- loc_ref
- local_ref
- Parameters:
tags- to verify- Returns:
- found values, empty if present
-
getValueAsInt
public static Integer getValueAsInt(Map<String,String> tags, String tagKey)
Parse value for key as Integer, return null and log warning if not possible to perform conversion- Parameters:
tags- to extract fromtagKey- key to get value for- Returns:
- parsed integer
-
toConcatEqualsString
public static String toConcatEqualsString(String key, String value)
Combine two string and add '=' in between- Parameters:
key- to usevalue- to use- Returns:
- key=value
-
-