Skip to content

Commit

Permalink
ENH: Avoid exposing complex relevant derived datasets if there is not…
Browse files Browse the repository at this point in the history
… at least one complex raster band
  • Loading branch information
jmichel-otb committed Jul 7, 2016
1 parent 03ca1aa commit a65e6ef
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions gdal/gcore/gdaldataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3305,16 +3305,31 @@ char ** GDALDataset::GetMetadata(const char * pszDomain)
// First condition: at least one raster band
if(GetRasterCount()>0)
{
// Check if there is at least one complex band
bool hasAComplexBand = false;

for(int rasterId = 1; rasterId <= GetRasterCount();++rasterId)
{
if(GDALDataTypeIsComplex(GetRasterBand(rasterId)->GetRasterDataType()))
{
hasAComplexBand = true;
break;
}
}

const unsigned int nbSupportedDerivedDS = GDALGetNumberOfDerivedDatasetDecriptions();

for(unsigned int derivedId = 0; derivedId<nbSupportedDerivedDS;++derivedId)
{

const DerivedDatasetDescription * poCurrentDerivedDatasetDescription = GDALGetDerivedDatasetDescription(&derivedId);
oDerivedMetadataList.SetNameValue(CPLSPrintf("DERIVED_SUBDATASET_%i_NAME",derivedId),CPLSPrintf("DERIVED_SUBDATASET:%s:%s",poCurrentDerivedDatasetDescription->pszDatasetName,GetDescription()));

CPLString osDesc(CPLSPrintf("%s from %s",poCurrentDerivedDatasetDescription->pszDatasetDescritpion,GetDescription()));
oDerivedMetadataList.SetNameValue(CPLSPrintf("DERIVED_SUBDATASET_%i_DESC",derivedId),osDesc.c_str());

if(hasAComplexBand || CPLString(poCurrentDerivedDatasetDescription->pszTargetPixelType) != "complex")
{
oDerivedMetadataList.SetNameValue(CPLSPrintf("DERIVED_SUBDATASET_%i_NAME",derivedId),CPLSPrintf("DERIVED_SUBDATASET:%s:%s",poCurrentDerivedDatasetDescription->pszDatasetName,GetDescription()));

CPLString osDesc(CPLSPrintf("%s from %s",poCurrentDerivedDatasetDescription->pszDatasetDescritpion,GetDescription()));
oDerivedMetadataList.SetNameValue(CPLSPrintf("DERIVED_SUBDATASET_%i_DESC",derivedId),osDesc.c_str());
}
}
}
return oDerivedMetadataList.List();
Expand Down

0 comments on commit a65e6ef

Please sign in to comment.