Exemple #1
0
        public void TestAddRelation()
        {
            Relation testRelation = new Relation();

            testRelation.Id = -1;
            var source = new MemoryDataSource();

            source.AddRelation(testRelation);

            // test if the relation is actually there.
            Assert.AreEqual(testRelation, source.GetRelation(-1));

            // test if the relation was not remove after getting it.
            Assert.AreEqual(testRelation, source.GetRelations(new List <long>()
            {
                -1
            })[0]);

            // test if the relation is in the list of relations.
            Assert.AreEqual(testRelation, new List <Relation>(source.GetRelations())[0]);

            // test if the relation will be retrieved using a list of ids.
            List <long> ids = new List <long>();

            ids.Add(-1);
            IList <Relation> relations = source.GetRelations(ids);

            Assert.IsNotNull(relations);
            Assert.AreEqual(1, relations.Count);
            Assert.AreEqual(testRelation, relations[0]);
        }
Exemple #2
0
        public void TestRelationMultipolygonAreaOneOuterTwoPartialInners()
        {
            MemoryDataSource 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),
                Way.Create(3, 7, 8, 5),
                Relation.Create(1,
                                new TagsCollection(
                                    Tag.Create("type", "multipolygon")),
                                RelationMember.Create(1, "outer", OsmGeoType.Way),
                                RelationMember.Create(2, "inner", OsmGeoType.Way),
                                RelationMember.Create(3, "inner", OsmGeoType.Way)));

            GeometryInterpreter interpreter = new SimpleGeometryInterpreter();
            GeometryCollection  geometries  = interpreter.Interpret(source.GetRelation(1), source);

            Assert.IsNotNull(geometries);
            Assert.AreEqual(1, geometries.Count);
            Geometry geometry = geometries[0];

            Assert.IsInstanceOf <Polygon>(geometry);
            Polygon polygon = geometry as Polygon;

            Assert.IsNotNull(polygon.Holes);
            Assert.AreEqual(1, polygon.Holes.Count());
            Assert.IsTrue(geometry.Attributes.ContainsKeyValue("type", "multipolygon"));
        }
Exemple #3
0
        public void TestRemoveRelation()
        {
            Relation testRelation = new Relation();

            testRelation.Id = -1;
            var source = new MemoryDataSource();

            source.AddRelation(testRelation);

            // test if the relation is actually there.
            Assert.AreEqual(testRelation, source.GetRelation(-1));

            // remove the relation.
            source.RemoveRelation(-1);

            // test if the relation is actually gone.
            Assert.IsNull(source.GetRelation(-1));
        }
        public void TestRelationMultipolygonAreaOneOuterTwoInners()
        {
            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),
                Node.Create(9, 0.60, 0.25),
                Node.Create(10, 0.60, 0.40),
                Node.Create(11, 0.75, 0.40),
                Node.Create(12, 0.75, 0.25),
                Way.Create(1, 1, 2, 3, 4, 1),
                Way.Create(2, 5, 6, 7, 8, 5),
                Way.Create(3, 9, 10, 11, 12, 9),
                Relation.Create(1,
                                new TagsCollection(
                                    Tag.Create("type", "multipolygon")),
                                RelationMember.Create(1, "outer", OsmGeoType.Way),
                                RelationMember.Create(2, "inner", OsmGeoType.Way),
                                RelationMember.Create(3, "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);
            Polygon polygon = feature.Geometry as Polygon;

            Assert.IsNotNull(polygon.Holes);
            Assert.AreEqual(2, polygon.Holes.Count());
            Assert.IsTrue(feature.Attributes.ContainsKeyValue("type", "multipolygon"));
        }
Exemple #5
0
        public void TestRelationMultipolygonAreaOneOuter()
        {
            // tests a multipolygon containing one 'outer' member.
            MemoryDataSource 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)));

            GeometryInterpreter interpreter = new SimpleGeometryInterpreter();
            GeometryCollection  geometries  = interpreter.Interpret(source.GetRelation(1), source);

            Assert.IsNotNull(geometries);
            Assert.AreEqual(1, geometries.Count);
            Geometry geometry = geometries[0];

            Assert.IsInstanceOf <LineairRing>(geometry);
            Assert.IsTrue(geometry.Attributes.ContainsKeyValue("type", "multipolygon"));
        }