예제 #1
0
        bool DoTagsMatch(TagsCollectionBase osmGeoTags, TagFilter tagFilter)
        {
            // No tags to match
            if (tagFilter == null)
            {
                return(true);
            }

            // Doesn't match if it doesn't contain all of tags
            foreach (var tag in tagFilter.AllOfTags)
            {
                if (!osmGeoTags.Contains(tag.Key, tag.Value))
                {
                    return(false);
                }
            }

            // Doesn't match if it contains at least none of tags
            foreach (var tag in tagFilter.NoneOfTags)
            {
                if (osmGeoTags.Contains(tag.Key, tag.Value))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        bool DoTagsMatch(TagsCollectionBase osmGeoTags, TagFilter tagFilter)
        {
            var allOfTags  = tagFilter.AllOfTags;
            var noneOfTags = tagFilter.NoneOfTags;

            // Doesn't match if it doesn't contain all of tags
            for (int i = 0; i < allOfTags.Length; i++)
            {
                if (!osmGeoTags.Contains(allOfTags[i].Key, allOfTags[i].Value))
                {
                    return(false);
                }
            }

            // Doesn't match if it contains at least none of tags
            for (int i = 0; i < noneOfTags.Length; i++)
            {
                if (osmGeoTags.Contains(noneOfTags[i].Key, noneOfTags[i].Value))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Returns true if the given tags collection contains tags that could represents an area.
        /// </summary>
        public override bool IsPotentiallyArea(TagsCollectionBase 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.Contains("waterway", "river") && !tags.Contains("waterway", "stream")) ||
                (tags.ContainsKey("wetland") && !tags.IsFalse("wetland")) ||
                (tags.ContainsKey("water") && !tags.IsFalse("water")) ||
                (tags.ContainsKey("aeroway") && !tags.IsFalse("aeroway")))
            {
                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);
        }
예제 #4
0
 /// <summary>
 /// Compares two tags collections.
 /// </summary>
 /// <param name="expected"></param>
 /// <param name="actual"></param>
 public static void CompareTags(TagsCollectionBase expected, TagsCollectionBase actual)
 {
     if (expected == null)
     {
         Assert.IsNull(actual);
     }
     else
     {
         Assert.AreEqual(expected.Count, actual.Count);
         foreach (Tag tag in expected)
         {
             Assert.IsTrue(actual.Contains(tag));
         }
         foreach (Tag tag in actual)
         {
             Assert.IsTrue(expected.Contains(tag));
         }
     }
 }