Example #1
0
def buildRtree(dataSetName, *B):
    global root
    global Bvalue

    Bvalue = 25
    if len(B) == 1 and B[0] != None:
        Bvalue = B[0]

    f = open(dataSetName, 'rt')
    nextLine = f.readline()
    # size of date set
    size = int(nextLine.strip('\n'))
    # read the first point and build a root
    nextLine = f.readline()
    point = Rtree.Point(scanRange.getPoint(nextLine))
    root = Rtree.Leaf(Bvalue, 1, point)
    root.addChild(point)

    # add the remained points
    nextLine = f.readline()
    while nextLine != '':
        point = Rtree.Point(scanRange.getPoint(nextLine))
        insert(root, point)
        nextLine = f.readline()

    f.close()
    print('R-tree has been built. B is:', Bvalue, 'Highest level is:',
          root.level)
    return root
Example #2
0
def buildRtree(dataSetName, *B):
    global root
    global Bvalue
    
    Bvalue = 25 # Upper limit of the node, initial 25.
    if len(B) == 1 and B[0] != None:
        Bvalue = B[0]
    f = open(dataSetName, 'rt')
    nextLine = f.readline()
    # size of date set
    size = int(nextLine.strip('\n'))
    # read the first point and build a root
    nextLine = f.readline()
    point = Rtree.Point(getPoint(nextLine))
    root = Rtree.Leaf(Bvalue, 1, point)
    root.addChild(point)
    # add the remained points
    nextLine = f.readline()
    while nextLine == '\n':
        nextLine = f.readline()
    while nextLine != '':
        point = Rtree.Point(getPoint(nextLine))
        insert(root, point)
        nextLine = f.readline()
        while nextLine == '\n':
            nextLine = f.readline()
    f.close()
    maintain(root)
    print('R-tree has been built. B is:', Bvalue,'. Highest level is:',root.level)
    '''print('第1层: ',root.attribute,'     ',root.bitmap)
    for child in root.childList:
        print('第2层: ',child.attribute,'    ',child.bitmap)
        for cc in child.childList:
            print('第3层: ', cc.attribute, '    ', cc.bitmap)
            for ccc in child.childList:
                print('第4层: ', ccc.attribute, '    ', ccc.bitmap)
                for aaa in ccc.childList:
                    print(aaa.x,' ',aaa.y,' ',aaa.attribute,aaa.bitmap)'''
                
    return root