Class OsmTagUtils


  • public class OsmTagUtils
    extends Object
    Class with some general convenience methods for dealing with OSM tags
    Author:
    markr
    • 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
    • Constructor Detail

      • OsmTagUtils

        public OsmTagUtils()
    • 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 check
        valueTags - 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 applying VALUETAG_SPECIALCHAR_STRIP_REGEX
        Parameters:
        tags - to check existence from
        keyTag - to check
        valueTags - 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 applying VALUETAG_SPECIALCHAR_STRIP_REGEX
        Parameters:
        tags - to check existence from
        keyTags - to check
        valueTags - 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 from
        regEx - 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 mistmach
        keyTags - to check
        valueTags - 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 currentKey
        subTagConditions - 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 check
        potentialKeys - 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 from
        tagKey - 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 use
        value - to use
        Returns:
        key=value
      • toConcatWithSep

        public static String toConcatWithSep​(String key,
                                             String value,
                                             String sep)
        Combine two string and add separator, e.g, '=' in between
        Parameters:
        key - to use
        value - to use
        sep - separator to use
        Returns:
        result e.g., a=b for ('a','b','=')