Exemple #1
0
        private static IEnumerable <IEnumerable <Vector2> > FindSpecialBuildingsWithinDistanceFromHouse(
            IEnumerable <Vector2> specialBuildings,
            IEnumerable <Tuple <Vector2, float> > housesAndDistances)
        {
            KDNode <Vector2> buildingTree = new KDVectorTreeFactory().CreateTree(specialBuildings);

            return(new VectorTreeSearcher(buildingTree).SearchBuildingsWithinDistance(housesAndDistances));
        }
Exemple #2
0
        public void CreateTreeTest()
        {
            //Arange
            KDVectorTreeFactory   factory          = new KDVectorTreeFactory();
            IEnumerable <Vector2> specialBuildings = new List <Vector2>()
            {
                new Vector2(5, 6), new Vector2(6, 9), new Vector2(3, 3), new Vector2(9, 8), new Vector2(1, 1), new Vector2(2, 5)
            };
            KDNode <Vector2> expectedTree = new KDVectorNode(null, Dimension.X, new Vector2(5, 6));

            expectedTree.LeftChild            = new KDVectorNode(expectedTree, Dimension.Y, new Vector2(3, 3));
            expectedTree.LeftChild.LeftChild  = new KDVectorNode(expectedTree.LeftChild, Dimension.X, new Vector2(1, 1));
            expectedTree.LeftChild.RightChild = new KDVectorNode(expectedTree.LeftChild, Dimension.X, new Vector2(2, 5));
            expectedTree.RightChild           = new KDVectorNode(expectedTree, Dimension.Y, new Vector2(6, 9));
            expectedTree.RightChild.LeftChild = new KDVectorNode(expectedTree.RightChild, Dimension.Y, new Vector2(9, 8));

            //Act
            KDNode <Vector2> resultTree = factory.CreateTree(specialBuildings);

            //Assert
            checkNode(expectedTree, resultTree);
        }