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

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

{quote}From this assumption, I'd suggest that the class name reflects its 
importance, similarly to the "Navigable" qualifier in the [JDK 
{{NavigableMap}}|https://docs.oracle.com/javase/8/docs/api/java/util/NavigableMap.html].
{quote}
It is part of the class name: {{DistanceOrdering}}, which is returned from 
several of the methods in my proposed API.

bq. In this case, there may be no reason; but we could imagine another selector 
where some part of the computation is performed at instantiation and should not 
be repeated for each point.

Yes. I would imagine a separate method in the API for that.

{quote}Could selectors be defined as

class PointMap<P, V> {
  public interface Selector<P, V> extends Function<PointMap<P, V>, P> {};
}

?
{quote}

Do you mean
{code:java}
interface Selector<P, V> extends Function<P, PointMap<P, V>> {}
{code}
?
In other words, the selector accepts a point and returns a {{PointMap}} view? 
There are 2 issues with this:
- This presupposes that the only selection criteria to be used will be a point, 
which may not be the case. For example, what if we wanted to select points with 
a bounding box? That would not fit this interface.
- Returning another full {{PointMap}} instance as a view of the main map is not 
feasible at this point. Doing so would be very complicated with the current 
algorithms and I don't believe it would have much use either.

bq. Can the "sub-map" be a "view" of the same data-structure?

That's what I have implemented. {{DistanceOrdering}} is a view of the 
underlying {{PointMap/Set}}. It is accessed through selection methods (e.g. 
{{PointMap.entriesWithinDistance(P, double)}}), similar to {{Map.entrySet()}}.

{quote}
Given a point "p" of type P, are the 2 iterators (over all points in the 
PointMap instance):

    in increasing distance from "p"
    in decreasing distance

"naturally" (efficiently) defined?
{quote}

Yes.

It would be helpful to me if you could respond to my latest API proposal from 
Mar 30. I feel like this both meets some of the requirements that you are 
mentioning as well as being similar to the approaches used in {{java.util.Map}}.



> 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