[gdal-dev] GDAL Overviews selection

HariPrasad hari.0516 at gmail.com
Mon Dec 10 03:15:01 PST 2012


Iam writing a custom GDAL driver (RBD format). I was able to display the base
image (overview no = -1) but for a big image(5 GB) it takes huge amount of
time. 
So i was displaying its overview (ex; image has 3 overviews and i always
displays the last overview). In this case ArcGIS 10 displays image fastly
since its a overview.

But i require help on dynamically displaying the overviews (i.e 0,1,2 or 3)
when the overview image is Zoomed in/out.

IReadBlock() gets invoked only for the first time when displaying the
overview image. 
Here is the code written in IReadBlock()

CPLErr RBDRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, void *
pImage )
{
	RBDDataset *poGDS = (RBDDataset *) poDS;
	long nBand = 0, nOVNumber = 0;
	unsigned long nMinX = 0, nMaxX = 0, nMinY = 0, nMaxY = 0;
	long nTileSizeX = 0, nTileSizeY = 0;
	long nBandFlag;
	long nBufferSize;
	ICTM *pICTM;

	pICTM = poGDS->pziiFile->pICTM;
	nOVNumber = poGDS ->pziiFile ->nNumberOfOVs - 1;  // if it has overviews
0,1,2 it dispalys 2 Ov.
	nBand = this->nBand;

	if(-1 == nOVNumber)
	{
		nTileSizeX = poGDS->pziiFile->nXTileSize;
		nTileSizeY = poGDS->pziiFile->nYTileSize;
	}
	else
	{
		nTileSizeX = poGDS->pziiFile->pzii_LayerOVInfo[nOVNumber]->nXTileSize;
		nTileSizeY = poGDS->pziiFile->pzii_LayerOVInfo[nOVNumber]->nYTileSize;
	}

	//Get the RowMin, RowMax, ColMin and ColMax values
	nMinX = nBlockXOff * nTileSizeX;
	nMinY = nBlockYOff * nTileSizeY;
	nMaxX = nMinX + nTileSizeX-1;//Zero Index
	nMaxY = nMinY + nTileSizeY-1;//Zero Index

	//Set the band flag
	if(nBand == 1)
		nBandFlag = RED_FLAG;
	else if(nBand == 2)
		nBandFlag = GREEN_FLAG;
	else if(nBand == 3)
		nBandFlag = BLUE_FLAG;

	//Calculate buffer size
	nBufferSize = (nMaxX + 1 - nMinX) * (nMaxY + 1 - nMinY) *
poGDS->pziiFile->nNumberOfBytesPerBand;

	////Call RenderRequestByOV on CTM object - it is our 3 part method which
fills the image buffer.

pICTM->RenderRequestByOV(nOVNumber,nBandFlag,nMinX,nMinY,nMaxX,nMaxY,&nBufferSize,(unsigned
char*)pImage,FALSE,0);
	return CE_None ;




--
View this message in context: http://osgeo-org.1560.n6.nabble.com/GDAL-Overviews-selection-tp5021862.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list