[Gdal-dev] bug in the documentation ?

Stephane Routelous route at cae.com
Wed Sep 1 12:01:09 EDT 2004


Hi,

according to the documentation
(http://www.remotesensing.org:16080/gdal/classGDALRasterBand.html#a10)

the test for the reading in the blocks is :
01  for( iYBlock = 0; iYBlock < nYBlocks; iYBlock++ )
02     {
03         for( iXBlock = 0; iXBlock < nXBlocks; iXBlock++ )
04         {
05             int        nXValid, nYValid;
06             poBand->ReadBlock( iXBlock, iYBlock, pabyData );
07             // Compute the portion of the block that is valid
08             // for partial edge blocks.
09             if( iXBlock * nXBlockSize > poBand->GetXSize())
10                 nXValid = poBand->GetXSize()- iXBlock * nXBlockSize;
11             else
12                 nXValid = nXBlockSize;
13             if( iYBlock * nYBlockSize > poBand->GetYSize() )
14                 nYValid = poBand->GetYSize()  - iYBlock * nYBlockSize;
15             else
16                 nYValid = nYBlockSize;
17             // Collect the histogram counts.
18             for( int iY = 0; iY < nXValid; iY++ )
19             {
20                 for( int iX = 0; iX < nXValid; iX++ )
21                 {
22                     panHistogram[pabyData[iX + iY * nXBlockSize]] += 1;
23                 }
24             }
25         }
26     }

should it not be :

09		   if( (iXBlock+1) * nXBlockSize > poBand->GetXSize())
//note the +1
10                 nXValid = poBand->GetXSize()- iXBlock * nXBlockSize;

and

13             if( (iYBlock+1) * nYBlockSize > poBand->GetYSize()) //note
the +1
14                 nYValid = poBand->GetYSize()  - iYBlock * nYBlockSize;

thanks,

Stephane



More information about the Gdal-dev mailing list