本文整理汇总了C++中OGRSFDriver::TestCapability方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRSFDriver::TestCapability方法的具体用法?C++ OGRSFDriver::TestCapability怎么用?C++ OGRSFDriver::TestCapability使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRSFDriver
的用法示例。
在下文中一共展示了OGRSFDriver::TestCapability方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Get_Description
//---------------------------------------------------------
CSG_String COGR_Driver::Get_Description(int iDriver)
{
OGRSFDriver *pDriver = m_pManager->GetDriver(iDriver);
CSG_String s;
s += pDriver->TestCapability(ODrCCreateDataSource) ? SG_T("\n[x] ") : SG_T("\n[ ] ");
s += _TL("create data source");
s += pDriver->TestCapability(ODrCDeleteDataSource) ? SG_T("\n[x] ") : SG_T("\n[ ] ");
s += _TL("delete data source");
/* s += pDriver->TestCapability(ODsCCreateLayer) ? SG_T("\n[x]") : SG_T("\n[ ]");
s += _TL("create layer");
s += pDriver->TestCapability(ODsCDeleteLayer) ? SG_T("\n[x]") : SG_T("\n[ ]");
s += _TL("delete layer");
s += pDriver->TestCapability(OLCDeleteFeature) ? SG_T("\n[x]") : SG_T("\n[ ]");
s += _TL("delete feature");
s += pDriver->TestCapability(OLCRandomRead) ? SG_T("\n[x]") : SG_T("\n[ ]");
s += _TL("random read");
s += pDriver->TestCapability(OLCRandomWrite) ? SG_T("\n[x]") : SG_T("\n[ ]");
s += _TL("random write");
s += pDriver->TestCapability(OLCSequentialWrite) ? SG_T("\n[x]") : SG_T("\n[ ]");
s += _TL("sequential write");
/**/
return( SG_STR_MBTOSG(s) );
}
示例2: Usage
void Usage()
{
OGRSFDriverRegistrar * poR = OGRSFDriverRegistrar::GetRegistrar();
printf(
"Usage: txt2shp -i <input directory>\n"
" -o <output directory>\n"
" [-f <output file format_name>]\n\n"
"Note :\n"
" You can not put any file except you data files in the input directory."
" And the output directory must be empty directory.\n\n"
);
printf("Advanced options :\n");
printf(" -f format_name: output file format name, possible values are:\n");
for (int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++)
{
OGRSFDriver * poDriver = poR->GetDriver(iDriver);
if (poDriver->TestCapability(ODrCCreateDataSource))
printf(" -f \"%s\"\n", poDriver->GetName());
}
printf(
"\nExample :\n"
" txt2shp -i you_dir -o you_dir -f \"ESRI Shapefile\"\n\n"
);
exit(1);
}
示例3:
JNIEXPORT jint JNICALL Java_es_gva_cit_jogr_OGRSFDriver_testCapabilityNat
(JNIEnv *env, jobject obj, jlong cPtr, jstring cap){
OGRSFDriver *drv = (OGRSFDriver *) 0 ;
drv = *(OGRSFDriver **)&cPtr;
int res=-1;
const char *testcap = env->GetStringUTFChars( cap, 0);
res = drv->TestCapability(testcap);
env->ReleaseStringUTFChars( cap, testcap);
return res;
}
示例4: main
//.........这里部分代码省略.........
poDstDS = OGRSFDriverRegistrar::Open( pszOutputName, TRUE );
/* -------------------------------------------------------------------- */
/* If that failed, find the driver so we can create the tile index.*/
/* -------------------------------------------------------------------- */
if( poDstDS == NULL )
{
OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar();
OGRSFDriver *poDriver = NULL;
int iDriver;
for( iDriver = 0;
iDriver < poR->GetDriverCount() && poDriver == NULL;
iDriver++ )
{
if( EQUAL(poR->GetDriver(iDriver)->GetName(),pszFormat) )
{
poDriver = poR->GetDriver(iDriver);
}
}
if( poDriver == NULL )
{
fprintf( stderr, "Unable to find driver `%s'.\n", pszFormat );
fprintf( stderr, "The following drivers are available:\n" );
for( iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
{
fprintf( stderr, " -> `%s'\n", poR->GetDriver(iDriver)->GetName() );
}
exit( 1 );
}
if( !poDriver->TestCapability( ODrCCreateDataSource ) )
{
fprintf( stderr, "%s driver does not support data source creation.\n",
pszFormat );
exit( 1 );
}
/* -------------------------------------------------------------------- */
/* Now create it. */
/* -------------------------------------------------------------------- */
poDstDS = poDriver->CreateDataSource( pszOutputName, NULL );
if( poDstDS == NULL )
{
fprintf( stderr, "%s driver failed to create %s\n",
pszFormat, pszOutputName );
exit( 1 );
}
if( poDstDS->GetLayerCount() == 0 )
{
OGRFieldDefn oLocation( pszTileIndexField, OFTString );
oLocation.SetWidth( 200 );
if( nFirstSourceDataset < nArgc && papszArgv[nFirstSourceDataset][0] == '-' )
{
nFirstSourceDataset++;
}
OGRSpatialReference* poSrcSpatialRef = NULL;
/* Fetches the SRS of the first layer and use it when creating the tileindex layer */
示例5: OGRGeneralCmdLineProcessor
//.........这里部分代码省略.........
while( (pszLine = CPLReadLine( fpOptFile )) != NULL )
{
char **papszTokens;
int i;
if( pszLine[0] == '#' || strlen(pszLine) == 0 )
continue;
papszTokens = CSLTokenizeString( pszLine );
for( i = 0; papszTokens != NULL && papszTokens[i] != NULL; i++)
papszReturn = CSLAddString( papszReturn, papszTokens[i] );
CSLDestroy( papszTokens );
}
VSIFClose( fpOptFile );
iArg += 1;
}
/* -------------------------------------------------------------------- */
/* --formats */
/* -------------------------------------------------------------------- */
#ifdef OGR_ENABLED
else if( EQUAL(papszArgv[iArg], "--formats") )
{
int iDr;
printf( "Supported Formats:\n" );
OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar();
for( iDr = 0; iDr < poR->GetDriverCount(); iDr++ )
{
OGRSFDriver *poDriver = poR->GetDriver(iDr);
if( poDriver->TestCapability( ODrCCreateDataSource ) )
printf( " -> \"%s\" (read/write)\n",
poDriver->GetName() );
else
printf( " -> \"%s\" (readonly)\n",
poDriver->GetName() );
}
CSLDestroy( papszReturn );
return 0;
}
#endif /* OGR_ENABLED */
/* -------------------------------------------------------------------- */
/* --locale */
/* -------------------------------------------------------------------- */
else if( EQUAL(papszArgv[iArg],"--locale") && iArg < nArgc-1 )
{
setlocale( LC_ALL, papszArgv[++iArg] );
}
/* -------------------------------------------------------------------- */
/* --pause - "hit enter" pause useful to connect a debugger. */
/* -------------------------------------------------------------------- */
else if( EQUAL(papszArgv[iArg],"--pause") )
{
char szLine[81];
printf( "Hit <ENTER> to continue.\n" );
fgets( szLine, sizeof(szLine), stdin );
}
/* -------------------------------------------------------------------- */
/* --help-general */
/* -------------------------------------------------------------------- */
else if( EQUAL(papszArgv[iArg],"--help-general") )
{
printf( "Generic GDAL/OGR utility command options:\n" );
printf( " --version: report version of GDAL/OGR in use.\n" );
printf( " --license: report GDAL/OGR license info.\n" );
#ifdef OGR_ENABLED
printf( " --formats: report all configured format drivers.\n" );
#endif /* OGR_ENABLED */
printf( " --optfile filename: expand an option file into the argument list.\n" );
printf( " --config key value: set system configuration option.\n" );
printf( " --debug [on/off/value]: set debug level.\n" );
printf( " --help-general: report detailed help on general options.\n" );
CSLDestroy( papszReturn );
return 0;
}
/* -------------------------------------------------------------------- */
/* carry through unrecognised options. */
/* -------------------------------------------------------------------- */
else
{
papszReturn = CSLAddString( papszReturn, papszArgv[iArg] );
}
}
*ppapszArgv = papszReturn;
return CSLCount( *ppapszArgv );
}
示例6: main
int main( int argc, char ** argv )
{
int i;
int bGotSRS = FALSE;
int bPretty = FALSE;
int bValidate = FALSE;
int bDebug = FALSE;
int bFindEPSG = FALSE;
int nEPSGCode = -1;
const char *pszInput = NULL;
const char *pszOutputType = "default";
OGRSpatialReference oSRS;
/* Check strict compilation and runtime library version as we use C++ API */
if (! GDAL_CHECK_VERSION(argv[0]))
exit(1);
/* Must process GDAL_SKIP before GDALAllRegister(), but we can't call */
/* GDALGeneralCmdLineProcessor before it needs the drivers to be registered */
/* for the --format or --formats options */
for( i = 1; i < argc; i++ )
{
if( EQUAL(argv[i],"--config") && i + 2 < argc && EQUAL(argv[i + 1], "GDAL_SKIP") )
{
CPLSetConfigOption( argv[i+1], argv[i+2] );
i += 2;
}
}
/* -------------------------------------------------------------------- */
/* Register standard GDAL and OGR drivers. */
/* -------------------------------------------------------------------- */
GDALAllRegister();
#ifdef OGR_ENABLED
OGRRegisterAll();
#endif
/* -------------------------------------------------------------------- */
/* Process --formats option. */
/* Code copied from gcore/gdal_misc.cpp and ogr/ogrutils.cpp. */
/* This is not ideal, but is best for more descriptive output and */
/* we don't want to call OGRGeneralCmdLineProcessor(). */
/* -------------------------------------------------------------------- */
for( i = 1; i < argc; i++ )
{
if( EQUAL(argv[i], "--formats") )
{
int iDr;
/* GDAL formats */
printf( "Supported Raster Formats:\n" );
for( iDr = 0; iDr < GDALGetDriverCount(); iDr++ )
{
GDALDriverH hDriver = GDALGetDriver(iDr);
const char *pszRWFlag, *pszVirtualIO;
if( GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATE, NULL ) )
pszRWFlag = "rw+";
else if( GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATECOPY,
NULL ) )
pszRWFlag = "rw";
else
pszRWFlag = "ro";
if( GDALGetMetadataItem( hDriver, GDAL_DCAP_VIRTUALIO, NULL) )
pszVirtualIO = "v";
else
pszVirtualIO = "";
printf( " %s (%s%s): %s\n",
GDALGetDriverShortName( hDriver ),
pszRWFlag, pszVirtualIO,
GDALGetDriverLongName( hDriver ) );
}
/* OGR formats */
#ifdef OGR_ENABLED
printf( "\nSupported Vector Formats:\n" );
OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar();
for( iDr = 0; iDr < poR->GetDriverCount(); iDr++ )
{
OGRSFDriver *poDriver = poR->GetDriver(iDr);
if( poDriver->TestCapability( ODrCCreateDataSource ) )
printf( " -> \"%s\" (read/write)\n",
poDriver->GetName() );
else
printf( " -> \"%s\" (readonly)\n",
poDriver->GetName() );
}
#endif
exit(1);
}
}
//.........这里部分代码省略.........