MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / choose_best_axis_internal

Function choose_best_axis_internal

nodedb-spatial/src/rtree/split.rs:139–160  ·  view source on GitHub ↗
(children: &mut [ChildRef], min_fill: usize)

Source from the content-addressed store, hash-verified

137}
138
139fn choose_best_axis_internal(children: &mut [ChildRef], min_fill: usize) -> usize {
140 let mut best_axis = 0;
141 let mut best_margin = f64::INFINITY;
142 for axis in 0..2 {
143 sort_children_by_axis(children, axis);
144 let mut margin_sum = 0.0;
145 for k in min_fill..=(children.len() - min_fill) {
146 let left = children[..k]
147 .iter()
148 .fold(children[0].bbox, |a, c| a.union(&c.bbox));
149 let right = children[k..]
150 .iter()
151 .fold(children[k].bbox, |a, c| a.union(&c.bbox));
152 margin_sum += left.margin() + right.margin();
153 }
154 if margin_sum < best_margin {
155 best_margin = margin_sum;
156 best_axis = axis;
157 }
158 }
159 best_axis
160}
161
162fn choose_best_split_leaf(entries: &[RTreeEntry], min_fill: usize) -> usize {
163 let mut best_k = min_fill;

Callers 1

split_internal_childrenFunction · 0.85

Calls 6

sort_children_by_axisFunction · 0.85
foldMethod · 0.80
marginMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45
unionMethod · 0.45

Tested by

no test coverage detected