You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The R-tree should allow storing points in addition to rectangles.
When implementing query, a Point type was added to allow querying the R-tree using a point location (instead of a rectangle). It seems expected that if one can query using a point, one should be able to store an entry using Point also.
The initial thought is that RTreeBase.insert should accept a Location (which can be either Point or Rect), instead of Rect (which is the only type it accepts currently). Whether something like Point(3, 5) then gets converted to a degenerate rectangle such as Rect(3, 5, 3, 5) so it works with the existing algorithms unchanged, or whether the algorithms need to be adjusted, is something that needs to be investigated.
Using a "degenerate" rectangle such as Rect(1, 1, 1, 1) with the current code does not work with query, and currently results in unexpected behavior:
my_tree = RTree()
my_tree.insert("A", Rect(1, 1, 1, 1))
my_tree.insert("B", Rect(2, 2, 2, 2))
print(list(my_tree.query(Rect(0, 0, 5, 5)))) # is [] but expected "A" and "B"
# debug
found = list(my_tree.query_nodes(Rect(0, 0, 5, 5))) # returns one node
for x in found:
for b in x.entries:
print(b.rect.intersects(Rect(0, 0, 5, 5))) # always False
Proper handling of "degenerate" rectangles will be handled in #6.
The text was updated successfully, but these errors were encountered:
The R-tree should allow storing points in addition to rectangles.
When implementing
query
, aPoint
type was added to allow querying the R-tree using a point location (instead of a rectangle). It seems expected that if one can query using a point, one should be able to store an entry usingPoint
also.The initial thought is that
RTreeBase.insert
should accept aLocation
(which can be eitherPoint
orRect
), instead ofRect
(which is the only type it accepts currently). Whether something likePoint(3, 5)
then gets converted to a degenerate rectangle such asRect(3, 5, 3, 5)
so it works with the existing algorithms unchanged, or whether the algorithms need to be adjusted, is something that needs to be investigated.Using a "degenerate" rectangle such as
Rect(1, 1, 1, 1)
with the current code does not work withquery
, and currently results in unexpected behavior:Proper handling of "degenerate" rectangles will be handled in #6.
The text was updated successfully, but these errors were encountered: