Skip to content

Commit

Permalink
ENH: Minor fixes in derived dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
jmichel-otb committed Jul 6, 2016
1 parent d384b9d commit 94d8ecc
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions gdal/frmts/cderived/cderiveddataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int ComplexDerivedDataset::Identify(GDALOpenInfo * poOpenInfo)
}

GDALDataset * ComplexDerivedDataset::Open(GDALOpenInfo * poOpenInfo)
{
{
if( !Identify(poOpenInfo) )
{
return NULL;
Expand Down Expand Up @@ -132,6 +132,12 @@ GDALDataset * ComplexDerivedDataset::Open(GDALOpenInfo * poOpenInfo)
return NULL;

int nbBands = poTmpDS->GetRasterCount();

if(nbBands == 0)
{
GDALClose(poTmpDS);
return NULL;
}

int nRows = poTmpDS->GetRasterYSize();
int nCols = poTmpDS->GetRasterXSize();
Expand Down Expand Up @@ -165,20 +171,23 @@ GDALDataset * ComplexDerivedDataset::Open(GDALOpenInfo * poOpenInfo)
GDALDataType type = GDT_Float64;

poBand = new VRTDerivedRasterBand(poDS,nBand,type,nCols,nRows);
poDS->SetBand(nBand,poBand);

poBand->SetPixelFunctionName("mod");
poBand->SetSourceTransferType(poTmpDS->GetRasterBand(nBand)->GetRasterDataType());
poDS->SetBand(nBand,poBand);


GDALProxyPoolDataset* proxyDS;
proxyDS = new GDALProxyPoolDataset( odFilename,
poDS->nRasterXSize,
poDS->nRasterYSize,
GA_ReadOnly,
TRUE);
proxyDS->AddSrcBandDescription(poTmpDS->GetRasterBand(nBand)->GetRasterDataType(), 128, 128);

for(int j=0;j<nbBands;++j)
proxyDS->AddSrcBandDescription(poTmpDS->GetRasterBand(nBand)->GetRasterDataType(), 128, 128);

poBand->AddComplexSource(proxyDS->GetRasterBand(nBand),0,0,nCols,nRows,0,0,nCols,nRows);
proxyDS->Dereference();

proxyDS->Dereference();
}

GDALClose(poTmpDS);
Expand Down

0 comments on commit 94d8ecc

Please sign in to comment.