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

Gilles Sadowski edited comment on GEOMETRY-146 at 3/29/22, 9:48 PM:
--------------------------------------------------------------------

bq. What would the calling code look like?

{code:java}
PointMap<Vector2D, Double> map = 
EuclideanCollections.pointMap2D(Precision.DoubleEquivalence.of(1e-7));
// Populate "map".

// Create selector.
final double resolution = 1e-2;
PointMap.EntrySetSelector<Vector2D, Double> selector = 
map.withinDistance(resolution);

// Interpolate on a regular grid.
final double[][] grid = ...
for (double x = xMin; x <= xMax; x+= resolution) {
    final int j = toColumnIndex(x, xMin, xMax);
    for (double y = yMin; y <= yMax; y+= resolution) {
        final int i = toRowIndex(y, yMin, yMax);
        final Vector2D v = Vector2D.of(x, y);
        // Retrieve neighbours of "v".
        final PointMap.EntrySet<Vector2D, Double> subSet = selector.apply(v);
        grid[i][j] = interpolate(subSet);
    }
}
{code}

All _untested_... ;-)


was (Author: erans):
bq. What would the calling code look like?

{code:java}
PointMap<Vector2D, Double> map = 
EuclideanCollections.pointMap2D(Precision.DoubleEquivalence.of(1e-7));
// Populate "map".

// Create selector.
final double resolution = 1e-2;
PointMap.EntrySetSelector<Vector2D, Double> selector = 
map.WithinDistance.of(resolution);

// Interpolate on a regular grid.
final double[][] grid = ...
for (double x = xMin; x <= xMax; x+= resolution) {
    final int j = toColumnIndex(x, xMin, xMax);
    for (double y = yMin; y <= yMax; y+= resolution) {
        final int i = toRowIndex(y, yMin, yMax);
        final Vector2D v = Vector2D.of(x, y);
        // Retrieve neighbours of "v".
        final PointMap.EntrySet<Vector2D, Double> subSet = selector.apply(v);
        grid[i][j] = interpolate(subSet);
    }
}
{code}

All _untested_... ;-)

> 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