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

Bulk-loading does not respect rbush._minEntries

TuomLarsen opened this issue · comments

When bulk-loading 91 items into rbush(10), the very last leaf contains only 1 item (as opposed to at least 4, as in Math.max(2, Math.ceil(this._maxEntries * 0.4))).

Yeah. But is this important? _minEntries is an implementation detail that only affects the R*-tree single item insertion algorithm. I'd say it's fine.

You definitely know better than I do, I just thought that _minEntries are requited by R-trees in general so that a tree wont degenerate into a linked list. But as I said, I presume you know better so feel free to close this.

You can get the number of nodes down to less than _minEntries with remove too (see the note in the readme). It's a tradeoff — it works fast for pretty much all practical cases, and can only degenerate to a linked list if you deliberately try to do so. So I think it's OK to leave it at that.