示例#1
0
 def test_bboxQuery_largedata(self):
     points = [Point(x, y, 1) for x, y in combinations(range(-200, 200), 2)]
     correct = list(filter(lambda f: f[0] >= -10 and f[0] <= 10 and f[1] >= -10 and f[1] <= 10, points))
     tree = RangeTree()
     tree.create(points)
     bbox = BBox(-10, -10, 10, 10)
     result = tree.bboxQuery(bbox)
     self.assertEqual(len(result), len(correct))
     self.assertEqual(set(correct), set(result))
示例#2
0
 def test_bboxQuery_miss(self):
     points = [
         Point(-2, 1, 1),
         Point(-1, 0, 1),
         Point(-2, 0, 1),
         Point(-2, 0, 1),
         Point(0, 0, 1),
         Point(1, 0, 1),
         Point(3, 3, 1),
     ]
     tree = RangeTree()
     tree.create(points)
     bbox = BBox(5, 5, 7, 7)
     result = tree.bboxQuery(bbox)
     self.assertEqual(result, [])
示例#3
0
 def test_bboxQuery_simple(self):
     points = [
         Point(-2, 1, 1),
         Point(-1, 0, 1),
         Point(-2, 0, 1),
         Point(0, 0, 1),
         Point(1, 0, 1),
         Point(3, 3, 1),
     ]
     correct = [
         Point(-2, 1, 1),
         Point(-1, 0, 1),
         Point(-2, 0, 1),
     ]
     tree = RangeTree()
     tree.create(points)
     bbox = BBox(-2.5, -2, -0.5, 2)
     result = tree.bboxQuery(bbox)
     self.assertEqual(len(result), len(correct))
     self.assertEqual(set(result), set(correct))