private void SyncImages(TagsCollectionBase tags, string[] images)
        {
            var tagsToRemove = tags.Where(t => t.Key.StartsWith(FeatureAttributes.IMAGE_URL) && images.Contains(t.Value) == false).ToArray();

            foreach (var tag in tagsToRemove)
            {
                tags.RemoveKeyValue(tag);
            }
            var imagesToAdd = images.Where(i => tags.Any(t => t.Value == i) == false).ToList();

            foreach (var imageUrl in imagesToAdd)
            {
                if (!tags.ContainsKey(FeatureAttributes.IMAGE_URL))
                {
                    tags[FeatureAttributes.IMAGE_URL] = imageUrl;
                    continue;
                }
                int imageIndex = 1;
                while (tags.ContainsKey(FeatureAttributes.IMAGE_URL + imageIndex))
                {
                    imageIndex++;
                }
                tags[FeatureAttributes.IMAGE_URL + imageIndex] = imageUrl;
            }
        }
Beispiel #2
0
        public override bool IsPotentiallyArea(TagsCollectionBase tags)
        {
            if (tags == null || tags.Count == 0)
            {
                return(false);
            }
            bool flag = 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"))))
            {
                flag = true;
            }
            string str;

            if (tags.TryGetValue("type", out str))
            {
                if (str == "multipolygon")
                {
                    flag = true;
                }
                else if (str == "boundary")
                {
                    flag = true;
                }
            }
            if (tags.IsTrue("area"))
            {
                flag = true;
            }
            else if (tags.IsFalse("area"))
            {
                flag = false;
            }
            return(flag);
        }
        private void SetWebsiteUrl(TagsCollectionBase tags, PointOfInterestExtended pointOfInterest)
        {
            var regexp           = new Regex("((https?://)|^)([a-z]+).wikipedia.org/wiki/(.*)");
            var nonWikipediaUrls = new List <string>();

            foreach (var url in pointOfInterest.References.Select(r => r.Url))
            {
                var match = regexp.Match(url ?? string.Empty);
                if (!match.Success)
                {
                    nonWikipediaUrls.Add(url);
                    continue;
                }
                var language  = match.Groups[3].Value;
                var pageTitle = Uri.UnescapeDataString(match.Groups[4].Value.Replace("_", " "));
                var key       = FeatureAttributes.WIKIPEDIA + ":" + language;
                tags.AddOrReplace(key, pageTitle);
                key       = FeatureAttributes.WIKIPEDIA;
                pageTitle = language + ":" + pageTitle;
                if (tags.ContainsKey(key) == false)
                {
                    tags.Add(key, pageTitle);
                }
            }
            SetMultipleValuesForTag(tags, FeatureAttributes.WEBSITE, nonWikipediaUrls.ToArray());
        }
Beispiel #4
0
 /// <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(TagsCollectionBase 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);
 }
Beispiel #5
0
 /// <summary>
 ///     Returns true if the edge with the given tags is routable.
 /// </summary>
 /// <param name="tags"></param>
 /// <returns></returns>
 public bool IsRoutable(TagsCollectionBase tags)
 {
     if (tags != null && tags.Count > 0)
     {
         return tags.ContainsKey("highway");
     }
     return false;
 }
Beispiel #6
0
 /// <summary>
 ///     Returns true if the edge with the given tags is routable.
 /// </summary>
 /// <param name="tags"></param>
 /// <returns></returns>
 public bool IsRoutable(TagsCollectionBase tags)
 {
     if (tags != null && tags.Count > 0)
     {
         return(tags.ContainsKey("highway"));
     }
     return(false);
 }
Beispiel #7
0
 /// <summary>
 ///     Returns the name of a given way.
 /// </summary>
 /// <param name="tags"></param>
 /// <returns></returns>
 public string GetName(TagsCollectionBase tags)
 {
     var name = string.Empty;
     if (tags.ContainsKey("name"))
     {
         name = tags["name"];
     }
     return name;
 }
Beispiel #8
0
 // Return true if less specific
 // Return false if more specific
 public static bool TagMatchesTags(Tag tag, TagsCollectionBase tags, out bool isMoreSpecific, out string key)
 {
     isMoreSpecific = false;
     key            = tag.Key;
     if (tags.ContainsKey(key) && ValuesMatch(key, tags[key], tag.Value, out isMoreSpecific))
     {
         return(true);
     }
     if (!AlternateKeys.TryGetValue(key, out string[] altKeys))
Beispiel #9
0
        /// <summary>
        /// Returns the name of a given way.
        /// </summary>
        /// <param name="tags"></param>
        /// <returns></returns>
        private string GetName(TagsCollectionBase tags)
        {
            var name = string.Empty;

            if (tags.ContainsKey("name"))
            {
                name = tags["name"];
            }
            return(name);
        }
Beispiel #10
0
        private string GetName(TagsCollectionBase tags)
        {
            string str = string.Empty;

            if (tags.ContainsKey("name"))
            {
                str = tags["name"];
            }
            return(str);
        }
Beispiel #11
0
 /// <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(TagsCollectionBase tags, string highwayType)
 {
     if (tags.ContainsKey("motor_vehicle"))
     {
         if (tags["motor_vehicle"] == "no")
         {
             return false;
         }
     }
     return AccessibleTags.ContainsKey(highwayType);
 }
Beispiel #12
0
 /// <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(TagsCollectionBase tags, string highwayType)
 {
     if (tags.ContainsKey("motor_vehicle"))
     {
         if (tags["motor_vehicle"] == "no")
         {
             return(false);
         }
     }
     return(AccessibleTags.ContainsKey(highwayType));
 }
        private void SetTagByLanguage(TagsCollectionBase tags, string key, string value, string language)
        {
            var keyWithLanguage = key + ":" + language;
            var previousValue   = string.Empty;

            if (tags.ContainsKey(keyWithLanguage))
            {
                previousValue         = tags[keyWithLanguage];
                tags[keyWithLanguage] = value;
            }
            else
            {
                tags.Add(new Tag(keyWithLanguage, value));
            }
            if (tags.ContainsKey(key) && tags[key] == previousValue)
            {
                tags[key] = value;
            }
            else if (tags.ContainsKey(key) == false)
            {
                tags.Add(new Tag(key, value));
            }
        }
Beispiel #14
0
 public static string GetName(this TagsCollectionBase tags)
 {
     if (tags.ContainsKey(FeatureAttributes.NAME))
     {
         return(tags[FeatureAttributes.NAME]);
     }
     foreach (var tag in tags)
     {
         if (tag.Key.StartsWith(FeatureAttributes.NAME))
         {
             return(tag.Value);
         }
     }
     return(string.Empty);
 }
Beispiel #15
0
 protected override bool IsVehicleAllowed(TagsCollectionBase tags, string highwayType)
 {
     if (!tags.InterpretAccessValues((IEnumerable <string>) this.VehicleTypes, "access"))
     {
         return(false);
     }
     if (tags.ContainsKey("foot"))
     {
         if (tags["foot"] == "designated" || tags["foot"] == "yes")
         {
             return(true);
         }
         if (tags["foot"] == "no")
         {
             return(false);
         }
     }
     return(this.AccessibleTags.ContainsKey(highwayType));
 }
Beispiel #16
0
 /// <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(TagsCollectionBase tags, string highwayType)
 {
     if (tags.ContainsKey("foot"))
     {
         if (tags["foot"] == "designated")
         {
             return(true); // designated foot
         }
         if (tags["foot"] == "yes")
         {
             return(true); // yes for foot
         }
         if (tags["foot"] == "no")
         {
             return(false); // no for foot
         }
     }
     return(AccessibleTags.ContainsKey(highwayType));
 }
 /// <summary>
 /// Returns true if the given object can be a routing restriction.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="tags"></param>
 /// <returns></returns>
 public bool IsRestriction(OsmGeoType type, TagsCollectionBase tags)
 {     // at least there need to be some tags.
     if (type == OsmGeoType.Relation)
     { // filter out relation-based turn-restrictions.
         if (tags != null &&
             tags.ContainsKeyValue("type", "restriction"))
         { // yep, there's a restriction here!
             return(true);
         }
     }
     else if (type == OsmGeoType.Node)
     { // a node is possibly a restriction too.
         if (tags != null)
         {
             return(tags.ContainsKey("barrier"));
         }
     }
     return(false);
 }
Beispiel #18
0
 /// <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(TagsCollectionBase 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
         }
     }
     return(AccessibleTags.ContainsKey(highwayType));
 }
Beispiel #19
0
 /// <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(TagsCollectionBase 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);
 }
Beispiel #20
0
        /// <summary>
        /// The actual conflation.
        /// Returns true if conflation is finished and this grbPoly has been matched
        /// </summary>
        private static bool AttemptConflate(Geometry grbPoly, Geometry osmPoly, TagsCollectionBase grbTags,
                                            ICompleteOsmGeo osmObj, EasyChangeset cs)
        {
            // Is there geographical match?
            if (Math.Abs(osmPoly.Centroid.Distance(grbPoly.Centroid)) > 0.000001)
            {
                return(false);
            }

            if (osmPoly.Difference(grbPoly).Area > 0.000000001)
            {
                return(false);
            }

            if (grbPoly.Difference(osmPoly).Area > 0.000000001)
            {
                return(false);
            }

            if (grbTags == null)
            {
                Console.WriteLine("PANIC for grb object " + grbPoly);
                return(false);
            }


            if (osmObj.Tags.TryGetValue("building", out var osmBuildingValue))
            {
                if (osmBuildingValue.Equals("yes"))
                {
                    osmObj.Tags.RemoveKey("building");
                }
                else
                {
                    grbTags.TryGetValue("building", out var grbBuildingValue);
                    if (grbBuildingValue == null)
                    {
                        Console.WriteLine("GRB Building value is null");
                    }
                    else if (osmBuildingValue != grbBuildingValue)
                    {
                        if (!grbBuildingValue.Equals("yes"))
                        {
                            Console.WriteLine(
                                $"Preferring OSM building-tag '{osmBuildingValue}' over the grb tag '{grbBuildingValue}'");
                        }

                        grbTags.RemoveKey("building");
                    }
                }
            }

            if (osmObj.Tags.TryGetValue("source:geometry:ref", out var osmSourceRef))
            {
                grbTags.TryGetValue("source:geometry:ref", out var grbRef);
                if (!osmSourceRef.Equals(grbRef))
                {
                    throw new Exception($"MISMATCH for {osmObj}: {osmSourceRef} != {grbRef}");
                }

                osmObj.Tags.RemoveKey("source:geometry:date");
            }


            if (osmObj.Tags.TryGetValue("addr:housenumber", out var osmHouseNumber))
            {
                grbTags.TryGetValue("addr:housenumber", out var grbHouseNumber);
                if (!osmHouseNumber.Equals(grbHouseNumber))
                {
                    grbTags.RemoveKey("addr:housenumber");

                    var msg = "GRB thinks that this has number " +
                              (string.IsNullOrEmpty(grbHouseNumber) ? "no number" : grbHouseNumber);

                    Console.WriteLine(
                        $"GRB and OSM disagree over housenumber of {osmObj}. Putting a fixme instead: grb: {grbHouseNumber} != osm {osmHouseNumber}");
                    if (grbTags.ContainsKey("fixme"))
                    {
                        msg += ";" + grbTags.GetValue("fixme");
                    }

                    grbTags.AddOrReplace("fixme", msg);
                }
            }

            if (osmObj.Tags.TryGetValue("addr:street", out var osmStreet))
            {
                grbTags.TryGetValue("addr:street", out var grbStreet);
                if (!string.IsNullOrEmpty(grbStreet) && !osmStreet.Equals(grbStreet))
                {
                    grbTags.RemoveKey("addr:street");

                    var msg = "GRB thinks that this lays in street " + grbStreet;

                    Console.WriteLine(
                        $"GRB and OSM disagree over streetname of {osmObj}. Putting a fixme instead: grb: {grbStreet} != osm {osmStreet}");
                    if (grbTags.ContainsKey("fixme"))
                    {
                        msg += ";" + grbTags.GetValue("fixme");
                    }

                    grbTags.AddOrReplace("fixme", msg);
                }
            }


            try
            {
                foreach (var grbTag in grbTags)
                {
                    if (grbTag.Key.Contains("wrong"))
                    {
                        continue;
                    }

                    osmObj.AddNewTag(grbTag.Key, grbTag.Value);
                }

                cs.AddChange(osmObj);
            }
            catch (Exception e)
            {
                Console.WriteLine($"{osmObj}: {e.Message}: skipping match");
            }


            return(true);
        }
        /// <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(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.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;
        }
Beispiel #22
0
        public override FeatureCollection Interpret(ICompleteOsmGeo osmObject)
        {
            FeatureCollection featureCollection = new FeatureCollection();

            if (osmObject != null)
            {
                switch (osmObject.Type)
                {
                case CompleteOsmType.Node:
                    TagsCollection tagsCollection = new TagsCollection((IEnumerable <Tag>)osmObject.Tags);
                    string         key1           = "FIXME";
                    tagsCollection.RemoveKey(key1);
                    string key2 = "node";
                    tagsCollection.RemoveKey(key2);
                    string key3 = "source";
                    tagsCollection.RemoveKey(key3);
                    if (tagsCollection.Count > 0)
                    {
                        featureCollection.Add(new Feature((Geometry) new Point((osmObject as Node).Coordinate), (GeometryAttributeCollection) new SimpleGeometryAttributeCollection((IEnumerable <Tag>)osmObject.Tags)));
                        break;
                    }
                    break;

                case CompleteOsmType.Way:
                    TagsCollectionBase tags = osmObject.Tags;
                    bool flag = 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"))))
                    {
                        flag = true;
                    }
                    if (tags.IsTrue("area"))
                    {
                        flag = true;
                    }
                    else if (tags.IsFalse("area"))
                    {
                        flag = false;
                    }
                    if (flag)
                    {
                        Feature feature = new Feature((Geometry) new LineairRing((osmObject as CompleteWay).GetCoordinates().ToArray <GeoCoordinate>()), (GeometryAttributeCollection) new SimpleGeometryAttributeCollection((IEnumerable <Tag>)tags));
                        featureCollection.Add(feature);
                        break;
                    }
                    Feature feature1 = new Feature((Geometry) new LineString((osmObject as CompleteWay).GetCoordinates().ToArray <GeoCoordinate>()), (GeometryAttributeCollection) new SimpleGeometryAttributeCollection((IEnumerable <Tag>)tags));
                    featureCollection.Add(feature1);
                    break;

                case CompleteOsmType.Relation:
                    CompleteRelation relation = osmObject as CompleteRelation;
                    string           str;
                    if (relation.Tags.TryGetValue("type", out str))
                    {
                        if (str == "multipolygon")
                        {
                            Feature feature2 = this.InterpretMultipolygonRelation(relation);
                            if (feature2 != null)
                            {
                                featureCollection.Add(feature2);
                                break;
                            }
                            break;
                        }
                        int num = str == "boundary" ? 1 : 0;
                        break;
                    }
                    break;
                }
            }
            return(featureCollection);
        }
Beispiel #23
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;
            }

            if (tags.TryGetValue("type", out var typeValue))
            {
                switch (typeValue)
                {
                // there is a type in this relation.
                case "multipolygon":
                // this relation is a boundary.
                case "boundary":     // this relation is a multipolygon.
                    isArea = true;
                    break;
                }
            }

            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);
        }
Beispiel #24
0
 public static bool HasAny(this TagsCollectionBase myTags, List <KeyValuePair <string, string> > tags)
 {
     return(tags.Any(t => myTags.ContainsKey(t.Key) &&
                     myTags[t.Key].Equals(t.Value)));
 }
 /// <summary>
 /// Returns true if the given object can be a routing restriction.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="tags"></param>
 /// <returns></returns>
 public bool IsRestriction(OsmGeoType type, TagsCollectionBase tags)
 { // at least there need to be some tags.
     if (type == OsmGeoType.Relation)
     { // filter out relation-based turn-restrictions.
         if (tags != null &&
             tags.ContainsKeyValue("type", "restriction"))
         { // yep, there's a restriction here!
             return true;
         }
     }
     else if(type == OsmGeoType.Node)
     { // a node is possibly a restriction too.
         if(tags != null)
         {
             return tags.ContainsKey("barrier");
         }
     }
     return false;
 }
 private bool ContainsTag(TagsCollectionBase tags, string key, string value)
 {
     return(tags != null && tags.ContainsKey(key) && tags[key].Equals(value));
 }