From f528a07751c6ba1cc39cb0ecbd876c7190caa64c Mon Sep 17 00:00:00 2001 From: jpcaram Date: Sat, 27 Dec 2014 17:26:00 -0500 Subject: [PATCH] Added rtree test script. --- tests/test_rt.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/test_rt.py diff --git a/tests/test_rt.py b/tests/test_rt.py new file mode 100644 index 00000000..018781e6 --- /dev/null +++ b/tests/test_rt.py @@ -0,0 +1,24 @@ +from rtree import index as rtindex + + +def pt2rect(pt): + return pt[0], pt[1], pt[0], pt[1] + +pts = [(0.0, 0.0), (1.0, 1.0), (0.0, 1.0)] + +#p = rtindex.Property() +#p.buffering_capacity = 1 +#rt = rtindex.Index(properties=p) +rt = rtindex.Index() + +# If interleaved is True, the coordinates must be in +# the form [xmin, ymin, ..., kmin, xmax, ymax, ..., kmax]. +print rt.interleaved + +[rt.add(0, pt2rect(pt)) for pt in pts] +print [r.bbox for r in list(rt.nearest((0, 0), 10, True))] + +for pt in pts: + rt.delete(0, pt2rect(pt)) + print pt2rect(pt), [r.bbox for r in list(rt.nearest((0, 0), 10, True))] +