Skip to content

Commit 78efacb

Browse files
committed
precalculate leaf extents and define for Extents.jl
1 parent 985f9e0 commit 78efacb

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)
@@ -53,7 +56,7 @@ function leafnodes(geoms; nodecapacity=10)
5356
S = ceil(Int, sqrt(P))
5457
x_splits = Iterators.partition(sorted_extents, S * nodecapacity)
5558

56-
nodes = STRLeafNode{Vector{typeof(extents_indices[1][1])}}[]
59+
nodes = STRLeafNode{typeof(extents_indices[1][1])}[]
5760
for x_split in x_splits
5861
perm = sortperm(x_split; by=(v -> ((v[1][2][1] + v[1][2][2]) / 2))) # [extent/index][dim][min/max] sort by y
5962
sorted_split = x_split[perm]

0 commit comments

Comments
 (0)