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

Insertion fails after rbush becomes empty

twpayne opened this issue · comments

After removing all items from an rbush, inserting new items fails.

Quick steps to reproduce

Extra information

The console displays:

Uncaught TypeError: Cannot read property 'leaf' of undefined rbush.js:223
rbush._chooseSubtree rbush.js:223
rbush._insert rbush.js:259
rbush.insert rbush.js:89
(anonymous function) viz-uniform.html:37

Interesting! It works perfectly for me with the steps you provided in Chrome / OS X. What browser / OS are you using? Could you check other browsers?

Oh, I see now! I clicked "bulk-insert" instead of insert. Thanks for the report!

Good that you can duplicate it. I've observed this in Mac OS X / Chrome Canary (32) but you're already on the case...

Yeah. The problem is that _condense doesn't update tree height and leaf status when condensing the tree after removal (which potentially can lead to other performance problems).

Nice work @mourner! Thanks for the super-quick fix!