本文整理汇总了C++中CPLGetFilename函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLGetFilename函数的具体用法?C++ CPLGetFilename怎么用?C++ CPLGetFilename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CPLGetFilename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDatasetFast
bool wxGxOpenFileGDB::Move(const CPLString &szDestPath, ITrackCancel* const pTrackCancel)
{
wxGISDataset* pDSet = GetDatasetFast();
if (NULL != pDSet)
{
pDSet->Close();
wsDELETE(pDSet);
}
if (pTrackCancel)
pTrackCancel->PutMessage(wxString::Format(_("%s %s %s"), _("Move"), GetCategory().c_str(), m_sName.c_str()), wxNOT_FOUND, enumGISMessageInfo);
//CPLString szFullDestPath = CPLFormFilename(szDestPath, CPLGetFilename(m_sPath), NULL);
CPLString szFullDestPath = CheckUniqPath(szDestPath, CPLGetFilename(m_sPath), true, " ");
bool bRet = MoveDir(m_sPath, szFullDestPath, 777, pTrackCancel);
if (!bRet)
{
const char* err = CPLGetLastErrorMsg();
wxString sErr = wxString::Format(_("Operation '%s' failed! GDAL error: %s, %s '%s'"), _("Move"), GetCategory().c_str(), wxString(err, wxConvUTF8).c_str(), wxString(m_sPath, wxConvUTF8).c_str());
wxLogError(sErr);
if (pTrackCancel)
pTrackCancel->PutMessage(sErr, wxNOT_FOUND, enumGISMessageErr);
return false;
}
return true;
}
示例2: CPLFormCIFilename
int TSXDataset::Identify( GDALOpenInfo *poOpenInfo )
{
if (poOpenInfo->fpL == NULL || poOpenInfo->nHeaderBytes < 260)
{
if( poOpenInfo->bIsDirectory )
{
const CPLString osFilename =
CPLFormCIFilename( poOpenInfo->pszFilename, CPLGetFilename( poOpenInfo->pszFilename ), "xml" );
/* Check if the filename contains TSX1_SAR (TerraSAR-X) or TDX1_SAR (TanDEM-X) */
if (!(STARTS_WITH_CI(CPLGetBasename( osFilename ), "TSX1_SAR") ||
STARTS_WITH_CI(CPLGetBasename( osFilename ), "TDX1_SAR")))
return 0;
VSIStatBufL sStat;
if( VSIStatL( osFilename, &sStat ) == 0 )
return 1;
}
return 0;
}
/* Check if the filename contains TSX1_SAR (TerraSAR-X) or TDX1_SAR (TanDEM-X) */
if (!(STARTS_WITH_CI(CPLGetBasename( poOpenInfo->pszFilename ), "TSX1_SAR") ||
STARTS_WITH_CI(CPLGetBasename( poOpenInfo->pszFilename ), "TDX1_SAR")))
return 0;
/* finally look for the <level1Product tag */
if (!STARTS_WITH_CI(reinterpret_cast<char *>( poOpenInfo->pabyHeader ),
"<level1Product") )
return 0;
return 1;
}
示例3: osFilename
int CTGDataset::Identify( GDALOpenInfo * poOpenInfo )
{
CPLString osFilename(poOpenInfo->pszFilename);
GDALOpenInfo* poOpenInfoToDelete = NULL;
/* GZipped grid_cell.gz files are common, so automagically open them */
/* if the /vsigzip/ has not been explicitely passed */
const char* pszFilename = CPLGetFilename(poOpenInfo->pszFilename);
if ((EQUAL(pszFilename, "grid_cell.gz") ||
EQUAL(pszFilename, "grid_cell1.gz") ||
EQUAL(pszFilename, "grid_cell2.gz")) &&
!EQUALN(poOpenInfo->pszFilename, "/vsigzip/", 9))
{
osFilename = "/vsigzip/";
osFilename += poOpenInfo->pszFilename;
poOpenInfo = poOpenInfoToDelete =
new GDALOpenInfo(osFilename.c_str(), GA_ReadOnly,
poOpenInfo->papszSiblingFiles);
}
if (poOpenInfo->nHeaderBytes < HEADER_LINE_COUNT * 80)
{
delete poOpenInfoToDelete;
return FALSE;
}
/* -------------------------------------------------------------------- */
/* Chech that it looks roughly as a CTG dataset */
/* -------------------------------------------------------------------- */
const char* pszData = (const char*)poOpenInfo->pabyHeader;
int i;
for(i=0;i<4 * 80;i++)
{
if (!((pszData[i] >= '0' && pszData[i] <= '9') ||
pszData[i] == ' ' || pszData[i] == '-'))
{
delete poOpenInfoToDelete;
return FALSE;
}
}
char szField[11];
int nRows = atoi(ExtractField(szField, pszData, 0, 10));
int nCols = atoi(ExtractField(szField, pszData, 20, 10));
int nMinColIndex = atoi(ExtractField(szField, pszData+80, 0, 5));
int nMinRowIndex = atoi(ExtractField(szField, pszData+80, 5, 5));
int nMaxColIndex = atoi(ExtractField(szField, pszData+80, 10, 5));
int nMaxRowIndex = atoi(ExtractField(szField, pszData+80, 15, 5));
if (nRows <= 0 || nCols <= 0 ||
nMinColIndex != 1 || nMinRowIndex != 1 ||
nMaxRowIndex != nRows || nMaxColIndex != nCols)
{
delete poOpenInfoToDelete;
return FALSE;
}
delete poOpenInfoToDelete;
return TRUE;
}
示例4: CPLStrdup
void OGRCSVDataSource::CreateForSingleFile( const char* pszDirname,
const char *pszFilename )
{
pszName = CPLStrdup( pszDirname );
bUpdate = true;
osDefaultCSVName = CPLGetFilename(pszFilename);
}
示例5: CPLFormCIFilename
int TSXDataset::Identify( GDALOpenInfo *poOpenInfo )
{
if (poOpenInfo->fpL == NULL || poOpenInfo->nHeaderBytes < 260)
{
if( poOpenInfo->bIsDirectory )
{
CPLString osFilename =
CPLFormCIFilename( poOpenInfo->pszFilename, CPLGetFilename( poOpenInfo->pszFilename ), "xml" );
/* Check if the filename contains TSX1_SAR (TerraSAR-X) or TDX1_SAR (TanDEM-X) */
if (!(EQUALN(CPLGetBasename( osFilename ), "TSX1_SAR", 8) ||
EQUALN(CPLGetBasename( osFilename ), "TDX1_SAR", 8)))
return 0;
VSIStatBufL sStat;
if( VSIStatL( osFilename, &sStat ) == 0 )
return 1;
}
return 0;
}
/* Check if the filename contains TSX1_SAR (TerraSAR-X) or TDX1_SAR (TanDEM-X) */
if (!(EQUALN(CPLGetBasename( poOpenInfo->pszFilename ), "TSX1_SAR", 8) ||
EQUALN(CPLGetBasename( poOpenInfo->pszFilename ), "TDX1_SAR", 8)))
return 0;
/* finally look for the <level1Product tag */
if (!EQUALN((char *)poOpenInfo->pabyHeader, "<level1Product", 14))
return 0;
return 1;
}
示例6: CPLGetFilename
int SRTMHGTDataset::Identify( GDALOpenInfo * poOpenInfo )
{
const char* fileName = CPLGetFilename(poOpenInfo->pszFilename);
if( strlen(fileName) < 11 || fileName[7] != '.' )
return FALSE;
CPLString osLCFilename(CPLString(fileName).tolower());
if( (osLCFilename[0] != 'n' && osLCFilename[0] != 's') ||
(osLCFilename[3] != 'e' && osLCFilename[3] != 'w') )
return FALSE;
if( !STARTS_WITH(fileName, "/vsizip/") &&
osLCFilename.endsWith(".hgt.zip") )
{
CPLString osNewName("/vsizip/");
osNewName += poOpenInfo->pszFilename;
osNewName += "/";
osNewName += CPLString(fileName).substr(0, 7);
osNewName += ".hgt";
GDALOpenInfo oOpenInfo(osNewName, GA_ReadOnly);
return Identify(&oOpenInfo);
}
if( !STARTS_WITH(fileName, "/vsizip/") &&
osLCFilename.endsWith(".srtmswbd.raw.zip") )
{
CPLString osNewName("/vsizip/");
osNewName += poOpenInfo->pszFilename;
osNewName += "/";
osNewName += CPLString(fileName).substr(0, 7);
osNewName += ".raw";
GDALOpenInfo oOpenInfo(osNewName, GA_ReadOnly);
return Identify(&oOpenInfo);
}
if( !osLCFilename.endsWith(".hgt") &&
!osLCFilename.endsWith(".raw") &&
!osLCFilename.endsWith(".hgt.gz") )
return FALSE;
/* -------------------------------------------------------------------- */
/* We check the file size to see if it is */
/* SRTM1 (below or above lat 50) or SRTM 3 */
/* -------------------------------------------------------------------- */
VSIStatBufL fileStat;
if(VSIStatL(poOpenInfo->pszFilename, &fileStat) != 0)
return FALSE;
if(fileStat.st_size != 3601 * 3601 &&
fileStat.st_size != 3601 * 3601 * 2 &&
fileStat.st_size != 1801 * 3601 * 2 &&
fileStat.st_size != 1201 * 1201 * 2 )
return FALSE;
return TRUE;
}
示例7: CSLFindString
int OGROpenFileGDBDataSource::FileExists(const char* pszFilename)
{
if( m_papszFiles )
return CSLFindString(m_papszFiles, CPLGetFilename(pszFilename)) >= 0;
else
{
VSIStatBufL sStat;
return VSIStatExL(pszFilename, &sStat, VSI_STAT_EXISTS_FLAG) == 0;
}
}
示例8: GDALMDReaderPleiades
/**
* GDALMDReaderSpot()
*/
GDALMDReaderSpot::GDALMDReaderSpot(const char *pszPath,
char **papszSiblingFiles) : GDALMDReaderPleiades(pszPath, papszSiblingFiles)
{
const char* pszIMDSourceFilename;
const char* pszDirName = CPLGetDirname(pszPath);
if(m_osIMDSourceFilename.empty())
{
pszIMDSourceFilename = CPLFormFilename( pszDirName, "METADATA.DIM", NULL );
if (CPLCheckForFile((char*)pszIMDSourceFilename, papszSiblingFiles))
{
m_osIMDSourceFilename = pszIMDSourceFilename;
}
else
{
pszIMDSourceFilename = CPLFormFilename( pszDirName, "metadata.dim", NULL );
if (CPLCheckForFile((char*)pszIMDSourceFilename, papszSiblingFiles))
{
m_osIMDSourceFilename = pszIMDSourceFilename;
}
}
}
// if the file name ended on METADATA.DIM
// Linux specific
// example: R2_CAT_091028105025131_1\METADATA.DIM
if(m_osIMDSourceFilename.empty())
{
if(EQUAL(CPLGetFilename(pszPath), "IMAGERY.TIF"))
{
pszIMDSourceFilename = CPLSPrintf( "%s\\METADATA.DIM",
CPLGetPath(pszPath));
if (CPLCheckForFile((char*)pszIMDSourceFilename, papszSiblingFiles))
{
m_osIMDSourceFilename = pszIMDSourceFilename;
}
else
{
pszIMDSourceFilename = CPLSPrintf( "%s\\metadata.dim",
CPLGetPath(pszPath));
if (CPLCheckForFile((char*)pszIMDSourceFilename, papszSiblingFiles))
{
m_osIMDSourceFilename = pszIMDSourceFilename;
}
}
}
}
if(m_osIMDSourceFilename.size())
CPLDebug( "MDReaderSpot", "IMD Filename: %s",
m_osIMDSourceFilename.c_str() );
}
示例9: Reset
int OGRXPlaneDataSource::Open( const char * pszFilename, int bReadWholeFile )
{
Reset();
this->bReadWholeFile = bReadWholeFile;
const char* pszShortFilename = CPLGetFilename(pszFilename);
if (EQUAL(pszShortFilename, "nav.dat") ||
EQUAL(pszShortFilename, "earth_nav.dat"))
{
poReader = OGRXPlaneCreateNavFileReader(this);
}
else if (EQUAL(pszShortFilename, "apt.dat"))
{
poReader = OGRXPlaneCreateAptFileReader(this);
}
else if (EQUAL(pszShortFilename, "fix.dat") ||
EQUAL(pszShortFilename, "earth_fix.dat"))
{
poReader = OGRXPlaneCreateFixFileReader(this);
}
else if (EQUAL(pszShortFilename, "awy.dat") ||
EQUAL(pszShortFilename, "earth_awy.dat"))
{
poReader = OGRXPlaneCreateAwyFileReader(this);
}
int bRet;
if (poReader && poReader->StartParsing(pszFilename) == FALSE)
{
delete poReader;
poReader = NULL;
}
if (poReader)
{
pszName = CPLStrdup(pszFilename);
if ( !bReadWholeFile )
{
for( int i = 0; i < nLayers; i++ )
papoLayers[i]->SetReader(poReader->CloneForLayer(papoLayers[i]));
}
bRet = TRUE;
}
else
bRet = FALSE;
return bRet;
}
示例10: CPLGetFilename
CPLErr
GDALDefaultOverviews::BuildOverviewsSubDataset(
const char * pszPhysicalFile,
const char * pszResampling,
int nOverviews, int * panOverviewList,
int nBands, int * panBandList,
GDALProgressFunc pfnProgress, void * pProgressData)
{
if( osOvrFilename.length() == 0 && nOverviews > 0 )
{
VSIStatBufL sStatBuf;
int iSequence = 0; // Used after for.
for( iSequence = 0; iSequence < 100; iSequence++ )
{
osOvrFilename.Printf( "%s_%d.ovr", pszPhysicalFile, iSequence );
if( VSIStatExL( osOvrFilename, &sStatBuf,
VSI_STAT_EXISTS_FLAG ) != 0 )
{
CPLString osAdjustedOvrFilename;
if( poDS->GetMOFlags() & GMO_PAM_CLASS )
{
osAdjustedOvrFilename.Printf(
":::BASE:::%s_%d.ovr",
CPLGetFilename(pszPhysicalFile),
iSequence );
}
else
{
osAdjustedOvrFilename = osOvrFilename;
}
poDS->SetMetadataItem( "OVERVIEW_FILE",
osAdjustedOvrFilename,
"OVERVIEWS" );
break;
}
}
if( iSequence == 100 )
osOvrFilename = "";
}
return BuildOverviews( NULL, pszResampling, nOverviews, panOverviewList,
nBands, panBandList, pfnProgress, pProgressData );
}
示例11: CPLFormCIFilename
int SAFEDataset::Identify( GDALOpenInfo *poOpenInfo )
{
/* Check for the case where we're trying to read the calibrated data: */
if (STARTS_WITH_CI(poOpenInfo->pszFilename, "SENTINEL1_CALIB:")) {
return TRUE;
}
/* Check for the case where we're trying to read the subdatasets: */
if (STARTS_WITH_CI(poOpenInfo->pszFilename, "SENTINEL1_DS:")) {
return TRUE;
}
/* Check for directory access when there is a manifest.safe file in the
directory. */
if( poOpenInfo->bIsDirectory )
{
VSIStatBufL sStat;
CPLString osMDFilename =
CPLFormCIFilename( poOpenInfo->pszFilename, "manifest.safe", nullptr );
if( VSIStatL( osMDFilename, &sStat ) == 0 && VSI_ISREG(sStat.st_mode) )
{
GDALOpenInfo oOpenInfo( osMDFilename, GA_ReadOnly, nullptr );
return Identify(&oOpenInfo);
}
return FALSE;
}
/* otherwise, do our normal stuff */
if( !EQUAL(CPLGetFilename(poOpenInfo->pszFilename), "manifest.safe") )
return FALSE;
if( poOpenInfo->nHeaderBytes < 100 )
return FALSE;
if( strstr((const char *) poOpenInfo->pabyHeader, "<xfdu:XFDU" ) == nullptr)
return FALSE;
// This driver doesn't handle Sentinel-2 data
if( strstr((const char *) poOpenInfo->pabyHeader, "sentinel-2" ) != nullptr)
return FALSE;
return TRUE;
}
示例12: 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;
}
示例13: CPLGetFilename
int SRTMHGTDataset::Identify( GDALOpenInfo * poOpenInfo )
{
const char* fileName = CPLGetFilename(poOpenInfo->pszFilename);
if( strlen(fileName) < 11 || !EQUALN(&fileName[7], ".hgt", 4) )
return FALSE;
/* -------------------------------------------------------------------- */
/* We check the file size to see if it is 25,934,402 bytes */
/* (SRTM 1) or 2,884,802 bytes (SRTM 3) */
/* -------------------------------------------------------------------- */
VSIStatBufL fileStat;
if(VSIStatL(poOpenInfo->pszFilename, &fileStat) != 0)
return FALSE;
if(fileStat.st_size != 25934402 && fileStat.st_size != 2884802)
return FALSE;
return TRUE;
}
示例14: EQUAL
static GDALDataset *OGRTABDriverOpen( GDALOpenInfo* poOpenInfo )
{
OGRTABDataSource *poDS;
if( OGRTABDriverIdentify(poOpenInfo) == FALSE )
{
return NULL;
}
if (EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "MIF") ||
EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "MID") )
{
if( poOpenInfo->eAccess == GA_Update )
return NULL;
}
#ifdef DEBUG
/* For AFL, so that .cur_input is detected as the archive filename */
if( poOpenInfo->fpL != NULL &&
!STARTS_WITH(poOpenInfo->pszFilename, "/vsitar/") &&
EQUAL(CPLGetFilename(poOpenInfo->pszFilename), ".cur_input") )
{
GDALOpenInfo oOpenInfo( (CPLString("/vsitar/") + poOpenInfo->pszFilename).c_str(),
poOpenInfo->nOpenFlags );
oOpenInfo.papszOpenOptions = poOpenInfo->papszOpenOptions;
return OGRTABDriverOpen(&oOpenInfo);
}
#endif
poDS = new OGRTABDataSource();
if( poDS->Open( poOpenInfo, TRUE ) )
return poDS;
else
{
delete poDS;
return NULL;
}
}
示例15: GetGxCatalog
bool wxGxLocalDBFactory::GetChildren(wxGxObject* pParent, char** &pFileNames, wxArrayLong & pChildrenIds)
{
wxGxCatalogBase* pCatalog = GetGxCatalog();
bool bCheckNames = CSLCount(pFileNames) < CHECK_DUBLES_MAX_COUNT;
for(int i = CSLCount(pFileNames) - 1; i >= 0; i-- )
{
VSIStatBufL BufL;
int ret = VSIStatL(pFileNames[i], &BufL);
if(ret == 0)
{
if (VSI_ISDIR(BufL.st_mode) && wxGISEQUAL(CPLGetExtension(pFileNames[i]), "gdb"))
{
wxGxObject* pObj = GetGxObject(pParent, wxString(CPLGetFilename(pFileNames[i]), wxConvUTF8), pFileNames[i], enumContGDBFolder, bCheckNames);
if(pObj)
pChildrenIds.Add(pObj->GetId());
pFileNames = CSLRemoveStrings( pFileNames, i, 1, NULL );
}
//TODO: mdb, sqlite, db extensions
}
}
return true;
}