def test_4d_rtree():
    """Testing the rtree ctypes wrapper"""

    tree = rtree.RTreeCreateTree(-1, 0, 4)

    for i in range(10):

        # Allocate the boundary
        rect = rtree.RTreeAllocRect(tree)
        rtree.RTreeSetRect4D(rect, tree, float(i - 2), float(i + 2),
                             float(i - 2), float(i + 2), float(i - 2),
                             float(i + 2), float(i - 2), float(i + 2))
        rtree.RTreeInsertRect(rect, i + 1, tree)

    rect = rtree.RTreeAllocRect(tree)
    rtree.RTreeSetRect4D(rect, tree, 2.0, 7.0, 2.0, 7.0, 2.0, 7.0, 2.0, 7.0)

    list_ = gis.ilist()

    num = vector.RTreeSearch2(tree, rect, byref(list_))

    rtree.RTreeFreeRect(rect)

    # print rectangle ids
    print("Number of overlapping rectangles", num)
    for i in range(list_.n_values):
        print("id", list_.value[i])

    rtree.RTreeDestroyTree(tree)
Example #2
0
def test_3d_rtree():
    """Testing the rtree ctypes wrapper"""

    tree = rtree.RTreeCreateTree(-1, 0, 3)

    for i in range(10):

        rect = rtree.RTreeAllocRect(tree)
        rtree.RTreeSetRect3D(rect, tree,
                             float(i - 2), float(i + 2),
                             float(i - 2), float(i + 2),
                             float(i - 2), float(i + 2))
        rtree.RTreeInsertRect(rect, i + 1, tree)
        print(i + 1)
        rtree.RTreePrintRect(rect, 1, tree)

    rect = rtree.RTreeAllocRect(tree)
    rtree.RTreeSetRect3D(rect, tree, 2.0, 7.0, 2.0, 7.0, 2.0, 7.0)
    print("Select")
    rtree.RTreePrintRect(rect, 1, tree)

    list_ = gis.ilist()

    num = vector.RTreeSearch2(tree, rect, byref(list_))
    rtree.RTreeFreeRect(rect)

    # print rectangle ids
    print("Number of overlapping rectangles", num)
    for i in range(list_.n_values):
        print("id", list_.value[i])

    rtree.RTreeDestroyTree(tree)
Example #3
0
def test_4d_rtree():
    """Testing the rtree ctypes wrapper"""

    tree = rtree.RTreeCreateTree(-1, 0, 4)

    for i in xrange(10):

        # Allocate the boundary
        rect = rtree.RTreeAllocRect(tree)
        rtree.RTreeSetRect4D(rect, tree,
                             float(i - 2), float(i + 2),
                             float(i - 2), float(i + 2),
                             float(i - 2), float(i + 2),
                             float(i - 2), float(i + 2))
        rtree.RTreeInsertRect(rect, i + 1, tree)

    rect = rtree.RTreeAllocRect(tree)
    rtree.RTreeSetRect4D(rect, tree, 2.0, 7.0, 2.0,
                         7.0, 2.0, 7.0, 2.0, 7.0)

    list_ = gis.ilist()

    num = vector.RTreeSearch2(tree, rect, byref(list_))

    rtree.RTreeFreeRect(rect)

    # print rectangle ids
    print "Number of overlapping rectangles", num
    for i in xrange(list_.n_values):
        print "id", list_.value[i]

    rtree.RTreeDestroyTree(tree)
Example #4
0
def test_3d_rtree():
    """Testing the rtree ctypes wrapper"""

    tree = rtree.RTreeCreateTree(-1, 0, 3)

    for i in xrange(10):

        rect = rtree.RTreeAllocRect(tree)
        rtree.RTreeSetRect3D(rect, tree, float(i - 2), float(i + 2),
                             float(i - 2), float(i + 2), float(i - 2),
                             float(i + 2))
        rtree.RTreeInsertRect(rect, i + 1, tree)
        print i + 1
        rtree.RTreePrintRect(rect, 1, tree)

    rect = rtree.RTreeAllocRect(tree)
    rtree.RTreeSetRect3D(rect, tree, 2.0, 7.0, 2.0, 7.0, 2.0, 7.0)
    print "Select"
    rtree.RTreePrintRect(rect, 1, tree)

    list_ = gis.ilist()

    num = vector.RTreeSearch2(tree, rect, byref(list_))
    rtree.RTreeFreeRect(rect)

    # print rectangle ids
    print "Number of overlapping rectangles", num
    for i in xrange(list_.n_values):
        print "id", list_.value[i]

    rtree.RTreeDestroyTree(tree)