Beispiel #1
0
        public void TestOneEdgeExcluded()
        {
            var routerDb = new RouterDb();
            var network  = routerDb.Network;

            network.AddVertex(0, 51.154800936865406f, 4.2070770263671875f);
            network.AddVertex(1, 51.159968767920475f, 4.2235565185546875f);
            var edgeId = network.AddEdge(0, 1, new Itinero.Data.Network.Edges.EdgeData()
            {
                Distance = 57.69f,
                Profile  = 1,
                MetaId   = 10
            });

            var area = new PolygonArea(new Polygon()
            {
                ExteriorRing = new List <Coordinate>(new Coordinate[]
                {
                    new Coordinate(51.27391736369659f, 4.799566268920898f),
                    new Coordinate(51.258531028690626f, 4.78879451751709f),
                    new Coordinate(51.2665873439388f, 4.817891120910644f),
                    new Coordinate(51.27391736369659f, 4.799566268920898f)
                })
            });

            var handler = new AreaMetaDataHandler(routerDb, area);

            handler.NewVertex  += id => { Assert.Fail("This should not be called!"); };
            handler.NewEdge    += (oldEdgeId, newEdgeId) => { Assert.Fail("This should not be called!"); };
            handler.EdgeInside += id => { Assert.Fail("This should not be called!"); };

            handler.Run();
            Assert.IsTrue(handler.HasSucceeded);
        }
Beispiel #2
0
        public void TestOneEdgeIncluded()
        {
            var routerDb = new RouterDb();
            var network  = routerDb.Network;

            network.AddVertex(0, 51.268305f, 4.8014116287231445f);
            network.AddVertex(1, 51.2643048646482f, 4.797978401184082f);
            var edgeId = network.AddEdge(0, 1, new Itinero.Data.Network.Edges.EdgeData()
            {
                Distance = 57.69f,
                Profile  = 1,
                MetaId   = 10
            });

            var area = new PolygonArea(new Polygon()
            {
                ExteriorRing = new List <Coordinate>(new Coordinate[]
                {
                    new Coordinate(51.27391736369659f, 4.799566268920898f),
                    new Coordinate(51.258531028690626f, 4.78879451751709f),
                    new Coordinate(51.2665873439388f, 4.817891120910644f),
                    new Coordinate(51.27391736369659f, 4.799566268920898f)
                })
            });

            var handler = new AreaMetaDataHandler(routerDb, area);

            handler.NewVertex  += id => { Assert.Fail("This should not be called!"); };
            handler.NewEdge    += (oldEdgeId, newEdgeId) => { Assert.Fail("This should not be called!"); };
            handler.EdgeInside += id => { Assert.AreEqual(edgeId, id); };

            handler.Run();
            Assert.IsTrue(handler.HasSucceeded);
        }
Beispiel #3
0
        public void TestOneEdgeSplitInTwo()
        {
            var routerDb = new RouterDb();
            var network  = routerDb.Network;

            network.AddVertex(0, 51.26830584177533f, 4.8014116287231445f);
            network.AddVertex(1, 51.27440062061442f, 4.810037612915039f);
            var edgeId = network.AddEdge(0, 1, new Itinero.Data.Network.Edges.EdgeData()
            {
                Distance = 906.00f,
                Profile  = 1,
                MetaId   = 10
            });
            var futureNewVertexId = network.VertexCount;

            var area = new PolygonArea(new Polygon()
            {
                ExteriorRing = new List <Coordinate>(new Coordinate[]
                {
                    new Coordinate(51.27391736369659f, 4.799566268920898f),
                    new Coordinate(51.258531028690626f, 4.78879451751709f),
                    new Coordinate(51.2665873439388f, 4.817891120910644f),
                    new Coordinate(51.27391736369659f, 4.799566268920898f)
                })
            });

            var handler       = new AreaMetaDataHandler(routerDb, area);
            var newEdgeCalled = 0;
            var newEdges      = new HashSet <uint>();

            handler.NewVertex += id => { Assert.AreEqual(futureNewVertexId, id); };
            handler.NewEdge   += (oldEdgeId, newEdgeId) =>
            { // this should be called twice.
                newEdgeCalled++;
                Assert.AreEqual(edgeId, oldEdgeId);
                newEdges.Add(newEdgeId);
            };
            var edgeInsideCalled = 0;

            handler.EdgeInside += id =>
            { // this should be called only once.
                Assert.AreNotEqual(edgeId, id);
                Assert.IsTrue(newEdges.Contains(id));
                edgeInsideCalled++;
                Assert.AreEqual(1, edgeInsideCalled);
            };

            handler.Run();
            Assert.IsTrue(handler.HasSucceeded);
            Assert.AreEqual(2, newEdgeCalled);
        }