diff --git a/rstar/src/algorithm/bulk_load/bulk_load_sequential.rs b/rstar/src/algorithm/bulk_load/bulk_load_sequential.rs index 886cf8c..cdfa524 100644 --- a/rstar/src/algorithm/bulk_load/bulk_load_sequential.rs +++ b/rstar/src/algorithm/bulk_load/bulk_load_sequential.rs @@ -11,7 +11,7 @@ use num_traits::Float; use super::cluster_group_iterator::{calculate_number_of_clusters_on_axis, ClusterGroupIterator}; -fn bulk_load_recursive(elements: Vec, depth: usize) -> ParentNode +fn bulk_load_recursive(elements: Vec) -> ParentNode where T: RTreeObject, ::Point: Point, @@ -28,7 +28,6 @@ where let iterator = PartitioningTask::<_, Params> { number_of_clusters_on_axis, - depth, work_queue: vec![PartitioningState { current_axis: ::Point::DIMENSIONS, elements, @@ -50,7 +49,6 @@ struct PartitioningState { /// Successively partitions the given elements into cluster groups and finally into clusters. struct PartitioningTask { work_queue: Vec>, - depth: usize, number_of_clusters_on_axis: usize, _params: core::marker::PhantomData, } @@ -66,7 +64,7 @@ impl Iterator for PartitioningTask(elements, self.depth - 1); + let data = bulk_load_recursive::<_, Params>(elements); return RTreeNode::Parent(data).into(); } else { // The cluster group needs to be partitioned further along the next axis @@ -95,9 +93,7 @@ where ::Point: Point, Params: RTreeParams, { - let m = Params::MAX_SIZE; - let depth = (elements.len() as f32).log(m as f32).ceil() as usize; - bulk_load_recursive::<_, Params>(elements, depth) + bulk_load_recursive::<_, Params>(elements) } #[cfg(test)] diff --git a/rstar/src/algorithm/nearest_neighbor.rs b/rstar/src/algorithm/nearest_neighbor.rs index f120ebc..515ed5a 100644 --- a/rstar/src/algorithm/nearest_neighbor.rs +++ b/rstar/src/algorithm/nearest_neighbor.rs @@ -28,8 +28,7 @@ where T: PointDistance, { fn partial_cmp(&self, other: &Self) -> Option<::core::cmp::Ordering> { - // Inverse comparison creates a min heap - other.distance.partial_cmp(&self.distance) + Some(self.cmp(other)) } } @@ -40,7 +39,8 @@ where T: PointDistance, { fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { - self.partial_cmp(other).unwrap() + // Inverse comparison creates a min heap + other.distance.partial_cmp(&self.distance).unwrap() } } diff --git a/rstar/src/algorithm/rstar.rs b/rstar/src/algorithm/rstar.rs index ef49faa..0995460 100644 --- a/rstar/src/algorithm/rstar.rs +++ b/rstar/src/algorithm/rstar.rs @@ -150,7 +150,7 @@ where } } -fn choose_subtree(node: &mut ParentNode, to_insert: &RTreeNode) -> usize +fn choose_subtree(node: &ParentNode, to_insert: &RTreeNode) -> usize where T: RTreeObject, {