[
https://issues.apache.org/jira/browse/GEOMETRY-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17520168#comment-17520168
]
Gilles Sadowski edited comment on GEOMETRY-146 at 4/11/22 1:18 PM:
-------------------------------------------------------------------
{quote} * nearToFar and farToNear return Collection{quote}
Hmm, I thought that it was inefficient (requiring iterating in order to copy
all references to entries into the returned collection) (?).
Otherwise, it is great; and, thus, why not have
{code:java}
interface PointMap<P, V> {
// ...
Collection<Entry<P, V>> entriesNearToFar(P pt);
default List<Entry<P, V>> neighborEntries(P pt, double maxDist) {
final List<Entry<P, V>> nList = new ArrayList<>();
for (Entry<P, V> e : entriesNearToFar(p)) {
if (distance(pt, e.key()) < maxDist) {
nList.put(e);
} else {
// Iteration is ordered by distance.
break;
}
}
return nList;
}
}
{code}
?
was (Author: erans):
{quote} * nearToFar and farToNear return Collection{quote}
Hmm, I thought that it was inefficient (requiring iterating in order to copy
all references to entries into the returned collection) (?).
Otherwise, it is great; and, thus, why not have
{code:java}
interface PointMap<P, V> {
// ...
Collection<Entry<P, V>> entriesNearToFar(P pt);
default List<Entry<P, V>> neighborEntries(P pt, double maxDist) {
final List<Entry<P, V>> nList = new ArrayList<>();
for (Entry<P, V> e : entriesNearToFar(p)) {
if (distance(pt, e.key()) < maxDist) {
nList.put(e);
}
}
return nList;
}
}
{code}
?
> PointSet/Map closest points
> ---------------------------
>
> Key: GEOMETRY-146
> URL: https://issues.apache.org/jira/browse/GEOMETRY-146
> Project: Commons Geometry
> Issue Type: New Feature
> Reporter: Matt Juntunen
> Priority: Major
> Fix For: 1.1
>
>
> Add methods to the new {{PointSet}} and {{PointMap}} interfaces to allow
> querying of points in order of distance from a query point.
> {code:java}
> PointSet<P> {
> // find the closest point to pt or null if empty
> P closest(P pt);
> // iterate through points in order, with points closest to pt coming first
> Iterable<P> closestFirst(P pt);
> // find the farthest point from pt or null if emtpy
> P farthest(P pt);
> // iterate through point in order, with points farthest from pt coming
> first
> Iterable<P> farthestFirst(P pt);
> }
> {code}
> {{PointMap}} should have similar methods providing access to the map keys and
> entries.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)