-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
An interesting package. Thanks for sharing.
When I ran the first example, it does not return as expected.
Please have a look.
import numpy as np
from python_prtree import PRTree2D
idxes = np.array([1, 2])
rects is a list of (xmin, ymin, xmax, ymax)
rects = np.array([[0.0, 0.0, 1.0, 0.5],
[1.0, 1.5, 1.2, 3.0]])
prtree = PRTree2D(idxes, rects)
batch query
q = np.array([[0.5, 0.2, 0.6, 0.3],
[0.8, 0.5, 1.5, 3.5]])
result = prtree.batch_query(q)
print(result)
[[1], [1, 2]]
You can insert an additional rectangle by insert method,
prtree.insert(3, np.array([1.0, 1.0, 2.0, 2.0]))
q = np.array([[0.5, 0.2, 0.6, 0.3],
[0.8, 0.5, 1.5, 3.5]])
result = prtree.batch_query(q)
print(result)
[[1], [1, 2, 3]]
Plus, you can erase by an index.
prtree.erase(2)
result = prtree.batch_query(q)
print(result)
[[1], [1, 3]]
Non-batch query is also supported.
print(prtree.query(0.5, 0.5))
[1]
print(prtree.query((0.5, 0.5)))
[1]
=============================================
The final output look like as follows:
[[1], [2]]
[[1], [2, 3]]
[[1], [3]]
[]
[]
atksh
Metadata
Metadata
Assignees
Labels
No labels