本文整理汇总了C++中CPLGetBasename函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLGetBasename函数的具体用法?C++ CPLGetBasename怎么用?C++ CPLGetBasename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CPLGetBasename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GDALMDReaderBase
/**
* GDALMDReaderRapidEye()
*/
GDALMDReaderRapidEye::GDALMDReaderRapidEye(const char *pszPath,
char **papszSiblingFiles) : GDALMDReaderBase(pszPath, papszSiblingFiles)
{
const char* pszDirName = CPLGetDirname(pszPath);
const char* pszBaseName = CPLGetBasename(pszPath);
const char* pszIMDSourceFilename = CPLFormFilename( pszDirName,
CPLSPrintf("%s_metadata",
pszBaseName), "xml" );
if (CPLCheckForFile((char*)pszIMDSourceFilename, papszSiblingFiles))
{
m_osXMLSourceFilename = pszIMDSourceFilename;
}
else
{
pszIMDSourceFilename = CPLFormFilename( pszDirName,
CPLSPrintf("%s_METADATA",
pszBaseName), "XML" );
if (CPLCheckForFile((char*)pszIMDSourceFilename, papszSiblingFiles))
{
m_osXMLSourceFilename = pszIMDSourceFilename;
}
}
if(m_osXMLSourceFilename.size())
CPLDebug( "MDReaderRapidEye", "XML Filename: %s",
m_osXMLSourceFilename.c_str() );
}
示例2: GDALMDReaderBase
/**
* GDALMDReaderOrbView()
*/
GDALMDReaderOrbView::GDALMDReaderOrbView(const char *pszPath,
char **papszSiblingFiles) : GDALMDReaderBase(pszPath, papszSiblingFiles)
{
m_osIMDSourceFilename = GDALFindAssociatedFile( pszPath, "PVL",
papszSiblingFiles, 0 );
const char* pszBaseName = CPLGetBasename(pszPath);
const char* pszDirName = CPLGetDirname(pszPath);
const char* pszRPBSourceFilename = CPLFormFilename( pszDirName,
CPLSPrintf("%s_rpc",
pszBaseName),
"txt" );
if (CPLCheckForFile((char*)pszRPBSourceFilename, papszSiblingFiles))
{
m_osRPBSourceFilename = pszRPBSourceFilename;
}
else
{
pszRPBSourceFilename = CPLFormFilename( pszDirName, CPLSPrintf("%s_RPC",
pszBaseName), "TXT" );
if (CPLCheckForFile((char*)pszRPBSourceFilename, papszSiblingFiles))
{
m_osRPBSourceFilename = pszRPBSourceFilename;
}
}
if( m_osIMDSourceFilename.size() )
CPLDebug( "MDReaderOrbView", "IMD Filename: %s",
m_osIMDSourceFilename.c_str() );
if( m_osRPBSourceFilename.size() )
CPLDebug( "MDReaderOrbView", "RPB Filename: %s",
m_osRPBSourceFilename.c_str() );
}
示例3: CPLStrdup
OGRShapeLayer::OGRShapeLayer( const char * pszName,
SHPHandle hSHPIn, DBFHandle hDBFIn,
OGRSpatialReference *poSRSIn, int bUpdate,
OGRwkbGeometryType eReqType )
{
poSRS = poSRSIn;
pszFullName = CPLStrdup(pszName);
hSHP = hSHPIn;
hDBF = hDBFIn;
bUpdateAccess = bUpdate;
iNextShapeId = 0;
panMatchingFIDs = NULL;
bCheckedForQIX = FALSE;
fpQIX = NULL;
bHeaderDirty = FALSE;
if( hSHP != NULL )
nTotalShapeCount = hSHP->nRecords;
else
nTotalShapeCount = hDBF->nRecords;
poFeatureDefn = SHPReadOGRFeatureDefn( CPLGetBasename(pszName),
hSHP, hDBF );
eRequestedGeomType = eReqType;
}
示例4: CPLGetBasename
string CRFile::GetTitleNameFromPath(const string& strPath)
{
const char* chname = CPLGetBasename(strPath.c_str());
if(strlen(chname) >0 )
return chname;
return "";
}
示例5: VSIFOpen
int OGRCSVDataSource::OpenTable( const char * pszFilename )
{
/* -------------------------------------------------------------------- */
/* Open the file. */
/* -------------------------------------------------------------------- */
FILE * fp;
if( bUpdate )
fp = VSIFOpen( pszFilename, "rb+" );
else
fp = VSIFOpen( pszFilename, "rb" );
if( fp == NULL )
{
CPLError( CE_Warning, CPLE_OpenFailed,
"Failed to open %s, %s.",
pszFilename, VSIStrerror( errno ) );
return FALSE;
}
/* -------------------------------------------------------------------- */
/* Read and parse a line. Did we get multiple fields? */
/* -------------------------------------------------------------------- */
const char* pszLine = CPLReadLine( fp );
if (pszLine == NULL)
{
VSIFClose( fp );
return FALSE;
}
char chDelimiter = CSVDetectSeperator(pszLine);
VSIRewind( fp );
char **papszFields = CSVReadParseLine2( fp, chDelimiter );
if( CSLCount(papszFields) < 2 )
{
VSIFClose( fp );
CSLDestroy( papszFields );
return FALSE;
}
VSIRewind( fp );
CSLDestroy( papszFields );
/* -------------------------------------------------------------------- */
/* Create a layer. */
/* -------------------------------------------------------------------- */
nLayers++;
papoLayers = (OGRCSVLayer **) CPLRealloc(papoLayers,
sizeof(void*) * nLayers);
papoLayers[nLayers-1] =
new OGRCSVLayer( CPLGetBasename(pszFilename), fp, pszFilename, FALSE, bUpdate, chDelimiter );
return TRUE;
}
示例6: CPLGetBasename
bool wxGxFile::Move(const CPLString &szDestPath, ITrackCancel* const pTrackCancel)
{
if(pTrackCancel)
pTrackCancel->PutMessage(wxString(_("Move file ")) + m_sName, -1, enumGISMessageInfo);
CPLString szFileName = CPLGetBasename(m_sPath);
CPLString szNewDestFileName = GetUniqPath(m_sPath, szDestPath, szFileName);
return MoveFile(m_sPath, szNewDestFileName, pTrackCancel);
}
示例7: CPLAssert
void OGRESRIJSONReader::ReadLayers( OGRGeoJSONDataSource* poDS,
GeoJSONSourceType eSourceType )
{
CPLAssert( nullptr == poLayer_ );
if( nullptr == poGJObject_ )
{
CPLDebug( "ESRIJSON",
"Missing parsed ESRIJSON data. Forgot to call Parse()?" );
return;
}
OGRSpatialReference* poSRS = OGRESRIJSONReadSpatialReference( poGJObject_ );
const char* pszName = "ESRIJSON";
if( eSourceType == eGeoJSONSourceFile )
{
pszName = poDS->GetDescription();
if( STARTS_WITH_CI(pszName, "ESRIJSON:") )
pszName += strlen("ESRIJSON:");
pszName = CPLGetBasename(pszName);
}
auto eGeomType = OGRESRIJSONGetGeometryType(poGJObject_);
if( eGeomType == wkbNone && poSRS != nullptr )
{
eGeomType = wkbUnknown;
}
poLayer_ = new OGRGeoJSONLayer( pszName, poSRS,
eGeomType,
poDS, nullptr );
if( poSRS != nullptr )
poSRS->Release();
if( !GenerateLayerDefn() )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Layer schema generation failed." );
delete poLayer_;
return;
}
OGRGeoJSONLayer *poThisLayer = ReadFeatureCollection( poGJObject_ );
if( poThisLayer == nullptr )
{
delete poLayer_;
return;
}
CPLErrorReset();
poLayer_->DetectGeometryType();
poDS->AddLayer(poLayer_);
}
示例8: locker
bool wxGISDataset::Move(const CPLString &szDestPath, ITrackCancel* const pTrackCancel)
{
wxCriticalSectionLocker locker(m_CritSect);
Close();
char** papszFileList = GetFileList();
papszFileList = CSLAddString( papszFileList, m_sPath );
if(!papszFileList)
{
if(pTrackCancel)
pTrackCancel->PutMessage(_("No files to move"), wxNOT_FOUND, enumGISMessageErr);
return false;
}
CPLString szFileName = CPLGetBasename(GetUniqPath(m_sPath, szDestPath, CPLGetBasename(m_sPath)));
char** papszMovedFileList = NULL;
for(int i = 0; papszFileList[i] != NULL; ++i )
{
CPLString szNewDestFileName(CPLFormFilename(szDestPath, szFileName, GetExtension(papszFileList[i], szFileName)));
papszMovedFileList = CSLAddString(papszMovedFileList, szNewDestFileName);
if(!MoveFile(szNewDestFileName, papszFileList[i], pTrackCancel))
{
// Try to put the ones we moved back.
pTrackCancel->Reset();
for( --i; i >= 0; i-- )
MoveFile( papszFileList[i], papszMovedFileList[i]);
CSLDestroy( papszFileList );
CSLDestroy( papszMovedFileList );
return false;
}
}
m_sPath = CPLFormFilename(szDestPath, CPLGetFilename(m_sPath), NULL);
CSLDestroy( papszFileList );
CSLDestroy( papszMovedFileList );
return true;
}
示例9: CPLGetBasename
OGRLayer *OGRShapeDataSource::GetLayerByName(const char * pszLayerNameIn)
{
#ifndef IMMEDIATE_OPENING
if (oVectorLayerName.size() != 0)
{
int j;
for(j=0;j<nLayers;j++)
{
if (strcmp(papoLayers[j]->GetName(), pszLayerNameIn) == 0)
{
return papoLayers[j];
}
}
size_t i;
for(j = 0; j < 2; j++)
{
for(i = 0; i < oVectorLayerName.size(); i++)
{
const char* pszFilename = oVectorLayerName[i].c_str();
const char* pszLayerName = CPLGetBasename(pszFilename);
if (j == 0)
{
if (strcmp(pszLayerName, pszLayerNameIn) != 0)
continue;
}
else
{
if ( !EQUAL(pszLayerName, pszLayerNameIn) )
continue;
}
if( !OpenFile( pszFilename, bDSUpdate, TRUE ) )
{
CPLError( CE_Failure, CPLE_OpenFailed,
"Failed to open file %s.\n"
"It may be corrupt or read-only file accessed in update mode.\n",
pszFilename );
return NULL;
}
else
{
return papoLayers[nLayers - 1];
}
}
}
return NULL;
}
#endif
return OGRDataSource::GetLayerByName(pszLayerNameIn);
}
示例10: OGRFeatureDefn
OGRSelafinLayer::OGRSelafinLayer( const char *pszLayerNameP, int bUpdateP,OGRSpatialReference *poSpatialRefP,Selafin::Header *poHeaderP,int nStepNumberP,SelafinTypeDef eTypeP):eType(eTypeP),bUpdate(bUpdateP),nStepNumber(nStepNumberP),poHeader(poHeaderP),poSpatialRef(poSpatialRefP),nCurrentId(-1) {
//CPLDebug("Selafin","Opening layer %s",pszLayerNameP);
poFeatureDefn = new OGRFeatureDefn( CPLGetBasename( pszLayerNameP ) );
SetDescription( poFeatureDefn->GetName() );
poFeatureDefn->Reference();
if (eType==POINTS) poFeatureDefn->SetGeomType( wkbPoint );
else poFeatureDefn->SetGeomType(wkbPolygon);
for (int i=0;i<poHeader->nVar;++i) {
OGRFieldDefn oFieldDefn(poHeader->papszVariables[i],OFTReal);
poFeatureDefn->AddFieldDefn(&oFieldDefn);
}
}
示例11: Identify
int TSXDataset::Identify( GDALOpenInfo *poOpenInfo ) {
if (poOpenInfo->fp == NULL || poOpenInfo->nHeaderBytes < 260)
return 0;
/* Check if the filename contains TSX1_SAR */
if (!EQUALN(CPLGetBasename( poOpenInfo->pszFilename ), "TSX1_SAR", 8))
return 0;
/* finally look for the <level1Product tag */
if (!EQUALN((char *)poOpenInfo->pabyHeader, "<level1Product", 14))
return 0;
return 1;
}
示例12: poFeatureDefn
OGRARCGENLayer::OGRARCGENLayer( const char* pszFilename,
VSILFILE* fpIn, OGRwkbGeometryType eType ) :
poFeatureDefn(NULL),
fp(fpIn),
bEOF(FALSE),
nNextFID(0)
{
poFeatureDefn = new OGRFeatureDefn( CPLGetBasename(pszFilename) );
poFeatureDefn->Reference();
poFeatureDefn->SetGeomType( eType );
OGRFieldDefn oField1( "ID", OFTInteger);
poFeatureDefn->AddFieldDefn( &oField1 );
SetDescription( poFeatureDefn->GetName() );
}
示例13: CPLError
CPLErr SAGADataset::SetGeoTransform( double *padfGeoTransform )
{
if( eAccess == GA_ReadOnly )
{
CPLError( CE_Failure, CPLE_NoWriteAccess,
"Unable to set GeoTransform, dataset opened read only.\n" );
return CE_Failure;
}
SAGARasterBand *poGRB = dynamic_cast<SAGARasterBand *>(GetRasterBand( 1 ));
if( poGRB == NULL || padfGeoTransform == NULL)
return CE_Failure;
if( padfGeoTransform[1] != padfGeoTransform[5] * -1.0 )
{
CPLError( CE_Failure, CPLE_NotSupported,
"Unable to set GeoTransform, SAGA binary grids only support "
"the same cellsize in x-y.\n" );
return CE_Failure;
}
double dfMinX = padfGeoTransform[0] + padfGeoTransform[1] / 2;
double dfMinY =
padfGeoTransform[5] * (nRasterYSize - 0.5) + padfGeoTransform[3];
CPLString osPath = CPLGetPath( GetDescription() );
CPLString osName = CPLGetBasename( GetDescription() );
CPLString osHDRFilename = CPLFormCIFilename( osPath, osName, ".sgrd" );
CPLErr eErr = WriteHeader( osHDRFilename, poGRB->GetRasterDataType(),
poGRB->nRasterXSize, poGRB->nRasterYSize,
dfMinX, dfMinY, padfGeoTransform[1],
poGRB->m_NoData, 1.0, false );
if( eErr == CE_None )
{
poGRB->m_Xmin = dfMinX;
poGRB->m_Ymin = dfMinY;
poGRB->m_Cellsize = padfGeoTransform[1];
poGRB->m_Cols = nRasterXSize;
poGRB->m_Rows = nRasterYSize;
}
return eErr;
}
示例14: OGRFeatureDefn
OGRARCGENLayer::OGRARCGENLayer( const char* pszFilename,
VSILFILE* fp, OGRwkbGeometryType eType )
{
this->fp = fp;
nNextFID = 0;
bEOF = FALSE;
poFeatureDefn = new OGRFeatureDefn( CPLGetBasename(pszFilename) );
poFeatureDefn->Reference();
poFeatureDefn->SetGeomType( eType );
OGRFieldDefn oField1( "ID", OFTInteger);
poFeatureDefn->AddFieldDefn( &oField1 );
SetDescription( poFeatureDefn->GetName() );
}
示例15: SaveGeometry
void SaveGeometry(const CPLString &path, const OGRPolygon &polygon, const OGRSpatialReference &spaRef)
{
const char *pszDriverName = "ESRI Shapefile";
GDALDriver *poDriver = GetGDALDriverManager()->GetDriverByName(pszDriverName );
if( poDriver == NULL )
{
printf( "%s driver not available.\n", pszDriverName );
exit( 1 );
}
GDALDataset *poDS = poDriver->Create( path, 0, 0, 0, GDT_Unknown, NULL );
if( poDS == NULL )
{
printf( "Creation of output file failed.\n" );
exit( 1 );
}
const char* pszLayerName = CPLGetBasename(path);
OGRLayer *poLayer = poDS->CreateLayer( pszLayerName, spaRef.Clone(), wkbPolygon, NULL );
if( poLayer == NULL )
{
printf( "Layer creation failed.\n" );
exit( 1 );
}
OGRFieldDefn oField( "Name", OFTString );
oField.SetWidth(32);
if( poLayer->CreateField( &oField ) != OGRERR_NONE )
{
printf( "Creating Name field failed.\n" );
exit( 1 );
}
OGRFeature *poFeature = OGRFeature::CreateFeature( poLayer->GetLayerDefn() );
//poFeature->SetField( "Name", szName );
poFeature->SetGeometry( polygon.clone() );
if( poLayer->CreateFeature( poFeature ) != OGRERR_NONE )
{
printf( "Failed to create feature in shapefile.\n" );
exit( 1 );
}
OGRFeature::DestroyFeature( poFeature );
GDALClose( poDS );
}