本文整理汇总了C++中CPLResetExtension函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLResetExtension函数的具体用法?C++ CPLResetExtension怎么用?C++ CPLResetExtension使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CPLResetExtension函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PAuxDelete
static CPLErr PAuxDelete( const char * pszBasename )
{
VSILFILE *fp = VSIFOpenL( CPLResetExtension( pszBasename, "aux" ), "r" );
if( fp == NULL )
{
CPLError( CE_Failure, CPLE_AppDefined,
"%s does not appear to be a PAux dataset, there is no .aux file.",
pszBasename );
return CE_Failure;
}
const char *pszLine = CPLReadLineL( fp );
CPL_IGNORE_RET_VAL(VSIFCloseL( fp ));
if( pszLine == NULL || !STARTS_WITH_CI(pszLine, "AuxilaryTarget") )
{
CPLError( CE_Failure, CPLE_AppDefined,
"%s does not appear to be a PAux dataset,\n"
"the .aux file does not start with AuxilaryTarget",
pszBasename );
return CE_Failure;
}
if( VSIUnlink( pszBasename ) != 0 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"OS unlinking file %s.", pszBasename );
return CE_Failure;
}
VSIUnlink( CPLResetExtension( pszBasename, "aux" ) );
return CE_None;
}
示例2: CPLResetExtension
OGRSpatialReference *OGRShapeLayer::GetSpatialRef()
{
if (bSRSSet)
return poSRS;
bSRSSet = TRUE;
/* -------------------------------------------------------------------- */
/* Is there an associated .prj file we can read? */
/* -------------------------------------------------------------------- */
const char *pszPrjFile = CPLResetExtension( pszFullName, "prj" );
char **papszLines;
char* apszOptions[] = { (char*)"EMIT_ERROR_IF_CANNOT_OPEN_FILE=FALSE", NULL };
papszLines = CSLLoad2( pszPrjFile, -1, -1, apszOptions );
if (papszLines == NULL)
{
pszPrjFile = CPLResetExtension( pszFullName, "PRJ" );
papszLines = CSLLoad2( pszPrjFile, -1, -1, apszOptions );
}
if( papszLines != NULL )
{
poSRS = new OGRSpatialReference();
if( poSRS->importFromESRI( papszLines ) != OGRERR_NONE )
{
delete poSRS;
poSRS = NULL;
}
CSLDestroy( papszLines );
}
return poSRS;
}
示例3: GetWorldFilePath
CPLString GetWorldFilePath(const CPLString &soPath)
{
//1. thirst and last char from ext and third char set w (e.g. jpw)
CPLString sExt = CPLGetExtension(soPath);
CPLString sNewExt;
sNewExt += sExt[0];
sNewExt += sExt[sExt.size() - 1];
sNewExt += 'w';
CPLString szPath = (char*)CPLResetExtension(soPath, sNewExt);
if(CPLCheckForFile((char*)szPath.c_str(), NULL))
return szPath;
//4. add wx to ext
sNewExt += 'x';
szPath = (char*)CPLResetExtension(soPath, sNewExt);
if(CPLCheckForFile((char*)szPath.c_str(), NULL))
return szPath;
//2. wld
szPath = (char*)CPLResetExtension(soPath, "wld");
if(CPLCheckForFile((char*)szPath.c_str(), NULL))
return szPath;
//3. add w to ext
szPath = soPath + CPLString("w");
if(CPLCheckForFile((char*)szPath.c_str(), NULL))
return szPath;
return CPLString();
}
示例4: CPLError
OGRErr OGRShapeLayer::DropSpatialIndex()
{
if( !CheckForQIX() )
{
CPLError( CE_Warning, CPLE_AppDefined,
"Layer %s has no spatial index, DROP SPATIAL INDEX failed.",
poFeatureDefn->GetName() );
return OGRERR_FAILURE;
}
VSIFClose( fpQIX );
fpQIX = NULL;
bCheckedForQIX = FALSE;
const char *pszQIXFilename;
pszQIXFilename = CPLResetExtension( pszFullName, "qix" );
CPLDebug( "SHAPE", "Unlinking index file %s", pszQIXFilename );
if( VSIUnlink( pszQIXFilename ) != 0 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Failed to delete file %s.\n%s",
pszQIXFilename, VSIStrerror( errno ) );
return OGRERR_FAILURE;
}
if( !bSbnSbxDeleted )
{
const char *pszIndexFilename;
const char papszExt[2][4] = { "sbn", "sbx" };
int i;
for( i = 0; i < 2; i++ )
{
pszIndexFilename = CPLResetExtension( pszFullName, papszExt[i] );
CPLDebug( "SHAPE", "Trying to unlink index file %s", pszIndexFilename );
if( VSIUnlink( pszIndexFilename ) != 0 )
{
CPLDebug( "SHAPE",
"Failed to delete file %s.\n%s",
pszIndexFilename, VSIStrerror( errno ) );
}
}
}
bSbnSbxDeleted = TRUE;
return OGRERR_NONE;
}
示例5: CPLError
OGRErr OGRShapeDataSource::DeleteLayer( int iLayer )
{
char *pszFilename;
/* -------------------------------------------------------------------- */
/* Verify we are in update mode. */
/* -------------------------------------------------------------------- */
if( !bDSUpdate )
{
CPLError( CE_Failure, CPLE_NoWriteAccess,
"Data source %s opened read-only.\n"
"Layer %d cannot be deleted.\n",
pszName, iLayer );
return OGRERR_FAILURE;
}
if( iLayer < 0 || iLayer >= nLayers )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Layer %d not in legal range of 0 to %d.",
iLayer, nLayers-1 );
return OGRERR_FAILURE;
}
OGRShapeLayer* poLayerToDelete = (OGRShapeLayer*) papoLayers[iLayer];
pszFilename = CPLStrdup(poLayerToDelete->GetFullName());
delete poLayerToDelete;
while( iLayer < nLayers - 1 )
{
papoLayers[iLayer] = papoLayers[iLayer+1];
iLayer++;
}
nLayers--;
VSIUnlink( CPLResetExtension(pszFilename, "shp") );
VSIUnlink( CPLResetExtension(pszFilename, "shx") );
VSIUnlink( CPLResetExtension(pszFilename, "dbf") );
VSIUnlink( CPLResetExtension(pszFilename, "prj") );
VSIUnlink( CPLResetExtension(pszFilename, "qix") );
CPLFree( pszFilename );
return OGRERR_NONE;
}
示例6: GDALClose
CPLErr GDALDefaultOverviews::CleanOverviews()
{
// Anything to do?
if( poODS == NULL )
return CE_None;
// Delete the overview file(s).
GDALDriver *poOvrDriver = poODS->GetDriver();
GDALClose( poODS );
poODS = NULL;
const CPLErr eErr = poOvrDriver != NULL ?
poOvrDriver->Delete( osOvrFilename ) : CE_None;
// Reset the saved overview filename.
if( !EQUAL(poDS->GetDescription(),":::VIRTUAL:::") )
{
const bool bUseRRD = CPLTestBool(CPLGetConfigOption("USE_RRD","NO"));
if( bUseRRD )
osOvrFilename = CPLResetExtension( poDS->GetDescription(), "aux" );
else
osOvrFilename.Printf( "%s.ovr", poDS->GetDescription() );
}
else
{
osOvrFilename = "";
}
return eErr;
}
示例7: CPLError
OGRErr OGRSXFDriver::DeleteDataSource(const char* pszName)
{
int iExt;
//TODO: add more extensions if aplicable
static const char *apszExtensions[] = { "szf", "rsc", "SZF", "RSC", NULL };
VSIStatBufL sStatBuf;
if (VSIStatL(pszName, &sStatBuf) != 0)
{
CPLError(CE_Failure, CPLE_AppDefined,
"%s does not appear to be a valid sxf file.",
pszName);
return OGRERR_FAILURE;
}
for (iExt = 0; apszExtensions[iExt] != NULL; iExt++)
{
const char *pszFile = CPLResetExtension(pszName,
apszExtensions[iExt]);
if (VSIStatL(pszFile, &sStatBuf) == 0)
VSIUnlink(pszFile);
}
return OGRERR_NONE;
}
示例8: CPLError
OGRErr OGRShapeLayer::DropSpatialIndex()
{
if( !CheckForQIX() )
{
CPLError( CE_Warning, CPLE_AppDefined,
"Layer %s has no spatial index, DROP SPATIAL INDEX failed.",
poFeatureDefn->GetName() );
return OGRERR_FAILURE;
}
VSIFClose( fpQIX );
fpQIX = NULL;
bCheckedForQIX = FALSE;
const char *pszQIXFilename;
pszQIXFilename = CPLResetExtension( pszFullName, "qix" );
CPLDebug( "SHAPE", "Unlinking index file %s", pszQIXFilename );
if( VSIUnlink( pszQIXFilename ) != 0 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Failed to delete file %s.\n%s",
pszQIXFilename, VSIStrerror( errno ) );
return OGRERR_FAILURE;
}
else
return OGRERR_NONE;
}
示例9: CPLError
OGRErr OGRGeoconceptDriver::DeleteDataSource( const char *pszDataSource )
{
int iExt;
VSIStatBuf sStatBuf;
static const char *apszExtensions[] =
{ "gxt", "txt", "gct", "gcm", "gcr", NULL };
if( VSIStat( pszDataSource, &sStatBuf ) != 0 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"%s does not appear to be a file or directory.",
pszDataSource );
return OGRERR_FAILURE;
}
if( VSI_ISREG(sStatBuf.st_mode)
&& (
EQUAL(CPLGetExtension(pszDataSource),"gxt") ||
EQUAL(CPLGetExtension(pszDataSource),"txt")
) )
{
for( iExt=0; apszExtensions[iExt] != NULL; iExt++ )
{
const char *pszFile = CPLResetExtension(pszDataSource,
apszExtensions[iExt] );
if( VSIStat( pszFile, &sStatBuf ) == 0 )
VSIUnlink( pszFile );
}
}
else if( VSI_ISDIR(sStatBuf.st_mode) )
{
char **papszDirEntries = CPLReadDir( pszDataSource );
int iFile;
for( iFile = 0;
papszDirEntries != NULL && papszDirEntries[iFile] != NULL;
iFile++ )
{
if( CSLFindString( (char **) apszExtensions,
CPLGetExtension(papszDirEntries[iFile])) != -1)
{
VSIUnlink( CPLFormFilename( pszDataSource,
papszDirEntries[iFile],
NULL ) );
}
}
CSLDestroy( papszDirEntries );
VSIRmdir( pszDataSource );
}
return OGRERR_NONE;
}
示例10: DropSpatialIndex
OGRErr OGRShapeLayer::CreateSpatialIndex( int nMaxDepth )
{
/* -------------------------------------------------------------------- */
/* If we have an existing spatial index, blow it away first. */
/* -------------------------------------------------------------------- */
if( CheckForQIX() )
DropSpatialIndex();
bCheckedForQIX = FALSE;
/* -------------------------------------------------------------------- */
/* Build a quadtree structure for this file. */
/* -------------------------------------------------------------------- */
SHPTree *psTree;
SyncToDisk();
psTree = SHPCreateTree( hSHP, 2, nMaxDepth, NULL, NULL );
if( NULL == psTree )
{
// TODO - mloskot: Is it better to return OGRERR_NOT_ENOUGH_MEMORY?
CPLDebug( "SHAPE",
"Index creation failure. Likely, memory allocation error." );
return OGRERR_FAILURE;
}
/* -------------------------------------------------------------------- */
/* Trim unused nodes from the tree. */
/* -------------------------------------------------------------------- */
SHPTreeTrimExtraNodes( psTree );
/* -------------------------------------------------------------------- */
/* Dump tree to .qix file. */
/* -------------------------------------------------------------------- */
char *pszQIXFilename;
pszQIXFilename = CPLStrdup(CPLResetExtension( pszFullName, "qix" ));
CPLDebug( "SHAPE", "Creating index file %s", pszQIXFilename );
SHPWriteTree( psTree, pszQIXFilename );
CPLFree( pszQIXFilename );
/* -------------------------------------------------------------------- */
/* cleanup */
/* -------------------------------------------------------------------- */
SHPDestroyTree( psTree );
CheckForQIX();
return OGRERR_NONE;
}
示例11: CPLFormFilename
void OGROpenFileGDBDataSource::AddLayer( const CPLString& osName,
int nInterestTable,
int& nCandidateLayers,
int& nLayersSDC,
const CPLString& osDefinition,
const CPLString& osDocumentation,
const char* pszGeomName,
OGRwkbGeometryType eGeomType )
{
std::map<std::string, int>::const_iterator oIter =
m_osMapNameToIdx.find(osName);
int idx = 0;
if( oIter != m_osMapNameToIdx.end() )
idx = oIter->second;
if( idx > 0 && (nInterestTable < 0 || nInterestTable == idx) )
{
const char* pszFilename = CPLFormFilename(
m_osDirName, CPLSPrintf("a%08x", idx), "gdbtable");
if( FileExists(pszFilename) )
{
nCandidateLayers ++;
if( m_papszFiles != NULL )
{
const char* pszSDC = CPLResetExtension(pszFilename, "gdbtable.sdc");
if( FileExists(pszSDC) )
{
nLayersSDC ++;
CPLError(CE_Warning, CPLE_AppDefined,
"%s layer has a %s file whose format is unhandled",
osName.c_str(), pszSDC);
return;
}
}
m_apoLayers.push_back(
new OGROpenFileGDBLayer(pszFilename,
osName,
osDefinition,
osDocumentation,
pszGeomName, eGeomType));
}
}
}
示例12: CPLFree
CPLErr SAGADataset::SetProjection( const char *pszSRS )
{
/* -------------------------------------------------------------------- */
/* Reset coordinate system on the dataset. */
/* -------------------------------------------------------------------- */
CPLFree( pszProjection );
pszProjection = CPLStrdup( pszSRS );
if( strlen(pszSRS) == 0 )
return CE_None;
/* -------------------------------------------------------------------- */
/* Convert to ESRI WKT. */
/* -------------------------------------------------------------------- */
OGRSpatialReference oSRS( pszSRS );
char *pszESRI_SRS = NULL;
oSRS.morphToESRI();
oSRS.exportToWkt( &pszESRI_SRS );
/* -------------------------------------------------------------------- */
/* Write to .prj file. */
/* -------------------------------------------------------------------- */
CPLString osPrjFilename = CPLResetExtension( GetDescription(), "prj" );
VSILFILE *fp;
fp = VSIFOpenL( osPrjFilename.c_str(), "wt" );
if( fp != NULL )
{
VSIFWriteL( pszESRI_SRS, 1, strlen(pszESRI_SRS), fp );
VSIFWriteL( (void *) "\n", 1, 1, fp );
VSIFCloseL( fp );
}
CPLFree( pszESRI_SRS );
return CE_None;
}
示例13: STARTS_WITH_CI
GDALDataset *PAuxDataset::Open( GDALOpenInfo * poOpenInfo )
{
if( poOpenInfo->nHeaderBytes < 1 )
return NULL;
/* -------------------------------------------------------------------- */
/* If this is an .aux file, fetch out and form the name of the */
/* file it references. */
/* -------------------------------------------------------------------- */
CPLString osTarget = poOpenInfo->pszFilename;
if( EQUAL(CPLGetExtension( poOpenInfo->pszFilename ),"aux")
&& STARTS_WITH_CI((const char *) poOpenInfo->pabyHeader, "AuxilaryTarget: "))
{
char szAuxTarget[1024];
const char *pszSrc = reinterpret_cast<const char *>(
poOpenInfo->pabyHeader+16 );
int i = 0;
for( ;
pszSrc[i] != 10 && pszSrc[i] != 13 && pszSrc[i] != '\0'
&& i < static_cast<int>( sizeof(szAuxTarget) ) - 1;
i++ )
{
szAuxTarget[i] = pszSrc[i];
}
szAuxTarget[i] = '\0';
char *pszPath = CPLStrdup(CPLGetPath(poOpenInfo->pszFilename));
osTarget = CPLFormFilename(pszPath, szAuxTarget, NULL);
CPLFree(pszPath);
}
/* -------------------------------------------------------------------- */
/* Now we need to tear apart the filename to form a .aux */
/* filename. */
/* -------------------------------------------------------------------- */
CPLString osAuxFilename = CPLResetExtension(osTarget,"aux");
/* -------------------------------------------------------------------- */
/* Do we have a .aux file? */
/* -------------------------------------------------------------------- */
char** papszSiblingFiles = poOpenInfo->GetSiblingFiles();
if( papszSiblingFiles != NULL
&& CSLFindString( papszSiblingFiles,
CPLGetFilename(osAuxFilename) ) == -1 )
{
return NULL;
}
VSILFILE *fp = VSIFOpenL( osAuxFilename, "r" );
if( fp == NULL )
{
osAuxFilename = CPLResetExtension(osTarget,"AUX");
fp = VSIFOpenL( osAuxFilename, "r" );
}
if( fp == NULL )
return NULL;
/* -------------------------------------------------------------------- */
/* Is this file a PCI .aux file? Check the first line for the */
/* telltale AuxilaryTarget keyword. */
/* */
/* At this point we should be verifying that it refers to our */
/* binary file, but that is a pretty involved test. */
/* -------------------------------------------------------------------- */
const char *pszLine = CPLReadLineL( fp );
CPL_IGNORE_RET_VAL(VSIFCloseL( fp ));
if( pszLine == NULL
|| (!STARTS_WITH_CI(pszLine, "AuxilaryTarget")
&& !STARTS_WITH_CI(pszLine, "AuxiliaryTarget")) )
{
return NULL;
}
/* -------------------------------------------------------------------- */
/* Create a corresponding GDALDataset. */
/* -------------------------------------------------------------------- */
PAuxDataset *poDS = new PAuxDataset();
/* -------------------------------------------------------------------- */
/* Load the .aux file into a string list suitable to be */
/* searched with CSLFetchNameValue(). */
/* -------------------------------------------------------------------- */
poDS->papszAuxLines = CSLLoad( osAuxFilename );
poDS->pszAuxFilename = CPLStrdup(osAuxFilename);
/* -------------------------------------------------------------------- */
/* Find the RawDefinition line to establish overall parameters. */
/* -------------------------------------------------------------------- */
pszLine = CSLFetchNameValue(poDS->papszAuxLines, "RawDefinition");
// It seems PCI now writes out .aux files without RawDefinition in
// some cases. See bug 947.
if( pszLine == NULL )
//.........这里部分代码省略.........
示例14: CSLCount
bool wxGxPrjFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds)
{
bool bCheckNames = CSLCount(pFileNames) < CHECK_DUBLES_MAX_COUNT;
for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- )
{
CPLString szExt = CPLGetExtension(pFileNames[i]);
wxGxObject* pGxObj = NULL;
if(wxGISEQUAL(szExt, "prj"))
{
bool bAdd = true;
for(int j = 0; prj_notadd_exts[j] != NULL; ++j )
{
if(CPLCheckForFile((char*)CPLResetExtension(pFileNames[i], prj_notadd_exts[j]), NULL))
{
bAdd = false;
break;
}
}
if(bAdd)
{
pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumESRIPrjFile, bCheckNames);
}
pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
}
else if(wxGISEQUAL(szExt, "qpj"))
{
bool bAdd = true;
for(int j = 0; prj_notadd_exts[j] != NULL; ++j )
{
if(CPLCheckForFile((char*)CPLResetExtension(pFileNames[i], prj_notadd_exts[j]), NULL))
{
bAdd = false;
break;
}
}
if(bAdd)
{
pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumQPJfile, bCheckNames);
}
pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
}
else if(wxGISEQUAL(szExt, "spr"))
{
pGxObj = GetGxObject(pParent, GetConvName(pFileNames[i]), pFileNames[i], enumSPRfile, bCheckNames);
pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
}
if(pGxObj)
{
pChildrenIds.Add(pGxObj->GetId());
pGxObj = NULL;
}
}
return true;
}
示例15: CPLError
//.........这里部分代码省略.........
pszCRLFFormat );
#ifdef WIN32
bUseCRLF = true;
#endif
}
poCSVLayer->SetCRLF( bUseCRLF );
/* -------------------------------------------------------------------- */
/* Should we write the geometry ? */
/* -------------------------------------------------------------------- */
const char *pszGeometry = CSLFetchNameValue( papszOptions, "GEOMETRY");
if( bEnableGeometryFields )
{
poCSVLayer->SetWriteGeometry(eGType, OGR_CSV_GEOM_AS_WKT,
CSLFetchNameValueDef(papszOptions, "GEOMETRY_NAME", "WKT"));
}
else if (pszGeometry != NULL)
{
if (EQUAL(pszGeometry, "AS_WKT"))
{
poCSVLayer->SetWriteGeometry(eGType, OGR_CSV_GEOM_AS_WKT,
CSLFetchNameValueDef(papszOptions, "GEOMETRY_NAME", "WKT"));
}
else if (EQUAL(pszGeometry, "AS_XYZ") ||
EQUAL(pszGeometry, "AS_XY") ||
EQUAL(pszGeometry, "AS_YX"))
{
if (eGType == wkbUnknown || wkbFlatten(eGType) == wkbPoint)
{
poCSVLayer->SetWriteGeometry(
eGType,
EQUAL(pszGeometry, "AS_XYZ") ? OGR_CSV_GEOM_AS_XYZ :
EQUAL(pszGeometry, "AS_XY") ? OGR_CSV_GEOM_AS_XY :
OGR_CSV_GEOM_AS_YX);
}
else
{
CPLError( CE_Warning, CPLE_AppDefined,
"Geometry type %s is not compatible with "
"GEOMETRY=AS_XYZ.",
OGRGeometryTypeToName(eGType) );
}
}
else
{
CPLError( CE_Warning, CPLE_AppDefined,
"Unsupported value %s for creation option GEOMETRY",
pszGeometry );
}
}
/* -------------------------------------------------------------------- */
/* Should we create a CSVT file ? */
/* -------------------------------------------------------------------- */
const char *pszCreateCSVT = CSLFetchNameValue( papszOptions, "CREATE_CSVT");
if (pszCreateCSVT && CPLTestBool(pszCreateCSVT))
{
poCSVLayer->SetCreateCSVT(true);
/* -------------------------------------------------------------------- */
/* Create .prj file */
/* -------------------------------------------------------------------- */
if( poSpatialRef != NULL && osFilename != "/vsistdout/" )
{
char* pszWKT = NULL;
poSpatialRef->exportToWkt(&pszWKT);
if( pszWKT )
{
VSILFILE* fpPRJ
= VSIFOpenL(CPLResetExtension(osFilename, "prj"), "wb");
if( fpPRJ )
{
CPL_IGNORE_RET_VAL(VSIFPrintfL(fpPRJ, "%s\n", pszWKT));
VSIFCloseL(fpPRJ);
}
CPLFree(pszWKT);
}
}
}
/* -------------------------------------------------------------------- */
/* Should we write a UTF8 BOM ? */
/* -------------------------------------------------------------------- */
const char *pszWriteBOM = CSLFetchNameValue( papszOptions, "WRITE_BOM");
if( pszWriteBOM )
poCSVLayer->SetWriteBOM(CPLTestBool(pszWriteBOM));
nLayers++;
papoLayers = static_cast<OGRLayer **>(
CPLRealloc( papoLayers, sizeof(void*) * nLayers ) );
OGRLayer* poLayer = poCSVLayer;
if( osFilename != "/vsistdout/" )
poLayer = new OGRCSVEditableLayer(poCSVLayer, NULL);
papoLayers[nLayers-1] = poLayer;
return poLayer;
}