当前位置: 首页>>代码示例>>C++>>正文


C++ CPLFormFilename函数代码示例

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


在下文中一共展示了CPLFormFilename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FindBoostDataBaseFile

std::string FindBoostDataBaseFile()
{
    const char* pszBase = "date_time_zonespec";
    const char* pszExt = "csv";
    const char* pszFilename;
    const char* pszNinjaPath;
    const char* pszNinjaSharePath;
    char pszFilePath[MAX_PATH];

    CPLGetExecPath(pszFilePath, MAX_PATH);
    pszNinjaPath = CPLGetPath(pszFilePath);

    pszNinjaSharePath = CPLProjectRelativeFilename(pszNinjaPath, 
        "../share/windninja");

    pszFilename = CPLFormFilename(CPLGetCurrentDir(), pszBase, pszExt);
    if(CPLCheckForFile((char*)pszFilename, NULL)) {
        return std::string((char*)pszFilename);
    }

    pszFilename = CPLFormFilename(pszNinjaPath, pszBase, pszExt);
    if(CPLCheckForFile((char*)pszFilename, NULL)) {
        return std::string((char*)pszFilename);
    }

    pszFilename = CPLFormFilename(pszNinjaSharePath, pszBase, pszExt);
    if(CPLCheckForFile((char*)pszFilename, NULL)) {
        return std::string((char*)pszFilename);
    }
    return std::string();
}
开发者ID:psuliuxf,项目名称:windninja,代码行数:31,代码来源:ninja_conv.cpp

示例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:AbdelghaniDr,项目名称:mirror,代码行数:37,代码来源:reader_orb_view.cpp

示例3: 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:drownedout,项目名称:datamap,代码行数:31,代码来源:reader_rapid_eye.cpp

示例4: CPLGetConfigOption

CPLString GMLASConfiguration::GetBaseCacheDirectory()
{
#ifdef WIN32
    const char* pszHome = CPLGetConfigOption("USERPROFILE", NULL);
#else
    const char* pszHome = CPLGetConfigOption("HOME", NULL);
#endif
    if( pszHome != NULL )
    {
        return CPLFormFilename( pszHome, ".gdal", NULL) ;
    }
    else
    {
        const char *pszDir = CPLGetConfigOption( "CPL_TMPDIR", NULL );

        if( pszDir == NULL )
            pszDir = CPLGetConfigOption( "TMPDIR", NULL );

        if( pszDir == NULL )
            pszDir = CPLGetConfigOption( "TEMP", NULL );

        const char* pszUsername = CPLGetConfigOption("USERNAME", NULL);
        if( pszUsername == NULL )
            pszUsername = CPLGetConfigOption("USER", NULL);

        if( pszDir != NULL && pszUsername != NULL )
        {
            return CPLFormFilename( pszDir,
                    CPLSPrintf(".gdal_%s", pszUsername), NULL) ;
        }
    }
    return CPLString();
}
开发者ID:ryandavid,项目名称:rotobox,代码行数:33,代码来源:ogrgmlasconf.cpp

示例5: 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() );
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:57,代码来源:reader_spot.cpp

示例6: CPLError

OGRErr OGRCSVDataSource::DeleteLayer( int iLayer )

{
/* -------------------------------------------------------------------- */
/*      Verify we are in update mode.                                   */
/* -------------------------------------------------------------------- */
    if( !bUpdate )
    {
        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;
    }

    char *pszFilename =
        CPLStrdup(
            CPLFormFilename( pszName,
                             papoLayers[iLayer]->GetLayerDefn()->GetName(),
                             "csv" ) );
    char *pszFilenameCSVT =
        CPLStrdup(
            CPLFormFilename( pszName,
                             papoLayers[iLayer]->GetLayerDefn()->GetName(),
                             "csvt" ) );

    delete papoLayers[iLayer];

    while( iLayer < nLayers - 1 )
    {
        papoLayers[iLayer] = papoLayers[iLayer+1];
        iLayer++;
    }

    nLayers--;

    VSIUnlink( pszFilename );
    CPLFree( pszFilename );
    VSIUnlink( pszFilenameCSVT );
    CPLFree( pszFilenameCSVT );

    return OGRERR_NONE;
}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:52,代码来源:ogrcsvdatasource.cpp

示例7: TEST

TEST(MapTests, TestCreate) {
    char** options = nullptr;
    options = ngsListAddNameValue(options, "DEBUG_MODE", "ON");
    options = ngsListAddNameValue(options, "SETTINGS_DIR",
                              ngsFormFileName(ngsGetCurrentDirectory(), "tmp",
                                              nullptr));
    EXPECT_EQ(ngsInit(options), COD_SUCCESS);

    ngsListFree(options);


    ngs::MapStore mapStore;
    char mapId = mapStore.createMap(DEFAULT_MAP_NAME, "unit test",
                                             DEFAULT_EPSG, ngs::DEFAULT_BOUNDS);
    EXPECT_GE(mapId, 0);

    ngs::MapViewPtr defMap = mapStore.getMap(mapId);
    ASSERT_NE(defMap, nullptr);
    ngsRGBA color = defMap->backgroundColor();
    EXPECT_EQ(color.R, DEFAULT_MAP_BK.R);
    EXPECT_EQ(color.G, DEFAULT_MAP_BK.G);
    EXPECT_EQ(color.B, DEFAULT_MAP_BK.B);

    // ngmd - NextGIS map document
    ngs::CatalogPtr catalog = ngs::Catalog::instance();
    CPLString tmpDir = CPLFormFilename(CPLGetCurrentDir(), "tmp", nullptr);
    ngs::Folder::mkDir(tmpDir);
    ngs::ObjectPtr tmpDirObj = catalog->getObjectBySystemPath(tmpDir);
    ASSERT_NE(tmpDirObj, nullptr);
    ngs::ObjectContainer* tmpDirContainer =
            ngsDynamicCast(ngs::ObjectContainer, tmpDirObj);
    CPLString mapPath = CPLFormFilename(tmpDirObj->path().c_str(), "default", "ngmd");
    CPLString iconsPath = CPLFormFilename(CPLGetCurrentDir(), "data", nullptr);
    CPLString iconSet = CPLFormFilename(iconsPath, "tex", "png");
    defMap->addIconSet("simple", iconSet, true);

    ngs::MapFile mapFile(tmpDirContainer, "default.ngmd", mapPath);
    EXPECT_EQ(defMap->save(&mapFile), true);

    mapId = mapStore.openMap(&mapFile);
    defMap = mapStore.getMap(mapId);
    defMap->setBackgroundColor({1,2,3,4});
    EXPECT_EQ(defMap->save(&mapFile), true);

    ngs::Catalog::setInstance(nullptr);

    ngsUnInit();
}
开发者ID:nextgis,项目名称:nextgis_datastore,代码行数:48,代码来源:map_test.cpp

示例8: CheckLayerDriver

CPLErr GNMFileNetwork::CreateFeaturesLayerFromFile( const char* pszFilename, char** papszOptions )
{
    CPLErr eResult = CheckLayerDriver(GNM_MD_DEFAULT_FILE_FORMAT, papszOptions);
    if(CE_None != eResult)
        return eResult;

    eResult = FormPath(pszFilename, papszOptions);
    if(CE_None != eResult)
        return eResult;

    const char* pszExt = m_poLayerDriver->GetMetadataItem(GDAL_DMD_EXTENSION);
    CPLString osDSFileName = CPLFormFilename(m_soNetworkFullName,
                                                GNM_SYSLAYER_FEATURES, pszExt);

    m_pFeaturesDS = m_poLayerDriver->Create(osDSFileName, 0, 0, 0, GDT_Unknown,
                                            NULL );

    if( m_pFeaturesDS == NULL )
    {
        CPLError( CE_Failure, CPLE_AppDefined, "Creation of '%s' file failed",
                  osDSFileName.c_str() );
        return CE_Failure;
    }

    return GNMGenericNetwork::CreateFeaturesLayer(m_pFeaturesDS);
}
开发者ID:garnertb,项目名称:gdal,代码行数:26,代码来源:gnmfilenetwork.cpp

示例9: CPLGetConfigOption

const char *CPLGenerateTempFilename( const char *pszStem )

{
    const char *pszDir = CPLGetConfigOption( "CPL_TMPDIR", NULL );
    static volatile int nTempFileCounter = 0;

    if( pszDir == NULL )
        pszDir = CPLGetConfigOption( "TMPDIR", NULL );

    if( pszDir == NULL )
        pszDir = CPLGetConfigOption( "TEMP", NULL );

    if( pszDir == NULL )
        pszDir = ".";

    CPLString osFilename;

    if( pszStem == NULL )
        pszStem = "";

    osFilename.Printf( "%s%u_%d", pszStem, 
                       (int) CPLGetPID(), nTempFileCounter++ );

    return CPLFormFilename( pszDir, osFilename, NULL );
}
开发者ID:ViacheslavN,项目名称:GIS,代码行数:25,代码来源:cpl_path.cpp

示例10: CPLFormFilename

OGRLayer* OGROpenFileGDBDataSource::GetLayerByName( const char* pszName )
{
    OGRLayer* poLayer;

    poLayer = OGRDataSource::GetLayerByName(pszName);
    if( poLayer != NULL )
        return poLayer;

    for(size_t i=0;i<m_apoHiddenLayers.size();i++)
    {
        if( EQUAL(m_apoHiddenLayers[i]->GetName(), pszName) )
            return m_apoHiddenLayers[i];
    }

    std::map<std::string, int>::const_iterator oIter = m_osMapNameToIdx.find(pszName);
    if( oIter != m_osMapNameToIdx.end() )
    {
        int idx = oIter->second;
        const char* pszFilename = CPLFormFilename(
                            m_osDirName, CPLSPrintf("a%08x", idx), "gdbtable");
        if( FileExists(pszFilename) )
        {
            poLayer = new OGROpenFileGDBLayer(
                                    pszFilename, pszName, "", "");
            m_apoHiddenLayers.push_back(poLayer);
            return poLayer;
        }
    }
    return NULL;
}
开发者ID:garnertb,项目名称:gdal,代码行数:30,代码来源:ogropenfilegdbdatasource.cpp

示例11: GetKeyword

int PDSDataset::ParseCompressedImage()

{
    CPLString osFileName = GetKeyword( "COMPRESSED_FILE.FILE_NAME", "" );
    CleanString( osFileName );

    CPLString osPath = CPLGetPath(GetDescription());
    CPLString osFullFileName = CPLFormFilename( osPath, osFileName, NULL );
    int iBand;

    poCompressedDS = (GDALDataset*) GDALOpen( osFullFileName, GA_ReadOnly );
    
    if( poCompressedDS == NULL )
        return FALSE;

    nRasterXSize = poCompressedDS->GetRasterXSize();
    nRasterYSize = poCompressedDS->GetRasterYSize();

    for( iBand = 0; iBand < poCompressedDS->GetRasterCount(); iBand++ )
    {
        SetBand( iBand+1, new PDSWrapperRasterBand( poCompressedDS->GetRasterBand( iBand+1 ) ) );
    }
    
    return TRUE;
}
开发者ID:TUW-GEO,项目名称:OGRSpatialRef3D,代码行数:25,代码来源:pdsdataset.cpp

示例12: BuildFullName

static const char* BuildFullName(const char* pszTOCFilename,
                                 const char* pszFramePath,
                                 const char* pszFrameName)
{
    char* pszPath;
    if (pszFramePath[0] == '.' &&
        (pszFramePath[1] == '/' ||pszFramePath[1] == '\\'))
        pszPath = CPLStrdup(pszFramePath + 2);
    else
        pszPath = CPLStrdup(pszFramePath);
    for(int i=0;pszPath[i] != '\0';i++)
    {
        if (pszPath[i] == '\\')
            pszPath[i] = '/';
    }
    const char* pszName = CPLFormFilename(pszPath, pszFrameName, NULL);
    CPLFree(pszPath);
    pszPath = NULL;
    const char* pszTOCPath = CPLGetDirname(pszTOCFilename);
    const char* pszFirstSlashInName = strchr(pszName, '/');
    if (pszFirstSlashInName != NULL)
    {
        int nFirstDirLen = pszFirstSlashInName - pszName;
        if ((int)strlen(pszTOCPath) >= nFirstDirLen + 1 &&
            (pszTOCPath[strlen(pszTOCPath) - (nFirstDirLen + 1)] == '/' ||
                pszTOCPath[strlen(pszTOCPath) - (nFirstDirLen + 1)] == '\\') &&
            strncmp(pszTOCPath + strlen(pszTOCPath) - nFirstDirLen, pszName, nFirstDirLen) == 0)
        {
            pszTOCPath = CPLGetDirname(pszTOCPath);
        }
    }
    return CPLProjectRelativeFilename(pszTOCPath, pszName);
}
开发者ID:drownedout,项目名称:datamap,代码行数:33,代码来源:ecrgtocdataset.cpp

示例13: FindDataPath

/**
 * \brief Find a file or folder in the WindNinja data path
 *
 * XXX: Refactored by Kyle 20130117
 *
 * For example the date_time_zonespec.csv file is location in data.  If
 * WINDNINJA_DATA is *not* defined, try to find the file relative to the bin
 * path, ie ../share/data, otherwise return WINDNINJA_DATA + filename.
 *
 * \param file file or folder to look for.
 * \return a full path to file
 */
std::string FindDataPath(std::string file)
{
    const char* pszFilename;
    const char* pszNinjaPath;
    const char* pszNinjaDataPath;
    const char* pszCurDir;
    char pszExePath[MAX_PATH];

    /* Check WINDNINJA_DATA */
    VSIStatBufL sStat;
    pszNinjaDataPath = CPLGetConfigOption( "WINDNINJA_DATA", NULL );
    if( pszNinjaDataPath != NULL )
    {
        pszFilename = CPLFormFilename( pszNinjaDataPath, file.c_str(), NULL );
        VSIStatL( pszFilename, &sStat );
        if( VSI_ISREG( sStat.st_mode ) || VSI_ISDIR( sStat.st_mode ) )
        {
            return std::string( pszFilename );
        }
    }

    /* Check 'normal' installation location */
    CPLGetExecPath( pszExePath, MAX_PATH );
    pszNinjaPath = CPLGetPath( pszExePath );

    pszNinjaDataPath = CPLProjectRelativeFilename(pszNinjaPath, 
                                                   "../share/windninja");
    pszFilename = CPLFormFilename( pszNinjaDataPath, file.c_str(), NULL );
    VSIStatL( pszFilename, &sStat );
    if( VSI_ISREG( sStat.st_mode ) || VSI_ISDIR( sStat.st_mode ) )
    {
        return std::string( pszFilename );
    }

    /* Check the current directory */
    pszCurDir = CPLGetCurrentDir();
    pszFilename = CPLFormFilename( pszCurDir, file.c_str(), NULL );
    CPLFree( (void*)pszCurDir );
    if( CPLCheckForFile( (char*)pszFilename, NULL ))
    {
        return std::string( pszFilename );
    }

    return std::string();

}
开发者ID:psuliuxf,项目名称:windninja,代码行数:58,代码来源:ninja_conv.cpp

示例14: CPLGetXMLValue

bool GMLRegistryFeatureType::Parse(const char *pszRegistryFilename,
                                   CPLXMLNode *psNode)
{
    const char *pszElementName = CPLGetXMLValue(psNode, "elementName", NULL);
    const char *pszSchemaLocation =
        CPLGetXMLValue(psNode, "schemaLocation", NULL);
    const char *pszGFSSchemaLocation =
        CPLGetXMLValue(psNode, "gfsSchemaLocation", NULL);
    if( pszElementName == NULL ||
        (pszSchemaLocation == NULL && pszGFSSchemaLocation == NULL) )
        return false;

    const char *pszElementValue = CPLGetXMLValue(psNode, "elementValue", NULL);
    osElementName = pszElementName;

    if( pszSchemaLocation != NULL )
    {
        if( !STARTS_WITH(pszSchemaLocation, "http://") &&
            !STARTS_WITH(pszSchemaLocation, "https://") &&
            CPLIsFilenameRelative(pszSchemaLocation) )
        {
            pszSchemaLocation = CPLFormFilename(
                CPLGetPath(pszRegistryFilename), pszSchemaLocation, NULL );
        }
        osSchemaLocation = pszSchemaLocation;
    }
    else if( pszGFSSchemaLocation != NULL )
    {
        if( !STARTS_WITH(pszGFSSchemaLocation, "http://") &&
            !STARTS_WITH(pszGFSSchemaLocation, "https://") &&
            CPLIsFilenameRelative(pszGFSSchemaLocation) )
        {
            pszGFSSchemaLocation = CPLFormFilename(
                CPLGetPath(pszRegistryFilename), pszGFSSchemaLocation, NULL);
        }
        osGFSSchemaLocation = pszGFSSchemaLocation;
    }

    if ( pszElementValue != NULL )
    {
        osElementValue = pszElementValue;
    }

    return true;
}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:45,代码来源:gmlregistry.cpp

示例15: GdalTestData

 GdalTestData()
 {
     GDALAllRegister();
     OGRRegisterAll();
     fetch = NULL;
     poDS  = NULL;
     pszFilename =
         CPLFormFilename( NULL, CPLGenerateTempFilename( "GDAL_TEST" ), ".tif" );
 }
开发者ID:psuliuxf,项目名称:windninja,代码行数:9,代码来源:test_gdal_fetch.cpp


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