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


C++ CPLGetPath函数代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: FindNinjaRootDir

/**
 * \brief Find the root directory for the installation.
 *
 * Allocate enough space to get the path plus the relative "/../\0" for the 
 * parent directory.
 * \return full path to the directory above the 'bin' folder
 */
std::string FindNinjaRootDir()
{
    char pszFilePath[MAX_PATH];
    CPLGetExecPath(pszFilePath, MAX_PATH - 5);
    const char* pszNinjaPath;
    pszNinjaPath = CPLSPrintf("%s/../", pszFilePath);
    pszNinjaPath = CPLGetPath(pszFilePath);
    return std::string((char*)pszNinjaPath);
}
开发者ID:psuliuxf,项目名称:windninja,代码行数:16,代码来源:ninja_conv.cpp

示例6: FindNinjaBinDir

std::string FindNinjaBinDir()
{
    char pszFilePath[MAX_PATH];
    CPLGetExecPath(pszFilePath, MAX_PATH);
    const char* pszNinjaPath;
    pszNinjaPath = CPLGetPath(pszFilePath);

    return std::string((char*)pszNinjaPath);
}
开发者ID:psuliuxf,项目名称:windninja,代码行数:9,代码来源:ninja_conv.cpp

示例7: CPLGetXMLValue

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

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

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

    return TRUE;
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:40,代码来源:gmlregistry.cpp

示例8: CPLAssert

int OGRVRTDataSource::Initialize( CPLXMLNode *psTree, const char *pszNewName,
                                  int bUpdate )

{
    CPLAssert( nLayers == 0 );

    this->psTree = psTree;

/* -------------------------------------------------------------------- */
/*      Set name, and capture the directory path so we can use it       */
/*      for relative datasources.                                       */
/* -------------------------------------------------------------------- */
    char *pszVRTDirectory = CPLStrdup( CPLGetPath( pszNewName ) );

    pszName = CPLStrdup( pszNewName );

/* -------------------------------------------------------------------- */
/*      Look for layers.                                                */
/* -------------------------------------------------------------------- */
    CPLXMLNode *psLTree;

    for( psLTree=psTree->psChild; psLTree != NULL; psLTree=psLTree->psNext )
    {
        if( psLTree->eType != CXT_Element
            || !EQUAL(psLTree->pszValue,"OGRVRTLayer") )
            continue;

/* -------------------------------------------------------------------- */
/*      Create the layer object.                                        */
/* -------------------------------------------------------------------- */
        OGRVRTLayer  *poLayer;
        
        poLayer = new OGRVRTLayer();
        
        if( !poLayer->FastInitialize( psLTree, pszVRTDirectory, bUpdate ) )
        {
            CPLFree( pszVRTDirectory );
            delete poLayer;
            return FALSE;
        }
        
/* -------------------------------------------------------------------- */
/*      Add layer to data source layer list.                            */
/* -------------------------------------------------------------------- */
        papoLayers = (OGRVRTLayer **)
            CPLRealloc( papoLayers,  sizeof(OGRVRTLayer *) * (nLayers+1) );
        papoLayers[nLayers++] = poLayer;
    }

    CPLFree( pszVRTDirectory );
    return TRUE;
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:52,代码来源:ogrvrtdatasource.cpp

示例9: EQUALN

void VRTDataset::FlushCache()

{
    GDALDataset::FlushCache();

    if( !bNeedsFlush || bWritable == FALSE)
        return;

    bNeedsFlush = FALSE;

    // We don't write to disk if there is no filename.  This is a 
    // memory only dataset.
    if( strlen(GetDescription()) == 0 
        || EQUALN(GetDescription(),"<VRTDataset",11) )
        return;

    /* -------------------------------------------------------------------- */
    /*      Create the output file.                                         */
    /* -------------------------------------------------------------------- */
    VSILFILE *fpVRT;

    fpVRT = VSIFOpenL( GetDescription(), "w" );
    if( fpVRT == NULL )
    {
        CPLError( CE_Failure, CPLE_AppDefined, 
                  "Failed to write .vrt file in FlushCache()." );
        return;
    }

    /* -------------------------------------------------------------------- */
    /*      Convert tree to a single block of XML text.                     */
    /* -------------------------------------------------------------------- */
    char *pszVRTPath = CPLStrdup(CPLGetPath(GetDescription()));
    CPLXMLNode *psDSTree = SerializeToXML( pszVRTPath );
    char *pszXML;

    pszXML = CPLSerializeXMLTree( psDSTree );

    CPLDestroyXMLNode( psDSTree );

    CPLFree( pszVRTPath );

    /* -------------------------------------------------------------------- */
    /*      Write to disk.                                                  */
    /* -------------------------------------------------------------------- */
    VSIFWriteL( pszXML, 1, strlen(pszXML), fpVRT );
    VSIFCloseL( fpVRT );

    CPLFree( pszXML );
}
开发者ID:Joe-xXx,项目名称:gdal,代码行数:50,代码来源:vrtdataset.cpp

示例10: 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,代码来源:sagadataset.cpp

示例11: LLVMFuzzerInitialize

int LLVMFuzzerInitialize(int* /*argc*/, char*** argv)
{
    const char* exe_path = (*argv)[0];
    if( CPLGetConfigOption("GDAL_DATA", nullptr) == nullptr )
    {
        CPLSetConfigOption("GDAL_DATA", CPLGetPath(exe_path));
    }
    CPLSetConfigOption("CPL_TMPDIR", "/tmp");
    CPLSetConfigOption("DISABLE_OPEN_REAL_NETCDF_FILES", "YES");
    CPLSetConfigOption("GDAL_HTTP_TIMEOUT", "1");
    CPLSetConfigOption("GDAL_HTTP_CONNECTTIMEOUT", "1");
#ifdef OGR_SKIP
    CPLSetConfigOption("OGR_SKIP", OGR_SKIP);
#endif
    REGISTER_FUNC();
    return 0;
}
开发者ID:hdfeos,项目名称:gdal,代码行数:17,代码来源:gdal_vector_translate_fuzzer.cpp

示例12: 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

示例13: LLVMFuzzerInitialize

int LLVMFuzzerInitialize(int* /*argc*/, char*** argv)
{
    const char* exe_path = (*argv)[0];
    if( CPLGetConfigOption("GDAL_DATA", nullptr) == nullptr )
    {
        CPLSetConfigOption("GDAL_DATA", CPLGetPath(exe_path));
    }
    CPLSetConfigOption("CPL_TMPDIR", "/tmp");
    CPLSetConfigOption("DISABLE_OPEN_REAL_NETCDF_FILES", "YES");
    // Disable PDF text rendering as fontconfig cannot access its config files
    CPLSetConfigOption("GDAL_PDF_RENDERING_OPTIONS", "RASTER,VECTOR");
    // to avoid timeout in WMS driver
    CPLSetConfigOption("GDAL_WMS_ABORT_CURL_REQUEST", "YES");
    CPLSetConfigOption("GDAL_HTTP_TIMEOUT", "1");
    CPLSetConfigOption("GDAL_HTTP_CONNECTTIMEOUT", "1");
    CPLSetConfigOption("GDAL_CACHEMAX", "1000"); // Limit to 1 GB
    GDALAllRegister();
    return 0;
}
开发者ID:OSGeo,项目名称:gdal,代码行数:19,代码来源:gdal_translate_fuzzer.cpp

示例14: locker

bool wxGISDataset::Rename(const wxString &sNewName, ITrackCancel* const pTrackCancel)
{
	wxCriticalSectionLocker locker(m_CritSect);

    Close();

    CPLString szDirPath = CPLGetPath(m_sPath);
    CPLString szName = CPLGetBasename(m_sPath);
	CPLString szNewName(ClearExt(sNewName).mb_str(wxConvUTF8));

    char** papszFileList = GetFileList();
    papszFileList = CSLAddString( papszFileList, m_sPath );
    if(!papszFileList)    
    {
        if(pTrackCancel)
            pTrackCancel->PutMessage(_("No files to rename"), wxNOT_FOUND, enumGISMessageErr);
        return false;
    }

    char **papszNewFileList = NULL;

    for(int i = 0; papszFileList[i] != NULL; ++i )
    {
        CPLString szNewPath(CPLFormFilename(szDirPath, szNewName, GetExtension(papszFileList[i], szName)));
        papszNewFileList = CSLAddString(papszNewFileList, szNewPath);
        if(!RenameFile(papszFileList[i], papszNewFileList[i], pTrackCancel))
        {
            // Try to put the ones we moved back.
            for( --i; i >= 0; i-- )
                RenameFile( papszNewFileList[i], papszFileList[i]);

 			CSLDestroy( papszFileList );
			CSLDestroy( papszNewFileList );
            return false;
        }
    }

	m_sPath = CPLString(CPLFormFilename(szDirPath, szNewName, CPLGetExtension(m_sPath)));

	CSLDestroy( papszFileList );
	CSLDestroy( papszNewFileList );
	return true;
}
开发者ID:Mileslee,项目名称:wxgis,代码行数:43,代码来源:dataset.cpp

示例15: getRscFilename

static CPLString getRscFilename( GDALOpenInfo *poOpenInfo )
{
    CPLString osRscFilename;

    char **papszSiblingFiles = poOpenInfo->GetSiblingFiles();
    if ( papszSiblingFiles == NULL )
    {
        osRscFilename = CPLFormFilename( NULL, poOpenInfo->pszFilename,
                                        "rsc" );
        VSIStatBufL psRscStatBuf;
        if ( VSIStatL( osRscFilename, &psRscStatBuf ) != 0 )
        {
            osRscFilename = "";
        }
    }
    else
    {
        /* ------------------------------------------------------------ */
        /*      We need to tear apart the filename to form a .rsc       */
        /*      filename.                                               */
        /* ------------------------------------------------------------ */
        CPLString osPath = CPLGetPath( poOpenInfo->pszFilename );
        CPLString osName = CPLGetFilename( poOpenInfo->pszFilename );

        int iFile = CSLFindString( papszSiblingFiles,
                                   CPLFormFilename( NULL, osName, "rsc" ) );
        if( iFile >= 0 )
        {
            osRscFilename = CPLFormFilename( osPath,
                                             papszSiblingFiles[iFile],
                                             NULL );
        }
    }

    return osRscFilename;
}
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:36,代码来源:roipacdataset.cpp


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