예제 #1
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);
        }
예제 #2
0
        /// <summary>
        /// Returns true if the given tags collection contains tags that could represents an area. waterway=river or waterway=stream could be potential false positives,
        /// but can't be confirmed without the actual geometry or the area=* tag set to true or false.
        /// </summary>
        public bool IsPotentiallyArea(TagsCollectionBase tags)
        {
            if (tags == null || tags.Count == 0)
            {
                return(false); // no tags, assume no area.
            }
            if (tags.IsTrue("area"))
            {
                return(true);
            }
            else if (tags.IsFalse("area"))
            {
                return(false);
            }

            bool isArea = false;

            if (tags.ContainsAnyKey(areaTags))
            {
                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;
                }
            }
            return(isArea);
        }
        /// <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;
        }
예제 #4
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);
        }
예제 #5
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);
        }