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

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

hoogw opened this issue · comments

commented

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.

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?

Duplicate of #104.