Skip to content

Commit eab32f2

Browse files
authored
Merge pull request #9 from rafaqz/leaf_extent
precalculate leaf extents and define for Extents.jl
2 parents 62948a4 + 78efacb commit eab32f2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/SortTileRecursiveTree.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@ end
2525

2626

2727
struct STRLeafNode{E}
28-
extents::E
28+
extent::E
29+
extents::Vector{E}
2930
indices::Vector{Int}
3031
end
32+
STRLeafNode(extents::Vector, indices::Vector) =
33+
STRLeafNode(foldl(Extents.union, extents), extents, indices)
3134

3235

33-
GI.extent(n::STRNode) = n.extent
34-
GI.extent(n::STRLeafNode) = foldl(Extents.union, n.extents)
36+
Extents.extent(n::STRNode) = n.extent
37+
Extents.extent(n::STRLeafNode) = n.extent
3538

3639

3740
function Base.show(io::IO, tree::SortTileRecursiveTree.STRtree)
@@ -55,7 +58,7 @@ function leafnodes(geoms; nodecapacity=10)
5558
S = ceil(Int, sqrt(P))
5659
x_splits = Iterators.partition(extents_indices, S * nodecapacity)
5760

58-
nodes = STRLeafNode{Vector{typeof(extents_indices[1][1])}}[]
61+
nodes = STRLeafNode{typeof(extents_indices[1][1])}[]
5962
for x_split in x_splits
6063
sort!(x_split;
6164
by=v -> (v[1][2][1] + v[1][2][2]) / 2, # [extent/index][dim][min/max] sort by y

0 commit comments

Comments
 (0)