Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/RTree/RTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private void Insert(RTreeNode<T> item, int level)
}

// adjust bboxes along the insertion path
AdjutsParentBounds(envelope, insertPath, level);
AdjustParentBounds(envelope, insertPath, level);
}

private static int CombinedArea(Envelope what, Envelope with)
Expand Down Expand Up @@ -416,24 +416,26 @@ public void Remove(T item, Envelope envelope)

private void CondenseNodes(IList<RTreeNode<T>> path)
{
var count = path.Count;

// go through the path, removing empty nodes and updating bboxes
for (var i = path.Count - 1; i >= 0; i--)
for (var i = 0; i < count; i++)
{
if (path[i].Children.Count == 0)
if (path[i].Children.Count == 0)
{
if (i == 0)
if (i == count - 1)
{
Clear();
Clear();
}
else
{
var siblings = path[i - 1].Children;
siblings.Remove(path[i]);
}
var siblings = path[i + 1].Children;
siblings.Remove(path[i]);
}
}
else
{
RefreshEnvelope(path[i]);
RefreshEnvelope(path[i]);
}
}
}
Expand All @@ -456,7 +458,7 @@ private static Envelope SumChildBounds(RTreeNode<T> node, int startIndex, int en
return retval;
}

private static void AdjutsParentBounds(Envelope bbox, List<RTreeNode<T>> path, int level)
private static void AdjustParentBounds(Envelope bbox, List<RTreeNode<T>> path, int level)
{
// adjust bboxes along the given tree path
for (var i = level; i >= 0; i--)
Expand Down