예제 #1
0
 /// <summary>
 /// Searches for a maxweight tag and returns the associated value.
 /// 
 ///  http://wiki.openstreetmap.org/wiki/Key:maxweight
 /// </summary>
 /// <param name="tags">The tags to search.</param>
 /// <param name="result"></param>
 /// <returns></returns>
 public static bool TryGetMaxWeight(this TagsCollectionBase tags, out Kilogram result)
 {
     result = double.MaxValue;
     string tagValue;
     if (tags == null || !tags.TryGetValue("maxweight", out tagValue) || Utilities.IsNullOrWhiteSpace(tagValue))
         return false;
     return TagExtensions.TryParseWeight(tagValue, out result);
 }
예제 #2
0
        /// <summary>
        /// Tries to parse a weight value from a given tag-value.
        /// </summary>
        /// <param name="s"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public static bool TryParseWeight(string s, out Kilogram result)
        {
            result = double.MaxValue;

            if (Utilities.IsNullOrWhiteSpace(s))
                return false;

            Regex tonnesRegex = new Regex("^" + REGEX_DECIMAL + REGEX_UNIT_TONNES + "$", RegexOptions.IgnoreCase);
            Match tonnesMatch = tonnesRegex.Match(s);
            if (tonnesMatch.Success)
            {
                result = (Kilogram)(double.Parse(tonnesMatch.Groups[1].Value, CultureInfo.InvariantCulture) * 1000);
                return true;
            }

            return false;
        }
예제 #3
0
 /// <summary>
 /// Searches for a max axle load tag and returns the associated value.
 /// 
 /// http://wiki.openstreetmap.org/wiki/Key:maxaxleload
 /// </summary>
 /// <param name="tags">The tags to search.</param>
 /// <param name="result"></param>
 /// <returns></returns>
 public static bool TryGetMaxAxleLoad(this TagsCollection tags, out Kilogram result)
 {
     result = double.MaxValue;
     string tagValue;
     if (tags == null || !tags.TryGetValue("maxaxleload", out tagValue) || string.IsNullOrWhiteSpace(tagValue))
         return false;
     return TagExtensions.TryParseWeight(tagValue, out result);
 }