[ 
https://issues.apache.org/jira/browse/GEOMETRY-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17519970#comment-17519970
 ] 

Matt Juntunen commented on GEOMETRY-146:
----------------------------------------

I've thought about it a bit more and I think I might see what you mean by an 
inconsistency in the API. By returning {{DistanceOrdering}} from the 
subset-selection methods we are assuming that the natural way to access 
elements relative to a specific point or within a specific radius is by 
increasing or decreasing distance. This is reasonable enough for the current 
implementations, but what if this is not the case for future implementations? 
What if an implementation incurs a large processing overhead in order to return 
points in a specific distance ordering but can return them immediately when the 
order does not matter. It would be unfortunate to impose this cost on callers 
who only care about the actual points returned and not about their ordering. It 
seems to me that we need an API that can perform the following:
- get the single nearest/farthest element from a given point and within an 
optional search radius
- get elements in order of increasing or decreasing distance from a given point 
and within an optional search radius
- get elements _in any order_ within a search radius of a specified point

Does this match what you're picturing?

> 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)

Reply via email to