Spatial Indexing

Dec 22, 2006 at 10:12 AM
Hi,
It seems there is a way to improve the performance of IntersectTreeRecursive(....) function in SpatialIndexing.cs.
The original:
private void IntersectTreeRecursive(SharpMap.Geometries.BoundingBox box, QuadTree node, ref List<uint> list)
{
if (node.IsLeaf) //Leaf has been reached
{
for (int i = 0; i < node._objList.Count; i++)
list.Add(node._objListi.ID);
}
else
{
if(node.Box.Intersects(box))
{
IntersectTreeRecursive(box, node.Child0, ref list);
IntersectTreeRecursive(box, node.Child1, ref list);
}
}
}


Suggest improvement:
private void IntersectTreeRecursive(SharpMap.Geometries.BoundingBox box, QuadTree node, ref List<uint> list)
{
if (node.IsLeaf) //Leaf has been reached
{
if (node.Box.Intersects(box))
for (int i = 0; i < node._objList.Count; i++)
if (node._objListi.box.Intersects(box))
list.Add(node._objListi.ID);
}
else
{
if(node.Box.Intersects(box))
{
IntersectTreeRecursive(box, node.Child0, ref list);
IntersectTreeRecursive(box, node.Child1, ref list);
}
}
}

I would like to get the feedbacks.
Coordinator
Jan 11, 2007 at 9:42 PM
Hi

I tested your snippet and could recognise any
significant performance improvement until indexed read.

What size has shape file?

BR
/Christian