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

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

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

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

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


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例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,


示例16: VRTCreateCopy

static GDALDataset *VRTCreateCopy( const char * pszFilename,               GDALDataset *poSrcDS,               int /* bStrict */,               char ** /* papszOptions */,               GDALProgressFunc /* pfnProgress */,               void * /* pProgressData */ ){    CPLAssert( NULL != poSrcDS );/* -------------------------------------------------------------------- *//*      If the source dataset is a virtual dataset then just write      *//*      it to disk as a special case to avoid extra layers of           *//*      indirection.                                                    *//* -------------------------------------------------------------------- */    if( poSrcDS->GetDriver() != NULL &&        EQUAL(poSrcDS->GetDriver()->GetDescription(),"VRT") )    {    /* -------------------------------------------------------------------- */    /*      Convert tree to a single block of XML text.                     */    /* -------------------------------------------------------------------- */        char *pszVRTPath = CPLStrdup(CPLGetPath(pszFilename));        reinterpret_cast<VRTDataset *>(            poSrcDS )->UnsetPreservedRelativeFilenames();        CPLXMLNode *psDSTree = reinterpret_cast<VRTDataset *>(            poSrcDS )->SerializeToXML( pszVRTPath );        char *pszXML = CPLSerializeXMLTree( psDSTree );        CPLDestroyXMLNode( psDSTree );        CPLFree( pszVRTPath );    /* -------------------------------------------------------------------- */    /*      Write to disk.                                                  */    /* -------------------------------------------------------------------- */        GDALDataset* pCopyDS = NULL;        if( 0 != strlen( pszFilename ) )        {            VSILFILE *fpVRT = VSIFOpenL( pszFilename, "wb" );            if( fpVRT == NULL )            {                CPLError(CE_Failure, CPLE_AppDefined,                         "Cannot create %s", pszFilename);                CPLFree( pszXML );                return NULL;            }            bool bRet = VSIFWriteL( pszXML, strlen(pszXML), 1, fpVRT ) > 0;            if( VSIFCloseL( fpVRT ) != 0 )                bRet = false;            if( bRet )                pCopyDS = reinterpret_cast<GDALDataset *>(                    GDALOpen( pszFilename, GA_Update ) );        }        else        {            /* No destination file is given, so pass serialized XML directly. */            pCopyDS = reinterpret_cast<GDALDataset *>(                GDALOpen( pszXML, GA_Update ) );        }        CPLFree( pszXML );        return pCopyDS;    }/* -------------------------------------------------------------------- *//*      Create the virtual dataset.                                     *//* -------------------------------------------------------------------- */    VRTDataset *poVRTDS = reinterpret_cast<VRTDataset *>(        VRTDataset::Create( pszFilename,                            poSrcDS->GetRasterXSize(),                            poSrcDS->GetRasterYSize(),                            0, GDT_Byte, NULL ) );    if( poVRTDS == NULL )        return NULL;/* -------------------------------------------------------------------- *//*      Do we have a geotransform?                                      *//* -------------------------------------------------------------------- */    double adfGeoTransform[6] = { 0.0 };    if( poSrcDS->GetGeoTransform( adfGeoTransform ) == CE_None )    {        poVRTDS->SetGeoTransform( adfGeoTransform );    }/* -------------------------------------------------------------------- *//*      Copy projection                                                 *//* -------------------------------------------------------------------- */    poVRTDS->SetProjection( poSrcDS->GetProjectionRef() );/* -------------------------------------------------------------------- *//*      Emit dataset level metadata.                                    *//* -------------------------------------------------------------------- */    poVRTDS->SetMetadata( poSrcDS->GetMetadata() );//.........这里部分代码省略.........
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,


示例17: 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,


示例18: 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,


示例19: STARTS_WITH_CI

GDALDataset *PAuxDataset::Open( GDALOpenInfo * poOpenInfo ){    if( poOpenInfo->nHeaderBytes < 1 )        return NULL;/* -------------------------------------------------------------------- *//*      If this is an .aux file, fetch out and form the name of the     *//*      file it references.                                             *//* -------------------------------------------------------------------- */    CPLString osTarget = poOpenInfo->pszFilename;    if( EQUAL(CPLGetExtension( poOpenInfo->pszFilename ),"aux")        && STARTS_WITH_CI((const char *) poOpenInfo->pabyHeader, "AuxilaryTarget: "))    {        char szAuxTarget[1024];        const char *pszSrc = reinterpret_cast<const char *>(            poOpenInfo->pabyHeader+16 );        int i = 0;        for( ;             pszSrc[i] != 10 && pszSrc[i] != 13 && pszSrc[i] != '/0'                 && i < static_cast<int>( sizeof(szAuxTarget) ) - 1;             i++ )        {            szAuxTarget[i] = pszSrc[i];        }        szAuxTarget[i] = '/0';        char *pszPath = CPLStrdup(CPLGetPath(poOpenInfo->pszFilename));        osTarget = CPLFormFilename(pszPath, szAuxTarget, NULL);        CPLFree(pszPath);    }/* -------------------------------------------------------------------- *//*      Now we need to tear apart the filename to form a .aux           *//*      filename.                                                       *//* -------------------------------------------------------------------- */    CPLString osAuxFilename = CPLResetExtension(osTarget,"aux");/* -------------------------------------------------------------------- *//*      Do we have a .aux file?                                         *//* -------------------------------------------------------------------- */    char** papszSiblingFiles = poOpenInfo->GetSiblingFiles();    if( papszSiblingFiles != NULL        && CSLFindString( papszSiblingFiles,                          CPLGetFilename(osAuxFilename) ) == -1 )    {        return NULL;    }    VSILFILE *fp = VSIFOpenL( osAuxFilename, "r" );    if( fp == NULL )    {        osAuxFilename = CPLResetExtension(osTarget,"AUX");        fp = VSIFOpenL( osAuxFilename, "r" );    }    if( fp == NULL )        return NULL;/* -------------------------------------------------------------------- *//*      Is this file a PCI .aux file?  Check the first line for the     *//*      telltale AuxilaryTarget keyword.                                *//*                                                                      *//*      At this point we should be verifying that it refers to our      *//*      binary file, but that is a pretty involved test.                *//* -------------------------------------------------------------------- */    const char *pszLine = CPLReadLineL( fp );    CPL_IGNORE_RET_VAL(VSIFCloseL( fp ));    if( pszLine == NULL        || (!STARTS_WITH_CI(pszLine, "AuxilaryTarget")            && !STARTS_WITH_CI(pszLine, "AuxiliaryTarget")) )    {        return NULL;    }/* -------------------------------------------------------------------- *//*      Create a corresponding GDALDataset.                             *//* -------------------------------------------------------------------- */    PAuxDataset *poDS = new PAuxDataset();/* -------------------------------------------------------------------- *//*      Load the .aux file into a string list suitable to be            *//*      searched with CSLFetchNameValue().                              *//* -------------------------------------------------------------------- */    poDS->papszAuxLines = CSLLoad( osAuxFilename );    poDS->pszAuxFilename = CPLStrdup(osAuxFilename);/* -------------------------------------------------------------------- *//*      Find the RawDefinition line to establish overall parameters.    *//* -------------------------------------------------------------------- */    pszLine = CSLFetchNameValue(poDS->papszAuxLines, "RawDefinition");    // It seems PCI now writes out .aux files without RawDefinition in    // some cases.  See bug 947.    if( pszLine == NULL )//.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,


示例20: CPLAssert

int OGRTABDataSource::Open( const char * pszName, int bTestOpen ){    VSIStatBuf  stat;    CPLAssert( m_pszName == NULL );        m_pszName = CPLStrdup( pszName );/* -------------------------------------------------------------------- *//*      Is this a file or directory?                                    *//* -------------------------------------------------------------------- */    if( VSIStat( pszName, &stat ) != 0         || (!VSI_ISDIR(stat.st_mode) && !VSI_ISREG(stat.st_mode)) )    {        if( !bTestOpen )        {            CPLError( CE_Failure, CPLE_OpenFailed,                      "%s is not a file or directory./n"                      "Unable to open as a Mapinfo dataset./n",                      pszName );        }        return FALSE;    }/* -------------------------------------------------------------------- *//*      If it is a file, try to open as a Mapinfo file.                 *//* -------------------------------------------------------------------- */    if( VSI_ISREG(stat.st_mode) )    {        IMapInfoFile    *poFile;        poFile = IMapInfoFile::SmartOpen( pszName, bTestOpen );        if( poFile == NULL )            return FALSE;        m_nLayerCount = 1;        m_papoLayers = (IMapInfoFile **) CPLMalloc(sizeof(void*));        m_papoLayers[0] = poFile;        m_pszDirectory = CPLStrdup( CPLGetPath(pszName) );    }/* -------------------------------------------------------------------- *//*      Otherwise, we need to scan the whole directory for files        *//*      ending in .tab or .mif.                                         *//* -------------------------------------------------------------------- */    else    {        char    **papszFileList = CPLReadDir( pszName );                m_pszDirectory = CPLStrdup( pszName );        for( int iFile = 0;             papszFileList != NULL && papszFileList[iFile] != NULL;             iFile++ )        {            IMapInfoFile *poFile;            const char  *pszExtension = CPLGetExtension(papszFileList[iFile]);            char        *pszSubFilename;            if( !EQUAL(pszExtension,"tab") && !EQUAL(pszExtension,"mif") )                continue;            pszSubFilename = CPLStrdup(                CPLFormFilename( m_pszDirectory, papszFileList[iFile], NULL ));            poFile = IMapInfoFile::SmartOpen( pszSubFilename, bTestOpen );            CPLFree( pszSubFilename );                        if( poFile == NULL )            {                CSLDestroy( papszFileList );                return FALSE;            }            m_nLayerCount++;            m_papoLayers = (IMapInfoFile **)                CPLRealloc(m_papoLayers,sizeof(void*)*m_nLayerCount);            m_papoLayers[m_nLayerCount-1] = poFile;        }        CSLDestroy( papszFileList );        if( m_nLayerCount == 0 )        {            if( !bTestOpen )                CPLError( CE_Failure, CPLE_OpenFailed,                          "No mapinfo files found in directory %s./n",                          m_pszDirectory );                        return FALSE;        }    }    return TRUE;}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:98,


示例21: GetLayerCount

//.........这里部分代码省略.........    }    else if( EQUAL(pszOverride,"NONE") || EQUAL(pszOverride,"NULL") )    {        nShapeType = SHPT_NULL;        eType = wkbNone;    }    else    {        CPLError( CE_Failure, CPLE_NotSupported,                  "Unknown SHPT value of `%s' passed to Shapefile layer/n"                  "creation.  Creation aborted./n",                  pszOverride );        return NULL;    }    if( nShapeType == -1 )    {        CPLError( CE_Failure, CPLE_NotSupported,                  "Geometry type of `%s' not supported in shapefiles./n"                  "Type can be overridden with a layer creation option/n"                  "of SHPT=POINT/ARC/POLYGON/MULTIPOINT/POINTZ/ARCZ/POLYGONZ/MULTIPOINTZ./n",                  OGRGeometryTypeToName(eType) );        return NULL;    }    /* -------------------------------------------------------------------- *//*      What filename do we use, excluding the extension?               *//* -------------------------------------------------------------------- */    char *pszFilenameWithoutExt;    if(  bSingleFileDataSource && nLayers == 0 )    {        char *pszPath = CPLStrdup(CPLGetPath(pszName));        char *pszFBasename = CPLStrdup(CPLGetBasename(pszName));        pszFilenameWithoutExt = CPLStrdup(CPLFormFilename(pszPath, pszFBasename, NULL));        CPLFree( pszFBasename );        CPLFree( pszPath );    }    else if(  bSingleFileDataSource )    {        /* This is a very weird use case : the user creates/open a datasource */        /* made of a single shapefile 'foo.shp' and wants to add a new layer */        /* to it, 'bar'. So we create a new shapefile 'bar.shp' in the same */        /* directory as 'foo.shp' */        /* So technically, we will not be any longer a single file */        /* datasource ... Ahem ahem */        char *pszPath = CPLStrdup(CPLGetPath(pszName));        pszFilenameWithoutExt = CPLStrdup(CPLFormFilename(pszPath,pszLayerName,NULL));        CPLFree( pszPath );    }    else        pszFilenameWithoutExt = CPLStrdup(CPLFormFilename(pszName,pszLayerName,NULL));/* -------------------------------------------------------------------- *//*      Create the shapefile.                                           *//* -------------------------------------------------------------------- */    char        *pszFilename;    int b2GBLimit = CSLTestBoolean(CSLFetchNameValueDef( papszOptions, "2GB_LIMIT", "FALSE" ));    if( nShapeType != SHPT_NULL )    {        pszFilename = CPLStrdup(CPLFormFilename( NULL, pszFilenameWithoutExt, "shp" ));
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:67,


示例22: CSLDuplicate

int OGRGeoconceptDataSource::Create( const char *pszName, char** papszOptions ){    const char *pszConf;    const char *pszExtension;    if( _pszName ) CPLFree(_pszName);    _papszOptions = CSLDuplicate( papszOptions );    pszConf= CSLFetchNameValue(papszOptions,"CONFIG");    if( pszConf != NULL )    {      _pszGCT = CPLStrdup(pszConf);    }    _pszExt = (char *)CSLFetchNameValue(papszOptions,"EXTENSION");    pszExtension = CSLFetchNameValue(papszOptions,"EXTENSION");    if( pszExtension == NULL )    {        _pszExt = CPLStrdup(CPLGetExtension(pszName));    }    else    {        _pszExt = CPLStrdup(pszExtension);    }    if( strlen(_pszExt) == 0 )    {        if( VSIMkdir( pszName, 0755 ) != 0 )        {            CPLError( CE_Failure, CPLE_AppDefined,                      "Directory %s already exists"                      " as geoconcept datastore or"                      " is made up of a non existing list of directories.",                      pszName );            return FALSE;        }        _pszDirectory = CPLStrdup( pszName );        CPLFree(_pszExt);        _pszExt = CPLStrdup("gxt");        char *pszbName = CPLStrdup(CPLGetBasename( pszName ));        if (strlen(pszbName)==0) {/* pszName ends with '/' */            CPLFree(pszbName);            char *pszNameDup= CPLStrdup(pszName);            pszNameDup[strlen(pszName)-2] = '/0';            pszbName = CPLStrdup(CPLGetBasename( pszNameDup ));            CPLFree(pszNameDup);        }        _pszName = CPLStrdup((char *)CPLFormFilename( _pszDirectory, pszbName, NULL ));        CPLFree(pszbName);    }    else    {        _pszDirectory = CPLStrdup( CPLGetPath(pszName) );        _pszName = CPLStrdup( pszName );    }/* -------------------------------------------------------------------- *//*      Create a new single file.                                       *//*      OGRGeoconceptDriver::CreateLayer() will do the job.             *//* -------------------------------------------------------------------- */    _bSingleNewFile = TRUE;    if( !LoadFile( "wt" ) )    {        CPLDebug( "GEOCONCEPT",                  "Failed to create Geoconcept %s.",                  pszName );        return FALSE;    }    return TRUE;}
开发者ID:brunosimoes,项目名称:WorldWind,代码行数:75,


示例23: VSIFOpenL

GDALDataset *VRTDataset::Open( GDALOpenInfo * poOpenInfo ){    char *pszVRTPath = NULL;/* -------------------------------------------------------------------- *//*      Does this appear to be a virtual dataset definition XML         *//*      file?                                                           *//* -------------------------------------------------------------------- */    if( !Identify( poOpenInfo ) )        return NULL;/* -------------------------------------------------------------------- *//*	Try to read the whole file into memory.				*//* -------------------------------------------------------------------- */    char        *pszXML;    VSILFILE        *fp = VSIFOpenL(poOpenInfo->pszFilename, "rb");    if( fp != NULL )    {        unsigned int nLength;             VSIFSeekL( fp, 0, SEEK_END );        nLength = (int) VSIFTellL( fp );        VSIFSeekL( fp, 0, SEEK_SET );                nLength = MAX(0,nLength);        pszXML = (char *) VSIMalloc(nLength+1);                if( pszXML == NULL )        {            VSIFCloseL(fp);            CPLError( CE_Failure, CPLE_OutOfMemory,                       "Failed to allocate %d byte buffer to hold VRT xml file.",                      nLength );            return NULL;        }                if( VSIFReadL( pszXML, 1, nLength, fp ) != nLength )        {            VSIFCloseL(fp);            CPLFree( pszXML );            CPLError( CE_Failure, CPLE_FileIO,                      "Failed to read %d bytes from VRT xml file.",                      nLength );            return NULL;        }                pszXML[nLength] = '/0';        pszVRTPath = CPLStrdup(CPLGetPath(poOpenInfo->pszFilename));        VSIFCloseL(fp);    }/* -------------------------------------------------------------------- *//*      Or use the filename as the XML input.                           *//* -------------------------------------------------------------------- */    else    {        pszXML = CPLStrdup( poOpenInfo->pszFilename );    }/* -------------------------------------------------------------------- *//*      Turn the XML representation into a VRTDataset.                  *//* -------------------------------------------------------------------- */    VRTDataset *poDS = (VRTDataset *) OpenXML( pszXML, pszVRTPath, poOpenInfo->eAccess );    if( poDS != NULL )        poDS->bNeedsFlush = FALSE;    CPLFree( pszXML );    CPLFree( pszVRTPath );/* -------------------------------------------------------------------- *//*      Open overviews.                                                 *//* -------------------------------------------------------------------- */    if( fp != NULL && poDS != NULL )        poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename );    return poDS;}
开发者ID:Joe-xXx,项目名称:gdal,代码行数:80,


示例24: 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,


示例25: switch

OGRLayer *OGRGmtDataSource::CreateLayer( const char * pszLayerName,                               OGRSpatialReference *poSRS,                               OGRwkbGeometryType eType,                               char ** papszOptions ){/* -------------------------------------------------------------------- *//*      Establish the geometry type.  Note this logic                   *//* -------------------------------------------------------------------- */    const char *pszGeom;    switch( wkbFlatten(eType) )    {      case wkbPoint:        pszGeom = " @GPOINT";        break;      case wkbLineString:        pszGeom = " @GLINESTRING";        break;      case wkbPolygon:        pszGeom = " @GPOLYGON";        break;      case wkbMultiPoint:        pszGeom = " @GMULTIPOINT";        break;      case wkbMultiLineString:        pszGeom = " @GMULTILINESTRING";        break;      case wkbMultiPolygon:        pszGeom = " @GMULTIPOLYGON";        break;      default:        pszGeom = "";        break;    }/* -------------------------------------------------------------------- *//*      If this is the first layer for this datasource, and if the      *//*      datasource name ends in .gmt we will override the provided      *//*      layer name with the name from the gmt.                          *//* -------------------------------------------------------------------- */    CPLString osPath = CPLGetPath( pszName );    CPLString osFilename;    if( EQUAL(CPLGetExtension(pszName),"gmt") )        osFilename = pszName;    else        osFilename = CPLFormFilename( osPath, pszLayerName, "gmt" );/* -------------------------------------------------------------------- *//*      Open the file.                                                  *//* -------------------------------------------------------------------- */    FILE *fp = VSIFOpenL( osFilename, "w" );    if( fp == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                   "open(%s) failed: %s",                   osFilename.c_str(), VSIStrerror(errno) );        return NULL;    }/* -------------------------------------------------------------------- *//*      Write out header.                                               *//* -------------------------------------------------------------------- */    VSIFPrintfL( fp, "# @VGMT1.0%s/n", pszGeom );    VSIFPrintfL( fp, "# REGION_STUB                                                             /n" );/* -------------------------------------------------------------------- *//*      Write the projection, if possible.                              *//* -------------------------------------------------------------------- */    if( poSRS != NULL )    {        char *pszValue = NULL;        if( poSRS->IsProjected()             && poSRS->GetAuthorityName("PROJCS")            && EQUAL(poSRS->GetAuthorityName("PROJCS"),"EPSG") )        {            VSIFPrintfL( fp, "# @Je%s/n",                          poSRS->GetAuthorityCode("PROJCS") );        }        else if( poSRS->IsGeographic()                  && poSRS->GetAuthorityName("GEOGCS")                 && EQUAL(poSRS->GetAuthorityName("GEOGCS"),"EPSG") )        {            VSIFPrintfL( fp, "# @Je%s/n",                          poSRS->GetAuthorityCode("GEOGCS") );        }        if( poSRS->exportToProj4( &pszValue ) == OGRERR_NONE )        {            VSIFPrintfL( fp, "# @Jp/"%s/"/n", pszValue );            CPLFree( pszValue );            pszValue = NULL;        }        if( poSRS->exportToWkt( &pszValue ) == OGRERR_NONE )        {            char *pszEscapedWkt = CPLEscapeString( pszValue, -1,//.........这里部分代码省略.........
开发者ID:Chaduke,项目名称:bah.mod,代码行数:101,


示例26: CPLAssert

int OGRTABDataSource::Open( GDALOpenInfo *poOpenInfo, int bTestOpen ){    CPLAssert(m_pszName == nullptr);    m_pszName = CPLStrdup(poOpenInfo->pszFilename);    m_bUpdate = poOpenInfo->eAccess == GA_Update;    // If it is a file, try to open as a Mapinfo file.    if( !poOpenInfo->bIsDirectory )    {        IMapInfoFile *poFile =            IMapInfoFile::SmartOpen(m_pszName, m_bUpdate, bTestOpen);        if( poFile == nullptr )            return FALSE;        poFile->SetDescription(poFile->GetName());        m_nLayerCount = 1;        m_papoLayers = static_cast<IMapInfoFile **>(CPLMalloc(sizeof(void *)));        m_papoLayers[0] = poFile;        m_pszDirectory = CPLStrdup(CPLGetPath(m_pszName));        m_bSingleFile = TRUE;        m_bSingleLayerAlreadyCreated = TRUE;    }    // Otherwise, we need to scan the whole directory for files    // ending in .tab or .mif.    else    {        char **papszFileList = VSIReadDir(m_pszName);        m_pszDirectory = CPLStrdup(m_pszName);        for( int iFile = 0;             papszFileList != nullptr && papszFileList[iFile] != nullptr;             iFile++ )        {            const char *pszExtension = CPLGetExtension(papszFileList[iFile]);            if( !EQUAL(pszExtension, "tab") && !EQUAL(pszExtension, "mif") )                continue;            char *pszSubFilename = CPLStrdup(                CPLFormFilename(m_pszDirectory, papszFileList[iFile], nullptr));            IMapInfoFile *poFile =                IMapInfoFile::SmartOpen(pszSubFilename, m_bUpdate, bTestOpen);            CPLFree(pszSubFilename);            if( poFile == nullptr )            {                CSLDestroy(papszFileList);                return FALSE;            }            poFile->SetDescription( poFile->GetName() );            m_nLayerCount++;            m_papoLayers = static_cast<IMapInfoFile **>(                CPLRealloc(m_papoLayers,sizeof(void *) * m_nLayerCount));            m_papoLayers[m_nLayerCount-1] = poFile;        }        CSLDestroy(papszFileList);        if( m_nLayerCount == 0 )        {            if( !bTestOpen )                CPLError(CE_Failure, CPLE_OpenFailed,                         "No mapinfo files found in directory %s.",                         m_pszDirectory);            return FALSE;        }    }    return TRUE;}
开发者ID:ksshannon,项目名称:gdal,代码行数:80,


示例27: 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,


示例28: CPLGetExtension

int OGRGeoconceptDataSource::LoadFile( const char *pszMode ){    OGRGeoconceptLayer *poFile;    if( _pszExt == NULL)    {      const char* pszExtension = CPLGetExtension(_pszName);      if( !EQUAL(pszExtension,"gxt") && !EQUAL(pszExtension,"txt") )      {        return FALSE;      }      _pszExt = CPLStrdup(pszExtension);    }    CPLStrlwr( _pszExt );    if( !_pszDirectory )        _pszDirectory = CPLStrdup( CPLGetPath(_pszName) );    if( (_hGXT= Open_GCIO(_pszName,_pszExt,pszMode,_pszGCT))==NULL )    {      return FALSE;    }    /* Collect layers : */    GCExportFileMetadata* Meta= GetGCMeta_GCIO(_hGXT);    if( Meta )    {      int nC, iC, nS, iS;      if( (nC= CountMetaTypes_GCIO(Meta))>0 )      {        GCType* aClass;        GCSubType* aSubclass;        for( iC= 0; iC<nC; iC++ )        {          if( (aClass= GetMetaType_GCIO(Meta,iC)) )          {            if( (nS= CountTypeSubtypes_GCIO(aClass)) )            {              for( iS= 0; iS<nS; iS++ )              {                if( (aSubclass= GetTypeSubtype_GCIO(aClass,iS)) )                {                  poFile = new OGRGeoconceptLayer;                  if( poFile->Open(aSubclass) != OGRERR_NONE )                  {                    delete poFile;                    return FALSE;                  }                  /* Add layer to data source layers list */                  _papoLayers = (OGRGeoconceptLayer **)                      CPLRealloc( _papoLayers,  sizeof(OGRGeoconceptLayer *) * (_nLayers+1) );                  _papoLayers[_nLayers++] = poFile;                  CPLDebug("GEOCONCEPT",                           "nLayers=%d - last=[%s]",                           _nLayers, poFile->GetLayerDefn()->GetName());                }              }            }          }        }      }    }    return TRUE;}
开发者ID:brunosimoes,项目名称:WorldWind,代码行数:70,



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


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