@@ -7,7 +7,7 @@ using ..SpatialTreeInterface
7
7
8
8
import .. GeometryOps as GO # TODO : only needed for NaturallyIndexedRing, remove when that is removed.
9
9
10
- export NaturalTree , NaturallyIndexedRing, prepare_naturally
10
+ export NaturalIndex , NaturallyIndexedRing, prepare_naturally
11
11
12
12
"""
13
13
NaturalLevel{E <: Extents.Extent}
124
124
125
125
# This is like a pointer to a node in the tree.
126
126
"""
127
- NaturalTreeNode {E <: Extents.Extent}
127
+ NaturalIndexNode {E <: Extents.Extent}
128
128
129
129
A reference to a node in the natural tree. Kind of like a tree cursor.
130
130
@@ -133,14 +133,14 @@ A reference to a node in the natural tree. Kind of like a tree cursor.
133
133
- `index` is the index of the node in the level
134
134
- `extent` is the extent of the node
135
135
"""
136
- struct NaturalTreeNode {E <: Extents.Extent }
136
+ struct NaturalIndexNode {E <: Extents.Extent }
137
137
parent_index:: NaturalIndex{E}
138
138
level:: Int
139
139
index:: Int
140
140
extent:: E
141
141
end
142
142
143
- Extents. extent (node:: NaturalTreeNode ) = node. extent
143
+ Extents. extent (node:: NaturalIndexNode ) = node. extent
144
144
145
145
# What does SpatialTreeInterface require of trees?
146
146
# - Parents completely cover their children
@@ -152,18 +152,18 @@ Extents.extent(node::NaturalTreeNode) = node.extent
152
152
# - `isleaf(node)` returns a boolean indicating whether the node is a leaf
153
153
# - `child_indices_extents(node)` returns an iterator over the indices and extents of the children of the node
154
154
155
- SpatialTreeInterface. isspatialtree (:: Type{<: NaturalIndexing } ) = true
156
- SpatialTreeInterface. isspatialtree (:: Type{<: NaturalTreeNode } ) = true
155
+ SpatialTreeInterface. isspatialtree (:: Type{<: NaturalIndex } ) = true
156
+ SpatialTreeInterface. isspatialtree (:: Type{<: NaturalIndexNode } ) = true
157
157
158
- function SpatialTreeInterface. nchild (node:: NaturalTreeNode )
158
+ function SpatialTreeInterface. nchild (node:: NaturalIndexNode )
159
159
start_idx = (node. index - 1 ) * node. parent_index. nodecapacity + 1
160
160
stop_idx = min (start_idx + node. parent_index. nodecapacity - 1 , length (node. parent_index. levels[node. level+ 1 ]. extents))
161
161
return stop_idx - start_idx + 1
162
162
end
163
163
164
- function SpatialTreeInterface. getchild (node:: NaturalTreeNode , i:: Int )
164
+ function SpatialTreeInterface. getchild (node:: NaturalIndexNode , i:: Int )
165
165
child_index = (node. index - 1 ) * node. parent_index. nodecapacity + i
166
- return NaturalTreeNode (
166
+ return NaturalIndexNode (
167
167
node. parent_index,
168
168
node. level + 1 , # increment level by 1
169
169
child_index, # index of this particular child
@@ -172,13 +172,13 @@ function SpatialTreeInterface.getchild(node::NaturalTreeNode, i::Int)
172
172
end
173
173
174
174
# Get all children of a node
175
- function SpatialTreeInterface. getchild (node:: NaturalTreeNode )
175
+ function SpatialTreeInterface. getchild (node:: NaturalIndexNode )
176
176
return (SpatialTreeInterface. getchild (node, i) for i in 1 : SpatialTreeInterface. nchild (node))
177
177
end
178
178
179
- SpatialTreeInterface. isleaf (node:: NaturalTreeNode ) = node. level == length (node. parent_index. levels) - 1
179
+ SpatialTreeInterface. isleaf (node:: NaturalIndexNode ) = node. level == length (node. parent_index. levels) - 1
180
180
181
- function SpatialTreeInterface. child_indices_extents (node:: NaturalTreeNode )
181
+ function SpatialTreeInterface. child_indices_extents (node:: NaturalIndexNode )
182
182
start_idx = (node. index - 1 ) * node. parent_index. nodecapacity + 1
183
183
stop_idx = min (start_idx + node. parent_index. nodecapacity - 1 , length (node. parent_index. levels[node. level+ 1 ]. extents))
184
184
return ((i, node. parent_index. levels[node. level+ 1 ]. extents[i]) for i in start_idx: stop_idx)
@@ -190,8 +190,8 @@ SpatialTreeInterface.isleaf(node::NaturalIndex) = length(node.levels) == 1
190
190
191
191
SpatialTreeInterface. nchild (node:: NaturalIndex ) = length (node. levels[1 ]. extents)
192
192
193
- SpatialTreeInterface. getchild (node:: NaturalIndex ) = SpatialTreeInterface. getchild (NaturalTreeNode (node, 0 , 1 , node. extent))
194
- SpatialTreeInterface. getchild (node:: NaturalIndex , i) = SpatialTreeInterface. getchild (NaturalTreeNode (node, 0 , 1 , node. extent), i)
193
+ SpatialTreeInterface. getchild (node:: NaturalIndex ) = SpatialTreeInterface. getchild (NaturalIndexNode (node, 0 , 1 , node. extent))
194
+ SpatialTreeInterface. getchild (node:: NaturalIndex , i) = SpatialTreeInterface. getchild (NaturalIndexNode (node, 0 , 1 , node. extent), i)
195
195
196
196
SpatialTreeInterface. child_indices_extents (node:: NaturalIndex ) = (i_ext for i_ext in enumerate (node. levels[1 ]. extents))
197
197
0 commit comments