[Gdal-dev] Library function for listing formats
Frank Warmerdam
warmerdam at pobox.com
Mon Nov 13 18:05:40 EST 2006
Matt Hanson wrote:
> It seems that there should be a function for listing all the suported
> formats GDAL was compiled with. I can't find one, does such a think exist?
>
> I have an exe file that uses GDAL. When the user calls my exe with
> --help I want to be able to print a list of supported formats.
Matt,
This is the implementation of the --formats help option for most
GDAL programs:
else if( EQUAL(papszArgv[iArg], "--formats") )
{
int iDr;
printf( "Supported Formats:\n" );
for( iDr = 0; iDr < GDALGetDriverCount(); iDr++ )
{
GDALDriverH hDriver = GDALGetDriver(iDr);
const char *pszRWFlag;
if( GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATE, NULL ) )
pszRWFlag = "rw+";
else if( GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATECOPY,
NULL ) )
pszRWFlag = "rw";
else
pszRWFlag = "ro";
printf( " %s (%s): %s\n",
GDALGetDriverShortName( hDriver ),
pszRWFlag,
GDALGetDriverLongName( hDriver ) );
}
CSLDestroy( papszReturn );
return 0;
}
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | President OSGeo, http://osgeo.org
More information about the Gdal-dev
mailing list