static void SHPTreeNodeSearchAndDump( SHPTree hTree, double[] padfBoundsMin, double[] padfBoundsMax ) { int[] panHits; int nShapeCount, i; /* -------------------------------------------------------------------- */ /* Perform the search for likely candidates. These are shapes */ /* that fall into a tree node whose bounding box intersects our */ /* area of interest. */ /* -------------------------------------------------------------------- */ panHits = hTree.FindLikelyShapes( padfBoundsMin, padfBoundsMax, out nShapeCount ); /* -------------------------------------------------------------------- */ /* Read all of these shapes, and establish whether the shape's */ /* bounding box actually intersects the area of interest. Note */ /* that the bounding box could intersect the area of interest, */ /* and the shape itself still not cross it but we don't try to */ /* address that here. */ /* -------------------------------------------------------------------- */ for( i = 0; i < nShapeCount; i++ ) { SHPObject psObject; psObject = hTree.hSHP.ReadObject( panHits[i] ); if( psObject == null ) continue; double[] adfMin = new double[] { psObject.dfXMin, psObject.dfYMin, psObject.dfZMin, psObject.dfMMin }; double[] adfMax = new double[] { psObject.dfXMax, psObject.dfYMax, psObject.dfZMax, psObject.dfMMax }; if( !SHPTree.CheckBoundsOverlap( padfBoundsMin, padfBoundsMax, adfMin, adfMax, hTree.nDimension ) ) { c.printf( "Shape {0:D}: not in area of interest, but fetched.\n", panHits[i] ); } else { c.printf( "Shape {0:D}: appears to be in area of interest.\n", panHits[i] ); } psObject = null; } if( nShapeCount == 0 ) c.printf( "No shapes found in search.\n" ); }
/// <summary> /// Dump a tree node in a readable form. /// </summary> static void SHPTreeNodeDump( SHPTree psTree, SHPTreeNode psTreeNode, string pszPrefix, int nExpandShapes ) { string szNextPrefix = null; int i; c.strcpy( ref szNextPrefix, pszPrefix ); if( c.strlen(pszPrefix) < 150 - 3 ) c.strcat( ref szNextPrefix, " " ); c.printf( "{0}( SHPTreeNode\n", pszPrefix ); /* -------------------------------------------------------------------- */ /* Emit the bounds. */ /* -------------------------------------------------------------------- */ c.printf( "{0} Min = (", pszPrefix ); EmitCoordinate( psTreeNode.adfBoundsMin, psTree.nDimension ); c.printf( ")\n" ); c.printf( "{0} Max = (", pszPrefix ); EmitCoordinate( psTreeNode.adfBoundsMax, psTree.nDimension ); c.printf( ")\n" ); /* -------------------------------------------------------------------- */ /* Emit the list of shapes on this node. */ /* -------------------------------------------------------------------- */ if( nExpandShapes != 0 ) { c.printf( "{0} Shapes({1}):\n", pszPrefix, psTreeNode.nShapeCount ); for( i = 0; i < psTreeNode.nShapeCount; i++ ) { SHPObject psObject; psObject = psTree.hSHP.ReadObject( psTreeNode.panShapeIds[i] ); c.assert( psObject != null ); if( psObject != null ) { EmitShape( psObject, szNextPrefix, psTree.nDimension ); } psObject = null; } } else { c.printf( "{0} Shapes({1}): ", pszPrefix, psTreeNode.nShapeCount ); for( i = 0; i < psTreeNode.nShapeCount; i++ ) { c.printf( "{0} ", psTreeNode.panShapeIds[i] ); } c.printf( "\n" ); } /* -------------------------------------------------------------------- */ /* Emit subnodes. */ /* -------------------------------------------------------------------- */ for( i = 0; i < psTreeNode.nSubNodes; i++ ) { if( psTreeNode.apsSubNode[i] != null ) SHPTreeNodeDump( psTree, psTreeNode.apsSubNode[i], szNextPrefix, nExpandShapes ); } c.printf( "{0})\n", pszPrefix ); return; }