Exemplo n.º 1
0
        public void DoesNotThrowIfRequestingTooManyItemsForMaxDistance()
        {
            var bush = new RBush <Box>();

            bush.BulkLoad(boxes);

            bush.Knn(1000, 40, 40, maxDistance: 10);
        }
Exemplo n.º 2
0
        public void DoesNotThrowIfRequestingTooManyItems()
        {
            var bush = new RBush <Box>();

            bush.BulkLoad(boxes);

            bush.Knn(1000, 40, 40);
        }
Exemplo n.º 3
0
        public void FindsNNeighbors()
        {
            var bush = new RBush <Box>();

            bush.BulkLoad(boxes);
            var result   = bush.Knn(10, 40, 40);
            var expected = boxes
                           .OrderBy(b => b.DistanceTo(40, 40))
                           .Take(10)
                           .ToList();

            Assert.Equal(expected, result);
        }
Exemplo n.º 4
0
        public void FindAllNeighborsForMaxDistance()
        {
            var bush = new RBush <Box>();

            bush.BulkLoad(boxes);

            var result   = bush.Knn(0, 40, 40, maxDistance: 10);
            var expected = boxes
                           .Where(b => b.DistanceTo(40, 40) <= 10)
                           .OrderBy(b => b.DistanceTo(40, 40))
                           .ToList();

            Assert.Equal(expected, result);
        }
Exemplo n.º 5
0
        public void FindNeighborsThatSatisfyAGivenPredicate()
        {
            var bush = new RBush <Box>();

            bush.BulkLoad(richData);

            var result   = bush.Knn(1, 2, 4, predicate: b => b.Version < 5);
            var expected = richData
                           .Where(b => b.Version < 5)
                           .OrderBy(b => b.DistanceTo(2, 4))
                           .Take(1)
                           .ToList();

            Assert.Equal(expected, result);
        }