Current implementation of _chooseSplitIndex may return undefined when all children have infinity area.
When all inserted rects are infinity, they will be all inserted in a single node, instead of properly balancing the tree (updated test to validate this).
When data is random, an incorrect split may occur in a non-leaf node, causing a non-leaf node to have 0 children and causing error #69 when the tree will try to insert new data in its path.
This fix ensure that _chooseSplitIndex always return a number.
Fix #69
Current implementation of
_chooseSplitIndex
may return undefined when all children have infinity area.When all inserted rects are infinity, they will be all inserted in a single node, instead of properly balancing the tree (updated test to validate this).
When data is random, an incorrect split may occur in a non-leaf node, causing a non-leaf node to have 0 children and causing error #69 when the tree will try to insert new data in its path.
This fix ensure that
_chooseSplitIndex
always return a number.