File: test_index.py

package info (click to toggle)
python-rtree 0.8.3%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 376 kB
  • sloc: python: 1,611; makefile: 105; sh: 1
file content (23 lines) | stat: -rw-r--r-- 626 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import unittest

from rtree import index

from .data import boxes15


class IndexTests(unittest.TestCase):

    def test_stream_input(self):
        p = index.Property()
        sindex = index.Index(boxes15_stream(), properties=p)
        bounds = (0, 0, 60, 60)
        hits = sindex.intersection(bounds)
        self.assertEqual(sorted(hits), [0, 4, 16, 27, 35, 40, 47, 50, 76, 80])


def boxes15_stream(interleaved=True):
    for i, (minx, miny, maxx, maxy) in enumerate(boxes15):
        if interleaved:
            yield (i, (minx, miny, maxx, maxy), 42)
        else:
            yield (i, (minx, maxx, miny, maxy), 42)