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

tree.intersects(bbox) #24

Closed
mourner opened this issue Dec 17, 2013 · 2 comments
Closed

tree.intersects(bbox) #24

mourner opened this issue Dec 17, 2013 · 2 comments

Comments

@mourner
Copy link
Owner

mourner commented Dec 17, 2013

RBush is often used for collisions, so lets make a method that does the same as search but without collecting/returning items, just true/false.

@twpayne
Copy link
Contributor

twpayne commented Dec 17, 2013

In the ol3 port RBush, the traversal takes a callback which allows you to break out of the traversal by returning a truthy value. This can be used in many ways, for example:

// return true if any feature is at the coordinate
var coordinate = [x, y];
var anyFeatureAtCoordinate = rBush.forEachInExtent(extent, function(feature) {
  return feature.getGeometry().containsCoordinate(coordinate);
});

// find first feature only
var firstFeatureFound = rBush.forEachInExtent(extent, function(feature) {
  return feature;
});

@mourner
Copy link
Owner Author

mourner commented Dec 17, 2013

@twpayne that's pretty neat. I'll think about this.

mourner added a commit that referenced this issue Apr 22, 2015
mourner added a commit that referenced this issue Apr 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants