Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return coincident points with find #38

Closed
cguastini opened this issue Feb 2, 2021 · 2 comments
Closed

Return coincident points with find #38

cguastini opened this issue Feb 2, 2021 · 2 comments

Comments

@cguastini
Copy link

Currently, quadtree.find returns one point even if many coincident points are in the tree.

var quadtree = d3.quadtree([[1, 1, "red"], [1, 1, "green"], [0, 0, "blue"]]);
var result = quadtree.find(1,1);

result will be [1, 1, "green"].

I'm working with a point-of-interest dataset that contains many locations at the same coordinates (e.g., stores in the same mall), and my desired behavior is to return all of the points at that one location [[1, 1, "green"], [1, 1, "red"]]. I have created a fork that does this with a couple minor changes. I would create a PR, but they are breaking changes because the results are now an array rather than a single value. It may not be worth trying to merge as is.

@Fil
Copy link
Member

Fil commented Feb 2, 2021

quadtree.find is meant to be simple; for this use case you can visit the quadtree with a custom function (there's no need to patch d3-quadtree).

Here's a similar example https://observablehq.com/d/ff2450667f13132f#findInCircle (#30)

@Fil Fil closed this as completed Feb 2, 2021
@cguastini
Copy link
Author

My patch didn’t feel like the best solution because of the change in quadtree.find behavior, so thank you for the alternative approach!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants