本文整理汇总了C++中CSLTestBoolean函数的典型用法代码示例。如果您正苦于以下问题:C++ CSLTestBoolean函数的具体用法?C++ CSLTestBoolean怎么用?C++ CSLTestBoolean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CSLTestBoolean函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CPLAssert
int OGRMDBDataSource::Open( const char * pszNewName, int bUpdate,
int bTestOpen )
{
CPLAssert( nLayers == 0 );
pszName = CPLStrdup( pszNewName );
if (!env.Init())
return FALSE;
poDB = OGRMDBDatabase::Open(&env, pszNewName);
if (!poDB)
return FALSE;
poDB->FetchTableNames();
/* Is it a ESRI Personal Geodatabase ? */
OGRMDBTable* poGDB_GeomColumns = poDB->GetTable("GDB_GeomColumns");
if (poGDB_GeomColumns && !CSLTestBoolean(CPLGetConfigOption("MDB_RAW", "OFF")))
{
int nRet = OpenGDB(poGDB_GeomColumns);
delete poGDB_GeomColumns;
return nRet;
}
delete poGDB_GeomColumns;
/* Is it a Geomedia warehouse ? */
OGRMDBTable* poGAliasTable = poDB->GetTable("GAliasTable");
if (poGAliasTable && !CSLTestBoolean(CPLGetConfigOption("MDB_RAW", "OFF")))
{
int nRet = OpenGeomediaWarehouse(poGAliasTable);
delete poGAliasTable;
return nRet;
}
delete poGAliasTable;
/* Well, no, just a regular MDB */
int nTables = (int) poDB->apoTableNames.size();
for(int i=0;i<nTables;i++)
{
OGRMDBTable* poTable = poDB->GetTable(poDB->apoTableNames[i]);
if (poTable == NULL)
continue;
OGRMDBLayer* poLayer = new OGRMDBLayer( this, poTable );
if( poLayer->BuildFeatureDefn() != CE_None )
{
delete poLayer;
continue;
}
papoLayers = (OGRMDBLayer**)CPLRealloc(papoLayers, (nLayers+1) * sizeof(OGRMDBLayer*));
papoLayers[nLayers++] = poLayer;
}
return TRUE;
}
示例2: VFKReader
/*!
\brief VFKReaderSQLite constructor
*/
VFKReaderSQLite::VFKReaderSQLite(const char *pszFilename) : VFKReader(pszFilename)
{
const char *pszDbNameConf;
CPLString pszDbName;
CPLString osCommand;
VSIStatBufL sStatBuf;
bool bNewDb;
/* open tmp SQLite DB (re-use DB file if already exists) */
pszDbNameConf = CPLGetConfigOption("OGR_VFK_DB_NAME", NULL);
if (pszDbNameConf) {
pszDbName = pszDbNameConf;
}
else {
pszDbName.Printf("%s.db", m_pszFilename);
}
if (CSLTestBoolean(CPLGetConfigOption("OGR_VFK_DB_SPATIAL", "YES")))
m_bSpatial = TRUE; /* build geometry from DB */
else
m_bSpatial = FALSE; /* store also geometry in DB */
bNewDb = TRUE;
if (VSIStatL(pszDbName, &sStatBuf ) == 0) {
if (CSLTestBoolean(CPLGetConfigOption("OGR_VFK_DB_OVERWRITE", "NO"))) {
bNewDb = TRUE; /* overwrite existing DB */
VSIUnlink(pszDbName);
}
else {
bNewDb = FALSE; /* re-use exising DB */
}
}
else {
CPLError(CE_Warning, CPLE_AppDefined,
"SQLite DB not found. Reading VFK data may take some time...");
}
CPLDebug("OGR-VFK", "New DB: %s Spatial: %s",
bNewDb ? "yes" : "no", m_bSpatial ? "yes" : "no");
if (SQLITE_OK != sqlite3_open(pszDbName, &m_poDB)) {
CPLError(CE_Failure, CPLE_AppDefined,
"Creating SQLite DB failed");
}
else {
char* pszErrMsg = NULL;
sqlite3_exec(m_poDB, "PRAGMA synchronous = OFF", NULL, NULL, &pszErrMsg);
sqlite3_free(pszErrMsg);
}
if (bNewDb) {
/* new DB, create support metadata tables */
osCommand = "CREATE TABLE 'vfk_blocks' "
"(file_name text, table_name text, num_records integer, "
"num_geometries integer, table_defn text)";
ExecuteSQL(osCommand.c_str());
}
}
示例3: if
OGRLayer * OGRGPXDataSource::CreateLayer( const char * pszLayerName,
OGRSpatialReference *poSRS,
OGRwkbGeometryType eType,
char ** papszOptions )
{
GPXGeometryType gpxGeomType;
if (eType == wkbPoint || eType == wkbPoint25D)
{
if (EQUAL(pszLayerName, "track_points"))
gpxGeomType = GPX_TRACK_POINT;
else if (EQUAL(pszLayerName, "route_points"))
gpxGeomType = GPX_ROUTE_POINT;
else
gpxGeomType = GPX_WPT;
}
else if (eType == wkbLineString || eType == wkbLineString25D)
{
const char *pszForceGPXTrack = CSLFetchNameValue( papszOptions, "FORCE_GPX_TRACK");
if (pszForceGPXTrack && CSLTestBoolean(pszForceGPXTrack))
gpxGeomType = GPX_TRACK;
else
gpxGeomType = GPX_ROUTE;
}
else if (eType == wkbMultiLineString || eType == wkbMultiLineString25D)
{
const char *pszForceGPXRoute = CSLFetchNameValue( papszOptions, "FORCE_GPX_ROUTE");
if (pszForceGPXRoute && CSLTestBoolean(pszForceGPXRoute))
gpxGeomType = GPX_ROUTE;
else
gpxGeomType = GPX_TRACK;
}
else if (eType == wkbUnknown)
{
CPLError(CE_Failure, CPLE_NotSupported,
"Cannot create GPX layer %s with unknown geometry type", pszLayerName);
return NULL;
}
else
{
CPLError( CE_Failure, CPLE_NotSupported,
"Geometry type of `%s' not supported in GPX.\n",
OGRGeometryTypeToName(eType) );
return NULL;
}
nLayers++;
papoLayers = (OGRGPXLayer **) CPLRealloc(papoLayers, nLayers * sizeof(OGRGPXLayer*));
papoLayers[nLayers-1] = new OGRGPXLayer( pszName, pszLayerName, gpxGeomType, this, TRUE );
return papoLayers[nLayers-1];
}
示例4: defined
FILE *VSIFOpen( const char * pszFilename, const char * pszAccess )
{
FILE *fp = NULL;
int nError;
#if defined(WIN32) && !defined(WIN32CE)
if( CSLTestBoolean(
CPLGetConfigOption( "GDAL_FILENAME_IS_UTF8", "YES" ) ) )
{
wchar_t *pwszFilename =
CPLRecodeToWChar( pszFilename, CPL_ENC_UTF8, CPL_ENC_UCS2 );
wchar_t *pwszAccess =
CPLRecodeToWChar( pszAccess, CPL_ENC_UTF8, CPL_ENC_UCS2 );
fp = _wfopen( pwszFilename, pwszAccess );
CPLFree( pwszFilename );
CPLFree( pwszAccess );
}
else
#endif
fp = fopen( (char *) pszFilename, (char *) pszAccess );
nError = errno;
VSIDebug3( "VSIFOpen(%s,%s) = %p", pszFilename, pszAccess, fp );
errno = nError;
return( fp );
}
示例5: strchr
VSIVirtualHandle* VSICurlStreamingFSHandler::Open( const char *pszFilename,
const char *pszAccess )
{
if (strchr(pszAccess, 'w') != NULL ||
strchr(pszAccess, '+') != NULL)
{
CPLError(CE_Failure, CPLE_AppDefined,
"Only read-only mode is supported for /vsicurl_streaming");
return NULL;
}
VSICurlStreamingHandle* poHandle = new VSICurlStreamingHandle(
this, pszFilename + strlen("/vsicurl_streaming/"));
/* If we didn't get a filelist, check that the file really exists */
if (!poHandle->Exists())
{
delete poHandle;
poHandle = NULL;
}
if( CSLTestBoolean( CPLGetConfigOption( "VSI_CACHE", "FALSE" ) ) )
return VSICreateCachedFile( poHandle );
else
return poHandle;
}
示例6: OGRGetXML_UTF8_EscapedString
char* OGRGetXML_UTF8_EscapedString(const char* pszString)
{
char *pszEscaped;
if (!CPLIsUTF8(pszString, -1) &&
CSLTestBoolean(CPLGetConfigOption("OGR_FORCE_ASCII", "YES")))
{
static int bFirstTime = TRUE;
if (bFirstTime)
{
bFirstTime = FALSE;
CPLError(CE_Warning, CPLE_AppDefined,
"%s is not a valid UTF-8 string. Forcing it to ASCII.\n"
"If you still want the original string and change the XML file encoding\n"
"afterwards, you can define OGR_FORCE_ASCII=NO as configuration option.\n"
"This warning won't be issued anymore", pszString);
}
else
{
CPLDebug("OGR", "%s is not a valid UTF-8 string. Forcing it to ASCII",
pszString);
}
char* pszTemp = CPLForceToASCII(pszString, -1, '?');
pszEscaped = CPLEscapeString( pszTemp, -1, CPLES_XML );
CPLFree(pszTemp);
}
else
pszEscaped = CPLEscapeString( pszString, -1, CPLES_XML );
return pszEscaped;
}
示例7: VSI_FOPEN64
VSIVirtualHandle *
VSIUnixStdioFilesystemHandler::Open( const char *pszFilename,
const char *pszAccess )
{
FILE *fp = VSI_FOPEN64( pszFilename, pszAccess );
int nError = errno;
VSIDebug3( "VSIUnixStdioFilesystemHandler::Open(\"%s\",\"%s\") = %p",
pszFilename, pszAccess, fp );
if( fp == NULL )
{
errno = nError;
return NULL;
}
VSIUnixStdioHandle *poHandle = new VSIUnixStdioHandle(this, fp);
errno = nError;
/* -------------------------------------------------------------------- */
/* If VSI_CACHE is set we want to use a cached reader instead */
/* of more direct io on the underlying file. */
/* -------------------------------------------------------------------- */
if( (EQUAL(pszAccess,"r") || EQUAL(pszAccess,"rb"))
&& CSLTestBoolean( CPLGetConfigOption( "VSI_CACHE", "FALSE" ) ) )
{
return VSICreateCachedFile( poHandle );
}
else
{
return poHandle;
}
}
示例8: SetVertCS
void OGRSXFDataSource::SetVertCS(const long iVCS, SXFPassport& passport)
{
if (!CSLTestBoolean(CPLGetConfigOption("SXF_SET_VERTCS", "NO")))
return;
const long nEPSG = aoVCS[iVCS];
if (nEPSG == 0)
{
CPLError(CE_Warning, CPLE_NotSupported, "SXF. Vertical coordinate system (SXF index %ld) not supported", iVCS);
return;
}
OGRSpatialReference* sr = new OGRSpatialReference();
OGRErr eImportFromEPSGErr = sr->importFromEPSG(nEPSG);
if (eImportFromEPSGErr != OGRERR_NONE)
{
CPLError( CE_Warning, CPLE_None, "SXF. Vertical coordinate system (SXF index %ld, EPSG %ld) import from EPSG error", iVCS, nEPSG);
return;
}
if (sr->IsVertical() != 1)
{
CPLError( CE_Warning, CPLE_None, "SXF. Coordinate system (SXF index %ld, EPSG %ld) is not Vertical", iVCS, nEPSG);
return;
}
//passport.stMapDescription.pSpatRef->SetVertCS("Baltic", "Baltic Sea");
OGRErr eSetVertCSErr = passport.stMapDescription.pSpatRef->SetVertCS(sr->GetAttrValue("VERT_CS"), sr->GetAttrValue("VERT_DATUM"));
if (eSetVertCSErr != OGRERR_NONE)
{
CPLError(CE_Warning, CPLE_None, "SXF. Vertical coordinate system (SXF index %ld, EPSG %ld) set error", iVCS, nEPSG);
return;
}
}
示例9: GDALClose
CPLErr GDALDefaultOverviews::CleanOverviews()
{
// Anything to do?
if( poODS == NULL )
return CE_None;
// Delete the overview file(s).
GDALDriver *poOvrDriver;
poOvrDriver = poODS->GetDriver();
GDALClose( poODS );
poODS = NULL;
CPLErr eErr;
if( poOvrDriver != NULL )
eErr = poOvrDriver->Delete( osOvrFilename );
else
eErr = CE_None;
// Reset the saved overview filename.
if( !EQUAL(poDS->GetDescription(),":::VIRTUAL:::") )
{
int bUseRRD = CSLTestBoolean(CPLGetConfigOption("USE_RRD","NO"));
if( bUseRRD )
osOvrFilename = CPLResetExtension( poDS->GetDescription(), "aux" );
else
osOvrFilename.Printf( "%s.ovr", poDS->GetDescription() );
}
else
osOvrFilename = "";
return eErr;
}
示例10: CPLError
OGRErr OGRPGDumpLayer::CreateFeature( OGRFeature *poFeature )
{
if( NULL == poFeature )
{
CPLError( CE_Failure, CPLE_AppDefined,
"NULL pointer to OGRFeature passed to CreateFeature()." );
return OGRERR_FAILURE;
}
nFeatures ++;
// We avoid testing the config option too often.
if( bUseCopy == USE_COPY_UNSET )
bUseCopy = CSLTestBoolean( CPLGetConfigOption( "PG_USE_COPY", "NO") );
if( !bUseCopy )
{
return CreateFeatureViaInsert( poFeature );
}
else
{
if ( !bCopyActive )
{
/* This is a heuristics. If the first feature to be copied has a */
/* FID set (and that a FID column has been identified), then we will */
/* try to copy FID values from features. Otherwise, we will not */
/* do and assume that the FID column is an autoincremented column. */
StartCopy(poFeature->GetFID() != OGRNullFID);
}
return CreateFeatureViaCopy( poFeature );
}
}
示例11: CPLGetConfigOption
int VSIWin32FilesystemHandler::Stat( const char * pszFilename,
VSIStatBufL * pStatBuf,
int nFlags )
{
(void) nFlags;
#if (defined(WIN32) && _MSC_VER >= 1310) || __MSVCRT_VERSION__ >= 0x0601
if( CSLTestBoolean(
CPLGetConfigOption( "GDAL_FILENAME_IS_UTF8", "YES" ) ) )
{
int nResult;
wchar_t *pwszFilename =
CPLRecodeToWChar( pszFilename, CPL_ENC_UTF8, CPL_ENC_UCS2 );
nResult = _wstat64( pwszFilename, pStatBuf );
CPLFree( pwszFilename );
return nResult;
}
else
#endif
{
return( VSI_STAT64( pszFilename, pStatBuf ) );
}
}
示例12: CPLError
int OGRGPSBabelWriteDataSource::Create( const char * pszName,
char **papszOptions )
{
GDALDriver* poGPXDriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName("GPX");
if (poGPXDriver == NULL)
{
CPLError(CE_Failure, CPLE_AppDefined, "GPX driver is necessary for GPSBabel write support");
return FALSE;
}
if (!EQUALN(pszName, "GPSBABEL:", 9))
{
const char* pszOptionGPSBabelDriverName =
CSLFetchNameValue(papszOptions, "GPSBABEL_DRIVER");
if (pszOptionGPSBabelDriverName != NULL)
pszGPSBabelDriverName = CPLStrdup(pszOptionGPSBabelDriverName);
else
{
CPLError(CE_Failure, CPLE_AppDefined, "GPSBABEL_DRIVER dataset creation option expected");
return FALSE;
}
pszFilename = CPLStrdup(pszName);
}
else
{
const char* pszSep = strchr(pszName + 9, ':');
if (pszSep == NULL)
{
CPLError(CE_Failure, CPLE_AppDefined,
"Wrong syntax. Expected GPSBabel:driver_name[,options]*:file_name");
return FALSE;
}
pszGPSBabelDriverName = CPLStrdup(pszName + 9);
*(strchr(pszGPSBabelDriverName, ':')) = '\0';
pszFilename = CPLStrdup(pszSep+1);
}
/* A bit of validation to avoid command line injection */
if (!OGRGPSBabelDataSource::IsValidDriverName(pszGPSBabelDriverName))
return FALSE;
const char* pszOptionUseTempFile = CSLFetchNameValue(papszOptions, "USE_TEMPFILE");
if (pszOptionUseTempFile == NULL)
pszOptionUseTempFile = CPLGetConfigOption("USE_TEMPFILE", NULL);
if (pszOptionUseTempFile && CSLTestBoolean(pszOptionUseTempFile))
osTmpFileName = CPLGenerateTempFilename(NULL);
else
osTmpFileName.Printf("/vsimem/ogrgpsbabeldatasource_%p", this);
poGPXDS = poGPXDriver->Create(osTmpFileName.c_str(), 0, 0, 0, GDT_Unknown, papszOptions);
if (poGPXDS == NULL)
return FALSE;
this->pszName = CPLStrdup(pszName);
return TRUE;
}
示例13: OGRFeatureDefn
OGRSEGP1Layer::OGRSEGP1Layer( const char* pszFilename,
VSILFILE* fp,
int nLatitudeCol )
{
this->fp = fp;
this->nLatitudeCol = nLatitudeCol;
nNextFID = 0;
bEOF = FALSE;
poSRS = NULL;
poFeatureDefn = new OGRFeatureDefn( CPLGetBasename(pszFilename) );
SetDescription( poFeatureDefn->GetName() );
poFeatureDefn->Reference();
poFeatureDefn->SetGeomType( wkbPoint );
for(int i=0;i<(int)(sizeof(SEGP1Fields)/sizeof(SEGP1Fields[0]));i++)
{
OGRFieldDefn oField( SEGP1Fields[i].pszName,
SEGP1Fields[i].eType );
poFeatureDefn->AddFieldDefn( &oField );
}
bUseEastingNorthingAsGeometry =
CSLTestBoolean(CPLGetConfigOption("SEGP1_USE_EASTING_NORTHING", "NO"));
ResetReading();
}
示例14: OGRSQLiteRegisterRegExpFunction
static
void* OGRSQLiteRegisterRegExpFunction(
#ifndef HAVE_PCRE
CPL_UNUSED
#endif
sqlite3* hDB)
{
#ifdef HAVE_PCRE
/* For debugging purposes mostly */
if( !CSLTestBoolean(CPLGetConfigOption("OGR_SQLITE_REGEXP", "YES")) )
return NULL;
/* Check if we really need to define our own REGEXP function */
int rc = sqlite3_exec(hDB, "SELECT 'a' REGEXP 'a'", NULL, NULL, NULL);
if( rc == SQLITE_OK )
{
CPLDebug("SQLITE", "REGEXP already available");
return NULL;
}
cache_entry *cache = (cache_entry*) CPLCalloc(CACHE_SIZE, sizeof(cache_entry));
sqlite3_create_function(hDB, "REGEXP", 2, SQLITE_UTF8, cache,
OGRSQLiteREGEXPFunction, NULL, NULL);
/* To clear the error flag */
sqlite3_exec(hDB, "SELECT 1", NULL, NULL, NULL);
return cache;
#else // HAVE_PCRE
return NULL;
#endif // HAVE_PCRE
}
示例15: rename
int VSIWin32FilesystemHandler::Rename( const char *oldpath,
const char *newpath )
{
#if (defined(WIN32) && _MSC_VER >= 1310) || __MSVCRT_VERSION__ >= 0x0601
if( CSLTestBoolean(
CPLGetConfigOption( "GDAL_FILENAME_IS_UTF8", "YES" ) ) )
{
int nResult;
wchar_t *pwszOldPath =
CPLRecodeToWChar( oldpath, CPL_ENC_UTF8, CPL_ENC_UCS2 );
wchar_t *pwszNewPath =
CPLRecodeToWChar( newpath, CPL_ENC_UTF8, CPL_ENC_UCS2 );
nResult = _wrename( pwszOldPath, pwszNewPath );
CPLFree( pwszOldPath );
CPLFree( pwszNewPath );
return nResult;
}
else
#endif
{
return rename( oldpath, newpath );
}
}