public void PathConnectionComplexTest1()
        {
            var pathConnection = new PathConnections();

            pathConnection.Add(0, 4);

            var pathConnectionTracker = new PathConnectionsChecksTracker(pathConnection);

            pathConnection.Split(0, 5, 1, true);

            Assert.IsTrue(pathConnectionTracker.HasConnection(0, 5));
            Assert.IsTrue(pathConnectionTracker.HasConnection(1, 5));
            Assert.IsTrue(pathConnectionTracker.HasConnection(5, 4));
            Assert.IsTrue(pathConnectionTracker.AllConnectionsChecked());

            pathConnection.Split(5, 6, 2, false);

            Assert.IsTrue(pathConnectionTracker.HasConnection(0, 5));
            Assert.IsTrue(pathConnectionTracker.HasConnection(1, 5));
            Assert.IsTrue(pathConnectionTracker.HasConnection(5, 6));
            Assert.IsTrue(pathConnectionTracker.HasConnection(5, 2));
            Assert.IsTrue(pathConnectionTracker.HasConnection(6, 4));
            Assert.IsTrue(pathConnectionTracker.AllConnectionsChecked());

            pathConnection.Split(6, 7, 3, true);

            Assert.IsTrue(pathConnectionTracker.HasConnection(0, 5));
            Assert.IsTrue(pathConnectionTracker.HasConnection(1, 5));
            Assert.IsTrue(pathConnectionTracker.HasConnection(5, 6));
            Assert.IsTrue(pathConnectionTracker.HasConnection(5, 2));
            Assert.IsTrue(pathConnectionTracker.HasConnection(6, 7));
            Assert.IsTrue(pathConnectionTracker.HasConnection(3, 7));
            Assert.IsTrue(pathConnectionTracker.HasConnection(7, 4));
            Assert.IsTrue(pathConnectionTracker.AllConnectionsChecked());
        }
Пример #2
0
        public void DuplicateRoadFilterRemovalAndSplitTest1()
        {
            var pathsData = PointUtils.CreateFromPoints(
                new List <GpsCoordinate>()
            {
                new GpsCoordinate()
                {
                    x = 30
                },                                    //0
                new GpsCoordinate()
                {
                    x = 35
                },

                new GpsCoordinate()
                {
                    x = 46
                },                                    //1
                new GpsCoordinate()
                {
                    x = 48
                },


                new GpsCoordinate()
                {
                    x = 20
                },                                    //2
                new GpsCoordinate()
                {
                    x = 25
                },
                new GpsCoordinate()
                {
                    x = 27
                },

                new GpsCoordinate()
                {
                    x = 31
                },                                    //-
                new GpsCoordinate()
                {
                    x = 34
                },                                    //-
                new GpsCoordinate()
                {
                    x = 36
                },                                    //-

                new GpsCoordinate()
                {
                    x = 37
                },                                    //3
                new GpsCoordinate()
                {
                    x = 40
                },
                new GpsCoordinate()
                {
                    x = 43
                },
                new GpsCoordinate()
                {
                    x = 47
                },                                    //-
                new GpsCoordinate()
                {
                    x = 49
                },                                    //-
                new GpsCoordinate()
                {
                    x = 50
                },                                    //4
                new GpsCoordinate()
                {
                    x = 51
                },
            }, 5);

            var filter      = new DuplicateRoadFilter(1);
            var connections = new PathConnections();

            filter.Process(pathsData, connections);

            var pathList = (List <PathData>)pathsData;

            Assert.AreEqual(5, pathList.Count);

            Assert.AreEqual(2, pathList[0].Points.Count);
            Assert.AreEqual(30, pathList[0].Points[0].x);
            Assert.AreEqual(35, pathList[0].Points[1].x);

            Assert.AreEqual(2, pathList[1].Points.Count);
            Assert.AreEqual(46, pathList[1].Points[0].x);
            Assert.AreEqual(48, pathList[1].Points[1].x);

            Assert.AreEqual(3, pathList[2].Points.Count);
            Assert.AreEqual(20, pathList[2].Points[0].x);
            Assert.AreEqual(25, pathList[2].Points[1].x);
            Assert.AreEqual(27, pathList[2].Points[2].x);

            Assert.AreEqual(3, pathList[3].Points.Count);
            Assert.AreEqual(37, pathList[3].Points[0].x);
            Assert.AreEqual(40, pathList[3].Points[1].x);
            Assert.AreEqual(43, pathList[3].Points[2].x);

            Assert.AreEqual(2, pathList[4].Points.Count);
            Assert.AreEqual(50, pathList[4].Points[0].x);
            Assert.AreEqual(51, pathList[4].Points[1].x);

            var connectionsChecker = new PathConnectionsChecksTracker(connections);

            Assert.IsFalse(connectionsChecker.IsEmpty());
            Assert.IsTrue(connectionsChecker.HasConnection(2, 0));
            Assert.IsTrue(connectionsChecker.HasConnection(0, 3));
            Assert.IsTrue(connectionsChecker.HasConnection(3, 1));
            Assert.IsTrue(connectionsChecker.HasConnection(1, 4));
            Assert.IsTrue(connectionsChecker.AllConnectionsChecked());
        }
Пример #3
0
        public void RoadSplitterComplexConnectionTest1()
        {
            var paths = PointUtils.CreateFromPoints(
                new List <GpsCoordinate>()
            {
                new GpsCoordinate()
                {
                    x = 0
                },                                // 0
                new GpsCoordinate()
                {
                    x = 1
                },
                new GpsCoordinate()
                {
                    x = 2
                },
                new GpsCoordinate()
                {
                    x = 3
                },
                new GpsCoordinate()
                {
                    x = 4
                },
                new GpsCoordinate()
                {
                    x = 5
                },
                new GpsCoordinate()
                {
                    x = 6
                },

                new GpsCoordinate()
                {
                    x = 1, y = 2
                },                                       // 1
                new GpsCoordinate()
                {
                    x = 1, y = 1
                },
                new GpsCoordinate()
                {
                    x = 1, y = 0.1
                },

                new GpsCoordinate()
                {
                    x = 3, y = -0.1
                },                                          // 2
                new GpsCoordinate()
                {
                    x = 3, y = -1
                },
                new GpsCoordinate()
                {
                    x = 3, y = -2
                },

                new GpsCoordinate()
                {
                    x = 5, y = 2
                },                                       // 3
                new GpsCoordinate()
                {
                    x = 5, y = 1
                },
                new GpsCoordinate()
                {
                    x = 5, y = 0.1
                },

                new GpsCoordinate()
                {
                    x = 6.1
                },                                  //4
                new GpsCoordinate()
                {
                    x = 7
                },

                new GpsCoordinate()
                {
                    x = -2
                },                                 // 5
                new GpsCoordinate()
                {
                    x = -1
                },
                new GpsCoordinate()
                {
                    x = -0.1
                },
            }, 1);

            var pathConnections = new PathConnections();

            pathConnections.Add(0, 4);
            pathConnections.Add(1, 0);
            pathConnections.Add(0, 2);
            pathConnections.Add(3, 0);
            pathConnections.Add(5, 0);

            var splitter = new RoadSplitter(0.5f, pathConnections);

            splitter.Process(paths);

            var connectionsTracker = new PathConnectionsChecksTracker(pathConnections);

            Assert.IsTrue(connectionsTracker.HasConnection(5, 0));
            Assert.IsTrue(connectionsTracker.HasConnection(0, 6));
            Assert.IsTrue(connectionsTracker.HasConnection(1, 6));
            Assert.IsTrue(connectionsTracker.HasConnection(6, 7));
            Assert.IsTrue(connectionsTracker.HasConnection(6, 2));
            Assert.IsTrue(connectionsTracker.HasConnection(3, 8));
            Assert.IsTrue(connectionsTracker.HasConnection(7, 8));
            Assert.IsTrue(connectionsTracker.HasConnection(8, 4));
            Assert.IsTrue(connectionsTracker.AllConnectionsChecked());
        }