We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 57f34bd commit fe01ebeCopy full SHA for fe01ebe
2 files changed
src/rtree/rtree.jl
@@ -131,6 +131,19 @@ RTree{T,N}(::Type{V}; kwargs...) where {T,N,V} =
131
RTree{T,N}(::Type{K}, ::Type{V}; kwargs...) where {T,N,K,V} =
132
RTree{T,N,SpatialElem{T,N,K,V}}(; kwargs...)
133
134
+# create an empty R-tree of the same type and with the same settings as `tree`
135
+Base.similar(tree::RTree) =
136
+ typeof(tree)(variant=tree.variant,
137
+ tight_mbrs=tree.tight_mbrs,
138
+ branch_capacity=capacity(Branch, tree),
139
+ leaf_capacity=capacity(Leaf, tree),
140
+ leafpool_capacity=capacity(tree.leafpool),
141
+ branchpool_capacity=capacity(tree.branchpool),
142
+ nearmin_overlap=tree.nearmin_overlap,
143
+ fill_factor=tree.fill_factor,
144
+ splitdistribution_factor=tree.splitdistribution_factor,
145
+ reinsert_factor=tree.reinsert_factor)
146
+
147
mbrtype(::Type{<:RTree{T,N}}) where {T,N} = Rect{T,N}
148
mbrtype(tree::RTree) = mbrtype(typeof(tree))
149
regiontype(R::Type{<:RTree}) = mbrtype(R)
test/rtree.jl
@@ -85,6 +85,11 @@ end
85
@test length(collect(contained_in(tree, SI.Rect((0.0, 0.0), (0.55, 0.55))))) == 1 # a only
86
@test length(collect(intersects_with(tree, SI.Rect((0.0, 0.0), (0.55, 0.55))))) == 2 # a and c
87
88
+ tree2 = similar(tree)
89
+ @test typeof(tree2) === typeof(tree)
90
+ @test tree2 !== tree
91
+ @test isempty(tree2)
92
93
@testset "findfirst()" begin
94
@test findfirst(tree, ambr, 2) === nothing
95
@test_throws MethodError findfirst(tree, ambr, "1") # wrong key type
0 commit comments