public void FindNeighborsThatSatisfyAGivenPredicate() { RBush <Box> bush = new RBush <Box>(); bush.BulkLoad(richData); IEnumerable <Box> result = bush.KnnToPointSearch(2, 4, 1, b => b.Version < 5); if (result.Count() == 1) { Box item = result.First(); if (item.Envelope.MinX == 3 && item.Envelope.MinY == 3 && item.Envelope.MaxX == 3 && item.Envelope.MaxY == 3 && item.Version == 2) { //Test passes. Found the correct item } else { //Could not find the correct item Assert.True(false); } } else { //Could not find the correct item Assert.True(false); } }
public void FindAllNeighborsForMaxDistance() { RBush <Box> bush = new RBush <Box>(); bush.BulkLoad(boxes); IEnumerable <Box> result = bush.KnnToPointSearch(40, 40, 0, maxDist: 10); foreach (Box resBox in result) { Assert.True(CalcBoxDist(resBox, 40, 40) <= 10); } }
public void DoesNotThrowIfRequestingTooManyItems() { RBush <Box> bush = new RBush <Box>(); bush.BulkLoad(boxes); try { IEnumerable <Box> result = bush.KnnToPointSearch(40, 40, 1000); } catch (Exception ex) { //Expected no exception Assert.True(false); } }
public void FindNNeighborsForMaxDistance() { RBush <Box> bush = new RBush <Box>(); bush.BulkLoad(boxes); IEnumerable <Box> result = bush.KnnToPointSearch(40, 40, 1, maxDist: 10); Assert.True(result.Count() == 1); Box resBox = result.First(); Assert.True(resBox.Envelope.MinX == 38); Assert.True(resBox.Envelope.MinY == 39); Assert.True(resBox.Envelope.MaxX == 39); Assert.True(resBox.Envelope.MaxY == 39); }
public void FindsNNeighbors() { RBush <Box> bush = new RBush <Box>(); bush.BulkLoad(boxes); IEnumerable <Box> result = bush.KnnToPointSearch(40, 40, 10); Box[] mustBeReturned = Box.CreateBoxes(new double[, ] { { 38, 39, 39, 39 }, { 35, 39, 38, 40 }, { 34, 43, 36, 44 }, { 29, 42, 33, 42 }, { 48, 38, 48, 40 }, { 31, 47, 33, 50 }, { 34, 29, 34, 32 }, { 29, 45, 31, 47 }, { 39, 52, 39, 56 }, { 57, 36, 61, 40 } }); Assert.True(result.Count() == result.Count()); int i = 0; foreach (Box resBox in result) { Box checkBox = mustBeReturned[i]; Assert.True(resBox.CompareTo(checkBox) == 0); i++; } }