[
https://issues.apache.org/jira/browse/GEOMETRY-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17515937#comment-17515937
]
Matt Juntunen commented on GEOMETRY-146:
----------------------------------------
I now have the internal logic for these operations implemented in all spaces
and dimensions. All that's left now is to decide on the public API, write a few
more tests, and then document it.
I see what you're saying about having a general API but I don't have any more
ideas at this time other than the one I posted more recently. What I'm looking
for is the ability to specify a point with an optional radius and then either
* obtain the single nearest/farthest point, orĀ
* iterate through all available points in nearest to farthest or farthest to
nearest order.
These two operations must be separate since there is a significant performance
benefit to obtaining a single result versus iterating through the available
points. (The single point version can be performed recursively in the
multidimensional cases while iteration requires allocation of queues and other
bookkeeping structures.) Also, I would like the specification of the iteration
order to be explicit and use the terms _near_/_far_ or similar in order to make
things readable and self-documenting. The API I proposed fulfills these
requirements and IMHO provides a pretty good generalization of the operations
in question. Do you have any objections to this API or any alternative
suggestions?
> 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)