/// <summary> /// Return a square envelope containing the argument envelope, /// whose extent is a power of two and which is based at a power of 2. /// </summary> /// <param name="itemInterval"></param> public void ComputeKey(Interval itemInterval) { _level = ComputeLevel(itemInterval); _interval = new Interval(); ComputeInterval(_level, itemInterval); // MD - would be nice to have a non-iterative form of this algorithm while (!_interval.Contains(itemInterval)) { _level += 1; ComputeInterval(_level, itemInterval); } }
/// <summary> /// /// </summary> /// <param name="node"></param> public virtual void Insert(Node node) { Assert.IsTrue(_interval == null || _interval.Contains(node.Interval)); int index = GetSubnodeIndex(node._interval, _centre); if (node._level == _level - 1) { Nodes[index] = node; } else { // the node is not a direct child, so make a new child node to contain it // and recursively insert the node Node childNode = CreateSubnode(index); childNode.Insert(node); Nodes[index] = childNode; } }