mourner / rbush

RBush — a high-performance JavaScript R-tree-based 2D spatial index for points and rectangles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: search(bbox, dataString)

maja42 opened this issue · comments

The entries/nodes I store in RBush have many properties, including an 'id' field.
When performing a search-query, I only need a list of ids, rather than a list of entries.

To do so, I currently use the map function:

var entries = tree.search(bbox);
var ids = entries.map(function(val) {
    return val.id;
});

For my specific case, it would be nice if RBush could offer this functionality for me, so that I don't need to convert the result myself anymore. (Note: changing the result.push(child); into an result.push(child.id); in rbush's search method does the trick.)

To do this, the search-function could take a second, optional parameter where I can pass the string ".id". This would work similar to the constructor method that accepts a format (and which is awesome!).

However, I'm not sure if there is enough demand for this feature and if it makes sense to put it into RBush.

Thanks for the suggestion! However, I don't think it's worth complicating the API with additional options if you can simply call entries.map(p => p.id), which is simple and straightforward.