예제 #1
0
        public void DuplicateRoadFilterCheckColinearNoNeighborsTest1()
        {
            var pathsData = PointUtils.CreateFromPoints(
                new List <GpsCoordinate>()
            {
                new GpsCoordinate()
                {
                    x = -1
                },
            }, 2);

            var onlyOnePointInPathPoints = new List <PathPoint> {
                PathPoint.CreateFromPathData(pathsData[0])
            };

            var checkedPoints = new List <GpsCoordinate>()
            {
                new GpsCoordinate()
                {
                    x = -1
                },
            };

            Assert.IsFalse(DuplicateRoadFilter.AtLeastOneNeighborIsColinear(null, checkedPoints, 0));
            Assert.IsFalse(DuplicateRoadFilter.AtLeastOneNeighborIsColinear(onlyOnePointInPathPoints, checkedPoints, 0));
            Assert.IsFalse(DuplicateRoadFilter.AtLeastOneNeighborIsColinear(onlyOnePointInPathPoints, checkedPoints, 1));
        }
예제 #2
0
        public void DuplicateRoadFilterCheckColinearReversedNeighborsTest1()
        {
            var pathsData = PointUtils.CreateFromPoints(
                new List <GpsCoordinate>()
            {
                new GpsCoordinate()
                {
                    x = -1
                },
                new GpsCoordinate()
                {
                    x = 0
                },
                new GpsCoordinate()
                {
                    x = 1
                },

                new GpsCoordinate()
                {
                    x = 1, y = 3
                },
                new GpsCoordinate()
                {
                    x = 0, y = 3
                },
                new GpsCoordinate()
                {
                    x = -1, y = 3
                },
            }, 2);

            var pathPoints = new List <PathPoint> {
                PathPoint.CreateFromPathData(pathsData[0]), PathPoint.CreateFromPathData(pathsData[1])
            };

            var checkedPoints = new List <GpsCoordinate>()
            {
                new GpsCoordinate()
                {
                    x = 1
                },
                new GpsCoordinate()
                {
                    x = 0
                },
                new GpsCoordinate()
                {
                    x = -1
                },
            };

            Assert.IsTrue(DuplicateRoadFilter.AtLeastOneNeighborIsColinear(pathPoints, checkedPoints, 0));
        }
예제 #3
0
        public void DuplicateRoadFilterKeepReversedTest1()
        {
            var pathsData = PointUtils.CreateFromPoints(
                new List <GpsCoordinate>()
            {
                new GpsCoordinate()
                {
                    x = -1
                },
                new GpsCoordinate()
                {
                    x = 0
                },
                new GpsCoordinate()
                {
                    x = 1
                },

                new GpsCoordinate()
                {
                    x = 1, y = 3
                },
                new GpsCoordinate()
                {
                    x = 0, y = 3
                },
                new GpsCoordinate()
                {
                    x = -1, y = 3
                },
            }, 2);

            var filter = new DuplicateRoadFilter(2);

            filter.Process(pathsData);

            var pathList = (List <PathData>)pathsData;

            Assert.AreEqual(2, pathList.Count);

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

            Assert.AreEqual(3, pathList[1].Points.Count);
            Assert.AreEqual(1, pathList[1].Points[0].x);
            Assert.AreEqual(0, pathList[1].Points[1].x);
            Assert.AreEqual(-1, pathList[1].Points[2].x);
        }
예제 #4
0
        public void DuplicateRoadFilterParallelTooDistantTest1()
        {
            var pathsData = PointUtils.CreateFromPoints(
                new List <GpsCoordinate>()
            {
                new GpsCoordinate()
                {
                    x = 0
                },
                new GpsCoordinate()
                {
                    x = 7
                },
                new GpsCoordinate()
                {
                    x = 16
                },

                new GpsCoordinate()
                {
                    x = 1, y = 5
                },
                new GpsCoordinate()
                {
                    x = 9, y = 5
                },
                new GpsCoordinate()
                {
                    x = 18, y = 5
                },
            }, 10);

            var filter = new DuplicateRoadFilter(5);

            filter.Process(pathsData);

            var pathList = (List <PathData>)pathsData;

            Assert.AreEqual(2, pathList.Count);

            Assert.AreEqual(3, pathList[0].Points.Count);
            Assert.AreEqual(0, pathList[0].Points[0].x);
            Assert.AreEqual(7, pathList[0].Points[1].x);
            Assert.AreEqual(16, pathList[0].Points[2].x);

            Assert.AreEqual(3, pathList[1].Points.Count);
            Assert.AreEqual(1, pathList[1].Points[0].x);
            Assert.AreEqual(9, pathList[1].Points[1].x);
            Assert.AreEqual(18, pathList[1].Points[2].x);
        }
예제 #5
0
        public void DuplicateRoadFilterNothingToRemoveTest1()
        {
            var filter = new DuplicateRoadFilter(10);

            var paths = PointUtils.CreateFromPoints(
                new List <GpsCoordinate>()
            {
                new GpsCoordinate()
                {
                    x = 0
                },
                new GpsCoordinate()
                {
                    x = 1
                },
                new GpsCoordinate()
                {
                    x = 2
                },

                new GpsCoordinate()
                {
                    x = 140
                },
                new GpsCoordinate()
                {
                    x = 141
                },
                new GpsCoordinate()
                {
                    x = 142
                },
            }, 2);

            var connections = new PathConnections();

            filter.Process(paths, connections);

            var pathList = (List <PathData>)paths;

            Assert.AreEqual(2, pathList.Count);

            Assert.AreEqual(3, pathList[0].Points.Count);
            Assert.AreEqual(3, pathList[1].Points.Count);

            Assert.IsTrue(connections.IsEmpty());
        }
예제 #6
0
        public void DuplicateRoadFilterSimpleConnectionTest2()
        {
            var pathsData = PointUtils.CreateFromPoints(
                new List <GpsCoordinate>()
            {
                new GpsCoordinate()
                {
                    x = 0
                },
                new GpsCoordinate()
                {
                    x = 1
                },
                new GpsCoordinate()
                {
                    x = 2
                },

                new GpsCoordinate()
                {
                    x = 0, y = 1
                },
                new GpsCoordinate()
                {
                    x = 1, y = 1
                },
                new GpsCoordinate()
                {
                    x = 2, y = 2
                },
            }, 2);

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

            filter.Process(pathsData, connections);

            var pathList = (List <PathData>)pathsData;

            Assert.AreEqual(2, pathList.Count);

            Assert.IsFalse(connections.IsEmpty());
            Assert.IsTrue(connections.HasConnection(0, 1));
            Assert.IsTrue(!connections.HasConnection(1, 0));
        }
예제 #7
0
        public void DuplicateRoadFilterComingCloserAndParallelTest1()
        {
            var pathsData = PointUtils.CreateFromPoints(
                new List <GpsCoordinate>()
            {
                new GpsCoordinate()
                {
                    x = -3
                },
                new GpsCoordinate()
                {
                    x = -2
                },
                new GpsCoordinate()
                {
                    x = -1
                },
                new GpsCoordinate()
                {
                    x = 0
                },
                new GpsCoordinate()
                {
                    x = 1
                },
                new GpsCoordinate()
                {
                    x = 2
                },
                new GpsCoordinate()
                {
                    x = 3
                },

                new GpsCoordinate()
                {
                    x = -3, y = 3
                },
                new GpsCoordinate()
                {
                    x = -2, y = 2
                },
                new GpsCoordinate()
                {
                    x = -1, y = 1
                },
                new GpsCoordinate()
                {
                    x = 0, y = 0
                },
                new GpsCoordinate()
                {
                    x = 1, y = -0.1
                },
                new GpsCoordinate()
                {
                    x = 2, y = -0.2
                },
                new GpsCoordinate()
                {
                    x = 3, y = -0.3
                },
            }, 2);

            var filter = new DuplicateRoadFilter(3);

            filter.Process(pathsData);

            var pathList = (List <PathData>)pathsData;

            Assert.AreEqual(2, pathList.Count);

            Assert.AreEqual(7, pathList[0].Points.Count);
            Assert.AreEqual(-3, pathList[0].Points[0].x);
            Assert.AreEqual(-2, pathList[0].Points[1].x);
            Assert.AreEqual(-1, pathList[0].Points[2].x);
            Assert.AreEqual(0, pathList[0].Points[3].x);
            Assert.AreEqual(1, pathList[0].Points[4].x);
            Assert.AreEqual(2, pathList[0].Points[5].x);
            Assert.AreEqual(3, pathList[0].Points[6].x);

            Assert.AreEqual(4, pathList[1].Points.Count);
            Assert.AreEqual(-3, pathList[1].Points[0].x);
            Assert.AreEqual(-2, pathList[1].Points[1].x);
            Assert.AreEqual(-1, pathList[1].Points[2].x);
            Assert.AreEqual(0, pathList[1].Points[3].x);
        }
예제 #8
0
        public void DuplicateRoadFilter_V_NoParallelPointsTest1()
        {
            var pathsData = PointUtils.CreateFromPoints(
                new List <GpsCoordinate>()
            {
                new GpsCoordinate()
                {
                    x = 0
                },
                new GpsCoordinate()
                {
                    x = 1
                },
                new GpsCoordinate()
                {
                    x = 2
                },
                new GpsCoordinate()
                {
                    x = 3
                },
                new GpsCoordinate()
                {
                    x = 4
                },
                new GpsCoordinate()
                {
                    x = 5
                },


                new GpsCoordinate()
                {
                    x = 0, y = 2
                },
                new GpsCoordinate()
                {
                    x = 1, y = 1
                },
                new GpsCoordinate()
                {
                    x = 2, y = 0
                },
                new GpsCoordinate()
                {
                    x = 3, y = 0
                },
                new GpsCoordinate()
                {
                    x = 4, y = 1
                },
                new GpsCoordinate()
                {
                    x = 5, y = 2
                },
            }, 1.5f);

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

            filter.Process(pathsData, connections);

            var pathList = (List <PathData>)pathsData;

            Assert.AreEqual(2, pathList.Count);

            Assert.AreEqual(6, pathList[0].Points.Count);
            Assert.AreEqual(0, pathList[0].Points[0].x);
            Assert.AreEqual(1, pathList[0].Points[1].x);
            Assert.AreEqual(2, pathList[0].Points[2].x);
            Assert.AreEqual(3, pathList[0].Points[3].x);
            Assert.AreEqual(4, pathList[0].Points[4].x);
            Assert.AreEqual(5, pathList[0].Points[5].x);

            Assert.AreEqual(6, pathList[1].Points.Count);
            Assert.AreEqual(2, pathList[1].Points[0].y);
            Assert.AreEqual(1, pathList[1].Points[1].y);
            Assert.AreEqual(0, pathList[1].Points[2].y);
            Assert.AreEqual(0, pathList[1].Points[3].y);
            Assert.AreEqual(1, pathList[1].Points[4].y);
            Assert.AreEqual(2, pathList[1].Points[5].y);

            Assert.IsTrue(connections.IsEmpty());
        }
예제 #9
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());
        }