public void TestRemoveNonExistent() { PointRegionQuadTree <object> tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100, 20, 20); Delete(tree, 10, 61); Set(tree, 10, 60, "P1"); Delete(tree, 10, 61); Set(tree, 10, 80, "P2"); Set(tree, 20, 70, "P3"); Set(tree, 10, 80, "P4"); AssertCollectAll(tree, "P1,P3,P4"); Assert.AreEqual(3, NavigateLeaf(tree, "").Count); Assert.AreEqual(3, NavigateLeaf(tree, "").Count); AssertCollectAll(tree, "P1,P3,P4"); Delete(tree, 10, 61); Assert.AreEqual(3, NavigateLeaf(tree, "").Count); AssertCollectAll(tree, "P1,P3,P4"); Delete(tree, 9, 60); Delete(tree, 10, 80); Assert.AreEqual(2, NavigateLeaf(tree, "").Count); AssertCollectAll(tree, "P1,P3"); Delete(tree, 9, 60); Delete(tree, 10, 80); Delete(tree, 10, 60); Assert.AreEqual(1, NavigateLeaf(tree, "").Count); AssertCollectAll(tree, "P3"); Delete(tree, 20, 70); Assert.AreEqual(0, NavigateLeaf(tree, "").Count); AssertCollectAll(tree, ""); }
public void TestPoints() { tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 10, 10); AddNonUnique(tree, 8.0, 4.0, "P0"); AssertFound(tree, 0, 0, 10, 10, "P0"); AddNonUnique(tree, 8.0, 1.0, "P1"); AssertFound(tree, 0, 0, 10, 10, "P0,P1"); AddNonUnique(tree, 8.0, 2.0, "P2"); AssertFound(tree, 0, 0, 10, 10, "P0,P1,P2"); AddNonUnique(tree, 4.0, 4.0, "P3"); AssertFound(tree, 0, 0, 10, 10, "P0,P1,P2,P3"); AddNonUnique(tree, 1.0, 9.0, "P4"); AssertFound(tree, 0, 0, 10, 10, "P0,P1,P2,P3,P4"); AddNonUnique(tree, 8.0, 3.0, "P5"); AssertFound(tree, 0, 0, 10, 10, "P0,P1,P2,P3,P4,P5"); AddNonUnique(tree, 0.0, 6.0, "P6"); AssertFound(tree, 0, 0, 10, 10, "P0,P1,P2,P3,P4,P5,P6"); AddNonUnique(tree, 5.0, 1.0, "P7"); AssertFound(tree, 0, 0, 10, 10, "P0,P1,P2,P3,P4,P5,P6,P7"); AddNonUnique(tree, 5.0, 8.0, "P8"); AssertFound(tree, 0, 0, 10, 10, "P0,P1,P2,P3,P4,P5,P6,P7,P8"); AddNonUnique(tree, 7.0, 6.0, "P9"); AssertFound(tree, 0, 0, 10, 10, "P0,P1,P2,P3,P4,P5,P6,P7,P8,P9"); }
public void TestFewValues() { tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100); Set(tree, 73.32704983331149, 23.46990952575032, "P0"); Set(tree, 53.09747562396894, 17.100976152185034, "P1"); Set(tree, 56.75757294858788, 25.508506696809608, "P2"); Set(tree, 83.66639067675291, 76.53772974832937, "P3"); Set(tree, 51.01654641861326, 43.49009281983866, "P4"); var beginX = 50.45945198254618; var endX = 88.31594559038719; var beginY = 4.577595744501329; var endY = 22.93393078279351; AssertCollect(tree, beginX, beginY, endX - beginX, endY - beginY, "P1"); AssertCollectAll(tree, "P0,P1,P2,P3,P4"); Assert.AreEqual("P0", PointRegionQuadTreeFilterIndexGet <object> .Get(73.32704983331149, 23.46990952575032, tree)); Assert.AreEqual("P1", PointRegionQuadTreeFilterIndexGet <object> .Get(53.09747562396894, 17.100976152185034, tree)); Assert.AreEqual("P2", PointRegionQuadTreeFilterIndexGet <object> .Get(56.75757294858788, 25.508506696809608, tree)); Assert.AreEqual("P3", PointRegionQuadTreeFilterIndexGet <object> .Get(83.66639067675291, 76.53772974832937, tree)); Assert.AreEqual("P4", PointRegionQuadTreeFilterIndexGet <object> .Get(51.01654641861326, 43.49009281983866, tree)); }
public void TestSubdivideAdd() { PointRegionQuadTree <object> tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100, 2, 3); AddNonUnique(tree, 0, 0, "P1"); AddNonUnique(tree, 0, 0, "P2"); AddNonUnique(tree, 0, 0, "P3"); Assert.AreEqual(3, NavigateLeaf(tree, "nw,nw").Count); }
public override EventTable Make( EventAdvancedIndexConfigStatement configStatement, AdvancedIndexConfigContextPartition configCP, EventTableOrganization organization) { var qt = (AdvancedIndexConfigContextPartitionQuadTree)configCP; var quadTree = PointRegionQuadTreeFactory <object> .Make(qt.X, qt.Y, qt.Width, qt.Height, qt.LeafCapacity, qt.MaxTreeHeight); return(new EventTableQuadTreePointRegionImpl(organization, (AdvancedIndexConfigStatementPointRegionQuadtree)configStatement, quadTree)); }
public void TestDimension() { PointRegionQuadTree <object> tree = PointRegionQuadTreeFactory <object> .Make(1000, 100000, 9000, 900000); Assert.IsFalse(AddNonUnique(tree, 10, 90, "P1")); Assert.IsFalse(AddNonUnique(tree, 10999999, 90, "P2")); Assert.IsTrue(AddNonUnique(tree, 5000, 800000, "P3")); AssertFound(tree, 0, 0, 10000000, 10000000, "P3"); AssertFound(tree, 4000, 790000, 1200, 11000, "P3"); AssertFound(tree, 4000, 790000, 900, 9000, ""); }
public FilterParamIndexQuadTreePointRegion(IReaderWriterLock readWriteLock, ExprFilterSpecLookupable lookupable) : base(FilterOperator.ADVANCED_INDEX, lookupable) { _readWriteLock = readWriteLock; _advancedIndex = (FilterSpecLookupableAdvancedIndex) lookupable; var quadTreeConfig = _advancedIndex.QuadTreeConfig; _quadTree = PointRegionQuadTreeFactory<object>.Make( quadTreeConfig.X, quadTreeConfig.Y, quadTreeConfig.Width, quadTreeConfig.Height); }
public void TestSuperSlim() { PointRegionQuadTree <object> tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100, 1, 100); AddNonUnique(tree, 10, 90, "P1"); AddNonUnique(tree, 10, 95, "P2"); PointRegionQuadTreeNodeLeaf <object> ne = NavigateLeaf(tree, "sw,sw,sw,ne"); Compare(10, 90, "\"P1\"", (XYPointMultiType)ne.Points); PointRegionQuadTreeNodeLeaf <object> se = NavigateLeaf(tree, "sw,sw,sw,se"); Compare(10, 95, "\"P2\"", (XYPointMultiType)se.Points); }
public void TestAddRemoveSimple() { tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 50, 60, 4, 20); AssertFound(tree, 0, 0, 10, 10, ""); AddNonUnique(tree, 5, 8, "P1"); AssertFound(tree, 0, 0, 10, 10, "P1"); AssertFound(tree, 0, 0, 5, 5, ""); Remove(tree, 5, 8, "P1"); AssertFound(tree, 0, 0, 10, 10, ""); }
public void TestSuperslim() { PointRegionQuadTree <object> tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100, 1, 100); Set(tree, 10, 90, "P1"); Set(tree, 10, 95, "P2"); PointRegionQuadTreeNodeLeaf <object> ne = NavigateLeaf(tree, "sw,sw,sw,ne"); Compare(10, 90, "P1", (XYPointWValue <object>)ne.Points); PointRegionQuadTreeNodeLeaf <object> se = NavigateLeaf(tree, "sw,sw,sw,se"); Compare(10, 95, "P2", (XYPointWValue <object>)se.Points); }
public void TestAddRemoveSamePoint() { tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100); AddNonUnique(tree, 5, 8, "P1"); AddNonUnique(tree, 5, 8, "P2"); AssertFound(tree, 0, 0, 10, 10, "P1,P2"); Remove(tree, 5, 8, "P1"); AssertFound(tree, 0, 0, 10, 10, "P2"); Remove(tree, 5, 8, "P2"); AssertFound(tree, 0, 0, 10, 10, ""); }
public void TestSetRemoveTwiceSamePoint() { tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100); Set(tree, 5, 8, "P1"); Set(tree, 5, 8, "P2"); AssertCollectAll(tree, "P2"); Delete(tree, 5, 8); AssertCollectAll(tree, ""); Delete(tree, 5, 8); AssertCollectAll(tree, ""); }
public void TestSubdivideAddMany() { PointRegionQuadTree <object> tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100, 2, 3); Set(tree, 0, 0, "P1"); Set(tree, 1, 2, "P2"); Set(tree, 3, 2, "P3"); Assert.AreEqual(3, NavigateLeaf(tree, "nw,nw").Count); Delete(tree, 1, 2); Delete(tree, 0, 0); Delete(tree, 3, 2); AssertCollectAll(tree, ""); }
public void TestSubdivideMultiChild() { PointRegionQuadTree <object> tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100, 4, 3); Set(tree, 60, 11, "P1"); Set(tree, 60, 40, "P2"); Set(tree, 70, 30, "P3"); Set(tree, 60, 10, "P4"); Set(tree, 90, 45, "P5"); NavigateLeaf(tree, "nw"); NavigateLeaf(tree, "se"); NavigateLeaf(tree, "sw"); PointRegionQuadTreeNodeBranch ne = NavigateBranch(tree, "ne"); Assert.AreEqual(2, ne.Level); PointRegionQuadTreeNodeLeaf <object> nw = NavigateLeaf(ne, "nw"); IList <XYPointWValue <object> > collection = (IList <XYPointWValue <object> >)nw.Points; Compare(60, 11, "P1", collection[0]); Compare(60, 10, "P4", collection[1]); Assert.AreEqual(2, nw.Count); PointRegionQuadTreeNodeLeaf <object> se = NavigateLeaf(ne, "se"); Compare(90, 45, "P5", (XYPointWValue <object>)se.Points); Assert.AreEqual(1, se.Count); PointRegionQuadTreeNodeLeaf <object> sw = NavigateLeaf(ne, "sw"); collection = (IList <XYPointWValue <object> >)sw.Points; Compare(60, 40, "P2", collection[0]); Compare(70, 30, "P3", collection[1]); Assert.AreEqual(2, sw.Count); Delete(tree, 60, 11); Delete(tree, 60, 40); PointRegionQuadTreeNodeLeaf <object> root = NavigateLeaf(tree, ""); collection = (IList <XYPointWValue <object> >)root.Points; Assert.AreEqual(3, root.Count); Assert.AreEqual(3, collection.Count); Compare(60, 10, "P4", collection[0]); Compare(70, 30, "P3", collection[1]); Compare(90, 45, "P5", collection[2]); }
public void TestGetSetRemove() { tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100); Assert.IsNull(PointRegionQuadTreeFilterIndexGet <object> .Get(10, 20, tree)); AssertCollectAll(tree, ""); PointRegionQuadTreeFilterIndexSet <object> .Set(10, 20, "P0", tree); Assert.AreEqual("P0", PointRegionQuadTreeFilterIndexGet <object> .Get(10, 20, tree)); AssertCollectAll(tree, "P0"); PointRegionQuadTreeFilterIndexDelete <object> .Delete(10, 20, tree); Assert.IsNull(PointRegionQuadTreeFilterIndexGet <object> .Get(10, 20, tree)); AssertCollectAll(tree, ""); }
public void TestSubdivideMultiChild() { PointRegionQuadTree <object> tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100, 4, 3); AddNonUnique(tree, 60, 10, "P1"); AddNonUnique(tree, 60, 40, "P2"); AddNonUnique(tree, 70, 30, "P3"); AddNonUnique(tree, 60, 10, "P4"); AddNonUnique(tree, 90, 45, "P5"); NavigateLeaf(tree, "nw"); NavigateLeaf(tree, "se"); NavigateLeaf(tree, "sw"); PointRegionQuadTreeNodeBranch ne = NavigateBranch(tree, "ne"); Assert.AreEqual(2, ne.Level); PointRegionQuadTreeNodeLeaf <object> nw = NavigateLeaf(ne, "nw"); Compare(60, 10, "[\"P1\", \"P4\"]", (XYPointMultiType)nw.Points); Assert.AreEqual(2, nw.Count); PointRegionQuadTreeNodeLeaf <object> se = NavigateLeaf(ne, "se"); Compare(90, 45, "\"P5\"", (XYPointMultiType)se.Points); Assert.AreEqual(1, se.Count); PointRegionQuadTreeNodeLeaf <object> sw = NavigateLeaf(ne, "sw"); var collection = AssertPointCollection(sw); Compare(60, 40, "\"P2\"", collection[0]); Compare(70, 30, "\"P3\"", collection[1]); Assert.AreEqual(2, sw.Count); Remove(tree, 60, 10, "P1"); Remove(tree, 60, 40, "P2"); PointRegionQuadTreeNodeLeaf <object> root = NavigateLeaf(tree, ""); collection = AssertPointCollection(root); Assert.AreEqual(3, root.Count); Assert.AreEqual(3, collection.Length); Compare(60, 10, "[\"P4\"]", collection[0]); Compare(70, 30, "\"P3\"", collection[1]); Compare(90, 45, "\"P5\"", collection[2]); }
public void TestSubdivideSingleMerge() { PointRegionQuadTree <object> tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100, 3, 2); AddNonUnique(tree, 65, 75, "P1"); AddNonUnique(tree, 80, 75, "P2"); AddNonUnique(tree, 80, 60, "P3"); AddNonUnique(tree, 80, 60, "P4"); AssertFound(tree, 60, 60, 21, 21, "P1,P2,P3,P4"); Assert.IsFalse(tree.Root is PointRegionQuadTreeNodeLeaf <object>); Assert.AreEqual(4, NavigateLeaf(tree, "se").Count); var collection = AssertPointCollection(NavigateLeaf(tree, "se")); Assert.That(collection, Has.Length.EqualTo(3)); Compare(65, 75, "\"P1\"", collection[0]); Compare(80, 75, "\"P2\"", collection[1]); Compare(80, 60, "[\"P3\", \"P4\"]", collection[2]); AddNonUnique(tree, 66, 78, "P5"); Remove(tree, 65, 75, "P1"); Remove(tree, 80, 60, "P3"); var leaf = NavigateLeaf(tree, "se"); collection = AssertPointCollection(leaf); Assert.That(leaf.Count, Is.EqualTo(3)); AssertFound(tree, 60, 60, 21, 21, "P2,P4,P5"); Assert.AreEqual(3, collection.Length); Compare(80, 75, "\"P2\"", collection[0]); Compare(80, 60, "[\"P4\"]", collection[1]); Compare(66, 78, "\"P5\"", collection[2]); Remove(tree, 66, 78, "P5"); AssertFound(tree, 60, 60, 21, 21, "P2,P4"); leaf = NavigateLeaf(tree, ""); Assert.AreEqual(2, leaf.Count); collection = AssertPointCollection(NavigateLeaf(tree, "")); Assert.That(collection, Has.Length.EqualTo(2)); Compare(80, 75, "\"P2\"", collection[0]); Compare(80, 60, "[\"P4\"]", collection[1]); }
public void TestFewValues() { tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100); AddNonUnique(tree, 73.32704983331149, 23.46990952575032, "P0"); AddNonUnique(tree, 53.09747562396894, 17.100976152185034, "P1"); AddNonUnique(tree, 56.75757294858788, 25.508506696809608, "P2"); AddNonUnique(tree, 83.66639067675291, 76.53772974832937, "P3"); AddNonUnique(tree, 51.01654641861326, 43.49009281983866, "P4"); var beginX = 50.45945198254618; var endX = 88.31594559038719; var beginY = 4.577595744501329; var endY = 22.93393078279351; AssertFound(tree, beginX, beginY, endX - beginX, endY - beginY, "P1"); }
public void TestDimension() { PointRegionQuadTree <object> tree = PointRegionQuadTreeFactory <object> .Make(1000, 100000, 9000, 900000); Assert.That( () => Set(tree, 10, 90, "P1"), Throws.Exception.With.Message.EqualTo( "Point (10.0d,90.0d) not in {MinX=1000.0d, MinY=100000.0d, MaxX=10000.0d, MaxY=1000000.0d}")); Assert.That( () => Set(tree, 10999999, 90, "P2"), Throws.Exception); Set(tree, 5000, 800000, "P3"); AssertCollect(tree, 0, 0, 10000000, 10000000, "P3"); AssertCollect(tree, 4000, 790000, 1200, 11000, "P3"); AssertCollect(tree, 4000, 790000, 900, 9000, ""); AssertCollectAll(tree, "P3"); }
public void TestSubdivideSingleMerge() { PointRegionQuadTree <object> tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100, 3, 2); Set(tree, 65, 75, "P1"); Set(tree, 81, 60, "P2"); Set(tree, 80, 60, "P3"); Set(tree, 80, 61, "P4"); AssertCollect(tree, 60, 60, 21, 21, "P1,P3,P4"); AssertCollectAll(tree, "P1,P2,P3,P4"); Assert.IsFalse(tree.Root is PointRegionQuadTreeNodeLeaf <object>); Assert.AreEqual(4, NavigateLeaf(tree, "se").Count); IList <XYPointWValue <object> > collection = (IList <XYPointWValue <object> >)NavigateLeaf(tree, "se").Points; Assert.AreEqual(4, collection.Count); Compare(65, 75, "P1", collection[0]); Compare(81, 60, "P2", collection[1]); Compare(80, 60, "P3", collection[2]); Compare(80, 61, "P4", collection[3]); Set(tree, 66, 78, "P5"); Delete(tree, 65, 75); Delete(tree, 80, 60); Assert.AreEqual(3, NavigateLeaf(tree, "se").Count); AssertCollectAll(tree, "P2,P4,P5"); Assert.AreEqual(3, collection.Count); Compare(81, 60, "P2", collection[0]); Compare(80, 61, "P4", collection[1]); Compare(66, 78, "P5", collection[2]); Delete(tree, 66, 78); AssertCollectAll(tree, "P2,P4"); Assert.AreEqual(2, NavigateLeaf(tree, "").Count); collection = (IList <XYPointWValue <object> >)NavigateLeaf(tree, "").Points; Assert.AreEqual(2, collection.Count); Compare(81, 60, "P2", collection[0]); Compare(80, 61, "P4", collection[1]); }
public void TestRemoveNonExistent() { PointRegionQuadTree <object> tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100, 20, 20); Remove(tree, 10, 61, "P1"); AddNonUnique(tree, 10, 60, "P1"); Remove(tree, 10, 61, "P1"); AddNonUnique(tree, 10, 80, "P2"); AddNonUnique(tree, 20, 70, "P3"); AddNonUnique(tree, 10, 80, "P4"); Assert.AreEqual(4, NavigateLeaf(tree, "").Count); AssertFound(tree, 10, 60, 10000, 10000, "P1,P2,P3,P4"); Remove(tree, 10, 61, "P1"); Remove(tree, 9, 60, "P1"); Remove(tree, 10, 60, "P2"); Remove(tree, 10, 80, "P1"); Assert.AreEqual(4, NavigateLeaf(tree, "").Count); AssertFound(tree, 10, 60, 10000, 10000, "P1,P2,P3,P4"); Remove(tree, 10, 80, "P4"); Assert.AreEqual(3, NavigateLeaf(tree, "").Count); AssertFound(tree, 10, 60, 10000, 10000, "P1,P2,P3"); Remove(tree, 10, 80, "P2"); Assert.AreEqual(2, NavigateLeaf(tree, "").Count); AssertFound(tree, 10, 60, 10000, 10000, "P1,P3"); Remove(tree, 10, 60, "P1"); Assert.AreEqual(1, NavigateLeaf(tree, "").Count); AssertFound(tree, 10, 60, 10000, 10000, "P3"); Remove(tree, 20, 70, "P3"); Assert.AreEqual(0, NavigateLeaf(tree, "").Count); AssertFound(tree, 10, 60, 10000, 10000, ""); }
public void TestSubdivideMerge() { PointRegionQuadTree <object> tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100, 3, 2); Assert.AreEqual(1, tree.Root.Level); Set(tree, 10, 10, "P1"); Set(tree, 9.9, 10, "P2"); Set(tree, 10, 9.9, "P3"); Set(tree, 10, 10, "P4"); Set(tree, 10, 9.9, "P5"); Set(tree, 9.9, 10, "P6"); Assert.IsInstanceOf <PointRegionQuadTreeNodeLeaf <object> >(tree.Root); AssertCollect(tree, 9, 10, 1, 1, "P6"); AssertCollect(tree, 10, 9, 1, 1, "P5"); AssertCollect(tree, 10, 10, 1, 1, "P4"); AssertCollect(tree, 9, 9, 2, 2, "P4,P5,P6"); AssertCollectAll(tree, "P4,P5,P6"); Set(tree, 10, 10, "P7"); Assert.IsInstanceOf <PointRegionQuadTreeNodeLeaf <object> >(tree.Root); Set(tree, 9.9, 9.9, "P8"); Assert.IsFalse(tree.Root is PointRegionQuadTreeNodeLeaf <object>); Assert.AreEqual(1, tree.Root.Level); Assert.AreEqual(4, NavigateLeaf(tree, "nw").Count); IList <XYPointWValue <object> > collection = (IList <XYPointWValue <object> >)NavigateLeaf(tree, "nw").Points; Assert.AreEqual(4, collection.Count); Compare(10, 10, "P7", collection[0]); Compare(9.9, 10, "P6", collection[1]); Compare(10, 9.9, "P5", collection[2]); Compare(9.9, 9.9, "P8", collection[3]); AssertCollect(tree, 9, 10, 1, 1, "P6"); AssertCollect(tree, 10, 9, 1, 1, "P5"); AssertCollect(tree, 10, 10, 1, 1, "P7"); AssertCollect(tree, 9, 9, 2, 2, "P5,P6,P7,P8"); AssertCollectAll(tree, "P5,P6,P7,P8"); Set(tree, 9.9, 10, "P9"); Set(tree, 10, 9.9, "P10"); Set(tree, 10, 10, "P11"); Set(tree, 10, 10, "P12"); Set(tree, 10, 10, "P13"); Assert.AreEqual(4, NavigateLeaf(tree, "nw").Count); Assert.AreEqual(2, NavigateLeaf(tree, "nw").Level); Assert.AreEqual(4, collection.Count); Compare(10, 10, "P13", collection[0]); Compare(9.9, 10, "P9", collection[1]); Compare(10, 9.9, "P10", collection[2]); Compare(9.9, 9.9, "P8", collection[3]); AssertCollect(tree, 9, 10, 1, 1, "P9"); AssertCollect(tree, 10, 9, 1, 1, "P10"); AssertCollect(tree, 10, 10, 1, 1, "P13"); AssertCollect(tree, 9, 9, 2, 2, "P8,P9,P10,P13"); Delete(tree, 9.9, 10); Delete(tree, 10, 9.9); Delete(tree, 10, 9.9); Delete(tree, 10, 9.9); AssertCollect(tree, 9, 10, 1, 1, ""); AssertCollect(tree, 10, 9, 1, 1, ""); AssertCollect(tree, 10, 10, 1, 1, "P13"); AssertCollect(tree, 9, 9, 2, 2, "P8,P13"); AssertCollectAll(tree, "P8,P13"); Assert.AreEqual(2, NavigateLeaf(tree, "").Count); collection = (IList <XYPointWValue <object> >)NavigateLeaf(tree, "").Points; Assert.AreEqual(2, collection.Count); Compare(10, 10, "P13", collection[0]); Compare(9.9, 9.9, "P8", collection[1]); Delete(tree, 9.9, 9.9); Delete(tree, 10, 10); Assert.IsInstanceOf <PointRegionQuadTreeNodeLeaf <object> >(tree.Root); Assert.AreEqual(0, NavigateLeaf(tree, "").Count); AssertCollectAll(tree, ""); }
public void TestSubdivideMultitypeMerge() { PointRegionQuadTree <object> tree = PointRegionQuadTreeFactory <object> .Make(0, 0, 100, 100, 6, 2); Assert.AreEqual(1, tree.Root.Level); AddNonUnique(tree, 10, 10, "P1"); AddNonUnique(tree, 9.9, 10, "P2"); AddNonUnique(tree, 10, 9.9, "P3"); AddNonUnique(tree, 10, 10, "P4"); AddNonUnique(tree, 10, 9.9, "P5"); AddNonUnique(tree, 9.9, 10, "P6"); Assert.IsInstanceOf <PointRegionQuadTreeNodeLeaf <object> >(tree.Root); AssertFound(tree, 9, 10, 1, 1, "P2,P6"); AssertFound(tree, 10, 9, 1, 1, "P3,P5"); AssertFound(tree, 10, 10, 1, 1, "P1,P4"); AssertFound(tree, 9, 9, 2, 2, "P1,P2,P3,P4,P5,P6"); AddNonUnique(tree, 10, 10, "P7"); Assert.IsFalse(tree.Root is PointRegionQuadTreeNodeLeaf <object>); Assert.AreEqual(1, tree.Root.Level); Assert.AreEqual(7, NavigateLeaf(tree, "nw").Count); var collection = AssertPointCollection(NavigateLeaf(tree, "nw")); Assert.That(collection, Has.Length.EqualTo(3)); Compare(10, 10, "[\"P1\", \"P4\", \"P7\"]", collection[0]); Compare(9.9, 10, "[\"P2\", \"P6\"]", collection[1]); Compare(10, 9.9, "[\"P3\", \"P5\"]", collection[2]); AssertFound(tree, 9, 10, 1, 1, "P2,P6"); AssertFound(tree, 10, 9, 1, 1, "P3,P5"); AssertFound(tree, 10, 10, 1, 1, "P1,P4,P7"); AssertFound(tree, 9, 9, 2, 2, "P1,P2,P3,P4,P5,P6,P7"); AddNonUnique(tree, 9.9, 10, "P8"); AddNonUnique(tree, 10, 9.9, "P9"); AddNonUnique(tree, 10, 10, "P10"); AddNonUnique(tree, 10, 10, "P11"); AddNonUnique(tree, 10, 10, "P12"); Assert.AreEqual(12, NavigateLeaf(tree, "nw").Count); Assert.AreEqual(2, NavigateLeaf(tree, "nw").Level); collection = AssertPointCollection(NavigateLeaf(tree, "nw")); Assert.That(collection, Has.Length.EqualTo(3)); Compare(10, 10, "[\"P1\", \"P4\", \"P7\", \"P10\", \"P11\", \"P12\"]", collection[0]); Compare(9.9, 10, "[\"P2\", \"P6\", \"P8\"]", collection[1]); Compare(10, 9.9, "[\"P3\", \"P5\", \"P9\"]", collection[2]); AssertFound(tree, 9, 10, 1, 1, "P2,P6,P8"); AssertFound(tree, 10, 9, 1, 1, "P3,P5,P9"); AssertFound(tree, 10, 10, 1, 1, "P1,P4,P7,P10,P11,P12"); AssertFound(tree, 9, 9, 2, 2, "P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12"); Remove(tree, 9.9, 10, "P8"); Remove(tree, 10, 9.9, "P3"); Remove(tree, 10, 9.9, "P5"); Remove(tree, 10, 9.9, "P9"); AssertFound(tree, 9, 10, 1, 1, "P2,P6"); AssertFound(tree, 10, 9, 1, 1, ""); AssertFound(tree, 10, 10, 1, 1, "P1,P4,P7,P10,P11,P12"); AssertFound(tree, 9, 9, 2, 2, "P1,P2,P4,P6,P7,P10,P11,P12"); Assert.AreEqual(8, NavigateLeaf(tree, "nw").Count); collection = AssertPointCollection(NavigateLeaf(tree, "nw")); Assert.That(collection, Has.Length.EqualTo(2)); Compare(10, 10, "[\"P1\", \"P4\", \"P7\", \"P10\", \"P11\", \"P12\"]", collection[0]); Compare(9.9, 10, "[\"P2\", \"P6\"]", collection[1]); Assert.IsFalse(tree.Root is PointRegionQuadTreeNodeLeaf <object>); Remove(tree, 9.9, 10, "P2"); Remove(tree, 10, 10, "P1"); Remove(tree, 10, 10, "P10"); Assert.IsInstanceOf <PointRegionQuadTreeNodeLeaf <object> >(tree.Root); Assert.AreEqual(5, NavigateLeaf(tree, "").Count); collection = AssertPointCollection(NavigateLeaf(tree, "")); Assert.That(collection, Has.Length.EqualTo(2)); Compare(10, 10, "[\"P4\", \"P7\", \"P11\", \"P12\"]", collection[0]); Compare(9.9, 10, "[\"P6\"]", collection[1]); AssertFound(tree, 9, 10, 1, 1, "P6"); AssertFound(tree, 10, 9, 1, 1, ""); AssertFound(tree, 10, 10, 1, 1, "P4,P7,P11,P12"); AssertFound(tree, 9, 9, 2, 2, "P4,P6,P7,P11,P12"); }