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

Add KdTree nearestNeighbor() and nearestNeighbors() #1114

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

micycle1
Copy link
Contributor

@micycle1 micycle1 commented Jan 27, 2025

Implement #758.
added a getNodes() too, and a few other minor touch ups.

@micycle1 micycle1 changed the title add KDtree nearestNeighbor() and nearestNeighbors() Add KdTree nearestNeighbor() and nearestNeighbors() Jan 27, 2025
* @param n the number of nearest nodes to find
* @return a list of the nearest nodes, sorted by distance (closest first), or an empty list if the tree is empty.
*/
public List<KdNode> nearestNeighbors(final Coordinate query, final int n) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These method names are different to the ones on STRtree - e.g. it has nearestNeighbourK. But I prefer this naming style. Perhaps STRtree should add methods with these names and deprecate the old ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting to do that in this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, they can be added in a future PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, ready for merge then I think.

testNearestNeighborsPerformance();
}

private void testNearestNeighborsPerformance() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should really be in a separate file KdtreePerfTest. Ideally it would use the performance test framework (see example). But it's ok to keep the current code structure for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@micycle1 are you able to split the performance test code out into a separate class?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants