Пример #1
0
    def testPointQuery(self):
        xs = [TstO(r) for r in take(1000, G.rect, 0.01)]
        tree = RTree()
        for x in xs:
            tree.insert(x, x.rect)
            self.invariants(tree)

        for x in xs:
            qp = G.pointInside(x.rect)
            self.assertTrue(x.rect.does_containpoint(qp))
            op = G.pointOutside(x.rect)
            rs = list([r.leaf_obj() for r in tree.query_point(qp)])
            self.assertTrue(x in rs, "Not in results of len %d :(" % (len(rs)))
            rrs = list([r.leaf_obj() for r in tree.query_point(op)])
            self.assertFalse(x in rrs)
Пример #2
0
 def testPointQuery(self):
     xs = [ TstO(r) for r in take(1000,G.rect, 0.01) ]
     tree = RTree()
     for x in xs:
         tree.insert(x,x.rect)
         self.invariants(tree)
     
     for x in xs:
         qp = G.pointInside(x.rect)
         self.assertTrue(x.rect.does_containpoint(qp))
         op = G.pointOutside(x.rect)
         rs = list([r.leaf_obj() for r in tree.query_point(qp)])
         self.assertTrue(x in rs, "Not in results of len %d :(" % (len(rs)))
         rrs = list([r.leaf_obj() for r in tree.query_point(op)])
         self.assertFalse(x in rrs)
Пример #3
0
    def testRectQuery(self):
        xs = [TstO(r) for r in take(1000, G.rect, 0.01)]
        rt = RTree()
        for x in xs:
            rt.insert(x, x.rect)
            self.invariants(rt)

        for x in xs:
            qrect = G.intersectingWith(x.rect)
            orect = G.disjointWith(x.rect)
            self.assertTrue(qrect.does_intersect(x.rect))
            p = G.pointInside(x.rect)
            res = list([ro.leaf_obj() for ro in rt.query_point(p)])
            self.invariants(rt)
            self.assertTrue(x in res)
            res2 = list([r.leaf_obj() for r in rt.query_rect(qrect)])
            self.assertTrue(x in res2)
            rres = list([r.leaf_obj() for r in rt.query_rect(orect)])
            self.assertFalse(x in rres)
Пример #4
0
    def testRectQuery(self):
        xs = [ TstO(r) for r in take(1000, G.rect, 0.01) ]
        rt = RTree()
        for x in xs: 
            rt.insert(x,x.rect)
            self.invariants(rt)

        for x in xs:
            qrect = G.intersectingWith(x.rect)
            orect = G.disjointWith(x.rect)
            self.assertTrue(qrect.does_intersect(x.rect))
            p = G.pointInside(x.rect)
            res = list([ro.leaf_obj() for ro in rt.query_point(p)])
            self.invariants(rt)
            self.assertTrue(x in res)
            res2 = list([r.leaf_obj() for r in rt.query_rect(qrect)])
            self.assertTrue(x in res2)
            rres = list([r.leaf_obj() for r in rt.query_rect(orect)])
            self.assertFalse(x in rres)
Пример #5
0
    #
    # p = plt.Rectangle(
    #  (x1, y1), wi, he,angle=0 ,fill=False
    #
    #  )
    # ax.add_patch(p)

    st = "tag" + str(i)
    i += 1
    #print st
    t.insert(st, Rect(x1, y1, x2, y2))
'''
querying
'''

point_res = t.query_point((2, 1025))
# rect_res = t.query_rect( Rect(0,1020,4,1040) )

rectx1 = 0
recty1 = 1020
rectx2 = 4
recty2 = 1040

tempx1 = -1000.0
tempy1 = 1030.0
tempx2 = -972.5
tempy2 = 1000.0
wi = rectx2 - rectx1
he = recty2 - recty1

p = plt.Rectangle((rectx1, recty1), wi, he, angle=0, fill=False)