mourner / rbush

RBush — a high-performance JavaScript R-tree-based 2D spatial index for points and rectangles
MIT License
2.46k stars 237 forks source link

tree.getById(id) how to get by id? #105

Closed hoogw closed 4 years ago

hoogw commented 4 years ago

Is there function I can get by id?

How to return item by id?

    For example I insert 2 item, with id field 1, 2
`const item = {
minX: 20,
minY: 40,
maxX: 30,
maxY: 50,
id: 1
};

const item2= {
minX: 10,
minY: 20,
maxX: 20,
maxY: 30,
id: 2
};

tree.insert(item);
tree.insert(item2);`

Now, I want get the item by id only.

        `const result = tree.getByID(2);`

Then I get item return as item2, because its id is 2.

photonstorm commented 4 years ago

There isn’t, because that’s not what an RTree does. Perhaps this isn’t the right sort of data structure you’re looking for?

IvanSanchez commented 4 years ago

Duplicate of #104.