-1

ポイントを含むrtreeがあります。つまり、左==右&&上==下です。

...
idx = index.Index()
....
*print list(idx.nearest((rand_point[0], rand_point[1], rand_point[0], rand_point[1])))
...
left, bottom, right, top = (newpoint[0], newpoint[1], newpoint[0], newpoint[1])
idx.insert(i, (left, bottom, right, top))
...

ドットの代わりに、'point'、'newpoint'、'i' およびループ内にあるすべてのものを定義する長いコードがあります。* でマークされた行は、次のようなものを返します。

[0L]
[0L]
[2L]
[2L]
[1L]
[4L]
[6L]
[5L].....

問題は、この出力を知っているポイント、つまり (左、下、右、上) を取得する方法です。

4

2 に答える 2

0

使用する

idx.nearest(.... objects="raw")

また

idx.nearest(.... objects=True)

IDだけでなく、実際のオブジェクトが必要な場合。

于 2014-04-29T22:50:44.917 に答える
0

私は解決策を見つけました:

    nearest_gen = idx.nearest((rand[0], rand[1], rand[0], rand[1]), objects=True)
    nearest_list = list(idx.nearest((rand[0], rand[1], rand[0], rand[1])))
    for j in nearest_gen:
        if j.id == nearest_list[0]:
            j.object
            print ['%.10f' % t for t in j.bbox]
于 2014-05-05T08:56:38.373 に答える