Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
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));
        }
 private void Insert(Envelope env, string id)
 {
     hpRtree.Insert(env, id);
     stRtree.Insert(env, id);
 }
Ejemplo n.º 7
0
 public void Insert(Envelope itemEnv, T item)
 {
     _index.Insert(itemEnv, item);
 }