@@ -393,8 +393,8 @@ GDALDriver::CreateMultiDimensional(const char *pszFilename,
393393 GetMetadataItem (GDAL_DMD_MULTIDIM_DATASET_CREATIONOPTIONLIST);
394394 CPLString osDriver;
395395 osDriver.Printf (" driver %s" , GetDescription ());
396- GDALValidateOptions (pszOptionList, papszOptions, " creation option " ,
397- osDriver);
396+ GDALValidateOptions (GDALDriver::ToHandle ( this ), pszOptionList ,
397+ papszOptions, " creation option " , osDriver);
398398 }
399399
400400 auto poDstDS = pfnCreateMultiDimensional (pszFilename, papszRootGroupOptions,
@@ -2318,8 +2318,9 @@ int CPL_STDCALL GDALValidateCreationOptions(GDALDriverH hDriver,
23182318 papszOptionsToValidate = papszOptionsToFree;
23192319 }
23202320
2321- const bool bRet = CPL_TO_BOOL (GDALValidateOptions (
2322- pszOptionList, papszOptionsToValidate, " creation option" , osDriver));
2321+ const bool bRet = CPL_TO_BOOL (
2322+ GDALValidateOptions (hDriver, pszOptionList, papszOptionsToValidate,
2323+ " creation option" , osDriver));
23232324 CSLDestroy (papszOptionsToFree);
23242325 return bRet;
23252326}
@@ -2338,15 +2339,15 @@ int GDALValidateOpenOptions(GDALDriverH hDriver,
23382339 CPLString osDriver;
23392340 osDriver.Printf (" driver %s" ,
23402341 GDALDriver::FromHandle (hDriver)->GetDescription ());
2341- return GDALValidateOptions (pszOptionList, papszOpenOptions, " open option " ,
2342- osDriver);
2342+ return GDALValidateOptions (hDriver, pszOptionList, papszOpenOptions ,
2343+ " open option " , osDriver);
23432344}
23442345
23452346/* ***********************************************************************/
23462347/* GDALValidateOptions() */
23472348/* ***********************************************************************/
23482349
2349- int GDALValidateOptions (const char *pszOptionList,
2350+ int GDALValidateOptions (GDALDriverH hDriver, const char *pszOptionList,
23502351 const char *const *papszOptionsToValidate,
23512352 const char *pszErrorMessageOptionType,
23522353 const char *pszErrorMessageContainerName)
@@ -2475,10 +2476,48 @@ int GDALValidateOptions(const char *pszOptionList,
24752476 CPLFetchBool (papszOptionsToValidate, " VALIDATE_OPEN_OPTIONS" ,
24762477 true )))
24772478 {
2479+ const char *pszAdditionalMsg = " " ;
2480+ if (hDriver &&
2481+ EQUAL (pszErrorMessageOptionType, " creation option" ))
2482+ {
2483+ const char *pszLCOList =
2484+ GDALDriver::FromHandle (hDriver)->GetMetadataItem (
2485+ GDAL_DS_LAYER_CREATIONOPTIONLIST);
2486+ if (pszLCOList &&
2487+ (CPLString (pszLCOList)
2488+ .ifind (CPLSPrintf (" \" %s\" " , pszKey)) !=
2489+ std::string::npos ||
2490+ CPLString (pszLCOList)
2491+ .ifind (CPLSPrintf (" '%s'" , pszKey)) !=
2492+ std::string::npos))
2493+ {
2494+ pszAdditionalMsg = " , but a layer creation option of "
2495+ " that name exists." ;
2496+ }
2497+ }
2498+ else if (hDriver && EQUAL (pszErrorMessageOptionType,
2499+ " layer creation option" ))
2500+ {
2501+ const char *pszLCOList =
2502+ GDALDriver::FromHandle (hDriver)->GetMetadataItem (
2503+ GDAL_DMD_CREATIONOPTIONLIST);
2504+ if (pszLCOList &&
2505+ (CPLString (pszLCOList)
2506+ .ifind (CPLSPrintf (" \" %s\" " , pszKey)) !=
2507+ std::string::npos ||
2508+ CPLString (pszLCOList)
2509+ .ifind (CPLSPrintf (" '%s'" , pszKey)) !=
2510+ std::string::npos))
2511+ {
2512+ pszAdditionalMsg = " , but a creation option of "
2513+ " that name exists." ;
2514+ }
2515+ }
2516+
24782517 CPLError (CE_Warning, CPLE_NotSupported,
2479- " %s does not support %s %s" ,
2518+ " %s does not support %s %s%s " ,
24802519 pszErrorMessageContainerName,
2481- pszErrorMessageOptionType, pszKey);
2520+ pszErrorMessageOptionType, pszKey, pszAdditionalMsg );
24822521 bRet = false ;
24832522 }
24842523
0 commit comments