/// <summary> /// Splits the given tags into a normalized version, profile tags, and the rest in metatags. /// </summary> public static bool Normalize(IAttributeCollection tags, IAttributeCollection profileTags, VehicleCache vehicleCache) { var normalizedTags = new HashSet <string>(new string[] { "highway", "maxspeed", "oneway", "oneway:bicycle", "cycleway", "junction", "access" }); foreach (var vehicle in vehicleCache.Vehicles) { foreach (var vehicleType in vehicle.VehicleTypes) { normalizedTags.Add(vehicleType); } } string highway; if (!tags.TryGetValue("highway", out highway)) { // there is no highway tag, don't continue the search. return(false); } // add the highway tag. profileTags.AddOrReplace("highway", highway); // normalize maxspeed tags. tags.NormalizeMaxspeed(profileTags); // normalize oneway tags. tags.NormalizeOneway(profileTags); tags.NormalizeOnewayBicycle(profileTags); // normalize cyclceway. tags.NormalizeCycleway(profileTags); // normalize junction=roundabout tag. tags.NormalizeJunction(profileTags); // normalize access tags. foreach (var vehicle in vehicleCache.Vehicles) { tags.NormalizeAccess(vehicleCache, vehicle, highway, profileTags); } // add whitelisted tags but only when they haven't been considered for normalization. foreach (var vehicle in vehicleCache.Vehicles) { foreach (var key in vehicle.ProfileWhiteList) { var value = string.Empty; if (tags.TryGetValue(key, out value)) { if (!normalizedTags.Contains(key)) { profileTags.AddOrReplace(key, value); } } } } return(true); }