davidmoten / davidmoten/rtree

Search for nearest neighbors with bounds on distances along different axes, not the eucledian distance

Open
#42 4 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Java
Stars
1.1k
Forks
218
Avg merge
2m
Merged PRs (30d)
1

Description

The problem is with this method:

``` java
public Observable> search(final Rectangle r, final double maxDistance) {
return search(new Func1() {
@Override
public Boolean call(Geometry g) {
return g.distance(r) < maxDistance;
}
});
}
```

which only accepts a single distance.

It would be nice to have something like `public Observable> search(final Rectangle r, final double maxDistX, double maxDistY)` or `public Observable> search(final Rectangle r, final double[] maxDistance)`.

The use case: the dimensions of the axes are different, so using a single distance doesn't make much sense. Trying to bring both dimensions to the same scale is not so simple, plus I just know the constraints I want to put on each of those coordinates.

The fact that r-tree class is marked final and the constructors are private also doesn't help extending the code.

I know that I can run `RTree.search(Rectangle)` with the desired constraints, but there are cases where this can bring up a lot of unnecessary stuff (e.g. larger rectangles in the tree covering the same region) and cause unnecessary slowdows, while I only need to get a few neighbors of a certain point.

**Thanks for the great library!**

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.