public void TestRelationMultipolygonAreaOneOuter()
        {
            // tests a multipolygon containing one 'outer' member.
            var source = new MemoryDataSource(
                Node.Create(1, 0, 0),
                Node.Create(2, 1, 0),
                Node.Create(3, 0, 1),
                Way.Create(1, 1, 2, 3, 1),
                Relation.Create(1,
                    new TagsCollection(
                        Tag.Create("type", "multipolygon")),
                    RelationMember.Create(1, "outer", OsmGeoType.Way)));

            var interpreter = new SimpleFeatureInterpreter();
            var features = interpreter.Interpret(source.GetRelation(1), source);
            Assert.IsNotNull(features);
            Assert.AreEqual(1, features.Count);
            var feature = features[0];
            Assert.IsInstanceOf<LineairRing>(feature.Geometry);
            Assert.IsTrue(feature.Attributes.ContainsKeyValue("type", "multipolygon"));
        }
        public void TestWayAreaIsYes()
        {
            Node node1 = new Node();
            node1.Id = 1;
            node1.Latitude = 0;
            node1.Longitude = 0;
            Node node2 = new Node();
            node2.Id = 2;
            node2.Latitude = 1;
            node2.Longitude = 0;
            Node node3 = new Node();
            node3.Id = 3;
            node3.Latitude = 0;
            node3.Longitude = 1;

            Way way = new Way();
            way.Id = 1;
            way.Nodes = new List<long>();
            way.Nodes.Add(1);
            way.Nodes.Add(2);
            way.Nodes.Add(3);
            way.Nodes.Add(1);
            way.Tags = new TagsCollection();
            way.Tags.Add("area", "yes");

            var source = new List<OsmGeo>();
            source.Add(node1);
            source.Add(node2);
            source.Add(node3);
            source.Add(way);

            // the use of natural=water implies an area-type.
            var interpreter = new SimpleFeatureInterpreter();
            var completeStreamSource = new OsmSimpleCompleteStreamSource(source.ToOsmStreamSource());

            // use the stream to interpret.
            var features = new List<Feature>(new FeatureInterpreterStreamSource(completeStreamSource, interpreter));

            Assert.AreEqual(1, features.Count);
        }
        public void TestRelationMultipolygonAreaOneOuterOneInner()
        {
            var source = new MemoryDataSource(
                Node.Create(1, 0, 0),
                Node.Create(2, 0, 1),
                Node.Create(3, 1, 1),
                Node.Create(4, 1, 0),
                Node.Create(5, 0.25, 0.25),
                Node.Create(6, 0.25, 0.40),
                Node.Create(7, 0.40, 0.40),
                Node.Create(8, 0.40, 0.25),
                Way.Create(1, 1, 2, 3, 4, 1),
                Way.Create(2, 5, 6, 7, 8, 5),
                Relation.Create(1,
                    new TagsCollection(
                        Tag.Create("type", "multipolygon")),
                    RelationMember.Create(1, "outer", OsmGeoType.Way),
                    RelationMember.Create(2, "inner", OsmGeoType.Way)));

            var interpreter = new SimpleFeatureInterpreter();
            var features = interpreter.Interpret(source.GetRelation(1), source);
            Assert.IsNotNull(features);
            Assert.AreEqual(1, features.Count);
            var feature = features[0];
            Assert.IsInstanceOf<Polygon>(feature.Geometry);
            var polygon = feature.Geometry as Polygon;
            Assert.IsNotNull(polygon.Holes);
            Assert.AreEqual(1, polygon.Holes.Count());
            Assert.IsTrue(feature.Attributes.ContainsKeyValue("type", "multipolygon"));
        }
        public void TestWayNaturalIsWaterArea()
        {
            var node1 = new Node();
            node1.Id = 1;
            node1.Latitude = 0;
            node1.Longitude = 0;
            var node2 = new Node();
            node2.Id = 2;
            node2.Latitude = 1;
            node2.Longitude = 0;
            var node3 = new Node();
            node3.Id = 3;
            node3.Latitude = 0;
            node3.Longitude = 1;

            var way = new Way();
            way.Id = 1;
            way.Nodes = new List<long>();
            way.Nodes.Add(1);
            way.Nodes.Add(2);
            way.Nodes.Add(3);
            way.Nodes.Add(1);
            way.Tags = new TagsCollection();
            way.Tags.Add("natural", "water");

            var source = new MemoryDataSource();
            source.AddNode(node1);
            source.AddNode(node2);
            source.AddNode(node3);
            source.AddWay(way);

            // the use of natural=water implies an area-type.
            var interpreter = new SimpleFeatureInterpreter();
            var features = interpreter.Interpret(way, source);

            Assert.IsNotNull(features);
            Assert.AreEqual(1, features.Count);
            var feature = features[0];
            Assert.IsInstanceOf<LineairRing>(feature.Geometry);
            Assert.IsTrue(feature.Attributes.ContainsKeyValue("natural", "water"));
        }