示例#1
0
        public void SubGridsAboutOriginGiveCorrectPartition(int x, int y, int expectedPartition)
        {
            var func = new SubGridBasedSpatialAffinityFunction();

            var partition = func.GetPartition(new SubGridSpatialAffinityKey(0, Guid.NewGuid(), new SubGridCellAddress(x, y)));

            partition.Should().Be(expectedPartition);
        }
示例#2
0
        public void OriginLocationGivesPartitionZero()
        {
            var func = new SubGridBasedSpatialAffinityFunction();

            var partition = func.GetPartition(new SubGridSpatialAffinityKey(0, Guid.NewGuid(), new SubGridCellAddress(0, 0)));

            partition.Should().Be(0);
        }
示例#3
0
        public void CalculateSinglePartition_AtGridFalseOrigin()
        {
            var aff = new SubGridBasedSpatialAffinityFunction();

            var partition = aff.GetPartition(new SubGridSpatialAffinityKey(0, Guid.NewGuid(), SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset));

            partition.Should().Be(0);
        }
示例#4
0
        public void CalculateSinglePartition_AtGridAbsoluteOrigin()
        {
            var aff = new SubGridBasedSpatialAffinityFunction();

            var partition = aff.GetPartition(new SubGridSpatialAffinityKey(0, Guid.NewGuid(), 0, 0));

            partition.Should().Be(0);
        }
示例#5
0
        public void AllCellsInOriginSubGridGivePartitionZero()
        {
            var func = new SubGridBasedSpatialAffinityFunction();

            SubGridUtilities.SubGridDimensionalIterator((x, y) =>
            {
                var partition = func.GetPartition(new SubGridSpatialAffinityKey(0, Guid.NewGuid(), new SubGridCellAddress(x, y)));
                partition.Should().Be(0);
            });
        }
示例#6
0
        public void CalculatePartitions_32x32SubGridPatch_AtGridAbsoluteOrigin()
        {
            var aff = new SubGridBasedSpatialAffinityFunction();

            var partitions = new List <int>();

            for (int i = 0; i < SubGridTreeConsts.SubGridTreeDimension; i++)
            {
                for (int j = 0; j < SubGridTreeConsts.SubGridTreeDimension; j++)
                {
                    partitions.Add(aff.GetPartition(new SubGridSpatialAffinityKey(0, Guid.NewGuid(),
                                                                                  i * SubGridTreeConsts.SubGridTreeDimension,
                                                                                  j * SubGridTreeConsts.SubGridTreeDimension)));
                }
            }

            partitions.Count.Should().Be(SubGridTreeConsts.SubGridTreeCellsPerSubGrid);

            var hashSet = new HashSet <int>();

            partitions.ForEach(x => hashSet.Add(x));

            hashSet.Count.Should().Be(SubGridTreeConsts.SubGridTreeCellsPerSubGrid);
        }