Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-export nearest neighbor iterators so they are nameable in downstream crates. #186

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions rstar/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Unreleased

## Added
- Added missing re-exports of nearest neighbor iterators so they can be named in downstream crates. ([PR](https://github.com/georust/rstar/pull/186))

# 0.12.2

## Changed
Expand Down
1 change: 1 addition & 0 deletions rstar/src/algorithm/iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::RTree;
use smallvec::SmallVec;

pub use super::intersection_iterator::IntersectionIterator;
pub use super::nearest_neighbor::{NearestNeighborDistance2Iterator, NearestNeighborIterator};
pub use super::removal::{DrainIterator, IntoIter};

/// Iterator returned by [`RTree::locate_all_at_point`].
Expand Down
15 changes: 13 additions & 2 deletions rstar/src/algorithm/nearest_neighbor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ use crate::node::{ParentNode, RTreeNode};
use crate::point::{min_inline, Point};
use crate::{Envelope, PointDistance, RTreeObject};

#[cfg(doc)]
use crate::RTree;

use alloc::collections::BinaryHeap;
#[cfg(not(test))]
use alloc::{vec, vec::Vec};
Expand Down Expand Up @@ -51,7 +54,10 @@ impl<'a, T> NearestNeighborDistance2Iterator<'a, T>
where
T: PointDistance,
{
pub fn new(root: &'a ParentNode<T>, query_point: <T::Envelope as Envelope>::Point) -> Self {
pub(crate) fn new(
root: &'a ParentNode<T>,
query_point: <T::Envelope as Envelope>::Point,
) -> Self {
let mut result = NearestNeighborDistance2Iterator {
nodes: SmallHeap::new(),
query_point,
Expand Down Expand Up @@ -106,6 +112,7 @@ where
}
}

/// Iterator returned by [`RTree::nearest_neighbor_iter_with_distance_2`].
pub struct NearestNeighborDistance2Iterator<'a, T>
where
T: PointDistance + 'a,
Expand All @@ -118,7 +125,10 @@ impl<'a, T> NearestNeighborIterator<'a, T>
where
T: PointDistance,
{
pub fn new(root: &'a ParentNode<T>, query_point: <T::Envelope as Envelope>::Point) -> Self {
pub(crate) fn new(
root: &'a ParentNode<T>,
query_point: <T::Envelope as Envelope>::Point,
) -> Self {
NearestNeighborIterator {
iter: NearestNeighborDistance2Iterator::new(root, query_point),
}
Expand All @@ -136,6 +146,7 @@ where
}
}

/// Iterator returned by [`RTree::nearest_neighbor_iter`].
pub struct NearestNeighborIterator<'a, T>
where
T: PointDistance + 'a,
Expand Down