public void TestQuery() { var factory = GeometryFactory.Default; var geometries = new List <Geometry> { factory.CreateLineString(new[] { new Coordinate(0, 0), new Coordinate(10, 10) }), factory.CreateLineString(new[] { new Coordinate(20, 20), new Coordinate(30, 30) }), factory.CreateLineString(new[] { new Coordinate(20, 20), new Coordinate(30, 30) }) }; var t = new HPRtree <object>(3); foreach (var g in geometries) { t.Insert(g.EnvelopeInternal, new object()); } t.Query(new Envelope(5, 6, 5, 6)); try { Assert.That(t.Query(new Envelope(5, 6, 5, 6)).Count, Is.EqualTo(1)); Assert.That(t.Query(new Envelope(20, 30, 0, 10)).Count, Is.EqualTo(0)); Assert.That(t.Query(new Envelope(25, 26, 25, 26)).Count, Is.EqualTo(2)); Assert.That(t.Query(new Envelope(0, 100, 0, 100)).Count, Is.EqualTo(3)); } catch (Exception x) { //STRtreeDemo.printSourceData(geometries, System.out); //STRtreeDemo.printLevels(t, System.out); throw x; } }
private static void QueryGrid(int size, HPRtree <object> t) { for (int i = 0; i < size; i++) { t.Insert(new Envelope(i, i + 1, i, i + 1), i); } t.Query(new Envelope(0, 1, 0, 1)); Assert.That(t.Query(new Envelope(5, 6, 5, 6)).Count, Is.EqualTo(3)); Assert.That(t.Query(new Envelope(9, 10, 9, 10)).Count, Is.EqualTo(3)); Assert.That(t.Query(new Envelope(25, 26, 25, 26)).Count, Is.EqualTo(3)); Assert.That(t.Query(new Envelope(0, 10, 0, 10)).Count, Is.EqualTo(11)); }
public void TestQuery3() { var t = new HPRtree <object>(); for (int i = 0; i < 3; i++) { t.Insert(new Envelope(i, i + 1, i, i + 1), i); } t.Query(new Envelope(0, 1, 0, 1)); Assert.That(t.Query(new Envelope(1, 2, 1, 2)).Count, Is.EqualTo(3)); Assert.That(t.Query(new Envelope(9, 10, 9, 10)).Count, Is.EqualTo(0)); }
public void TestQuery10() { var t = new HPRtree <object>(); for (int i = 0; i < 10; i++) { t.Insert(new Envelope(i, i + 1, i, i + 1), i); } t.Query(new Envelope(0, 1, 0, 1)); Assert.That(t.Query(new Envelope(5, 6, 5, 6)).Count, Is.EqualTo(3)); Assert.That(t.Query(new Envelope(9, 10, 9, 10)).Count, Is.EqualTo(2)); Assert.That(t.Query(new Envelope(25, 26, 25, 26)).Count, Is.EqualTo(0)); Assert.That(t.Query(new Envelope(0, 10, 0, 10)).Count, Is.EqualTo(10)); }
public void TestEmptyTreeUsingListQuery() { var tree = new HPRtree <object>(); var list = tree.Query(new Envelope(0, 0, 1, 1)); Assert.That(list.Count, Is.EqualTo(0)); }
public void RunQueries() { var visitor = new CountItemVisitor <object>(); int size = _index.Count; int side = (int)Math.Sqrt(size); for (int i = 0; i < side; i++) { for (int j = 0; j < side; j++) { var env = new Envelope(i, i + QUERY_ENV_SIZE, j, j + QUERY_ENV_SIZE); _index.Query(env, visitor); } } Console.WriteLine($"Total query result items = {visitor.Count}"); }
public void TestDisallowedInserts() { var t = new HPRtree <object>(3); t.Insert(new Envelope(0, 0, 0, 0), new object()); t.Insert(new Envelope(0, 0, 0, 0), new object()); t.Query(new Envelope()); try { t.Insert(new Envelope(0, 0, 0, 0), new object()); Assert.Fail(); } catch (InvalidOperationException) { Assert.That(true); } }
private void QueryRandom() { var env = RandomEnvelope(BASE_MIN, BASE_MAX, 10 * SIZE_MAX); var hpVisitor = new CountItemVisitor <object>(); hpRtree.Query(env, hpVisitor); //List hpResult = hpRtree.query(env); IList <string> hprResult = null; //CountItemVisitor stVisitor = new CountItemVisitor(); //stRtree.query(env, stVisitor); //List strResult = stRtree.query(env); IList <string> strResult = null; CheckResults(hprResult, strResult); }
public IList <T> Query(Envelope searchEnv) { return(_index.Query(searchEnv)); }
public void TestEmptyTreeUsingItemVisitorQuery() { var tree = new HPRtree <object>(0); tree.Query(new Envelope(0, 0, 1, 1), new ShouldNeverReachHereItemVisitor()); }