/// <summary> /// Returns true if the vehicle is allowed on the way represented by these tags /// </summary> /// <param name="tags"></param> /// <param name="highwayType"></param> /// <returns></returns> protected override bool IsVehicleAllowed(TagsCollection tags, string highwayType) { if (tags.ContainsKey("motor_vehicle")) { if (tags["motor_vehicle"] == "no") { return(false); } } if (tags.ContainsKey("foot")) { if (tags["foot"] == "designated") { return(false); // designated foot } } if (tags.ContainsKey("bicycle")) { if (tags["bicycle"] == "designated") { return(false); // designated bicycle } } return(AccessibleTags.ContainsKey(highwayType)); }
/// <summary> /// Returns true if the vehicle is allowed on the way represented by these tags /// </summary> /// <param name="tags"></param> /// <param name="highwayType"></param> /// <returns></returns> protected override bool IsVehicleAllowed(TagsCollection tags, string highwayType) { // do the designated tags. if (tags.ContainsKey("bicycle")) { if (tags["bicycle"] == "designated") { return(true); // designated bicycle } if (tags["bicycle"] == "yes") { return(true); // yes for bicycle } if (tags["bicycle"] == "no") { return(false); // no for bicycle } } if (tags.ContainsKey("foot")) { if (tags["foot"] == "designated") { return(false); // designated foot } } return(AccessibleTags.ContainsKey(highwayType)); }
public void When_AddNewTag_Then_NewTagAdded() { tagsCollection.Add(TagName, TagValue); Assert.IsTrue(tagsCollection.ContainsKey(TagName)); Assert.AreEqual(tagsCollection[TagName], TagValue); }
/// <summary> /// Replace all fields in string with values /// </summary> /// <param name="text">String with fields to replace</param> /// <param name="tags">Tags to replace fields with</param> /// <returns></returns> public string ReplaceFields(string text, TagsCollection tags) { if (string.IsNullOrWhiteSpace(text)) { return(text); } var result = text; var match = regExFields.Match(text); while (match.Success) { var field = match.Groups[1].Captures[0].Value; // Search field var replacement = string.Empty; if (tags.ContainsKey(field)) { replacement = tags[field].ToString(); } // Replace field with new value result = result.Replace(match.Groups[0].Captures[0].Value, replacement); // Check for next field match = match.NextMatch(); } ; return(result); }
/// <summary> /// Returns true if the edge with the given tags is routable. /// </summary> /// <param name="tags"></param> /// <returns></returns> public bool IsRoutable(TagsCollection tags) { if (tags != null && tags.Count > 0) { return(tags.ContainsKey("highway")); } return(false); }
/// <summary> /// Returns the name of a given way. /// </summary> /// <param name="tags"></param> /// <returns></returns> public string GetName(TagsCollection tags) { var name = string.Empty; if (tags.ContainsKey("name")) { name = tags["name"]; } return(name); }
public void TestSimpleTagsCollectionSimple() { var collection = new TagsCollection(); collection["simple"] = "yes"; Assert.IsTrue(collection.ContainsKey("simple")); Assert.IsTrue(collection.ContainsKeyValue("simple", "yes")); Assert.AreEqual("yes", collection["simple"]); Assert.AreEqual(1, collection.Count); }
/// <summary> /// Tests an empty tags collection. /// </summary> protected void TestTagsCollectionSimple() { TagsCollectionBase collection = new TagsCollection(); collection["simple"] = "yes"; Assert.IsTrue(collection.ContainsKey("simple")); Assert.IsTrue(collection.ContainsKeyValue("simple", "yes")); Assert.AreEqual("yes", collection["simple"]); Assert.AreEqual(1, collection.Count); }
/// <summary> /// Returns true if the vehicle is allowed on the way represented by these tags /// </summary> /// <param name="tags"></param> /// <param name="highwayType"></param> /// <returns></returns> protected override bool IsVehicleAllowed(TagsCollection tags, string highwayType) { if (tags.ContainsKey("motor_vehicle")) { if (tags["motor_vehicle"] == "no") { return(false); } } return(AccessibleTags.ContainsKey(highwayType)); }
/// <summary> /// Returns the name of a given way. /// </summary> /// <param name="tags"></param> /// <returns></returns> private string GetName(TagsCollection tags) { //TODO: Maybe passing tags around isn't the right way to do this var name = string.Empty; if (tags.ContainsKey("name")) { name = tags["name"]; } return(name); }
/// <summary> /// Returns true if the given tags collection contains tags that could represents an area. /// </summary> /// <param name="tags"></param> /// <returns></returns> public override bool IsPotentiallyArea(TagsCollection tags) { if (tags == null || tags.Count == 0) { return(false); } // no tags, assume no area. bool isArea = false; if ((tags.ContainsKey("building") && !tags.IsFalse("building")) || (tags.ContainsKey("landuse") && !tags.IsFalse("landuse")) || (tags.ContainsKey("amenity") && !tags.IsFalse("amenity")) || (tags.ContainsKey("harbour") && !tags.IsFalse("harbour")) || (tags.ContainsKey("historic") && !tags.IsFalse("historic")) || (tags.ContainsKey("leisure") && !tags.IsFalse("leisure")) || (tags.ContainsKey("man_made") && !tags.IsFalse("man_made")) || (tags.ContainsKey("military") && !tags.IsFalse("military")) || (tags.ContainsKey("natural") && !tags.IsFalse("natural")) || (tags.ContainsKey("office") && !tags.IsFalse("office")) || (tags.ContainsKey("place") && !tags.IsFalse("place")) || (tags.ContainsKey("power") && !tags.IsFalse("power")) || (tags.ContainsKey("public_transport") && !tags.IsFalse("public_transport")) || (tags.ContainsKey("shop") && !tags.IsFalse("shop")) || (tags.ContainsKey("sport") && !tags.IsFalse("sport")) || (tags.ContainsKey("tourism") && !tags.IsFalse("tourism")) || (tags.ContainsKey("waterway") && !tags.IsFalse("waterway")) || (tags.ContainsKey("wetland") && !tags.IsFalse("wetland")) || (tags.ContainsKey("water") && !tags.IsFalse("water")) || (tags.ContainsKey("aeroway") && !tags.IsFalse("aeroway"))) { // these tags usually indicate an area. isArea = true; } string typeValue; if (tags.TryGetValue("type", out typeValue)) { // there is a type in this relation. if (typeValue == "multipolygon") { // this relation is a multipolygon. isArea = true; } else if (typeValue == "boundary") { // this relation is a boundary. isArea = true; } } if (tags.IsTrue("area")) { // explicitly indicated that this is an area. isArea = true; } else if (tags.IsFalse("area")) { // explicitly indicated that this is not an area. isArea = false; } return(isArea); }