您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CPLGetBasename函数代码示例

51自学网 2021-06-01 20:04:35
  C++
这篇教程C++ CPLGetBasename函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CPLGetBasename函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLGetBasename函数的具体用法?C++ CPLGetBasename怎么用?C++ CPLGetBasename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CPLGetBasename函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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() );}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:31,


示例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() );}
开发者ID:drownedout,项目名称:datamap,代码行数:37,


示例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;}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:32,


示例4: CPLGetBasename

string CRFile::GetTitleNameFromPath(const string& strPath){	const char* chname = CPLGetBasename(strPath.c_str());	if(strlen(chname) >0 )		return chname;	return "";}
开发者ID:soxueren,项目名称:rabbit-gis,代码行数:9,


示例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;}
开发者ID:brunosimoes,项目名称:WorldWind,代码行数:57,


示例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);}
开发者ID:GimpoByte,项目名称:nextgismanager,代码行数:9,


示例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_);}
开发者ID:koordinates,项目名称:gdal,代码行数:56,


示例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;}
开发者ID:Mileslee,项目名称:wxgis,代码行数:42,


示例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);}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:54,


示例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);    }}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:12,


示例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;}
开发者ID:brunosimoes,项目名称:WorldWind,代码行数:14,


示例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() );}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:15,


示例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;}
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:48,


示例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() );}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:16,


示例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 );}
开发者ID:BishopGIS,项目名称:gisconf2015,代码行数:46,


示例16: OGRFeatureDefn

OGRSEGUKOOALineLayer::OGRSEGUKOOALineLayer(const char* pszFilename,                                           OGRLayer *poBaseLayer){    nNextFID = 0;    bEOF = FALSE;    poFeatureDefn = new OGRFeatureDefn( CPLSPrintf("%s_lines",                                                   CPLGetBasename(pszFilename)) );    poFeatureDefn->Reference();    poFeatureDefn->SetGeomType( wkbLineString );    poFeatureDefn->GetGeomFieldDefn(0)->SetSpatialRef(poBaseLayer->GetSpatialRef());    OGRFieldDefn    oField( "LINENAME", OFTString );    poFeatureDefn->AddFieldDefn( &oField );    this->poBaseLayer = poBaseLayer;    poNextBaseFeature = NULL;}
开发者ID:drownedout,项目名称:datamap,代码行数:18,


示例17: GDALMDReaderBase

/** * GDALMDReaderLandsat() */GDALMDReaderLandsat::GDALMDReaderLandsat(const char *pszPath,        char **papszSiblingFiles) : GDALMDReaderBase(pszPath, papszSiblingFiles){    const char* pszBaseName = CPLGetBasename(pszPath);    const char* pszDirName = CPLGetDirname(pszPath);    size_t nBaseNameLen = strlen(pszBaseName);    if( nBaseNameLen > 511 )        return;    // split file name by _B or _b    char szMetadataName[512] = {0};    size_t i;    for(i = 0; i < nBaseNameLen; i++)    {        szMetadataName[i] = pszBaseName[i];        if(STARTS_WITH_CI(pszBaseName + i, "_B") || STARTS_WITH_CI(pszBaseName + i, "_b"))        {            break;        }    }    // form metadata file name    CPLStrlcpy(szMetadataName + i, "_MTL.txt", 9);    const char* pszIMDSourceFilename = CPLFormFilename( pszDirName,                                                        szMetadataName, NULL );    if (CPLCheckForFile((char*)pszIMDSourceFilename, papszSiblingFiles))    {        m_osIMDSourceFilename = pszIMDSourceFilename;    }    else    {        CPLStrlcpy(szMetadataName + i, "_MTL.TXT", 9);        pszIMDSourceFilename = CPLFormFilename( pszDirName, szMetadataName, NULL );        if (CPLCheckForFile((char*)pszIMDSourceFilename, papszSiblingFiles))        {            m_osIMDSourceFilename = pszIMDSourceFilename;        }    }    if( !m_osIMDSourceFilename.empty() )        CPLDebug( "MDReaderLandsat", "IMD Filename: %s",                  m_osIMDSourceFilename.c_str() );}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:47,


示例18: Identify

int PALSARJaxaDataset::Identify( GDALOpenInfo *poOpenInfo ) {    if ( poOpenInfo->fp == NULL || poOpenInfo->nHeaderBytes < 360 )        return 0;    /* First, check that this is a PALSAR image indeed */    if ( !EQUALN((char *)(poOpenInfo->pabyHeader + 60),"AL", 2)          || !EQUALN(CPLGetBasename((char *)(poOpenInfo->pszFilename)) + 4,                     "ALPSR", 5) )    {        return 0;    }    FILE *fpL = VSIFOpenL( poOpenInfo->pszFilename, "r" );    if( fpL == NULL )        return FALSE;    /* Check that this is a volume directory file */    int nRecordSeq = 0;    int nRecordSubtype = 0;    int nRecordType = 0;    int nSecondSubtype = 0;    int nThirdSubtype = 0;    int nLengthRecord = 0;    VSIFSeekL(fpL, 0, SEEK_SET);    READ_WORD(fpL, nRecordSeq);    READ_BYTE(fpL, nRecordSubtype);    READ_BYTE(fpL, nRecordType);    READ_BYTE(fpL, nSecondSubtype);    READ_BYTE(fpL, nThirdSubtype);    READ_WORD(fpL, nLengthRecord);    VSIFCloseL( fpL );    /* Check that we have the right record */    if ( nRecordSeq == 1 && nRecordSubtype == 192 && nRecordType == 192 &&         nSecondSubtype == 18 && nThirdSubtype == 18 && nLengthRecord == 360 )    {        return 1;    }    return 0;}
开发者ID:Chaduke,项目名称:bah.mod,代码行数:44,


示例19: CPLStrdup

int OGRRECDataSource::Open( const char * pszFilename ){    pszName = CPLStrdup( pszFilename );    /* -------------------------------------------------------------------- *//*      Verify that the extension is REC.                               *//* -------------------------------------------------------------------- */    if( !(strlen(pszFilename) > 4 &&          EQUAL(pszFilename+strlen(pszFilename)-4,".rec") ) )        return FALSE;    /* -------------------------------------------------------------------- *//*      Open the file.                                                  *//* -------------------------------------------------------------------- */    const char * pszLine;    FILE       * fp;    fp = VSIFOpen( pszFilename, "rb" );    if( fp == NULL )        return FALSE;    /* -------------------------------------------------------------------- *//*      Read a line, and verify that it consists of at least one        *//*      field that is a number greater than zero.                       *//* -------------------------------------------------------------------- */    int  nFieldCount;    pszLine = CPLReadLine( fp );    nFieldCount = atoi(pszLine);    if( nFieldCount < 1 || nFieldCount > 1000 )    {        VSIFClose( fp );        return FALSE;    }/* -------------------------------------------------------------------- *//*      Create a layer.                                                 *//* -------------------------------------------------------------------- */    poLayer = new OGRRECLayer( CPLGetBasename(pszFilename), fp, nFieldCount );    return poLayer->IsValid();}
开发者ID:0004c,项目名称:node-gdal,代码行数:43,


示例20: CPLError

GDALDataset* OGRJMLDataset::Open( GDALOpenInfo* poOpenInfo ){    if( !Identify(poOpenInfo) || poOpenInfo->fpL == NULL ||        poOpenInfo->eAccess == GA_Update )        return NULL;#ifndef HAVE_EXPAT    CPLError(CE_Failure, CPLE_NotSupported,             "OGR/JML driver has not been built with read support. Expat library required");    return NULL;#else    OGRJMLDataset* poDS = new OGRJMLDataset();    poDS->SetDescription( poOpenInfo->pszFilename );    poDS->fp = poOpenInfo->fpL;    poOpenInfo->fpL = NULL;    poDS->poLayer = new OGRJMLLayer( CPLGetBasename(poOpenInfo->pszFilename), poDS, poDS->fp);    return poDS;#endif}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:23,


示例21: AAIGDataset

//.........这里部分代码省略.........            delete poDS;            return nullptr;        }        pabyChunk[nChunkSize] = '/0';        if( VSIFSeekL(poDS->fp, nStartOfData, SEEK_SET) < 0 )        {            delete poDS;            VSIFree(pabyChunk);            return nullptr;        }        // Scan for dot in subsequent chunks of data.        while( !VSIFEofL(poDS->fp) )        {            CPL_IGNORE_RET_VAL(VSIFReadL(pabyChunk, nChunkSize, 1, poDS->fp));            for( int i = 0; i < static_cast<int>(nChunkSize); i++)            {                GByte ch = pabyChunk[i];                if (ch == '.' || ch == ',' || ch == 'e' || ch == 'E')                {                    poDS->eDataType = GDT_Float32;                    break;                }            }        }        // Deallocate chunk.        VSIFree(pabyChunk);    }    // Create band information objects.    AAIGRasterBand *band = new AAIGRasterBand(poDS, nStartOfData);    poDS->SetBand(1, band);    if (band->panLineOffset == nullptr)    {        delete poDS;        return nullptr;    }    // Try to read projection file.    char *const pszDirname = CPLStrdup(CPLGetPath(poOpenInfo->pszFilename));    char *const pszBasename =        CPLStrdup(CPLGetBasename(poOpenInfo->pszFilename));    poDS->osPrjFilename = CPLFormFilename(pszDirname, pszBasename, "prj");    int nRet = 0;    {        VSIStatBufL sStatBuf;        nRet = VSIStatL(poDS->osPrjFilename, &sStatBuf);    }    if( nRet != 0 && VSIIsCaseSensitiveFS(poDS->osPrjFilename) )    {        poDS->osPrjFilename = CPLFormFilename(pszDirname, pszBasename, "PRJ");        VSIStatBufL sStatBuf;        nRet = VSIStatL(poDS->osPrjFilename, &sStatBuf);    }    if( nRet == 0 )    {        poDS->papszPrj = CSLLoad(poDS->osPrjFilename);        CPLDebug("AAIGrid", "Loaded SRS from %s", poDS->osPrjFilename.c_str());        OGRSpatialReference oSRS;        if( oSRS.importFromESRI(poDS->papszPrj) == OGRERR_NONE )        {            // If geographic values are in seconds, we must transform.            // Is there a code for minutes too?            if( oSRS.IsGeographic() &&                EQUAL(OSR_GDS(poDS->papszPrj, "Units", ""), "DS") )            {                poDS->adfGeoTransform[0] /= 3600.0;                poDS->adfGeoTransform[1] /= 3600.0;                poDS->adfGeoTransform[2] /= 3600.0;                poDS->adfGeoTransform[3] /= 3600.0;                poDS->adfGeoTransform[4] /= 3600.0;                poDS->adfGeoTransform[5] /= 3600.0;            }            CPLFree(poDS->pszProjection);            oSRS.exportToWkt(&(poDS->pszProjection));        }    }    CPLFree(pszDirname);    CPLFree(pszBasename);    // Initialize any PAM information.    poDS->SetDescription(poOpenInfo->pszFilename);    poDS->TryLoadXML();    // Check for external overviews.    poDS->oOvManager.Initialize(        poDS, poOpenInfo->pszFilename, poOpenInfo->GetSiblingFiles());    return poDS;}
开发者ID:hdfeos,项目名称:gdal,代码行数:101,


示例22: CPLError

//.........这里部分代码省略.........                    }                    else if( !CPLIsInf(padfScanline[iPixel]) &&                             !CPLIsNan(padfScanline[iPixel]) )                    {                        strcat(szHeader, ".0");                        bHasOutputDecimalDot = true;                    }                }                osBuf += szHeader;                if( (iPixel & 1023) == 0 || iPixel == nXSize - 1 )                {                  if ( VSIFWriteL(osBuf, static_cast<int>(osBuf.size()), 1,                                  fpImage) != 1 )                    {                        eErr = CE_Failure;                        CPLError(CE_Failure, CPLE_AppDefined,                                 "Write failed, disk full?");                        break;                    }                    osBuf = "";                }            }        }        if( VSIFWriteL("/n", 1, 1, fpImage) != 1 )            eErr = CE_Failure;        if( eErr == CE_None &&            !pfnProgress((iLine + 1) / static_cast<double>(nYSize), nullptr,                         pProgressData) )        {            eErr = CE_Failure;            CPLError(CE_Failure, CPLE_UserInterrupt,                     "User terminated CreateCopy()");        }    }    CPLFree(panScanline);    CPLFree(padfScanline);    if( VSIFCloseL(fpImage) != 0 )        eErr = CE_Failure;    if( eErr != CE_None )        return nullptr;    // Try to write projection file.    const char *pszOriginalProjection = poSrcDS->GetProjectionRef();    if( !EQUAL(pszOriginalProjection, "") )    {        char *pszDirname = CPLStrdup(CPLGetPath(pszFilename));        char *pszBasename = CPLStrdup(CPLGetBasename(pszFilename));        char *pszPrjFilename =            CPLStrdup(CPLFormFilename(pszDirname, pszBasename, "prj"));        VSILFILE *fp = VSIFOpenL(pszPrjFilename, "wt");        if (fp != nullptr)        {            OGRSpatialReference oSRS;            oSRS.importFromWkt(pszOriginalProjection);            oSRS.morphToESRI();            char *pszESRIProjection = nullptr;            oSRS.exportToWkt(&pszESRIProjection);            CPL_IGNORE_RET_VAL(VSIFWriteL(pszESRIProjection, 1,                                          strlen(pszESRIProjection), fp));            CPL_IGNORE_RET_VAL(VSIFCloseL(fp));            CPLFree(pszESRIProjection);        }        else        {            CPLError(CE_Failure, CPLE_FileIO, "Unable to create file %s.",                     pszPrjFilename);        }        CPLFree(pszDirname);        CPLFree(pszBasename);        CPLFree(pszPrjFilename);    }    // Re-open dataset, and copy any auxiliary pam information.    // If writing to stdout, we can't reopen it, so return    // a fake dataset to make the caller happy.    CPLPushErrorHandler(CPLQuietErrorHandler);    GDALPamDataset *poDS =        reinterpret_cast<GDALPamDataset *>(GDALOpen(pszFilename, GA_ReadOnly));    CPLPopErrorHandler();    if (poDS)    {        poDS->CloneInfo(poSrcDS, GCIF_PAM_DEFAULT);        return poDS;    }    CPLErrorReset();    AAIGDataset *poAAIG_DS = new AAIGDataset();    poAAIG_DS->nRasterXSize = nXSize;    poAAIG_DS->nRasterYSize = nYSize;    poAAIG_DS->nBands = 1;    poAAIG_DS->SetBand(1, new AAIGRasterBand(poAAIG_DS, 1));    return poAAIG_DS;}
开发者ID:hdfeos,项目名称:gdal,代码行数:101,


示例23: VSIFOpenL

int OGRCSVDataSource::OpenTable( const char * pszFilename,                                 char** papszOpenOptions,                                 const char* pszNfdcRunwaysGeomField,                                 const char* pszGeonamesGeomFieldPrefix){/* -------------------------------------------------------------------- *//*      Open the file.                                                  *//* -------------------------------------------------------------------- */    VSILFILE       * fp;    if( bUpdate )        fp = VSIFOpenL( pszFilename, "rb+" );    else        fp = VSIFOpenL( pszFilename, "rb" );    if( fp == NULL )    {        CPLError( CE_Warning, CPLE_OpenFailed,                   "Failed to open %s, %s.",                   pszFilename, VSIStrerror( errno ) );        return FALSE;    }    if( !bUpdate && strstr(pszFilename, "/vsigzip/") == NULL &&        strstr(pszFilename, "/vsizip/") == NULL )        fp = (VSILFILE*) VSICreateBufferedReaderHandle((VSIVirtualHandle*)fp);    CPLString osLayerName = CPLGetBasename(pszFilename);    CPLString osExt = CPLGetExtension(pszFilename);    if( strncmp(pszFilename, "/vsigzip/", 9) == 0 && EQUAL(osExt, "gz") )    {        if( strlen(pszFilename) > 7 && EQUAL(pszFilename + strlen(pszFilename) - 7, ".csv.gz") )        {            osLayerName = osLayerName.substr(0, osLayerName.size() - 4);            osExt = "csv";        }        else if( strlen(pszFilename) > 7 && EQUAL(pszFilename + strlen(pszFilename) - 7, ".tsv.gz") )        {            osLayerName = osLayerName.substr(0, osLayerName.size() - 4);            osExt = "tsv";        }    }/* -------------------------------------------------------------------- *//*      Read and parse a line.  Did we get multiple fields?             *//* -------------------------------------------------------------------- */    const char* pszLine = CPLReadLineL( fp );    if (pszLine == NULL)    {        VSIFCloseL( fp );        return FALSE;    }    char chDelimiter = CSVDetectSeperator(pszLine);    if( chDelimiter != '/t' && strchr(pszLine, '/t') != NULL )    {        /* Force the delimiter to be TAB for a .tsv file that has a tabulation */        /* in its first line */        if( EQUAL(osExt, "tsv") )        {            chDelimiter = '/t';        }        else        {            for(int bDontHonourStrings=0; bDontHonourStrings<=1; bDontHonourStrings++)            {                // Read the first 2 lines to see if they have the same number of fields, if using tabulation                VSIRewindL( fp );                char** papszTokens = OGRCSVReadParseLineL( fp, '/t', bDontHonourStrings );                int nTokens1 = CSLCount(papszTokens);                CSLDestroy(papszTokens);                papszTokens = OGRCSVReadParseLineL( fp, '/t', bDontHonourStrings );                int nTokens2 = CSLCount(papszTokens);                CSLDestroy(papszTokens);                if( nTokens1 >= 2 && nTokens1 == nTokens2 )                {                    chDelimiter = '/t';                    break;                }            }        }    }    VSIRewindL( fp );#if 0    const char *pszDelimiter = CSLFetchNameValueDef( papszOpenOptions, "SEPARATOR", "AUTO");    if( !EQUAL(pszDelimiter, "AUTO") )    {        if (EQUAL(pszDelimiter, "COMMA"))            chDelimiter = ',';        else if (EQUAL(pszDelimiter, "SEMICOLON"))            chDelimiter = ';';        else if (EQUAL(pszDelimiter, "TAB"))            chDelimiter = '/t';        else if (EQUAL(pszDelimiter, "SPACE"))            chDelimiter = ' ';        else        {            CPLError( CE_Warning, CPLE_AppDefined, //.........这里部分代码省略.........
开发者ID:MattLatt,项目名称:GDAL_2.0.x_VC,代码行数:101,


示例24: VSIFOpenL

int OGRCSVDataSource::OpenTable( const char * pszFilename,                                 const char* pszNfdcRunwaysGeomField,                                 const char* pszGeonamesGeomFieldPrefix){/* -------------------------------------------------------------------- *//*      Open the file.                                                  *//* -------------------------------------------------------------------- */    VSILFILE       * fp;    if( bUpdate )        fp = VSIFOpenL( pszFilename, "rb+" );    else        fp = VSIFOpenL( pszFilename, "rb" );    if( fp == NULL )    {        CPLError( CE_Warning, CPLE_OpenFailed,                   "Failed to open %s, %s.",                   pszFilename, VSIStrerror( errno ) );        return FALSE;    }    if( !bUpdate && strstr(pszFilename, "/vsigzip/") == NULL &&        strstr(pszFilename, "/vsizip/") == NULL )        fp = (VSILFILE*) VSICreateBufferedReaderHandle((VSIVirtualHandle*)fp);    CPLString osLayerName = CPLGetBasename(pszFilename);    CPLString osExt = CPLGetExtension(pszFilename);    if( strncmp(pszFilename, "/vsigzip/", 9) == 0 && EQUAL(osExt, "gz") )    {        if( strlen(pszFilename) > 7 && EQUAL(pszFilename + strlen(pszFilename) - 7, ".csv.gz") )        {            osLayerName = osLayerName.substr(0, osLayerName.size() - 4);            osExt = "csv";        }        else if( strlen(pszFilename) > 7 && EQUAL(pszFilename + strlen(pszFilename) - 7, ".tsv.gz") )        {            osLayerName = osLayerName.substr(0, osLayerName.size() - 4);            osExt = "tsv";        }    }/* -------------------------------------------------------------------- *//*      Read and parse a line.  Did we get multiple fields?             *//* -------------------------------------------------------------------- */    const char* pszLine = CPLReadLineL( fp );    if (pszLine == NULL)    {        VSIFCloseL( fp );        return FALSE;    }    char chDelimiter = CSVDetectSeperator(pszLine);    /* Force the delimiter to be TAB for a .tsv file that has a tabulation */    /* in its first line */    if( EQUAL(osExt, "tsv") && chDelimiter != '/t' &&        strchr(pszLine, '/t') != NULL )    {        chDelimiter = '/t';    }    VSIRewindL( fp );    /* GNIS specific */    if (pszGeonamesGeomFieldPrefix != NULL &&        strchr(pszLine, '|') != NULL)        chDelimiter = '|';    char **papszFields = OGRCSVReadParseLineL( fp, chDelimiter, FALSE );						    if( CSLCount(papszFields) < 2 )    {        VSIFCloseL( fp );        CSLDestroy( papszFields );        return FALSE;    }    VSIRewindL( fp );    CSLDestroy( papszFields );/* -------------------------------------------------------------------- *//*      Create a layer.                                                 *//* -------------------------------------------------------------------- */    nLayers++;    papoLayers = (OGRCSVLayer **) CPLRealloc(papoLayers,                                              sizeof(void*) * nLayers);    if (pszNfdcRunwaysGeomField != NULL)    {        osLayerName += "_";        osLayerName += pszNfdcRunwaysGeomField;    }    else if (pszGeonamesGeomFieldPrefix != NULL &&             !EQUAL(pszGeonamesGeomFieldPrefix, ""))    {        osLayerName += "_";        osLayerName += pszGeonamesGeomFieldPrefix;    }    if (EQUAL(pszFilename, "/vsistdin/"))//.........这里部分代码省略.........
开发者ID:imincik,项目名称:pkg-gdal,代码行数:101,


示例25: CPLError

GDALDataset *ARGDataset::CreateCopy( const char *pszFilename,                                     GDALDataset *poSrcDS,                                     int /* bStrict */ ,                                     char ** /* papszOptions */ ,                                     GDALProgressFunc /* pfnProgress */ ,                                     void * /*pProgressData */ ){    const int nBands = poSrcDS->GetRasterCount();    if( nBands != 1 )    {        CPLError( CE_Failure, CPLE_NotSupported,              "ARG driver doesn't support %d bands.  Must be 1 band.", nBands );        return nullptr;    }    CPLString pszDataType;    int nPixelOffset = 0;    GDALDataType eType = poSrcDS->GetRasterBand(1)->GetRasterDataType();    if( eType == GDT_Unknown ||        eType == GDT_CInt16 ||        eType == GDT_CInt32 ||        eType == GDT_CFloat32 ||        eType == GDT_CFloat64 )    {        CPLError( CE_Failure, CPLE_NotSupported,                  "ARG driver doesn't support data type %s.",                  GDALGetDataTypeName(eType) );        return nullptr;    }    else if (eType == GDT_Int16) {        pszDataType = "int16";        nPixelOffset = 2;    }    else if (eType == GDT_Int32) {        pszDataType = "int32";        nPixelOffset = 4;    }    else if (eType == GDT_Byte) {        pszDataType = "uint8";        nPixelOffset = 1;    }    else if (eType == GDT_UInt16) {        pszDataType = "uint16";        nPixelOffset = 2;    }    else if (eType == GDT_UInt32) {        pszDataType = "uint32";        nPixelOffset = 4;    }    else if (eType == GDT_Float32) {        pszDataType = "float32";        nPixelOffset = 4;    }    else if (eType == GDT_Float64) {        pszDataType = "float64";        nPixelOffset = 8;    }    double adfTransform[6];    poSrcDS->GetGeoTransform( adfTransform );    const char *pszWKT = poSrcDS->GetProjectionRef();    OGRSpatialReference oSRS;    OGRErr nErr = oSRS.importFromWkt(pszWKT);    if (nErr != OGRERR_NONE) {        CPLError( CE_Failure, CPLE_NotSupported,              "Cannot import spatial reference WKT from source dataset.");        return nullptr;    }    int nSrs = 0;    if (oSRS.GetAuthorityCode("PROJCS") != nullptr) {        nSrs = atoi(oSRS.GetAuthorityCode("PROJCS"));    }    else if (oSRS.GetAuthorityCode("GEOGCS") != nullptr) {        nSrs = atoi(oSRS.GetAuthorityCode("GEOGCS"));    }    else {        // could not determine projected or geographic code        // default to EPSG:3857 if no code could be found        nSrs = 3857;    }    /********************************************************************/    /* Create JSON companion file.                                      */    /********************************************************************/    const CPLString osJSONFilename = GetJsonFilename(pszFilename);    json_object *poJSONObject = json_object_new_object();    char **pszTokens = poSrcDS->GetMetadata();    const char *pszLayer = CSLFetchNameValue(pszTokens, "LAYER");    if ( pszLayer == nullptr) {        // Set the layer        json_object_object_add(poJSONObject, "layer", json_object_new_string(            CPLGetBasename(osJSONFilename)        ));    }//.........这里部分代码省略.........
开发者ID:AsgerPetersen,项目名称:gdal,代码行数:101,


示例26: GetJsonFilename

static CPLString GetJsonFilename(CPLString pszFilename){    return CPLSPrintf( "%s/%s.json", CPLGetDirname(pszFilename),                       CPLGetBasename(pszFilename) );}
开发者ID:AsgerPetersen,项目名称:gdal,代码行数:5,


示例27: CPLGetBasename

GDALDataset *ACE2Dataset::Open( GDALOpenInfo * poOpenInfo ){    if (!Identify(poOpenInfo))        return NULL;    const char* pszBasename = CPLGetBasename(poOpenInfo->pszFilename);    int nXSize = 0, nYSize = 0;    if (strlen(pszBasename) < 7)        return NULL;    /* Determine southwest coordinates from filename */    /* e.g. 30S120W_5M.ACE2 */    char pszLatLonValueString[4] = { '/0' };    memset(pszLatLonValueString, 0, 4);    strncpy(pszLatLonValueString, &pszBasename[0], 2);    int southWestLat = atoi(pszLatLonValueString);    memset(pszLatLonValueString, 0, 4);    strncpy(pszLatLonValueString, &pszBasename[3], 3);    int southWestLon = atoi(pszLatLonValueString);    if(pszBasename[2] == 'N' || pszBasename[2] == 'n')        /*southWestLat = southWestLat*/;    else if(pszBasename[2] == 'S' || pszBasename[2] == 's')        southWestLat = southWestLat * -1;    else        return NULL;    if(pszBasename[6] == 'E' || pszBasename[6] == 'e')        /*southWestLon = southWestLon*/;    else if(pszBasename[6] == 'W' || pszBasename[6] == 'w')        southWestLon = southWestLon * -1;    else        return NULL;    GDALDataType eDT = GDT_Unknown;    if (strstr(pszBasename, "_CONF_") ||        strstr(pszBasename, "_QUALITY_") ||        strstr(pszBasename, "_SOURCE_"))        eDT = GDT_Int16;    else        eDT = GDT_Float32;    int nWordSize = GDALGetDataTypeSize(eDT) / 8;    VSIStatBufL sStat;    if (strstr(pszBasename, "_5M"))        sStat.st_size = 180 * 180 * nWordSize;    else if (strstr(pszBasename, "_30S"))        sStat.st_size = 1800 * 1800 * nWordSize;    else if (strstr(pszBasename, "_9S"))        sStat.st_size = 6000 * 6000 * nWordSize;    else if (strstr(pszBasename, "_3S"))        sStat.st_size = 18000 * 18000 * nWordSize;    /* Check file size otherwise */    else if(VSIStatL(poOpenInfo->pszFilename, &sStat) != 0)    {        return NULL;    }    double dfPixelSize = 0;    if (sStat.st_size == 180 * 180 * nWordSize)    {        /* 5 minute */        nXSize = nYSize = 180;        dfPixelSize = 5. / 60;    }    else if (sStat.st_size == 1800 * 1800 * nWordSize)    {        /* 30 s */        nXSize = nYSize = 1800;        dfPixelSize = 30. / 3600;    }    else if (sStat.st_size == 6000 * 6000 * nWordSize)    {        /* 9 s */        nXSize = nYSize = 6000;        dfPixelSize = 9. / 3600;    }    else if (sStat.st_size == 18000 * 18000 * nWordSize)    {        /* 3 s */        nXSize = nYSize = 18000;        dfPixelSize = 3. / 3600;    }    else        return NULL;/* -------------------------------------------------------------------- *//*      Open file.                                                      *//* -------------------------------------------------------------------- */    CPLString osFilename = poOpenInfo->pszFilename;    if ((strstr(poOpenInfo->pszFilename, ".ACE2.gz") ||         strstr(poOpenInfo->pszFilename, ".ace2.gz")) &&        !STARTS_WITH(poOpenInfo->pszFilename, "/vsigzip/"))        osFilename = "/vsigzip/" + osFilename;    VSILFILE* fpImage = VSIFOpenL( osFilename, "rb+" );//.........这里部分代码省略.........
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,


示例28: VSIFOpenL

GDALDataset *EIRDataset::Open( GDALOpenInfo * poOpenInfo ){    int     i;    VSILFILE    *fp;    const char *    pszLine;            if( !Identify( poOpenInfo ) )        return NULL;                      fp = VSIFOpenL( poOpenInfo->pszFilename, "r" );    if( fp == NULL )        return NULL;        /* header example and description        IMAGINE_RAW_FILE // must be on first line, by itself    WIDTH 581        // number of columns in the image    HEIGHT 695       // number of rows in the image    NUM_LAYERS 3     // number of spectral bands in the image; default 1    PIXEL_FILES raw8_3n_ui_sanjack.bl // raster file                                      // default: same name with no extension    FORMAT BIL       // BIL BIP BSQ; default BIL    DATATYPE U8      // U1 U2 U4 U8 U16 U32 S16 S32 F32 F64; default U8    BYTE_ORDER       // LSB MSB; required for U16 U32 S16 S32 F32 F64    DATA_OFFSET      // start of image data in raster file; default 0 bytes    END_RAW_FILE     // end RAW file - stop reading        For a true color image with three bands (R, G, B) stored using 8 bits    for each pixel in each band, DATA_TYPE equals U8 and NUM_LAYERS equals    3 for a total of 24 bits per pixel.        Note that the current version of ERDAS Raw Raster Reader/Writer does    not support the LAYER_SKIP_BYTES, RECORD_SKIP_BYTES, TILE_WIDTH and     TILE_HEIGHT directives. Since the reader does not read the PIXEL_FILES     directive, the reader always assumes that the raw binary file is the     dataset, and the name of this file is the name of the header without the     extension. Currently, the reader does not support multiple raw binary    files in one dataset or a single file with both the header and the raw     binary data at the same time.    */        bool         bDone = FALSE;    int          nRows = -1, nCols = -1, nBands = 1;    int          nSkipBytes = 0;    int          nLineCount = 0;    GDALDataType eDataType = GDT_Byte;    int          nBits = 8;    char         chByteOrder = 'M';    char         szLayout[10] = "BIL";    char         **papszHDR = NULL;        // default raster file: same name with no extension    CPLString osPath = CPLGetPath( poOpenInfo->pszFilename );    CPLString osName = CPLGetBasename( poOpenInfo->pszFilename );    CPLString osRasterFilename = CPLFormCIFilename( osPath, osName, "" );        // parse the header file    while( !bDone && (pszLine = CPLReadLineL( fp )) != NULL )    {        char    **papszTokens;        nLineCount++;                if ( (nLineCount == 1) && !EQUAL(pszLine,"IMAGINE_RAW_FILE") ) {            return NULL;        }                    if ( (nLineCount > 50) || EQUAL(pszLine,"END_RAW_FILE") ) {            bDone = TRUE;            break;        }                if( strlen(pszLine) > 1000 )            break;        papszHDR = CSLAddString( papszHDR, pszLine );        papszTokens = CSLTokenizeStringComplex( pszLine, " /t", TRUE, FALSE );        if( CSLCount( papszTokens ) < 2 )        {            CSLDestroy( papszTokens );            continue;        }                if( EQUAL(papszTokens[0],"WIDTH") )        {            nCols = atoi(papszTokens[1]);        }        else if( EQUAL(papszTokens[0],"HEIGHT") )        {            nRows = atoi(papszTokens[1]);        }        else if( EQUAL(papszTokens[0],"NUM_LAYERS") )        {            nBands = atoi(papszTokens[1]);        }        else if( EQUAL(papszTokens[0],"PIXEL_FILES") )        {//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,


示例29: CPLError

OGRErr OGRShapeLayer::Repack(){    if( !bUpdateAccess )    {        CPLError( CE_Failure, CPLE_AppDefined,             "The REPACK operation is not permitted on a read-only shapefile." );        return OGRERR_FAILURE;    }        if( hDBF == NULL )    {        CPLError( CE_Failure, CPLE_NotSupported,                   "Attempt to repack a shapefile with no .dbf file not supported.");        return OGRERR_FAILURE;    }    /* -------------------------------------------------------------------- *//*      Build a list of records to be dropped.                          *//* -------------------------------------------------------------------- */    int *panRecordsToDelete = (int *)         CPLMalloc(sizeof(int)*(nTotalShapeCount+1));    int nDeleteCount = 0;    int iShape = 0;    OGRErr eErr = OGRERR_NONE;    for( iShape = 0; iShape < nTotalShapeCount; iShape++ )    {        if( DBFIsRecordDeleted( hDBF, iShape ) )            panRecordsToDelete[nDeleteCount++] = iShape;    }    panRecordsToDelete[nDeleteCount] = -1;/* -------------------------------------------------------------------- *//*      If there are no records marked for deletion, we take no         *//*      action.                                                         *//* -------------------------------------------------------------------- */    if( nDeleteCount == 0 )    {        CPLFree( panRecordsToDelete );        return OGRERR_NONE;    }/* -------------------------------------------------------------------- *//*      Find existing filenames with exact case (see #3293).            *//* -------------------------------------------------------------------- */    CPLString osDirname(CPLGetPath(pszFullName));    CPLString osBasename(CPLGetBasename(pszFullName));        CPLString osDBFName, osSHPName, osSHXName;    char **papszCandidates = CPLReadDir( osDirname );    int i = 0;    while(papszCandidates != NULL && papszCandidates[i] != NULL)    {        CPLString osCandidateBasename = CPLGetBasename(papszCandidates[i]);        CPLString osCandidateExtension = CPLGetExtension(papszCandidates[i]);        if (osCandidateBasename.compare(osBasename) == 0)        {            if (EQUAL(osCandidateExtension, "dbf"))                osDBFName = CPLFormFilename(osDirname, papszCandidates[i], NULL);            else if (EQUAL(osCandidateExtension, "shp"))                osSHPName = CPLFormFilename(osDirname, papszCandidates[i], NULL);            else if (EQUAL(osCandidateExtension, "shx"))                osSHXName = CPLFormFilename(osDirname, papszCandidates[i], NULL);        }                i++;    }    CSLDestroy(papszCandidates);    papszCandidates = NULL;        if (osDBFName.size() == 0)    {        /* Should not happen, really */        CPLFree( panRecordsToDelete );        return OGRERR_FAILURE;    }    /* -------------------------------------------------------------------- *//*      Cleanup any existing spatial index.  It will become             *//*      meaningless when the fids change.                               *//* -------------------------------------------------------------------- */    if( CheckForQIX() )        DropSpatialIndex();/* -------------------------------------------------------------------- *//*      Create a new dbf file, matching the old.                        *//* -------------------------------------------------------------------- */    DBFHandle hNewDBF = NULL;        CPLString oTempFile(CPLFormFilename(osDirname, osBasename, NULL));    oTempFile += "_packed.dbf";    hNewDBF = DBFCloneEmpty( hDBF, oTempFile );    if( hNewDBF == NULL )    {        CPLFree( panRecordsToDelete );        CPLError( CE_Failure, CPLE_OpenFailed,                   "Failed to create temp file %s.", //.........这里部分代码省略.........
开发者ID:dlsyaim,项目名称:osgEarthX,代码行数:101,



注:本文中的CPLGetBasename函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ CPLGetConfigOption函数代码示例
C++ CPLFree函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。