Пример #1
0
		public void SearchTest()
		{
			DynamicRTree<int> rTree = new DynamicRTree<int>(new GuttmanQuadraticInsert<int>(),
			                                                new GuttmanQuadraticSplit<int>(), new DynamicRTreeBalanceHeuristic());

			addEntries(rTree);

			List<RTreeIndexEntry<int>> resultsList = new List<RTreeIndexEntry<int>>();

			resultsList.AddRange(rTree.Search(new BoundingBox(-100, -100, 5928.57523425, 3252.50803582)));
			Assert.AreEqual(8, resultsList.Count);
			resultsList.Clear();

			resultsList.AddRange(rTree.Search(new BoundingBox(0, 0, 100, 100)));
			Assert.AreEqual(6, resultsList.Count);
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 1; }));
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 2; }));
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 3; }));
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 6; }));
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 7; }));
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 8; }));
			resultsList.Clear();

			resultsList.AddRange(rTree.Search(new BoundingBox(1500, 1500, 1500, 1500)));
			Assert.AreEqual(2, resultsList.Count);
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 4; }));
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 5; }));
			resultsList.Clear();

			resultsList.AddRange(rTree.Search(new BoundingBox(100, 100, 100, 100)));
			Assert.AreEqual(4, resultsList.Count);
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 1; }));
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 2; }));
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 7; }));
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 8; }));
			resultsList.Clear();

			addRandomEntries(rTree);
			resultsList.AddRange(rTree.Search(new BoundingBox(100, 100, 100, 100)));
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 1; }));
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 2; }));
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 7; }));
			Assert.IsTrue(resultsList.Exists(delegate(RTreeIndexEntry<int> match) { return match.Value == 8; }));
			resultsList.Clear();

			rTree.Dispose();
		}