diff --git a/gdal/frmts/derived/deriveddataset.cpp b/gdal/frmts/derived/deriveddataset.cpp index bee7b185868a..891185350449 100644 --- a/gdal/frmts/derived/deriveddataset.cpp +++ b/gdal/frmts/derived/deriveddataset.cpp @@ -80,16 +80,16 @@ GDALDataset * DerivedDataset::Open(GDALOpenInfo * poOpenInfo) CPLString pixelFunctionName = ""; bool datasetFound = false; - const unsigned int nbSupportedDerivedDS = GDALGetNumberOfDerivedDatasetDecriptions(); + unsigned int nbSupportedDerivedDS(0); + + const DerivedDatasetDescription * poDDSDesc = GDALGetDerivedDatasetDescriptions(&nbSupportedDerivedDS); for(unsigned int derivedId = 0; derivedIdpszDatasetName) + { + if(odDerivedName == poDDSDesc[derivedId].pszDatasetName) { datasetFound = true; - pixelFunctionName = poCurrentDerivedDatasetDescription->pszPixelFunction; + pixelFunctionName = poDDSDesc[derivedId].pszPixelFunction; } } diff --git a/gdal/frmts/derived/derivedlist.c b/gdal/frmts/derived/derivedlist.c index 31a4579a1968..7cfcbe5313ef 100644 --- a/gdal/frmts/derived/derivedlist.c +++ b/gdal/frmts/derived/derivedlist.c @@ -43,18 +43,10 @@ static const DerivedDatasetDescription asDDSDesc [] = #define NB_DERIVED_DATASETS (sizeof(asDDSDesc)/sizeof(asDDSDesc[0])) -const DerivedDatasetDescription* CPL_DLL CPL_STDCALL GDALGetDerivedDatasetDescription(const unsigned int * pnDescriptionCount) +const DerivedDatasetDescription* CPL_DLL CPL_STDCALL GDALGetDerivedDatasetDescriptions(unsigned int * pnDescriptionCount) { - if(*pnDescriptionCount < (int)NB_DERIVED_DATASETS) - { - return &asDDSDesc[*pnDescriptionCount]; - } - return NULL; -} - -unsigned int CPL_DLL CPL_STDCALL GDALGetNumberOfDerivedDatasetDecriptions(void) -{ - return (unsigned int)NB_DERIVED_DATASETS; + *pnDescriptionCount = (unsigned int)NB_DERIVED_DATASETS; + return asDDSDesc; } CPL_C_END diff --git a/gdal/frmts/derived/derivedlist.h b/gdal/frmts/derived/derivedlist.h index 2f0b2620fca4..3202f8860e6c 100644 --- a/gdal/frmts/derived/derivedlist.h +++ b/gdal/frmts/derived/derivedlist.h @@ -40,9 +40,7 @@ typedef struct const char * pszTargetPixelType; } DerivedDatasetDescription; -const DerivedDatasetDescription* CPL_DLL CPL_STDCALL GDALGetDerivedDatasetDescription(const unsigned int * pnDescriptionCount); - -unsigned int CPL_DLL CPL_STDCALL GDALGetNumberOfDerivedDatasetDecriptions(void); +const DerivedDatasetDescription* CPL_DLL CPL_STDCALL GDALGetDerivedDatasetDescriptions(unsigned int * pnDescriptionCount); CPL_C_END diff --git a/gdal/gcore/gdaldataset.cpp b/gdal/gcore/gdaldataset.cpp index 98d9f546c6cc..24652f95783f 100644 --- a/gdal/gcore/gdaldataset.cpp +++ b/gdal/gcore/gdaldataset.cpp @@ -3316,17 +3316,17 @@ char ** GDALDataset::GetMetadata(const char * pszDomain) } } - const unsigned int nbSupportedDerivedDS = GDALGetNumberOfDerivedDatasetDecriptions(); + unsigned int nbSupportedDerivedDS; + const DerivedDatasetDescription * poDDSDesc = GDALGetDerivedDatasetDescriptions(&nbSupportedDerivedDS); for(unsigned int derivedId = 0; derivedIdpszTargetPixelType) != "complex") + + if(hasAComplexBand || CPLString(poDDSDesc[derivedId].pszTargetPixelType) != "complex") { - oDerivedMetadataList.SetNameValue(CPLSPrintf("DERIVED_SUBDATASET_%i_NAME",derivedId),CPLSPrintf("DERIVED_SUBDATASET:%s:%s",poCurrentDerivedDatasetDescription->pszDatasetName,GetDescription())); + oDerivedMetadataList.SetNameValue(CPLSPrintf("DERIVED_SUBDATASET_%i_NAME",derivedId),CPLSPrintf("DERIVED_SUBDATASET:%s:%s",poDDSDesc[derivedId].pszDatasetName,GetDescription())); - CPLString osDesc(CPLSPrintf("%s from %s",poCurrentDerivedDatasetDescription->pszDatasetDescritpion,GetDescription())); + CPLString osDesc(CPLSPrintf("%s from %s",poDDSDesc[derivedId].pszDatasetDescritpion,GetDescription())); oDerivedMetadataList.SetNameValue(CPLSPrintf("DERIVED_SUBDATASET_%i_DESC",derivedId),osDesc.c_str()); } }