-
Notifications
You must be signed in to change notification settings - Fork 448
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
base: master
Are you sure you want to change the base?
Conversation
modules/core/src/test/java/org/locationtech/jts/index/kdtree/KdTreeTest.java
Outdated
Show resolved
Hide resolved
* @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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
Implement #758.
added a
getNodes()
too, and a few other minor touch ups.