public void CanBoundingBox() { var qt = new PointQuadtree <int>(); Assert.False(qt.IsDirty); Assert.Equal(0, qt.ItemCount); Assert.Null(qt.BoundingBox); qt.Add(33, new Point(3, 3)); qt.Build(); Assert.NotNull(qt.BoundingBox); Assert.Equal(new Envelope(3, 3, 3, 3), qt.BoundingBox); qt.Add(55, new Point(5, 5)); qt.Build(); Assert.NotNull(qt.BoundingBox); Assert.Equal(new Envelope(3, 3, 5, 5), qt.BoundingBox); qt.Clear(); Assert.False(qt.IsDirty); Assert.Null(qt.BoundingBox); }
public void CanMaintainDirtyFlag() { var qt = new PointQuadtree <int>(); // New empty inverted index isn't dirty: Assert.False(qt.IsDirty); qt.Add(0, new Point(0, 0)); // After adding an item, it's dirty: Assert.True(qt.IsDirty); qt.Build(); // After building, the index is clean: Assert.False(qt.IsDirty); qt.Add(1, new Point(1, 1)); // After adding items, index is dirty: Assert.True(qt.IsDirty); qt.Clear(); // After clearing, index is empty and thus clean: Assert.False(qt.IsDirty); }
private void ShowStats <T>(PointQuadtree <T> qt) { if (qt.IsDirty) { qt.Build(); } _output.WriteLine($"Items: {qt.ItemCount}, Depth: {qt.MeanDepth} mean {qt.MaxDepth} max"); }
private static PointQuadtree <Place> GetSampleDataset() { var quadtree = new PointQuadtree <Place>(); quadtree.Add(Chicago, Chicago.Point); quadtree.Add(Mobile, Mobile.Point); quadtree.Add(Toronto, Toronto.Point); quadtree.Add(Buffalo, Buffalo.Point); quadtree.Add(Denver, Denver.Point); quadtree.Add(Omaha, Omaha.Point); quadtree.Add(Atlanta, Atlanta.Point); quadtree.Add(Miami, Miami.Point); // don't add Memphis quadtree.Build(); return(quadtree); }
private static PointQuadtree <Place> GetGlobalDataset() { var places = new[] { FernsehturmBerlin, ElizabethTowerLondon, NotreDameTourNord, NotreDameTourSud, EiffelTower, EsriRedlands, LadyLiberty, SydneyOpera, Anadyr, Josefstrasse21, Josefstrasse211, Josefstrasse212, Josefstrasse214, Josefstrasse216, Josefstrasse218, KigaliAirport, StMatthewIsland, Longyearbyen }; var quadtree = new PointQuadtree <Place>(); foreach (var place in places) { quadtree.Add(place, place.Point); } quadtree.Build(); return(quadtree); }