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

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

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

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

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

示例1: CPLPushErrorHandler

CPLErr GS7BGDataset::GetGeoTransform( double *padfGeoTransform ){    if( padfGeoTransform == NULL )        return CE_Failure;    GS7BGRasterBand *poGRB = (GS7BGRasterBand *)GetRasterBand( 1 );    if( poGRB == NULL )    {        padfGeoTransform[0] = 0;        padfGeoTransform[1] = 1;        padfGeoTransform[2] = 0;        padfGeoTransform[3] = 0;        padfGeoTransform[4] = 0;        padfGeoTransform[5] = 1;        return CE_Failure;    }    /* check if we have a PAM GeoTransform stored */    CPLPushErrorHandler( CPLQuietErrorHandler );    CPLErr eErr = GDALPamDataset::GetGeoTransform( padfGeoTransform );    CPLPopErrorHandler();    if( eErr == CE_None )        return CE_None;    /* calculate pixel size first */    padfGeoTransform[1] = (poGRB->dfMaxX - poGRB->dfMinX)/(nRasterXSize - 1);    padfGeoTransform[5] = (poGRB->dfMinY - poGRB->dfMaxY)/(nRasterYSize - 1);    /* then calculate image origin */    padfGeoTransform[0] = poGRB->dfMinX - padfGeoTransform[1] / 2;    padfGeoTransform[3] = poGRB->dfMaxY - padfGeoTransform[5] / 2;    /* tilt/rotation does not supported by the GS grids */    padfGeoTransform[4] = 0.0;    padfGeoTransform[2] = 0.0;    return CE_None;}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:40,


示例2: main

int main( int argc, char ** argv ){  QCoreApplication app( argc, argv );  QgsApplication::init();  if ( !QgsApplication::isRunningFromBuildDir() )  {    char* prefixPath = getenv( "QGIS_PREFIX_PATH" );    QgsApplication::setPrefixPath( prefixPath ? prefixPath : CMAKE_INSTALL_PREFIX, TRUE );  }  std::cout << "Synchronizing CRS database with GDAL/PROJ definitions." << std::endl;  CPLPushErrorHandler( showError );  int res = QgsCoordinateReferenceSystem::syncDb();  CPLPopErrorHandler();  if ( res == 0 )  {    std::cout << "No CRS updates were necessary." << std::endl;  }  else if ( res > 0 )  {    std::cout << res << " CRSs updated." << std::endl;  }  else if ( res == std::numeric_limits<int>::min() )  {    std::cout << "CRSs synchronization not possible." << std::endl;  }  else if ( res < 0 )  {    std::cout << -res << " CRSs could not be updated." << std::endl;  }  exit( 0 );}
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:39,


示例3: CPL_transform

// [[Rcpp::export]]Rcpp::List CPL_transform(Rcpp::List sfc, Rcpp::CharacterVector proj4) {	// import proj4string:	OGRSpatialReference *dest = new OGRSpatialReference;	handle_error(dest->importFromProj4((const char *) (proj4[0])));	// transform geometries:	std::vector<OGRGeometry *> g = ogr_from_sfc(sfc, NULL);	if (g.size() == 0) {		dest->Release(); // #nocov		Rcpp::stop("CPL_transform: zero length geometry list"); // #nocov	}	OGRCoordinateTransformation *ct = 		OGRCreateCoordinateTransformation(g[0]->getSpatialReference(), dest);	if (ct == NULL) {		dest->Release(); // #nocov		Rcpp::stop("OGRCreateCoordinateTransformation() returned NULL: PROJ.4 available?"); // #nocov	}	for (size_t i = 0; i < g.size(); i++) {		CPLPushErrorHandler(CPLQuietErrorHandler);		OGRErr err = 0;		if (! g[i]->IsEmpty())			err = g[i]->transform(ct);		CPLPopErrorHandler();		if (err == 1 || err == 6) {			OGRwkbGeometryType geomType = g[i]->getGeometryType();			OGRGeometryFactory f;			f.destroyGeometry(g[i]);			g[i] = f.createGeometry(geomType);		} else			handle_error(err);	}	Rcpp::List ret = sfc_from_ogr(g, true); // destroys g;	ct->DestroyCT(ct);	dest->Release();	return ret; }
开发者ID:rundel,项目名称:sfr,代码行数:39,


示例4: CPLPushErrorHandler

CPLErr SAGADataset::GetGeoTransform( double *padfGeoTransform ){    if( padfGeoTransform == NULL )		return CE_Failure;    SAGARasterBand *poGRB = dynamic_cast<SAGARasterBand *>(GetRasterBand( 1 ));    if( poGRB == NULL )    {		padfGeoTransform[0] = 0;		padfGeoTransform[1] = 1;		padfGeoTransform[2] = 0;		padfGeoTransform[3] = 0;		padfGeoTransform[4] = 0;		padfGeoTransform[5] = 1;		return CE_Failure;    }    /* check if we have a PAM GeoTransform stored */    CPLPushErrorHandler( CPLQuietErrorHandler );    CPLErr eErr = GDALPamDataset::GetGeoTransform( padfGeoTransform );    CPLPopErrorHandler();    if( eErr == CE_None )		return CE_None;	padfGeoTransform[1] = poGRB->m_Cellsize;	padfGeoTransform[5] = poGRB->m_Cellsize * -1.0;	padfGeoTransform[0] = poGRB->m_Xmin - poGRB->m_Cellsize / 2;	padfGeoTransform[3] = poGRB->m_Ymin + (nRasterYSize - 1) * poGRB->m_Cellsize + poGRB->m_Cellsize / 2;	/* tilt/rotation is not supported by SAGA grids */    padfGeoTransform[4] = 0.0;    padfGeoTransform[2] = 0.0;    return CE_None;}
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:37,


示例5: CPLGetExtension

int OGRShapeDataSource::OpenFile( const char *pszNewName, int bUpdate,                                  int bTestOpen ){    SHPHandle   hSHP;    DBFHandle   hDBF;    const char *pszExtension = CPLGetExtension( pszNewName );    (void) bTestOpen;    if( !EQUAL(pszExtension,"shp") && !EQUAL(pszExtension,"shx")        && !EQUAL(pszExtension,"dbf") )        return FALSE;/* -------------------------------------------------------------------- *//*      SHPOpen() should include better (CPL based) error reporting,    *//*      and we should be trying to distinquish at this point whether    *//*      failure is a result of trying to open a non-shapefile, or       *//*      whether it was a shapefile and we want to report the error      *//*      up.                                                             *//*                                                                      *//*      Care is taken to suppress the error and only reissue it if      *//*      we think it is appropriate.                                     *//* -------------------------------------------------------------------- */    CPLPushErrorHandler( CPLQuietErrorHandler );    if( bUpdate )        hSHP = DS_SHPOpen( pszNewName, "r+" );    else        hSHP = DS_SHPOpen( pszNewName, "r" );    CPLPopErrorHandler();    if( hSHP == NULL         && (!EQUAL(CPLGetExtension(pszNewName),"dbf")             || strstr(CPLGetLastErrorMsg(),".shp") == NULL) )    {        CPLString osMsg = CPLGetLastErrorMsg();        CPLError( CE_Failure, CPLE_OpenFailed, "%s", osMsg.c_str() );        return FALSE;    }    CPLErrorReset();    /* -------------------------------------------------------------------- *//*      Open the .dbf file, if it exists.  To open a dbf file, the      *//*      filename has to either refer to a successfully opened shp       *//*      file or has to refer to the actual .dbf file.                   *//* -------------------------------------------------------------------- */    if( hSHP != NULL || EQUAL(CPLGetExtension(pszNewName),"dbf") )    {        if( bUpdate )        {            hDBF = DS_DBFOpen( pszNewName, "r+" );            if( hSHP != NULL && hDBF == NULL )            {                for(int i=0;i<2;i++)                {                    VSIStatBufL sStat;                    const char* pszDBFName = CPLResetExtension(pszNewName,                                                    (i == 0 ) ? "dbf" : "DBF");                    VSILFILE* fp = NULL;                    if( VSIStatExL( pszDBFName, &sStat, VSI_STAT_EXISTS_FLAG) == 0 )                    {                        fp = VSIFOpenL(pszDBFName, "r+");                        if (fp == NULL)                        {                            CPLError( CE_Failure, CPLE_OpenFailed,                                    "%s exists, but cannot be opened in update mode",                                    pszDBFName );                            SHPClose(hSHP);                            return FALSE;                        }                        VSIFCloseL(fp);                        break;                    }                }            }        }        else            hDBF = DS_DBFOpen( pszNewName, "r" );    }    else        hDBF = NULL;            if( hDBF == NULL && hSHP == NULL )        return FALSE;/* -------------------------------------------------------------------- *//*      Create the layer object.                                        *//* -------------------------------------------------------------------- */    OGRShapeLayer       *poLayer;    poLayer = new OGRShapeLayer( this, pszNewName, hSHP, hDBF, NULL, FALSE, bUpdate,                                 wkbNone );    poLayer->SetModificationDate(            CSLFetchNameValue( papszOpenOptions, "DBF_DATE_LAST_UPDATE" ) );/* -------------------------------------------------------------------- *//*      Add layer to data source layer list.                            *//* -------------------------------------------------------------------- *///.........这里部分代码省略.........
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:101,


示例6: main

//.........这里部分代码省略.........    }/* -------------------------------------------------------------------- *//*      Report RPCs                                                     *//* -------------------------------------------------------------------- */    papszMetadata = (bShowMetadata) ? GDALGetMetadata( hDataset, "RPC" ) : NULL;    if( bShowMetadata && CSLCount(papszMetadata) > 0 )    {        printf( "RPC Metadata:/n" );        for( i = 0; papszMetadata[i] != NULL; i++ )        {            printf( "  %s/n", papszMetadata[i] );        }    }/* -------------------------------------------------------------------- *//*      Setup projected to lat/long transform if appropriate.           *//* -------------------------------------------------------------------- */    if( GDALGetGeoTransform( hDataset, adfGeoTransform ) == CE_None )        pszProjection = GDALGetProjectionRef(hDataset);    if( pszProjection != NULL && strlen(pszProjection) > 0 )    {        OGRSpatialReferenceH hProj, hLatLong = NULL;        hProj = OSRNewSpatialReference( pszProjection );        if( hProj != NULL )            hLatLong = OSRCloneGeogCS( hProj );        if( hLatLong != NULL )        {            CPLPushErrorHandler( CPLQuietErrorHandler );            hTransform = OCTNewCoordinateTransformation( hProj, hLatLong );            CPLPopErrorHandler();                        OSRDestroySpatialReference( hLatLong );        }        if( hProj != NULL )            OSRDestroySpatialReference( hProj );    }/* -------------------------------------------------------------------- *//*      Report corners.                                                 *//* -------------------------------------------------------------------- */    printf( "Corner Coordinates:/n" );    GDALInfoReportCorner( hDataset, hTransform, "Upper Left",                           0.0, 0.0 );    GDALInfoReportCorner( hDataset, hTransform, "Lower Left",                           0.0, GDALGetRasterYSize(hDataset));    GDALInfoReportCorner( hDataset, hTransform, "Upper Right",                           GDALGetRasterXSize(hDataset), 0.0 );    GDALInfoReportCorner( hDataset, hTransform, "Lower Right",                           GDALGetRasterXSize(hDataset),                           GDALGetRasterYSize(hDataset) );    GDALInfoReportCorner( hDataset, hTransform, "Center",                           GDALGetRasterXSize(hDataset)/2.0,                           GDALGetRasterYSize(hDataset)/2.0 );    if( hTransform != NULL )    {        OCTDestroyCoordinateTransformation( hTransform );        hTransform = NULL;    }    /* ==================================================================== */
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:67,


示例7: CPLError

//.........这里部分代码省略.........    else        osTmpFileName.Printf("/vsimem/ogrgpsbabeldatasource_%p", this);    int bRet = FALSE;    if (IsSpecialFile(pszFilename))    {        /* Special file : don't try to open it */        char** argv = GetArgv(bExplicitFeatures, bWaypoints, bRoutes,                              bTracks, pszGPSBabelDriverName, pszFilename);        VSILFILE* tmpfp = VSIFOpenL(osTmpFileName.c_str(), "wb");        bRet = (CPLSpawn(argv, NULL, tmpfp, TRUE) == 0);        VSIFCloseL(tmpfp);        tmpfp = NULL;        CSLDestroy(argv);        argv = NULL;    }    else    {        VSILFILE* fp = VSIFOpenL(pszFilename, "rb");        if (fp == NULL)        {            CPLError(CE_Failure, CPLE_AppDefined,                    "Cannot open file %s", pszFilename);            return FALSE;        }        char** argv = GetArgv(bExplicitFeatures, bWaypoints, bRoutes,                              bTracks, pszGPSBabelDriverName, "-");        VSILFILE* tmpfp = VSIFOpenL(osTmpFileName.c_str(), "wb");        CPLPushErrorHandler(CPLQuietErrorHandler);        bRet = (CPLSpawn(argv, fp, tmpfp, TRUE) == 0);        CPLPopErrorHandler();        CSLDestroy(argv);        argv = NULL;        CPLErr nLastErrorType = CPLGetLastErrorType();        int nLastErrorNo = CPLGetLastErrorNo();        CPLString osLastErrorMsg = CPLGetLastErrorMsg();        VSIFCloseL(tmpfp);        tmpfp = NULL;        VSIFCloseL(fp);        fp = NULL;        if (!bRet)        {            if (strstr(osLastErrorMsg.c_str(), "This format cannot be used in piped commands") == NULL)            {                CPLError(nLastErrorType, nLastErrorNo, "%s", osLastErrorMsg.c_str());            }            else            {                VSIStatBuf sStatBuf;                if (VSIStat(pszFilename, &sStatBuf) != 0)                {                    CPLError(CE_Failure, CPLE_NotSupported,                            "Driver %s only supports real (non virtual) files", pszGPSBabelDriverName);                    return FALSE;                }                /* Try without piping in */                argv = GetArgv(bExplicitFeatures, bWaypoints, bRoutes,
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:67,


示例8: gv_symbol_manager_get_symbol

GvSymbolObj *gv_symbol_manager_get_symbol(GvSymbolManager *manager, const char *symbol_name){    gchar   *pszOpenEVHome = NULL;    gchar   *pszSymbolsDir = NULL;    gchar   *pszAbsolutePath = NULL;    gchar   *pszPathSeparator = NULL;    GDALDatasetH hDataset;    GvSymbolObj *poSymbol;    CPLXMLNode  *xml_shape = NULL;    GByte *rgba_buffer;/* -------------------------------------------------------------------- *//*      Lookup the symbol in the hash table, and return it if found.    *//* -------------------------------------------------------------------- */    poSymbol = g_hash_table_lookup( manager->symbol_cache, symbol_name );    if( poSymbol != NULL )        return poSymbol;/* -------------------------------------------------------------------- *//*      We didn't already have it, so try to find a file to load it     *//*      from.                                                           *//* -------------------------------------------------------------------- */#ifndef WIN32    pszPathSeparator = "/";#else    pszPathSeparator = "//";#endif /* WIN32 */    /* validate inputs */    g_return_val_if_fail( manager != NULL, 0 );    g_return_val_if_fail( symbol_name != NULL, 0 );    /* get an absolute path */    if ( !g_path_is_absolute( symbol_name ) )    {        /* check configuration option first */        pszSymbolsDir = g_strdup( gv_manager_get_preference( gv_get_manager(),                                                             "symbols_dir" ) );        /* if not configured check $OPENEV_HOME */        if ( !pszSymbolsDir )        {            pszOpenEVHome = g_getenv( "OPENEV_HOME" );            if( pszOpenEVHome == NULL )                pszOpenEVHome = g_getenv( "OPENEVHOME" );            if ( pszOpenEVHome )                pszSymbolsDir = g_strjoin( pszPathSeparator, pszOpenEVHome,                                           "symbols", NULL );        }                /* get current directory as last resort */        if ( !pszSymbolsDir )            pszSymbolsDir = g_get_current_dir();        pszAbsolutePath = g_strjoin( pszPathSeparator, pszSymbolsDir,                                      symbol_name, NULL );        g_free( pszSymbolsDir );    }    else        pszAbsolutePath = g_strdup( symbol_name );/* -------------------------------------------------------------------- *//*      pszAbsolutePath contains a newly allocated string that is       *//*      suitable for using as a key in the hash table.  If a texture    *//*      is found in the hash table then this string needs to be         *//*      freed.  If one isn't found then the string is used in the       *//*      hash table and should be freed when the associated hash         *//*      table entry is released                                         *//* -------------------------------------------------------------------- */    CPLDebug( "OpenEV",               "gv_symbol_manager_get_symbol(%s) ... need to load.",                   pszAbsolutePath );        /*      * validate path by opening with GDAL and looking for an error      * Disable CPL error handler to supress error reporting     */        CPLErrorReset();    CPLPushErrorHandler( CPLQuietErrorHandler );    hDataset = GDALOpen( pszAbsolutePath, GA_ReadOnly );    CPLPopErrorHandler();        if ( hDataset )    {        rgba_buffer = gdal_to_rgba( hDataset );                if ( rgba_buffer )        {            gv_symbol_manager_inject_raster_symbol(                 manager, symbol_name,                GDALGetRasterXSize( hDataset ),                GDALGetRasterYSize( hDataset ),                rgba_buffer );            CPLFree( rgba_buffer );        }                GDALClose( hDataset );    }//.........这里部分代码省略.........
开发者ID:Onjrew,项目名称:OpenEV,代码行数:101,


示例9: CPLError

//.........这里部分代码省略.........    sPicture.progress_hook = WEBPDatasetProgressHook;#endif    if (!WebPPictureAlloc(&sPicture))    {        CPLError(CE_Failure, CPLE_AppDefined, "WebPPictureAlloc() failed");        VSIFree(pabyBuffer);        VSIFCloseL( fpImage );        return NULL;    }/* -------------------------------------------------------------------- *//*      Acquire source imagery.                                         *//* -------------------------------------------------------------------- */    CPLErr      eErr = CE_None;    eErr = poSrcDS->RasterIO( GF_Read, 0, 0, nXSize, nYSize,                              pabyBuffer, nXSize, nYSize, GDT_Byte,                              nBands, NULL,                              nBands, nBands * nXSize, 1, NULL );/* -------------------------------------------------------------------- *//*      Import and write to file                                        *//* -------------------------------------------------------------------- */#if WEBP_ENCODER_ABI_VERSION >= 0x0100    if (eErr == CE_None && nBands == 4)    {        if (!WebPPictureImportRGBA(&sPicture, pabyBuffer, nBands * nXSize))        {            CPLError(CE_Failure, CPLE_AppDefined, "WebPPictureImportRGBA() failed");            eErr = CE_Failure;        }    }    else#endif    if (eErr == CE_None &&        !WebPPictureImportRGB(&sPicture, pabyBuffer, nBands * nXSize))    {        CPLError(CE_Failure, CPLE_AppDefined, "WebPPictureImportRGB() failed");        eErr = CE_Failure;    }    if (eErr == CE_None && !WebPEncode(&sConfig, &sPicture))    {        const char* pszErrorMsg = NULL;#if WEBP_ENCODER_ABI_VERSION >= 0x0100        switch(sPicture.error_code)        {            case VP8_ENC_ERROR_OUT_OF_MEMORY: pszErrorMsg = "Out of memory"; break;            case VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY: pszErrorMsg = "Out of memory while flushing bits"; break;            case VP8_ENC_ERROR_NULL_PARAMETER: pszErrorMsg = "A pointer parameter is NULL"; break;            case VP8_ENC_ERROR_INVALID_CONFIGURATION: pszErrorMsg = "Configuration is invalid"; break;            case VP8_ENC_ERROR_BAD_DIMENSION: pszErrorMsg = "Picture has invalid width/height"; break;            case VP8_ENC_ERROR_PARTITION0_OVERFLOW: pszErrorMsg = "Partition is bigger than 512k. Try using less SEGMENTS, or increase PARTITION_LIMIT value"; break;            case VP8_ENC_ERROR_PARTITION_OVERFLOW: pszErrorMsg = "Partition is bigger than 16M"; break;            case VP8_ENC_ERROR_BAD_WRITE: pszErrorMsg = "Error while flusing bytes"; break;            case VP8_ENC_ERROR_FILE_TOO_BIG: pszErrorMsg = "File is bigger than 4G"; break;            case VP8_ENC_ERROR_USER_ABORT: pszErrorMsg = "User interrupted"; break;            default: break;        }#endif        if (pszErrorMsg)            CPLError(CE_Failure, CPLE_AppDefined, "WebPEncode() failed : %s", pszErrorMsg);        else            CPLError(CE_Failure, CPLE_AppDefined, "WebPEncode() failed");        eErr = CE_Failure;    }/* -------------------------------------------------------------------- *//*      Cleanup and close.                                              *//* -------------------------------------------------------------------- */    CPLFree( pabyBuffer );    WebPPictureFree(&sPicture);    VSIFCloseL( fpImage );    if( eErr != CE_None )    {        VSIUnlink( pszFilename );        return NULL;    }/* -------------------------------------------------------------------- *//*      Re-open dataset, and copy any auxiliary pam information.         *//* -------------------------------------------------------------------- */    GDALOpenInfo oOpenInfo(pszFilename, GA_ReadOnly);    /* If outputing to stdout, we can't reopen it, so we'll return */    /* a fake dataset to make the caller happy */    CPLPushErrorHandler(CPLQuietErrorHandler);    WEBPDataset *poDS = (WEBPDataset*) WEBPDataset::Open( &oOpenInfo );    CPLPopErrorHandler();    if( poDS )    {        poDS->CloneInfo( poSrcDS, GCIF_PAM_DEFAULT );        return poDS;    }    return NULL;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:101,


示例10: CPLPopErrorHandler

Debug::~Debug(){    CPLPopErrorHandler();}
开发者ID:mweisman,项目名称:PDAL,代码行数:5,


示例11: CPLGetExtension

int OGRShapeDataSource::OpenFile( const char *pszNewName, int bUpdate,                                  int bTestOpen ){    SHPHandle   hSHP;    DBFHandle   hDBF;    const char *pszExtension = CPLGetExtension( pszNewName );    (void) bTestOpen;    if( !EQUAL(pszExtension,"shp") && !EQUAL(pszExtension,"shx")            && !EQUAL(pszExtension,"dbf") )        return FALSE;    /* -------------------------------------------------------------------- */    /*      SHPOpen() should include better (CPL based) error reporting,    */    /*      and we should be trying to distinquish at this point whether    */    /*      failure is a result of trying to open a non-shapefile, or       */    /*      whether it was a shapefile and we want to report the error      */    /*      up.                                                             */    /*                                                                      */    /*      Care is taken to suppress the error and only reissue it if      */    /*      we think it is appropriate.                                     */    /* -------------------------------------------------------------------- */    CPLPushErrorHandler( CPLQuietErrorHandler );    if( bUpdate )        hSHP = SHPOpen( pszNewName, "r+" );    else        hSHP = SHPOpen( pszNewName, "r" );    CPLPopErrorHandler();    if( hSHP == NULL            && (!EQUAL(CPLGetExtension(pszNewName),"dbf")                || strstr(CPLGetLastErrorMsg(),".shp") == NULL) )    {        CPLString osMsg = CPLGetLastErrorMsg();        CPLError( CE_Failure, CPLE_OpenFailed, "%s", osMsg.c_str() );        return FALSE;    }    CPLErrorReset();    /* -------------------------------------------------------------------- */    /*      Open the .dbf file, if it exists.  To open a dbf file, the      */    /*      filename has to either refer to a successfully opened shp       */    /*      file or has to refer to the actual .dbf file.                   */    /* -------------------------------------------------------------------- */    if( hSHP != NULL || EQUAL(CPLGetExtension(pszNewName),"dbf") )    {        if( bUpdate )            hDBF = DBFOpen( pszNewName, "r+" );        else            hDBF = DBFOpen( pszNewName, "r" );    }    else        hDBF = NULL;    if( hDBF == NULL && hSHP == NULL )        return FALSE;    /* -------------------------------------------------------------------- */    /*      Is there an associated .prj file we can read?                   */    /* -------------------------------------------------------------------- */    OGRSpatialReference *poSRS = NULL;    const char  *pszPrjFile = CPLResetExtension( pszNewName, "prj" );    FILE        *fp = NULL;    fp = VSIFOpenL( pszPrjFile, "r" );#ifndef WIN32    if( NULL == fp )    {        pszPrjFile = CPLResetExtension( pszNewName, "PRJ" );        fp = VSIFOpenL( pszPrjFile, "r" );    }#endif    if( fp != NULL )    {        char    **papszLines;        VSIFCloseL( fp );        papszLines = CSLLoad( pszPrjFile );        poSRS = new OGRSpatialReference();        if( poSRS->importFromESRI( papszLines ) != OGRERR_NONE )        {            delete poSRS;            poSRS = NULL;        }        CSLDestroy( papszLines );    }    /* -------------------------------------------------------------------- */    /*      Create the layer object.                                        */    /* -------------------------------------------------------------------- */    OGRShapeLayer       *poLayer;//.........这里部分代码省略.........
开发者ID:RyanHun,项目名称:World-Wind-Java,代码行数:101,


示例12: CPLResetExtension

int OGRIdrisiLayer::Detect_AVL_ADC(const char* pszFilename){// --------------------------------------------------------------------//      Look for .adc file// --------------------------------------------------------------------    const char* pszADCFilename = CPLResetExtension(pszFilename, "adc");    VSILFILE* fpADC = VSIFOpenL(pszADCFilename, "rb");    if (fpADC == NULL)    {        pszADCFilename = CPLResetExtension(pszFilename, "ADC");        fpADC = VSIFOpenL(pszADCFilename, "rb");    }    char** papszADC = NULL;    if (fpADC != NULL)    {        VSIFCloseL(fpADC);        fpADC = NULL;        CPLPushErrorHandler(CPLQuietErrorHandler);        papszADC = CSLLoad2(pszADCFilename, 1024, 256, NULL);        CPLPopErrorHandler();        CPLErrorReset();    }    if (papszADC == NULL)        return FALSE;    CSLSetNameValueSeparator( papszADC, ":" );    const char *pszVersion = CSLFetchNameValue( papszADC, "file format " );    if( pszVersion == NULL || !EQUAL( pszVersion, "IDRISI Values A.1" ) )    {        CSLDestroy( papszADC );        return FALSE;    }    const char *pszFileType = CSLFetchNameValue( papszADC, "file type   " );    if( pszFileType == NULL || !EQUAL( pszFileType, "ascii" ) )    {        CPLDebug("IDRISI", ".adc file found, but file type != ascii");        CSLDestroy( papszADC );        return FALSE;    }    const char* pszRecords = CSLFetchNameValue( papszADC, "records     " );    if( pszRecords == NULL || atoi(pszRecords) != (int)nTotalFeatures )    {        CPLDebug("IDRISI", ".adc file found, but 'records' not found or not "                 "consistent with feature number declared in .vdc");        CSLDestroy( papszADC );        return FALSE;    }    const char* pszFields = CSLFetchNameValue( papszADC, "fields      " );    if( pszFields == NULL || atoi(pszFields) <= 1 )    {        CPLDebug("IDRISI", ".adc file found, but 'fields' not found or invalid");        CSLDestroy( papszADC );        return FALSE;    }// --------------------------------------------------------------------//      Look for .avl file// --------------------------------------------------------------------    const char* pszAVLFilename = CPLResetExtension(pszFilename, "avl");    fpAVL = VSIFOpenL(pszAVLFilename, "rb");    if (fpAVL == NULL)    {        pszAVLFilename = CPLResetExtension(pszFilename, "AVL");        fpAVL = VSIFOpenL(pszAVLFilename, "rb");    }    if (fpAVL == NULL)    {        CSLDestroy( papszADC );        return FALSE;    }// --------------------------------------------------------------------//      Build layer definition// --------------------------------------------------------------------    int iCurField;    char szKey[32];    iCurField = 0;    sprintf(szKey, "field %d ", iCurField);    char** papszIter = papszADC;    const char* pszLine;    int bFieldFound = FALSE;    CPLString osFieldName;    while((pszLine = *papszIter) != NULL)    {        //CPLDebug("IDRISI", "%s", pszLine);        if (strncmp(pszLine, szKey, strlen(szKey)) == 0)        {            const char* pszColon = strchr(pszLine, ':');            if (pszColon)            {//.........这里部分代码省略.........
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:101,


示例13: CPLPushErrorHandler

int OGRAVCBinDataSource::Open( const char * pszNewName, int bTestOpen ){/* -------------------------------------------------------------------- *//*      Open the source file.  Supress error reporting if we are in     *//*      TestOpen mode.                                                  *//* -------------------------------------------------------------------- */    if( bTestOpen )        CPLPushErrorHandler( CPLQuietErrorHandler );    psAVC = AVCE00ReadOpen( pszNewName );    if( bTestOpen )    {        CPLPopErrorHandler();        CPLErrorReset();    }    if( psAVC == NULL )        return FALSE;    pszName = CPLStrdup( pszNewName );    pszCoverageName = CPLStrdup( psAVC->pszCoverName );/* -------------------------------------------------------------------- *//*      Create layers for the "interesting" sections of the coverage.   *//* -------------------------------------------------------------------- */    int		iSection;    papoLayers = (OGRLayer **)        CPLCalloc( sizeof(OGRLayer *), psAVC->numSections );    nLayers = 0;    for( iSection = 0; iSection < psAVC->numSections; iSection++ )    {        AVCE00Section *psSec = psAVC->pasSections + iSection;        switch( psSec->eType )        {          case AVCFileARC:          case AVCFilePAL:          case AVCFileCNT:          case AVCFileLAB:          case AVCFileRPL:          case AVCFileTXT:          case AVCFileTX6:            papoLayers[nLayers++] = new OGRAVCBinLayer( this, psSec );            break;          case AVCFilePRJ:          {              char 	**papszPRJ;              AVCBinFile *hFile;                            hFile = AVCBinReadOpen(psAVC->pszCoverPath,                                      psSec->pszFilename,                                      psAVC->eCoverType,                                      psSec->eType,                                     psAVC->psDBCSInfo);              if( hFile && poSRS == NULL )              {                  papszPRJ = AVCBinReadNextPrj( hFile );                  poSRS = new OGRSpatialReference();                  if( poSRS->importFromESRI( papszPRJ ) != OGRERR_NONE )                  {                      CPLError( CE_Warning, CPLE_AppDefined,                                 "Failed to parse PRJ section, ignoring." );                      delete poSRS;                      poSRS = NULL;                  }                  AVCBinReadClose( hFile );              }          }          break;          default:            ;        }    }        return nLayers > 0;}
开发者ID:0004c,项目名称:node-gdal,代码行数:83,


示例14: main

int main(int argc, char** argv){    /* Check strict compilation and runtime library version as we use C++ API */    if (! GDAL_CHECK_VERSION(argv[0]))        exit(1);    EarlySetConfigOptions(argc, argv);/* -------------------------------------------------------------------- *//*      Generic arg processing.                                         *//* -------------------------------------------------------------------- */    GDALAllRegister();    argc = GDALGeneralCmdLineProcessor( argc, &argv, 0 );    if( argc < 1 )        exit( -argc );        for( int i = 0; i < argc; i++ )    {        if( EQUAL(argv[i], "--utility_version") )        {            printf("%s was compiled against GDAL %s and is running against GDAL %s/n",                   argv[0], GDAL_RELEASE_NAME, GDALVersionInfo("RELEASE_NAME"));            CSLDestroy( argv );            return 0;        }        else if( EQUAL(argv[i],"--help") )        {            Usage();        }    }    GDALRasterizeOptionsForBinary* psOptionsForBinary = GDALRasterizeOptionsForBinaryNew();    GDALRasterizeOptions *psOptions = GDALRasterizeOptionsNew(argv + 1, psOptionsForBinary);    CSLDestroy( argv );    if( psOptions == NULL )    {        Usage();    }    if( !(psOptionsForBinary->bQuiet) )    {        GDALRasterizeOptionsSetProgress(psOptions, GDALTermProgress, NULL);    }    if( psOptionsForBinary->pszSource == NULL )        Usage("No input file specified.");    if( psOptionsForBinary->pszDest == NULL )        Usage("No output file specified.");/* -------------------------------------------------------------------- *//*      Open input file.                                                *//* -------------------------------------------------------------------- */    GDALDatasetH hInDS = GDALOpenEx( psOptionsForBinary->pszSource, GDAL_OF_VECTOR | GDAL_OF_VERBOSE_ERROR,                                     NULL, NULL, NULL );    if( hInDS == NULL )        exit( 1 );/* -------------------------------------------------------------------- *//*      Open output file if it exists.                                  *//* -------------------------------------------------------------------- */    GDALDatasetH hDstDS = NULL;    if( !(psOptionsForBinary->bCreateOutput) )    {        CPLPushErrorHandler( CPLQuietErrorHandler );        hDstDS = GDALOpenEx( psOptionsForBinary->pszDest, GDAL_OF_RASTER | GDAL_OF_VERBOSE_ERROR | GDAL_OF_UPDATE,                                        NULL, NULL, NULL );        CPLPopErrorHandler();    }    if (hDstDS == NULL && !psOptionsForBinary->bQuiet && !psOptionsForBinary->bFormatExplicitlySet)        CheckExtensionConsistency(psOptionsForBinary->pszDest, psOptionsForBinary->pszFormat);        int bUsageError = FALSE;    GDALDatasetH hRetDS = GDALRasterize(psOptionsForBinary->pszDest,                                        hDstDS,                                        hInDS,                                        psOptions, &bUsageError);    if(bUsageError == TRUE)        Usage();    int nRetCode = (hRetDS) ? 0 : 1;        GDALClose(hInDS);    GDALClose(hRetDS);    GDALRasterizeOptionsFree(psOptions);    GDALRasterizeOptionsForBinaryFree(psOptionsForBinary);    GDALDestroyDriverManager();    return nRetCode;}
开发者ID:sameke,项目名称:node-gdal,代码行数:94,


示例15: CPLError

//.........这里部分代码省略........./* -------------------------------------------------------------------- */    GByte   *pabyBuffer;    pabyBuffer = (GByte *) VSIMalloc( 3 * nXSize * nYSize );    if (pabyBuffer == NULL)    {        return NULL;    }/* -------------------------------------------------------------------- *//*      Create the dataset.                                             *//* -------------------------------------------------------------------- */    VSILFILE    *fpImage;    fpImage = VSIFOpenL( pszFilename, "wb" );    if( fpImage == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "Unable to create WEBP file %s./n",                  pszFilename );        VSIFree(pabyBuffer);        return NULL;    }/* -------------------------------------------------------------------- *//*      WEBP library settings                                           *//* -------------------------------------------------------------------- */    sPicture.colorspace = 0;    sPicture.width = nXSize;    sPicture.height = nYSize;    sPicture.writer = WEBPDatasetWriter;    sPicture.custom_ptr = fpImage;    if (!WebPPictureAlloc(&sPicture))    {        CPLError(CE_Failure, CPLE_AppDefined, "WebPPictureAlloc() failed");        VSIFree(pabyBuffer);        VSIFCloseL( fpImage );        return NULL;    }/* -------------------------------------------------------------------- *//*      Acquire source imagery.                                         *//* -------------------------------------------------------------------- */    CPLErr      eErr = CE_None;    eErr = poSrcDS->RasterIO( GF_Read, 0, 0, nXSize, nYSize,                              pabyBuffer, nXSize, nYSize, GDT_Byte,                              3, NULL,                              3, 3 * nXSize, 1 );/* -------------------------------------------------------------------- *//*      Import and write to file                                        *//* -------------------------------------------------------------------- */    if (eErr == CE_None &&        !WebPPictureImportRGB(&sPicture, pabyBuffer, 3 * nXSize))    {        CPLError(CE_Failure, CPLE_AppDefined, "WebPPictureImportRGB() failed");        eErr = CE_Failure;    }    if (eErr == CE_None && !WebPEncode(&sConfig, &sPicture))    {        CPLError(CE_Failure, CPLE_AppDefined, "WebPEncode() failed");        eErr = CE_Failure;    }/* -------------------------------------------------------------------- *//*      Cleanup and close.                                              *//* -------------------------------------------------------------------- */    CPLFree( pabyBuffer );    WebPPictureFree(&sPicture);    VSIFCloseL( fpImage );    if( eErr != CE_None )    {        VSIUnlink( pszFilename );        return NULL;    }/* -------------------------------------------------------------------- *//*      Re-open dataset, and copy any auxilary pam information.         *//* -------------------------------------------------------------------- */    GDALOpenInfo oOpenInfo(pszFilename, GA_ReadOnly);    /* If outputing to stdout, we can't reopen it, so we'll return */    /* a fake dataset to make the caller happy */    CPLPushErrorHandler(CPLQuietErrorHandler);    WEBPDataset *poDS = (WEBPDataset*) WEBPDataset::Open( &oOpenInfo );    CPLPopErrorHandler();    if( poDS )    {        poDS->CloneInfo( poSrcDS, GCIF_PAM_DEFAULT );        return poDS;    }    return NULL;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,


示例16: osSQL

int OGRGFTTableLayer::FetchNextRows(){    aosRows.resize(0);    CPLString osSQL("SELECT ROWID");    for(int i=0;i<poFeatureDefn->GetFieldCount();i++)    {        osSQL += ",";        if (i < (int)aosColumnInternalName.size())            osSQL += aosColumnInternalName[i];        else        {            const char* pszFieldName =                poFeatureDefn->GetFieldDefn(i)->GetNameRef();            osSQL += EscapeAndQuote(pszFieldName);        }    }    if (bHiddenGeometryField)    {        osSQL += ",";        osSQL += EscapeAndQuote(GetGeometryColumn());    }    osSQL += " FROM ";    osSQL += osTableId;    if (osWHERE.size())    {        osSQL += " ";        osSQL += osWHERE;    }    int nFeaturesToFetch = GetFeaturesToFetch();    if (nFeaturesToFetch > 0)        osSQL += CPLSPrintf(" OFFSET %d LIMIT %d", nOffset, nFeaturesToFetch);    CPLPushErrorHandler(CPLQuietErrorHandler);    CPLHTTPResult * psResult = poDS->RunSQL(osSQL);    CPLPopErrorHandler();    if (psResult == NULL)    {        bEOF = TRUE;        return FALSE;    }    char* pszLine = (char*) psResult->pabyData;    if (pszLine == NULL || psResult->pszErrBuf != NULL)    {        CPLDebug("GFT", "Error : %s", pszLine ? pszLine : psResult->pszErrBuf);        CPLHTTPDestroyResult(psResult);        bEOF = TRUE;        return FALSE;    }    ParseCSVResponse(pszLine, aosRows);    if (aosRows.size() > 0)        aosRows.erase(aosRows.begin());    if (nFeaturesToFetch > 0)        bEOF = (int)aosRows.size() < GetFeaturesToFetch();    else        bEOF = TRUE;    CPLHTTPDestroyResult(psResult);    return TRUE;}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:68,


示例17: CPLError

//.........这里部分代码省略.........        iNextDeletedShape = 0;        for( iShape = 0;              iShape < nTotalShapeCount && eErr == OGRERR_NONE;              iShape++ )        {            if( panRecordsToDelete[iNextDeletedShape] == iShape )                iNextDeletedShape++;            else            {                SHPObject *hObject;                hObject = SHPReadObject( hSHP, iShape );                if( hObject == NULL )                    eErr = OGRERR_FAILURE;                else if( SHPWriteObject( hNewSHP, -1, hObject ) == -1 )                    eErr = OGRERR_FAILURE;                if( hObject )                    SHPDestroyObject( hObject );            }        }        if( eErr != OGRERR_NONE )        {            CPLFree( panRecordsToDelete );            VSIUnlink( CPLResetExtension( oTempFile, "shp" ) );            VSIUnlink( CPLResetExtension( oTempFile, "shx" ) );            return eErr;        }/* -------------------------------------------------------------------- *//*      Cleanup the old .shp/.shx and rename the new one.               *//* -------------------------------------------------------------------- */        SHPClose( hSHP );        SHPClose( hNewSHP );        hSHP = hNewSHP = NULL;        VSIUnlink( osSHPName );        VSIUnlink( osSHXName );        oTempFile = CPLResetExtension( oTempFile, "shp" );        if( VSIRename( oTempFile, osSHPName ) != 0 )        {            CPLDebug( "Shape", "Can not rename SHP file: %s", VSIStrerror( errno ) );            CPLFree( panRecordsToDelete );            return OGRERR_FAILURE;        }            oTempFile = CPLResetExtension( oTempFile, "shx" );        if( VSIRename( oTempFile, osSHXName ) != 0 )        {            CPLDebug( "Shape", "Can not rename SHX file: %s", VSIStrerror( errno ) );            CPLFree( panRecordsToDelete );            return OGRERR_FAILURE;        }    }        CPLFree( panRecordsToDelete );    panRecordsToDelete = NULL;/* -------------------------------------------------------------------- *//*      Reopen the shapefile                                            *//*                                                                      *//* We do not need to reimplement OGRShapeDataSource::OpenFile() here    */  /* with the fully featured error checking.                              *//* If all operations above succeeded, then all necessery files are      *//* in the right place and accessible.                                   *//* -------------------------------------------------------------------- */    CPLAssert( NULL == hSHP );    CPLAssert( NULL == hDBF && NULL == hNewDBF );        CPLPushErrorHandler( CPLQuietErrorHandler );        const char* pszAccess = NULL;    if( bUpdateAccess )        pszAccess = "r+";    else        pszAccess = "r";        hSHP = SHPOpen ( CPLResetExtension( pszFullName, "shp" ) , pszAccess );    hDBF = DBFOpen ( CPLResetExtension( pszFullName, "dbf" ) , pszAccess );        CPLPopErrorHandler();        if( NULL == hSHP || NULL == hDBF )    {        CPLString osMsg(CPLGetLastErrorMsg());        CPLError( CE_Failure, CPLE_OpenFailed, "%s", osMsg.c_str() );        return OGRERR_FAILURE;    }/* -------------------------------------------------------------------- *//*      Update total shape count.                                       *//* -------------------------------------------------------------------- */    nTotalShapeCount = hDBF->nRecords;    return OGRERR_NONE;}
开发者ID:dlsyaim,项目名称:osgEarthX,代码行数:101,


示例18: CPLAssert

//.........这里部分代码省略.........    else        osTmpFileName.Printf("/vsimem/ogrgpsbabeldatasource_%p", this);    bool bRet = false;    if (IsSpecialFile(pszFilename))    {        /* Special file : don't try to open it */        char** argv = GetArgv(bExplicitFeatures, bWaypoints, bRoutes,                              bTracks, pszGPSBabelDriverName, pszFilename);        VSILFILE* tmpfp = VSIFOpenL(osTmpFileName.c_str(), "wb");        bRet = (CPLSpawn(argv, NULL, tmpfp, TRUE) == 0);        VSIFCloseL(tmpfp);        tmpfp = NULL;        CSLDestroy(argv);        argv = NULL;    }    else    {        VSILFILE* fp = VSIFOpenL(pszFilename, "rb");        if (fp == NULL)        {            CPLError(CE_Failure, CPLE_AppDefined,                    "Cannot open file %s", pszFilename);            return FALSE;        }        char** argv = GetArgv(bExplicitFeatures, bWaypoints, bRoutes,                              bTracks, pszGPSBabelDriverName, "-");        VSILFILE* tmpfp = VSIFOpenL(osTmpFileName.c_str(), "wb");        CPLPushErrorHandler(CPLQuietErrorHandler);        bRet = (CPLSpawn(argv, fp, tmpfp, TRUE) == 0);        CPLPopErrorHandler();        CSLDestroy(argv);        argv = NULL;        CPLErr nLastErrorType = CPLGetLastErrorType();        CPLErrorNum nLastErrorNo = CPLGetLastErrorNo();        CPLString osLastErrorMsg = CPLGetLastErrorMsg();        VSIFCloseL(tmpfp);        tmpfp = NULL;        VSIFCloseL(fp);        fp = NULL;        if (!bRet)        {            if ( strstr(osLastErrorMsg.c_str(),                        "This format cannot be used in piped commands") == NULL)            {                CPLError( nLastErrorType, nLastErrorNo, "%s",                          osLastErrorMsg.c_str());            }            else            {                VSIStatBuf sStatBuf;                if (VSIStat(pszFilename, &sStatBuf) != 0)                {                    CPLError( CE_Failure, CPLE_NotSupported,                              "Driver %s only supports real (non virtual) "                              "files",                              pszGPSBabelDriverName );                    return FALSE;
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:67,


示例19: RasterliteCreateTables

OGRDataSourceH RasterliteCreateTables(OGRDataSourceH hDS, const char* pszTableName,                                      int nSRSId, int bWipeExistingData){    CPLString osSQL;        CPLString osDBName = OGR_DS_GetName(hDS);        CPLString osRasterLayer;    osRasterLayer.Printf("%s_rasters", pszTableName);        CPLString osMetatadataLayer;    osMetatadataLayer.Printf("%s_metadata", pszTableName);    OGRLayerH hLyr;    if (OGR_DS_GetLayerByName(hDS, osRasterLayer.c_str()) == NULL)    {/* -------------------------------------------------------------------- *//*      The table don't exist. Create them                              *//* -------------------------------------------------------------------- */        /* Create _rasters table */        osSQL.Printf   ("CREATE TABLE /"%s/" ("                        "id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,"                        "raster BLOB NOT NULL)", osRasterLayer.c_str());        OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL);                    /* Create _metadata table */        osSQL.Printf   ("CREATE TABLE /"%s/" ("                        "id INTEGER NOT NULL PRIMARY KEY,"                        "source_name TEXT NOT NULL,"                        "tile_id INTEGER NOT NULL,"                        "width INTEGER NOT NULL,"                        "height INTEGER NOT NULL,"                        "pixel_x_size DOUBLE NOT NULL,"                        "pixel_y_size DOUBLE NOT NULL)",                        osMetatadataLayer.c_str());        OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL);        /* Add geometry column to _metadata table */        osSQL.Printf("SELECT AddGeometryColumn('%s', 'geometry', %d, 'POLYGON', 2)",                      osMetatadataLayer.c_str(), nSRSId);        if ((hLyr = OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL)) == NULL)        {            CPLError(CE_Failure, CPLE_AppDefined,                     "Check that the OGR SQLite driver has Spatialite support");            OGRReleaseDataSource(hDS);            return NULL;        }        OGR_DS_ReleaseResultSet(hDS, hLyr);                        /* Create spatial index on _metadata table */        osSQL.Printf("SELECT CreateSpatialIndex('%s', 'geometry')",                      osMetatadataLayer.c_str());        if ((hLyr = OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL)) == NULL)        {            OGRReleaseDataSource(hDS);            return NULL;        }        OGR_DS_ReleaseResultSet(hDS, hLyr);        /* Create statistics tables */        osSQL.Printf("SELECT UpdateLayerStatistics()");        CPLPushErrorHandler(CPLQuietErrorHandler);        hLyr = OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL);        CPLPopErrorHandler();        OGR_DS_ReleaseResultSet(hDS, hLyr);        /* Re-open the DB to take into account the new tables*/        OGRReleaseDataSource(hDS);                hDS = OGROpen(osDBName.c_str(), TRUE, NULL);    }    else    {        /* Check that the existing SRS is consistent with the one of the new */        /* data to be inserted */        osSQL.Printf("SELECT srid FROM geometry_columns WHERE f_table_name = '%s'",                     osMetatadataLayer.c_str());        hLyr = OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL);        if (hLyr)        {            int nExistingSRID = -1;            OGRFeatureH hFeat = OGR_L_GetNextFeature(hLyr);            if (hFeat)            {                nExistingSRID = OGR_F_GetFieldAsInteger(hFeat, 0);                OGR_F_Destroy(hFeat);            }            OGR_DS_ReleaseResultSet(hDS, hLyr);            if (nExistingSRID != nSRSId)            {                if (bWipeExistingData)                {                    osSQL.Printf("UPDATE geometry_columns SET srid = %d "                                 "WHERE f_table_name = /"%s/"",                                 nSRSId, osMetatadataLayer.c_str());                    OGR_DS_ExecuteSQL(hDS, osSQL.c_str(), NULL, NULL);        //.........这里部分代码省略.........
开发者ID:GeospatialDaryl,项目名称:VS2013__00_GDAL_111_x64,代码行数:101,


示例20: main

//.........这里部分代码省略.........            {                printf( "Unrecognizable band number (%s)./n", papszArgv[iArg+1] );                Usage();                GDALDestroyDriverManager();                exit( 2 );            }            iArg++;            nBandCount++;            panBandList = (int *)                 CPLRealloc(panBandList, sizeof(int) * nBandCount);            panBandList[nBandCount-1] = nBand;        }        else if( EQUAL(papszArgv[iArg], "-oo") )        {            CHECK_HAS_ENOUGH_ADDITIONAL_ARGS(1);            papszOpenOptions = CSLAddString( papszOpenOptions,                                             papszArgv[++iArg] );        }        else if( papszArgv[iArg][0] == '-' )            Usage(CPLSPrintf("Unknown option name '%s'", papszArgv[iArg]));        else if( pszFilename == NULL )            pszFilename = papszArgv[iArg];        else if( atoi(papszArgv[iArg]) > 0 )        {            anLevels[nLevelCount++] = atoi(papszArgv[iArg]);            if( anLevels[nLevelCount-1] == 1 )            {                printf("Warning: Overview with subsampling factor of 1 requested. This will copy the full resolution dataset in the overview !/n");            }        }        else            Usage("Too many command options.");    }    if( pszFilename == NULL )        Usage("No datasource specified.");    if( nLevelCount == 0 && !bClean )        Usage("No overview level specified.");/* -------------------------------------------------------------------- *//*      Open data file.                                                 *//* -------------------------------------------------------------------- */    if (bReadOnly)        hDataset = NULL;    else    {        CPLPushErrorHandler( CPLQuietErrorHandler );        hDataset = GDALOpenEx( pszFilename, GDAL_OF_RASTER | GDAL_OF_UPDATE, NULL, papszOpenOptions, NULL );        CPLPopErrorHandler();    }    if( hDataset == NULL )        hDataset = GDALOpenEx( pszFilename, GDAL_OF_RASTER, NULL, papszOpenOptions, NULL );    CSLDestroy(papszOpenOptions);    papszOpenOptions = NULL;    if( hDataset == NULL )        exit( 2 );/* -------------------------------------------------------------------- *//*      Clean overviews.                                                *//* -------------------------------------------------------------------- */    if ( bClean &&        GDALBuildOverviews( hDataset,pszResampling, 0, 0,                              0, NULL, pfnProgress, NULL ) != CE_None )    {        printf( "Cleaning overviews failed./n" );        nResultStatus = 200;    }/* -------------------------------------------------------------------- *//*      Generate overviews.                                             *//* -------------------------------------------------------------------- */    //Only HFA support selected layers    if(nBandCount > 0)        CPLSetConfigOption( "USE_RRD", "YES" );    if (nLevelCount > 0 && nResultStatus == 0 &&        GDALBuildOverviews( hDataset,pszResampling, nLevelCount, anLevels,                             nBandCount, panBandList, pfnProgress, NULL ) != CE_None )    {        printf( "Overview building failed./n" );        nResultStatus = 100;    }/* -------------------------------------------------------------------- *//*      Cleanup                                                         *//* -------------------------------------------------------------------- */    GDALClose(hDataset);    CSLDestroy( papszArgv );    CPLFree(panBandList);    GDALDestroyDriverManager();    return nResultStatus;}
开发者ID:sameke,项目名称:node-gdal,代码行数:101,


示例21: MAIN_START

//.........这里部分代码省略.........            OSRDestroySpatialReference( hTargetSRS );            fprintf( stderr, "Invalid target SRS `%s'./n",                     pszTargetSRS );            exit(1);        }    }/* -------------------------------------------------------------------- *//*      Open or create the target datasource                            *//* -------------------------------------------------------------------- */    GDALDatasetH hTileIndexDS = GDALOpenEx(        index_filename, GDAL_OF_VECTOR | GDAL_OF_UPDATE, nullptr, nullptr, nullptr );    OGRLayerH hLayer = nullptr;    CPLString osFormat;    if( hTileIndexDS != nullptr )    {        GDALDriverH hDriver = GDALGetDatasetDriver(hTileIndexDS);        if( hDriver )            osFormat = GDALGetDriverShortName(hDriver);        if( GDALDatasetGetLayerCount(hTileIndexDS) == 1 )        {            hLayer = GDALDatasetGetLayer(hTileIndexDS, 0);        }        else        {            if( pszIndexLayerName == nullptr )            {                printf( "-lyr_name must be specified./n" );                exit( 1 );            }            CPLPushErrorHandler(CPLQuietErrorHandler);            hLayer = GDALDatasetGetLayerByName(hTileIndexDS, pszIndexLayerName);            CPLPopErrorHandler();        }    }    else    {        printf( "Creating new index file.../n" );        if( pszDriverName == nullptr )        {            std::vector<CPLString> aoDrivers =                GetOutputDriversFor(index_filename, GDAL_OF_VECTOR);            if( aoDrivers.empty() )            {                CPLError( CE_Failure, CPLE_AppDefined,                        "Cannot guess driver for %s", index_filename);                exit( 10 );            }            else            {                if( aoDrivers.size() > 1 )                {                    CPLError( CE_Warning, CPLE_AppDefined,                            "Several drivers matching %s extension. Using %s",                            CPLGetExtension(index_filename), aoDrivers[0].c_str() );                }                osFormat = aoDrivers[0];            }        }        else        {            osFormat = pszDriverName;        }        if( !EQUAL(osFormat, "ESRI Shapefile") )            nMaxFieldSize = 0;
开发者ID:AsgerPetersen,项目名称:gdal,代码行数:67,


示例22: main

//.........这里部分代码省略.........        {            poDS = (GDALDataset*)GDALOpen(pszDataset, GA_ReadOnly);            if( poDS == NULL )                exit(1);        }        if( bMigrate )        {            Resource* psResource = (Resource*)CPLMalloc(sizeof(Resource));            psResource->poDS = poDS;            int nBufferSize;            if( eStrategy == STRATEGY_RANDOM )                nBufferSize = CreateRandomStrategyRequests(                        poDS, nMaxRequests, psGlobalRequestList, psGlobalRequestLast);            else if( eStrategy == STRATEGY_LINE )                nBufferSize = CreateLineStrategyRequests(                        poDS, nMaxRequests, psGlobalRequestList, psGlobalRequestLast);            else                nBufferSize = CreateBlockStrategyRequests(                        poDS, nMaxRequests, psGlobalRequestList, psGlobalRequestLast);            psResource->pBuffer = CPLMalloc(nBufferSize);            PutResourceAtEnd(psResource);        }        else        {            ThreadDescription sThreadDescription;            sThreadDescription.poDS = poDS;            sThreadDescription.psRequestList = NULL;            Request* psRequestLast = NULL;            if( eStrategy == STRATEGY_RANDOM )                sThreadDescription.nBufferSize = CreateRandomStrategyRequests(                        poDS, nMaxRequests, sThreadDescription.psRequestList, psRequestLast);            else if( eStrategy == STRATEGY_LINE )                sThreadDescription.nBufferSize = CreateLineStrategyRequests(                        poDS, nMaxRequests, sThreadDescription.psRequestList, psRequestLast);            else                sThreadDescription.nBufferSize = CreateBlockStrategyRequests(                        poDS, nMaxRequests, sThreadDescription.psRequestList, psRequestLast);            asThreadDescription.push_back(sThreadDescription);        }    }    if( bCreatedDataset && poMEMDS == NULL && bOnDisk )    {        CPLPushErrorHandler(CPLQuietErrorHandler);        VSIUnlink(pszDataset);        CPLPopErrorHandler();    }        if( bMigrate )    {        psLock = CPLCreateLock(LOCK_SPIN);    }    for(i = 0; i < nThreads; i++ )    {        CPLJoinableThread* pThread;        if( bMigrate )            pThread = CPLCreateJoinableThread(ThreadFuncWithMigration, NULL);        else            pThread = CPLCreateJoinableThread(ThreadFuncDedicatedDataset,                                              &(asThreadDescription[i]));        apsThreads.push_back(pThread);    }    for(i = 0; i < nThreads; i++ )    {        CPLJoinThread(apsThreads[i]);        if( !bMigrate && poMEMDS == NULL )            GDALClose(asThreadDescription[i].poDS);    }    while( psGlobalResourceList != NULL )    {        CPLFree( psGlobalResourceList->pBuffer);        if( poMEMDS == NULL )            GDALClose(psGlobalResourceList->poDS);        Resource* psNext = psGlobalResourceList->psNext;        CPLFree( psGlobalResourceList );        psGlobalResourceList = psNext;    }    if( psLock )    {        CPLDestroyLock( psLock );    }    if( bCreatedDataset && poMEMDS == NULL  )    {        CPLPushErrorHandler(CPLQuietErrorHandler);        VSIUnlink(pszDataset);        CPLPopErrorHandler();    }    if( poMEMDS )        GDALClose(poMEMDS);    assert( GDALGetCacheUsed64() == 0 );    GDALDestroyDriverManager();    CSLDestroy( argv );    return 0;}
开发者ID:nextgis-borsch,项目名称:tests,代码行数:101,


示例23: CPLStrdup

int OGRPDSDataSource::Open( const char * pszFilename ){    pszName = CPLStrdup( pszFilename );// --------------------------------------------------------------------//      Does this appear to be a .PDS table file?// --------------------------------------------------------------------    VSILFILE* fp = VSIFOpenL(pszFilename, "rb");    if (fp == NULL)        return FALSE;    char szBuffer[512];    int nbRead = (int)VSIFReadL(szBuffer, 1, sizeof(szBuffer) - 1, fp);    szBuffer[nbRead] = '/0';    const char* pszPos = strstr(szBuffer, "PDS_VERSION_ID");    int bIsPDS = (pszPos != NULL);    if (!bIsPDS)    {        VSIFCloseL(fp);        return FALSE;    }    if (!oKeywords.Ingest(fp, pszPos - szBuffer))    {        VSIFCloseL(fp);        return FALSE;    }    VSIFCloseL(fp);    CPLString osRecordType = oKeywords.GetKeyword( "RECORD_TYPE", "" );    CPLString osFileRecords = oKeywords.GetKeyword( "FILE_RECORDS", "" );    CPLString osRecordBytes = oKeywords.GetKeyword( "RECORD_BYTES", "" );    int nRecordSize = atoi(osRecordBytes);    if (osRecordType.size() == 0 || osFileRecords.size() == 0 ||        osRecordBytes.size() == 0 || nRecordSize <= 0)    {        CPLError(CE_Failure, CPLE_NotSupported,                 "One of RECORD_TYPE, FILE_RECORDS or RECORD_BYTES is missing");        return FALSE;    }    CleanString(osRecordType);    if (osRecordType.compare("FIXED_LENGTH") != 0)    {        CPLError(CE_Failure, CPLE_NotSupported,                 "Only RECORD_TYPE=FIXED_LENGTH is supported");        return FALSE;    }    CPLString osTable = oKeywords.GetKeyword( "^TABLE", "" );    if (osTable.size() != 0)        LoadTable(pszFilename, nRecordSize, "TABLE");    else    {        VSILFILE* fp = VSIFOpenL(pszFilename, "rb");        if (fp == NULL)            return FALSE;        while(TRUE)        {            CPLPushErrorHandler(CPLQuietErrorHandler);            const char* pszLine = CPLReadLine2L(fp, 256, NULL);            CPLPopErrorHandler();            CPLErrorReset();            if (pszLine == NULL)                break;            char** papszTokens =                CSLTokenizeString2( pszLine, " =", CSLT_HONOURSTRINGS );            int nTokens = CSLCount(papszTokens);            if (nTokens == 2 &&                papszTokens[0][0] == '^' &&                strstr(papszTokens[0], "TABLE") != NULL)            {                LoadTable(pszFilename, nRecordSize, papszTokens[0] + 1);            }            CSLDestroy(papszTokens);            papszTokens = NULL;        }        VSIFCloseL(fp);    }    return nLayers != 0;}
开发者ID:samalone,项目名称:gdal-ios,代码行数:86,


示例24: CPLError

//.........这里部分代码省略.........        return NULL;    }/* -------------------------------------------------------------------- *//*      Read creation options                                           *//* -------------------------------------------------------------------- */    const char* pszColSep =            CSLFetchNameValue(papszOptions, "COLUMN_SEPARATOR");    if (pszColSep == NULL)        pszColSep = " ";    else if (EQUAL(pszColSep, "COMMA"))        pszColSep = ",";    else if (EQUAL(pszColSep, "SPACE"))        pszColSep = " ";    else if (EQUAL(pszColSep, "SEMICOLON"))        pszColSep = ";";    else if (EQUAL(pszColSep, "//t") || EQUAL(pszColSep, "TAB"))        pszColSep = "/t";    const char* pszAddHeaderLine =            CSLFetchNameValue(papszOptions, "ADD_HEADER_LINE");    if (pszAddHeaderLine != NULL && CSLTestBoolean(pszAddHeaderLine))    {        VSIFPrintfL(fp, "X%sY%sZ/n", pszColSep, pszColSep);    }/* -------------------------------------------------------------------- *//*      Copy imagery                                                    *//* -------------------------------------------------------------------- */    void* pLineBuffer = (void*) CPLMalloc(nXSize * sizeof(int));    int i, j;    CPLErr eErr = CE_None;    for(j=0;j<nYSize && eErr == CE_None;j++)    {        eErr = poSrcDS->GetRasterBand(1)->RasterIO(                                            GF_Read, 0, j, nXSize, 1,                                            pLineBuffer, nXSize, 1,                                            eReqDT, 0, 0, NULL);        if (eErr != CE_None)            break;        double dfY = adfGeoTransform[3] + (j + 0.5) * adfGeoTransform[5];        CPLString osBuf;        for(i=0;i<nXSize;i++)        {            char szBuf[256];            double dfX = adfGeoTransform[0] + (i + 0.5) * adfGeoTransform[1];            if (eReqDT == GDT_Int32)                CPLsnprintf(szBuf, sizeof(szBuf), "%.18g%c%.18g%c%d/n", dfX, pszColSep[0], dfY, pszColSep[0], ((int*)pLineBuffer)[i]);            else                CPLsnprintf(szBuf, sizeof(szBuf), "%.18g%c%.18g%c%.18g/n", dfX, pszColSep[0], dfY, pszColSep[0], ((float*)pLineBuffer)[i]);            osBuf += szBuf;            if( (i & 1023) == 0 || i == nXSize - 1 )            {                if ( VSIFWriteL( osBuf, (int)osBuf.size(), 1, fp ) != 1 )                {                    eErr = CE_Failure;                    CPLError( CE_Failure, CPLE_AppDefined,                               "Write failed, disk full?/n" );                    break;                }                osBuf = "";            }        }        if (!pfnProgress( (j+1) * 1.0 / nYSize, NULL, pProgressData))        {            eErr = CE_Failure;            break;        }    }    CPLFree(pLineBuffer);    VSIFCloseL(fp);        if (eErr != CE_None)        return NULL;/* -------------------------------------------------------------------- *//*      We don't want to call GDALOpen() since it will be expensive,    *//*      so we "hand prepare" an XYZ dataset referencing our file.       *//* -------------------------------------------------------------------- */    XYZDataset* poXYZ_DS = new XYZDataset();    poXYZ_DS->nRasterXSize = nXSize;    poXYZ_DS->nRasterYSize = nYSize;    poXYZ_DS->nBands = 1;    poXYZ_DS->SetBand( 1, new XYZRasterBand( poXYZ_DS, 1, eReqDT ) );    /* If outputing to stdout, we can't reopen it --> silence warning */    CPLPushErrorHandler(CPLQuietErrorHandler);    poXYZ_DS->fp = VSIFOpenL( pszFilename, "rb" );    CPLPopErrorHandler();    memcpy( &(poXYZ_DS->adfGeoTransform), adfGeoTransform, sizeof(double)*6 );    poXYZ_DS->nXIndex = 0;    poXYZ_DS->nYIndex = 1;    poXYZ_DS->nZIndex = 2;    if( pszAddHeaderLine )    {        poXYZ_DS->nDataLineNum = 1;        poXYZ_DS->bHasHeaderLine = TRUE;    }    return poXYZ_DS;}
开发者ID:garnertb,项目名称:gdal,代码行数:101,


示例25: CSLAddString

json_object* OGRCouchDBDataSource::REQUEST(const char* pszVerb,                                           const char* pszURI,                                           const char* pszData){    bMustCleanPersistent = true;    char** papszOptions = NULL;    papszOptions = CSLAddString(papszOptions, CPLSPrintf("PERSISTENT=CouchDB:%p", this));    CPLString osCustomRequest("CUSTOMREQUEST=");    osCustomRequest += pszVerb;    papszOptions = CSLAddString(papszOptions, osCustomRequest);    CPLString osPOSTFIELDS("POSTFIELDS=");    if (pszData)        osPOSTFIELDS += pszData;    papszOptions = CSLAddString(papszOptions, osPOSTFIELDS);    papszOptions = CSLAddString(papszOptions, "HEADERS=Content-Type: application/json");    if (!osUserPwd.empty() )    {        CPLString osUserPwdOption("USERPWD=");        osUserPwdOption += osUserPwd;        papszOptions = CSLAddString(papszOptions, osUserPwdOption);    }    CPLDebug("CouchDB", "%s %s", pszVerb, pszURI);    CPLString osFullURL(osURL);    osFullURL += pszURI;    CPLPushErrorHandler(CPLQuietErrorHandler);    CPLHTTPResult * psResult = CPLHTTPFetch( osFullURL, papszOptions);    CPLPopErrorHandler();    CSLDestroy(papszOptions);    if (psResult == NULL)        return NULL;    const char* pszServer = CSLFetchNameValue(psResult->papszHeaders, "Server");    if (pszServer == NULL || !STARTS_WITH_CI(pszServer, "CouchDB"))    {        CPLHTTPDestroyResult(psResult);        return NULL;    }    if (psResult->nDataLen == 0)    {        CPLHTTPDestroyResult(psResult);        return NULL;    }    json_object* jsobj = NULL;    const char* pszText = reinterpret_cast<const char*>(psResult->pabyData);    if( !OGRJSonParse(pszText, &jsobj, true) )    {        CPLHTTPDestroyResult(psResult);        return NULL;    }    CPLHTTPDestroyResult(psResult);    return jsobj;}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:62,


示例26: LoadProjLibrary

static int LoadProjLibrary(){    CPLMutexHolderD( &hPROJMutex );    static int  bTriedToLoad = FALSE;    const char *pszLibName;        if( bTriedToLoad )        return( pfn_pj_transform != NULL );    bTriedToLoad = TRUE;    pszLibName = GetProjLibraryName();#ifdef PROJ_STATIC    pfn_pj_init = pj_init;    pfn_pj_init_plus = pj_init_plus;    pfn_pj_free = pj_free;    pfn_pj_transform = pj_transform;    pfn_pj_get_errno_ref = (int *(*)(void)) pj_get_errno_ref;    pfn_pj_strerrno = pj_strerrno;    pfn_pj_dalloc = pj_dalloc;#if PJ_VERSION >= 446    pfn_pj_get_def = pj_get_def;#endif#if PJ_VERSION >= 480    pfn_pj_ctx_alloc = pj_ctx_alloc;    pfn_pj_ctx_free = pj_ctx_free;    pfn_pj_init_plus_ctx = pj_init_plus_ctx;    pfn_pj_ctx_get_errno = pj_ctx_get_errno;#endif#else    CPLPushErrorHandler( CPLQuietErrorHandler );    pfn_pj_init = (projPJ (*)(int, char**)) CPLGetSymbol( pszLibName,                                                       "pj_init" );    CPLPopErrorHandler();        if( pfn_pj_init == NULL )       return( FALSE );    pfn_pj_init_plus = (projPJ (*)(const char *))         CPLGetSymbol( pszLibName, "pj_init_plus" );    pfn_pj_free = (void (*)(projPJ))         CPLGetSymbol( pszLibName, "pj_free" );    pfn_pj_transform = (int (*)(projPJ,projPJ,long,int,double*,                                double*,double*))                        CPLGetSymbol( pszLibName, "pj_transform" );    pfn_pj_get_errno_ref = (int *(*)(void))        CPLGetSymbol( pszLibName, "pj_get_errno_ref" );    pfn_pj_strerrno = (char *(*)(int))        CPLGetSymbol( pszLibName, "pj_strerrno" );    CPLPushErrorHandler( CPLQuietErrorHandler );    pfn_pj_get_def = (char *(*)(projPJ,int))        CPLGetSymbol( pszLibName, "pj_get_def" );    pfn_pj_dalloc = (void (*)(void*))        CPLGetSymbol( pszLibName, "pj_dalloc" );    /* PROJ 4.8.0 symbols */    pfn_pj_ctx_alloc = (projCtx (*)( void ))        CPLGetSymbol( pszLibName, "pj_ctx_alloc" );    pfn_pj_ctx_free = (void (*)( projCtx ))        CPLGetSymbol( pszLibName, "pj_ctx_free" );    pfn_pj_init_plus_ctx = (projPJ (*)( projCtx, const char * ))        CPLGetSymbol( pszLibName, "pj_init_plus_ctx" );    pfn_pj_ctx_get_errno = (int (*)( projCtx ))        CPLGetSymbol( pszLibName, "pj_ctx_get_errno" );    CPLPopErrorHandler();    CPLErrorReset();#endif    if (pfn_pj_ctx_alloc != NULL &&        pfn_pj_ctx_free != NULL &&        pfn_pj_init_plus_ctx != NULL &&        pfn_pj_ctx_get_errno != NULL &&        CSLTestBoolean(CPLGetConfigOption("USE_PROJ_480_FEATURES", "YES")))    {        CPLDebug("OGRCT", "PROJ >= 4.8.0 features enabled");    }    else    {        pfn_pj_ctx_alloc = NULL;        pfn_pj_ctx_free = NULL;        pfn_pj_init_plus_ctx = NULL;        pfn_pj_ctx_get_errno = NULL;    }    if( pfn_pj_transform == NULL )    {        CPLError( CE_Failure, CPLE_AppDefined,                   "Attempt to load %s, but couldn't find pj_transform./n"                  "Please upgrade to PROJ 4.1.2 or later.",                   pszLibName );        return FALSE;    }    return( TRUE );//.........这里部分代码省略.........
开发者ID:nvdnkpr,项目名称:node-srs,代码行数:101,


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

//.........这里部分代码省略.........        int 	i, j;        int nLinesRead = 0;        int nLinesToRead = 0;        for ( i = 0; i < 4; i++)        {            for (j = InterlacedOffset[i]; j < nYSize; j += InterlacedJumps[i])             {                nLinesToRead ++;            }        }        /* Need to perform 4 passes on the images: */        for ( i = 0; i < 4; i++)        {            for (j = InterlacedOffset[i]; j < nYSize; j += InterlacedJumps[i])             {                eErr= poBand->RasterIO( GF_Read, 0, j, nXSize, 1,                                         pabyScanline, nXSize, 1, GDT_Byte,                                        1, nXSize );                if (eErr != CE_None || EGifPutLine(hGifFile, pabyScanline, nXSize) == GIF_ERROR)                {                    CPLError( CE_Failure, CPLE_AppDefined,                             "Error writing gif file." );                    goto error;                }                nLinesRead ++;                if( !pfnProgress( nLinesRead * 1.0 / nYSize, NULL, pProgressData ) )                {                    goto error;                }            }        }    }    CPLFree( pabyScanline );    pabyScanline = NULL;/* -------------------------------------------------------------------- *//*      cleanup                                                         *//* -------------------------------------------------------------------- */    if (GIFAbstractDataset::myEGifCloseFile(hGifFile) == GIF_ERROR)    {        CPLError( CE_Failure, CPLE_AppDefined,                   "EGifCloseFile() failed./n" );        hGifFile = NULL;        goto error;    }    hGifFile = NULL;    VSIFCloseL( fp );    fp = NULL;/* -------------------------------------------------------------------- *//*      Do we need a world file?                                          *//* -------------------------------------------------------------------- */    if( CSLFetchBoolean( papszOptions, "WORLDFILE", FALSE ) )    {    	double      adfGeoTransform[6];		if( poSrcDS->GetGeoTransform( adfGeoTransform ) == CE_None )            GDALWriteWorldFile( pszFilename, "wld", adfGeoTransform );    }/* -------------------------------------------------------------------- *//*      Re-open dataset, and copy any auxilary pam information.         *//* -------------------------------------------------------------------- */    /* If outputing to stdout, we can't reopen it, so we'll return */    /* a fake dataset to make the caller happy */    CPLPushErrorHandler(CPLQuietErrorHandler);    poDS = (GDALPamDataset*) GDALOpen(pszFilename, GA_ReadOnly);    CPLPopErrorHandler();    if (poDS)    {        poDS->CloneInfo( poSrcDS, GCIF_PAM_DEFAULT );        return poDS;    }    else    {        CPLErrorReset();        GIFDataset* poGIF_DS = new GIFDataset();        poGIF_DS->nRasterXSize = nXSize;        poGIF_DS->nRasterYSize = nYSize;        for(int i=0;i<nBands;i++)            poGIF_DS->SetBand( i+1, new GIFRasterBand( poGIF_DS, i+1, NULL, 0 ) );        return poGIF_DS;    }error:    if (hGifFile)        GIFAbstractDataset::myEGifCloseFile(hGifFile);    if (fp)        VSIFCloseL( fp );    if (pabyScanline)        CPLFree( pabyScanline );    return NULL;}
开发者ID:GeospatialDaryl,项目名称:VS2013__00_GDAL_111_x64,代码行数:101,



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


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