fastquadtree 0.9.0__cp38-abi3-win_amd64.whl → 0.9.1__cp38-abi3-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastquadtree/_native.pyd +0 -0
- fastquadtree/pyqtree.py +14 -10
- {fastquadtree-0.9.0.dist-info → fastquadtree-0.9.1.dist-info}/METADATA +1 -1
- {fastquadtree-0.9.0.dist-info → fastquadtree-0.9.1.dist-info}/RECORD +6 -6
- {fastquadtree-0.9.0.dist-info → fastquadtree-0.9.1.dist-info}/WHEEL +0 -0
- {fastquadtree-0.9.0.dist-info → fastquadtree-0.9.1.dist-info}/licenses/LICENSE +0 -0
fastquadtree/_native.pyd
CHANGED
Binary file
|
fastquadtree/pyqtree.py
CHANGED
@@ -7,7 +7,7 @@ from __future__ import annotations
|
|
7
7
|
|
8
8
|
from typing import Any, Tuple
|
9
9
|
|
10
|
-
from .
|
10
|
+
from ._native import RectQuadTree
|
11
11
|
|
12
12
|
Point = Tuple[float, float] # only for type hints in docstrings
|
13
13
|
|
@@ -71,18 +71,15 @@ class Index:
|
|
71
71
|
"""
|
72
72
|
if bbox is not None:
|
73
73
|
x1, y1, x2, y2 = bbox
|
74
|
-
self.
|
75
|
-
(x1, y1, x2, y2), max_items, max_depth=max_depth, track_objects=True
|
76
|
-
)
|
74
|
+
self._qt = RectQuadTree((x1, y1, x2, y2), max_items, max_depth=max_depth)
|
77
75
|
|
78
76
|
elif (
|
79
77
|
x is not None and y is not None and width is not None and height is not None
|
80
78
|
):
|
81
|
-
self.
|
79
|
+
self._qt = RectQuadTree(
|
82
80
|
(x - width / 2, y - height / 2, x + width / 2, y + height / 2),
|
83
81
|
max_items,
|
84
82
|
max_depth=max_depth,
|
85
|
-
track_objects=True,
|
86
83
|
)
|
87
84
|
|
88
85
|
else:
|
@@ -90,6 +87,8 @@ class Index:
|
|
90
87
|
"Either the bbox argument must be set, or the x, y, width, and height arguments must be set"
|
91
88
|
)
|
92
89
|
|
90
|
+
self._id_to_obj: dict[int, Any] = {}
|
91
|
+
|
93
92
|
def insert(self, item: Any, bbox): # pyright: ignore[reportIncompatibleMethodOverride]
|
94
93
|
"""
|
95
94
|
Inserts an item into the quadtree along with its bounding box.
|
@@ -98,7 +97,8 @@ class Index:
|
|
98
97
|
- **item**: The item to insert into the index, which will be returned by the intersection method
|
99
98
|
- **bbox**: The spatial bounding box tuple of the item, with four members (xmin,ymin,xmax,ymax)
|
100
99
|
"""
|
101
|
-
self.
|
100
|
+
self._id_to_obj[id(item)] = item
|
101
|
+
self._qt.insert(id(item), bbox)
|
102
102
|
|
103
103
|
def remove(self, item, bbox):
|
104
104
|
"""
|
@@ -110,7 +110,10 @@ class Index:
|
|
110
110
|
|
111
111
|
Both parameters need to exactly match the parameters provided to the insert method.
|
112
112
|
"""
|
113
|
-
self.
|
113
|
+
self._qt.delete(id(item), bbox)
|
114
|
+
|
115
|
+
# Pops
|
116
|
+
self._id_to_obj.pop(id(item), None)
|
114
117
|
|
115
118
|
def intersect(self, bbox):
|
116
119
|
"""
|
@@ -123,5 +126,6 @@ class Index:
|
|
123
126
|
Returns:
|
124
127
|
- A list of inserted items whose bounding boxes intersect with the input bbox.
|
125
128
|
"""
|
126
|
-
|
127
|
-
|
129
|
+
results = self._qt.query(bbox)
|
130
|
+
# result = (id, x0, y0, x1, y1)
|
131
|
+
return [self._id_to_obj[result[0]] for result in results]
|
@@ -1,13 +1,13 @@
|
|
1
|
-
fastquadtree-0.9.
|
2
|
-
fastquadtree-0.9.
|
3
|
-
fastquadtree-0.9.
|
1
|
+
fastquadtree-0.9.1.dist-info/METADATA,sha256=kye0Fazqa8vr4j0YDt2dW-dhl7HOW8_xhvZJjF1-k1Y,9243
|
2
|
+
fastquadtree-0.9.1.dist-info/WHEEL,sha256=CG8OzNtm0LMpJ2zhrjswlO8N-965OeMLklsQAG-nMvQ,94
|
3
|
+
fastquadtree-0.9.1.dist-info/licenses/LICENSE,sha256=46IVFhoCIwMo-ocq4olyEB1eBvvtaKic5yGLeKXnDuc,1092
|
4
4
|
fastquadtree/__init__.py,sha256=jy7uimnd7QDllmNOgnRByKom1aONIKOWhCvCJxndsnM,200
|
5
5
|
fastquadtree/_base_quadtree.py,sha256=sfHAvKsWbrBX6RSUNi32Lh0fxCu8D6hAnyp1-SJj0Ok,8676
|
6
6
|
fastquadtree/_bimap.py,sha256=oNvJOk-BjYLo6aNJnG0i3uEQCq8FsUTGRE6c6_kVC2c,3439
|
7
7
|
fastquadtree/_item.py,sha256=cXiKXCjCfOWK19LUbxnzvAx6xffejd3F1axxYR9SMeM,1400
|
8
|
-
fastquadtree/_native.pyd,sha256=
|
8
|
+
fastquadtree/_native.pyd,sha256=_gxlEfX3srSGEOk64a8h1IlnxN7WUCAFPLO2Z7o68T4,264704
|
9
9
|
fastquadtree/point_quadtree.py,sha256=Xs2Igat4ekewnMd2wHVYu0pm7f7duvLdEcm_DUrO2B4,5744
|
10
10
|
fastquadtree/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
-
fastquadtree/pyqtree.py,sha256=
|
11
|
+
fastquadtree/pyqtree.py,sha256=bkxjgj61f5UL2jN_INgvqGtbKWJCA9DJfeufJyI19OM,4856
|
12
12
|
fastquadtree/rect_quadtree.py,sha256=jGt3ThbKKu4VsrdiLfsWuyyFIJRv2g_kJYOubO2FVeA,3619
|
13
|
-
fastquadtree-0.9.
|
13
|
+
fastquadtree-0.9.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|