Skip to content

Does not work properly along borders and for points #37

@royalosyin

Description

@royalosyin

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]]
[]
[]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions