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

Function choose_best_axis_leaf

nodedb-spatial/src/rtree/split.rs:116–137  ·  view source on GitHub ↗
(entries: &mut [RTreeEntry], min_fill: usize)

Source from the content-addressed store, hash-verified

114}
115
116fn choose_best_axis_leaf(entries: &mut [RTreeEntry], min_fill: usize) -> usize {
117 let mut best_axis = 0;
118 let mut best_margin = f64::INFINITY;
119 for axis in 0..2 {
120 sort_entries_by_axis(entries, axis);
121 let mut margin_sum = 0.0;
122 for k in min_fill..=(entries.len() - min_fill) {
123 let left = entries[..k]
124 .iter()
125 .fold(entries[0].bbox, |a, e| a.union(&e.bbox));
126 let right = entries[k..]
127 .iter()
128 .fold(entries[k].bbox, |a, e| a.union(&e.bbox));
129 margin_sum += left.margin() + right.margin();
130 }
131 if margin_sum < best_margin {
132 best_margin = margin_sum;
133 best_axis = axis;
134 }
135 }
136 best_axis
137}
138
139fn choose_best_axis_internal(children: &mut [ChildRef], min_fill: usize) -> usize {
140 let mut best_axis = 0;

Callers 1

split_leaf_entriesFunction · 0.85

Calls 6

sort_entries_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