[
https://issues.apache.org/jira/browse/GEOMETRY-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17516875#comment-17516875
]
Gilles Sadowski edited comment on GEOMETRY-146 at 4/4/22 3:19 PM:
------------------------------------------------------------------
{quote}[...] near/far qualification is important enough to warrant inclusion in
the top-level public API.
{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}
{code:java}
PointMap.EntrySetSelector<Vector2D, Double> selector =
map.withinDistance(resolution);
// ...
PointMap.EntrySet<Vector2D, Double> subSet = selector.apply(v);
{code}
Also, the subset selection here seems to be split into two parts: the first to
specify the distance and the second to specify the reference point. I don't see
a reason to separate these.
{quote}
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.
When the use-case does not need the separation, the call is a one-liner
{code:java}
PointMap.EntrySet<Vector2D, Double> subSet =
map.withinDistance(resolution).apply(v);
{code}
Could selectors be defined as
{code:java}
class PointMap<P, V> {
public interface Selector<P, V> extends Function<PointMap<P, V>, P> {};
}
{code}
?
Can the "sub-map" be a "view" of the same data-structure?
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?
was (Author: erans):
{quote}[...] near/far qualification is important enough to warrant inclusion in
the top-level public API.
{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}
{code:java}
PointMap.EntrySetSelector<Vector2D, Double> selector =
map.withinDistance(resolution);
// ...
PointMap.EntrySet<Vector2D, Double> subSet = selector.apply(v);
{code}
Also, the subset selection here seems to be split into two parts: the first to
specify the distance and the second to specify the reference point. I don't see
a reason to separate these.
{quote}
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.
When the use-case does not need the separation, the call is a one-liner
{code:java}
PointMap.EntrySet<Vector2D, Double> subSet =
map.withinDistance(resolution).apply(v);
{code}
{quote}
Computing distance between points is one of the few things that all spaces and
dimensions provide [...]
{quote}
Does it allow defining selectors as
{code}
class PointMap<P, V> {
public interface Selector<P, V> extends Function<PointMap<P, V>, P> {};
}
{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)