public void BulkLoadSplitsTreeProperly() { var tree = new RTree <Point>(maxEntries: 4); tree.BulkLoad(points); tree.BulkLoad(points); Assert.AreEqual(points.Length * 2, tree.Count); Assert.AreEqual(4, tree.Root.Height); }
public void BasicRemoveTest() { var tree = new RTree <Point>(maxEntries: 4); tree.BulkLoad(points); var len = points.Length; tree.Delete(points[0]); tree.Delete(points[1]); tree.Delete(points[2]); tree.Delete(points[len - 1]); tree.Delete(points[len - 2]); tree.Delete(points[len - 3]); var shouldFindPoints = points .Skip(3).Take(len - 6) .OrderBy(x => x) .ToList(); var foundPoints = tree.Search() .OrderBy(x => x) .ToList(); Assert.AreEqual(shouldFindPoints, foundPoints); Assert.AreEqual(shouldFindPoints.Count, tree.Count); Assert.AreEqual( shouldFindPoints.Aggregate(Envelope.EmptyBounds, (e, p) => e.Extend(p.Envelope)), tree.Envelope); }
public void SearchReturnsEmptyResultIfNothingFound() { var tree = new RTree <Point>(maxEntries: 4); tree.BulkLoad(points); Assert.AreEqual(new Point[] { }, tree.Search(new Envelope(200, 200, 210, 210))); }
public void BulkLoadAfterDeleteTest2() { var pts = GetPoints(20); var ptsDelete = pts.Take(4); var tree = new RTree <Point>(maxEntries: 4); tree.BulkLoad(pts); foreach (var item in ptsDelete) { tree.Delete(item); } tree.BulkLoad(ptsDelete); Assert.AreEqual(pts.Count, tree.Search().Count); Assert.AreEqual(pts.OrderBy(x => x).ToList(), tree.Search().OrderBy(x => x).ToList()); }
public void NonExistentItemCanBeDeleted() { var tree = new RTree <Point>(maxEntries: 4); tree.BulkLoad(points); tree.Delete(new Point(13, 13, 13, 13)); Assert.AreEqual(points.Length, tree.Count); }
public void BulkLoadTestData() { var tree = new RTree <Point>(); tree.BulkLoad(points); Assert.AreEqual(points.Length, tree.Count); Assert.AreEqual(points.OrderBy(x => x).ToList(), tree.Search().OrderBy(x => x).ToList()); }
public void ClearWorks() { var tree = new RTree <Point>(maxEntries: 4); tree.BulkLoad(points); tree.Clear(); Assert.AreEqual(0, tree.Count); Assert.IsEmpty(tree.Root.children); }
public void TestSearchAfterBulkLoadWithSplitRoot() { var maxEntries = 4; var tree = new RTree <Point>(maxEntries); var numFirstSet = maxEntries * maxEntries + 2; // Split-root will occur twice. var firstSet = points.Take(numFirstSet); tree.BulkLoad(firstSet); var numExtraPoints = 5; var extraPointsSet = points.Skip(points.Length - numExtraPoints); var extraPointsSetEnvelope = extraPointsSet.Aggregate(Envelope.EmptyBounds, (e, p) => e.Extend(p.Envelope)); tree.BulkLoad(extraPointsSet); // first 10 entries and last 5 entries are completely mutually exclusive // so searching the bounds of the new set should only return the new set exactly Assert.AreEqual(extraPointsSet.OrderBy(x => x), tree.Search(extraPointsSetEnvelope).OrderBy(x => x)); }
public void BulkLoadMergesTreesProperly() { var smaller = GetPoints(10); var tree1 = new RTree <Point>(maxEntries: 4); tree1.BulkLoad(smaller); tree1.BulkLoad(points); var tree2 = new RTree <Point>(maxEntries: 4); tree2.BulkLoad(points); tree2.BulkLoad(smaller); Assert.True(tree1.Count == tree2.Count); Assert.True(tree1.Root.Height == tree2.Root.Height); var allPoints = points.Concat(smaller).OrderBy(x => x).ToList(); Assert.AreEqual(allPoints, tree1.Search().OrderBy(x => x).ToList()); Assert.AreEqual(allPoints, tree2.Search().OrderBy(x => x).ToList()); }
public void TestBulk() { var tree = new RTree <Point>(); tree.BulkLoad(missingEnvelopeTestData); var envelope = new Envelope( minX: 34.73274678, minY: 31.87729923, maxX: 34.73274678, maxY: 31.87729923); Assert.AreEqual( expected: tree.Search().Where(p => p.Envelope.Intersects(envelope)).Count(), actual: tree.Search(envelope).Count); }
public void SearchReturnsMatchingResults() { var tree = new RTree <Point>(maxEntries: 4); tree.BulkLoad(points); var searchEnvelope = new Envelope(40, 20, 80, 70); var shouldFindPoints = points .Where(p => p.Envelope.Intersects(searchEnvelope)) .OrderBy(x => x) .ToList(); var foundPoints = tree.Search(searchEnvelope) .OrderBy(x => x) .ToList(); Assert.AreEqual(shouldFindPoints, foundPoints); }
public void StartupBulkLoad() { staticTree.BulkLoad(staticEntities); staticTreeInitialized = true; }