本文整理汇总了C++中OGRSFDriver::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRSFDriver::GetName方法的具体用法?C++ OGRSFDriver::GetName怎么用?C++ OGRSFDriver::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRSFDriver
的用法示例。
在下文中一共展示了OGRSFDriver::GetName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetGDALDriverManager
Handle<Value> GDALDrivers::getNames(const Arguments& args)
{
HandleScope scope;
int gdal_count = GetGDALDriverManager()->GetDriverCount();
int i, ogr_count = 0;
std::string name;
#if GDAL_VERSION_MAJOR < 2
ogr_count = OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount();
#endif
int n = gdal_count + ogr_count;
Local<Array> driver_names = Array::New(n);
for (i = 0; i < gdal_count; ++i) {
GDALDriver *driver = GetGDALDriverManager()->GetDriver(i);
name = driver->GetDescription();
#if GDAL_VERSION_MAJOR < 2
if(name == "VRT") name = "VRT:raster";
#endif
driver_names->Set(i, SafeString::New(name.c_str()));
}
for (; i < n; ++i) {
OGRSFDriver *driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriver(i - gdal_count);
name = driver->GetName();
#if GDAL_VERSION_MAJOR < 2
if(name == "VRT") name = "VRT:vector";
#endif
driver_names->Set(i, SafeString::New(name.c_str()));
}
return scope.Close(driver_names);
}
示例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: getDriversNames
void TeOGRDriver::getDriversNames(std::vector<std::string>& dnames)
{
int ndrivers = OGRSFDriverRegistrar::GetRegistrar()->GetDriverCount();
for(int i = 0; i < ndrivers; ++i)
{
OGRSFDriver* driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriver(i);
dnames.push_back(driver->GetName());
}
}
示例4:
JNIEXPORT jstring JNICALL Java_es_gva_cit_jogr_OGRSFDriver_getNameNat
(JNIEnv *env, jobject obj, jlong cPtr){
OGRSFDriver *drv = (OGRSFDriver *) 0 ;
jstring nom_drv;
drv = *(OGRSFDriver **)&cPtr;
const char *name = drv->GetName();
if(name!=NULL)
nom_drv = env->NewStringUTF(name);
else return NULL;
return nom_drv;
}
示例5: testFormatAvailable
bool AoIIntersection::testFormatAvailable ( const char *outFmt )
{
// this is how you find what drivers are available
OGRSFDriverRegistrar *reg = OGRSFDriverRegistrar::GetRegistrar();
int driverCount = reg->GetDriverCount();
for ( int i = 0; i < driverCount; ++i )
{
OGRSFDriver *driver = reg->GetDriver( i );
if ( driver )
{
const char *name = driver->GetName();
if (! stricmp( name, outFmt ))
return true;
}
}
return false;
}
示例6: 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 );
}
示例7: main
//.........这里部分代码省略.........
if( pszDataSource == NULL )
Usage();
/* -------------------------------------------------------------------- */
/* Open data source. */
/* -------------------------------------------------------------------- */
OGRDataSource *poDS = NULL;
OGRSFDriver *poDriver = NULL;
poDS = OGRSFDriverRegistrar::Open( pszDataSource, !bReadOnly, &poDriver );
if( poDS == NULL && !bReadOnly )
{
poDS = OGRSFDriverRegistrar::Open( pszDataSource, FALSE, &poDriver );
if( poDS != NULL && bVerbose )
{
printf( "Had to open data source read-only.\n" );
bReadOnly = TRUE;
}
}
/* -------------------------------------------------------------------- */
/* Report failure */
/* -------------------------------------------------------------------- */
if( poDS == NULL )
{
OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar();
printf( "FAILURE:\n"
"Unable to open datasource `%s' with the following drivers.\n",
pszDataSource );
for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
{
printf( " -> %s\n", poR->GetDriver(iDriver)->GetName() );
}
exit( 1 );
}
CPLAssert( poDriver != NULL);
/* -------------------------------------------------------------------- */
/* Some information messages. */
/* -------------------------------------------------------------------- */
if( bVerbose )
printf( "INFO: Open of `%s'\n"
" using driver `%s' successful.\n",
pszDataSource, poDriver->GetName() );
if( bVerbose && !EQUAL(pszDataSource,poDS->GetName()) )
{
printf( "INFO: Internal data source name `%s'\n"
" different from user name `%s'.\n",
poDS->GetName(), pszDataSource );
}
/* -------------------------------------------------------------------- */
/* Special case for -sql clause. No source layers required. */
/* -------------------------------------------------------------------- */
if( pszSQLStatement != NULL )
{
OGRLayer *poResultSet = NULL;
nRepeatCount = 0; // skip layer reporting.
if( CSLCount(papszLayers) > 0 )
示例8: main
int main( int nArgc, char ** papszArgv )
{
const char *pszWHERE = NULL;
const char *pszDataSource = NULL;
char **papszLayers = NULL;
OGRGeometry *poSpatialFilter = NULL;
/* -------------------------------------------------------------------- */
/* Register format(s). */
/* -------------------------------------------------------------------- */
RegisterOGRTAB();
/* -------------------------------------------------------------------- */
/* Processing command line arguments. */
/* -------------------------------------------------------------------- */
for( int iArg = 1; iArg < nArgc; iArg++ )
{
if( EQUAL(papszArgv[iArg],"-ro") )
bReadOnly = TRUE;
else if( EQUAL(papszArgv[iArg],"-q") )
bVerbose = FALSE;
else if( EQUAL(papszArgv[iArg],"-spat")
&& papszArgv[iArg+1] != NULL
&& papszArgv[iArg+2] != NULL
&& papszArgv[iArg+3] != NULL
&& papszArgv[iArg+4] != NULL )
{
OGRLinearRing oRing;
oRing.addPoint( atof(papszArgv[iArg+1]), atof(papszArgv[iArg+2]) );
oRing.addPoint( atof(papszArgv[iArg+1]), atof(papszArgv[iArg+4]) );
oRing.addPoint( atof(papszArgv[iArg+3]), atof(papszArgv[iArg+4]) );
oRing.addPoint( atof(papszArgv[iArg+3]), atof(papszArgv[iArg+2]) );
oRing.addPoint( atof(papszArgv[iArg+1]), atof(papszArgv[iArg+2]) );
poSpatialFilter = new OGRPolygon();
((OGRPolygon *) poSpatialFilter)->addRing( &oRing );
iArg += 4;
}
else if( EQUAL(papszArgv[iArg],"-where") && papszArgv[iArg+1] != NULL )
{
pszWHERE = papszArgv[++iArg];
}
else if( papszArgv[iArg][0] == '-' )
{
Usage();
}
else if( pszDataSource == NULL )
pszDataSource = papszArgv[iArg];
else
papszLayers = CSLAddString( papszLayers, papszArgv[iArg] );
}
if( pszDataSource == NULL )
Usage();
/* -------------------------------------------------------------------- */
/* Open data source. */
/* -------------------------------------------------------------------- */
OGRDataSource *poDS;
OGRSFDriver *poDriver;
poDS = OGRSFDriverRegistrar::Open( pszDataSource, !bReadOnly, &poDriver );
if( poDS == NULL && !bReadOnly )
{
poDS = OGRSFDriverRegistrar::Open( pszDataSource, FALSE, &poDriver );
if( poDS != NULL && bVerbose )
{
printf( "Had to open data source read-only.\n" );
bReadOnly = TRUE;
}
}
/* -------------------------------------------------------------------- */
/* Report failure */
/* -------------------------------------------------------------------- */
if( poDS == NULL )
{
OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar();
printf( "FAILURE:\n"
"Unable to open datasource `%s' with the following drivers.\n",
pszDataSource );
for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
{
printf( " -> %s\n", poR->GetDriver(iDriver)->GetName() );
}
exit( 1 );
}
/* -------------------------------------------------------------------- */
/* Some information messages. */
/* -------------------------------------------------------------------- */
if( bVerbose )
printf( "INFO: Open of `%s'\n"
"using driver `%s' successful.\n",
pszDataSource, poDriver->GetName() );
//.........这里部分代码省略.........
示例9: 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);
}
}
//.........这里部分代码省略.........
示例10: main
int main( int nArgc, char ** papszArgv )
{
const char *pszDataSource = NULL;
char** papszLayers = NULL;
const char *pszSQLStatement = NULL;
int bRet = TRUE;
/* Must process OGR_SKIP before OGRRegisterAll(), but we can't call */
/* OGRGeneralCmdLineProcessor before it needs the drivers to be registered */
/* for the --format or --formats options */
for( int iArg = 1; iArg < nArgc; iArg++ )
{
if( EQUAL(papszArgv[iArg], "--config") && iArg + 2 < nArgc &&
EQUAL(papszArgv[iArg+1], "OGR_SKIP") )
{
CPLSetConfigOption(papszArgv[iArg+1], papszArgv[iArg+2]);
break;
}
}
/* -------------------------------------------------------------------- */
/* Register format(s). */
/* -------------------------------------------------------------------- */
OGRRegisterAll();
/* -------------------------------------------------------------------- */
/* Processing command line arguments. */
/* -------------------------------------------------------------------- */
nArgc = OGRGeneralCmdLineProcessor( nArgc, &papszArgv, 0 );
if( nArgc < 1 )
exit( -nArgc );
/* -------------------------------------------------------------------- */
/* Processing command line arguments. */
/* -------------------------------------------------------------------- */
for( int iArg = 1; iArg < nArgc; iArg++ )
{
if( EQUAL(papszArgv[iArg], "--utility_version") )
{
printf("%s was compiled against GDAL %s and is running against GDAL %s\n",
papszArgv[0], GDAL_RELEASE_NAME, GDALVersionInfo("RELEASE_NAME"));
return 0;
}
else if( EQUAL(papszArgv[iArg],"-ro") )
bReadOnly = TRUE;
else if( EQUAL(papszArgv[iArg],"-q") || EQUAL(papszArgv[iArg],"-quiet"))
bVerbose = FALSE;
else if( EQUAL(papszArgv[iArg],"-sql") && iArg + 1 < nArgc)
pszSQLStatement = papszArgv[++iArg];
else if( papszArgv[iArg][0] == '-' )
{
Usage();
}
else if (pszDataSource == NULL)
pszDataSource = papszArgv[iArg];
else
papszLayers = CSLAddString(papszLayers, papszArgv[iArg]);
}
if( pszDataSource == NULL )
Usage();
/* -------------------------------------------------------------------- */
/* Open data source. */
/* -------------------------------------------------------------------- */
OGRDataSource *poDS;
OGRSFDriver *poDriver;
poDS = OGRSFDriverRegistrar::Open( pszDataSource, !bReadOnly, &poDriver );
if( poDS == NULL && !bReadOnly )
{
poDS = OGRSFDriverRegistrar::Open( pszDataSource, FALSE, &poDriver );
if( poDS != NULL && bVerbose )
{
printf( "Had to open data source read-only.\n" );
bReadOnly = TRUE;
}
}
/* -------------------------------------------------------------------- */
/* Report failure */
/* -------------------------------------------------------------------- */
if( poDS == NULL )
{
OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar();
printf( "FAILURE:\n"
"Unable to open datasource `%s' with the following drivers.\n",
pszDataSource );
for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
{
printf( " -> %s\n", poR->GetDriver(iDriver)->GetName() );
}
exit( 1 );
}
//.........这里部分代码省略.........