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

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

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

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

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

示例1: CPLFree

OGRErr OGRSQLiteSelectLayerCommonBehaviour::SetAttributeFilter( const char *pszQuery ){    char*& m_pszAttrQuertyString = poLayer->GetAttrQueryString();    if( m_pszAttrQuertyString == NULL && pszQuery == NULL )        return OGRERR_NONE;    CPLFree(m_pszAttrQuertyString);    m_pszAttrQuertyString = (pszQuery) ? CPLStrdup(pszQuery) : NULL;    bAllowResetReadingEvenIfIndexAtZero = TRUE;    OGRFeatureQuery oQuery;    CPLPushErrorHandler(CPLQuietErrorHandler);    int bHasSpecialFields = (pszQuery != NULL && pszQuery[0] != '/0' &&        oQuery.Compile( poLayer->GetLayerDefn(), pszQuery ) == OGRERR_NONE &&        HasSpecialFields((swq_expr_node*)oQuery.GetSWQExpr(), poLayer->GetLayerDefn()->GetFieldCount()) );    CPLPopErrorHandler();    if( bHasSpecialFields || !BuildSQL() )    {        return poLayer->BaseSetAttributeFilter(pszQuery);    }    ResetReading();    return OGRERR_NONE;}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:29,


示例2: m_isDebug

Debug::Debug(bool isDebug, pdal::LogPtr log)    : m_isDebug(isDebug)    , m_log(log){    if (m_isDebug)    {        const char* gdal_debug = ::pdal::Utils::getenv("CPL_DEBUG");        if (gdal_debug == 0)        {            pdal::Utils::putenv("CPL_DEBUG=ON");        }        m_gdal_callback = boost::bind(&Debug::log, this, _1, _2, _3);    }    else    {        m_gdal_callback = boost::bind(&Debug::error, this, _1, _2, _3);    }#if ((GDAL_VERSION_MAJOR == 1 && GDAL_VERSION_MINOR >= 9) || (GDAL_VERSION_MAJOR > 1))     CPLPushErrorHandlerEx(&Debug::trampoline, this);#else    CPLPushErrorHandler(&Debug::trampoline);#endif}
开发者ID:mweisman,项目名称:PDAL,代码行数:25,


示例3: pszEncoding

int IMapInfoFile::TestUtf8Capability() const{    const char* pszEncoding( GetEncoding() );    if( strlen( pszEncoding ) == 0 )    {        return FALSE;    }    CPLClearRecodeWarningFlags();    CPLErrorReset();    CPLPushErrorHandler(CPLQuietErrorHandler);    char* pszTest( CPLRecode( "test", GetEncoding(), CPL_ENC_UTF8 ) );    CPLPopErrorHandler();    if( pszTest == nullptr )    {        return FALSE;    }    CPLFree( pszTest );    if( CPLGetLastErrorType() != 0 )    {        return FALSE;    }    return TRUE;}
开发者ID:OSGeo,项目名称:gdal,代码行数:29,


示例4: GeoJSONStringPropertyToFieldType

OGRFieldType GeoJSONStringPropertyToFieldType( json_object* poObject ){    if (poObject == NULL) {        return OFTString;    }    const char* pszStr = json_object_get_string( poObject );    OGRField sWrkField;    CPLPushErrorHandler(CPLQuietErrorHandler);    int bSuccess = OGRParseDate( pszStr, &sWrkField, 0 );    CPLPopErrorHandler();    CPLErrorReset();    if( bSuccess )    {        int bHasDate = strchr( pszStr, '/' ) != NULL ||                       strchr( pszStr, '-' ) != NULL;        int bHasTime = strchr( pszStr, ':' ) != NULL;        if( bHasDate && bHasTime )            return OFTDateTime;        else if( bHasDate )            return OFTDate;        else            return OFTTime;    }    return OFTString;}
开发者ID:drownedout,项目名称:datamap,代码行数:26,


示例5: GetLayerDefn

OGRFeature * OGRGFTTableLayer::GetFeature( GIntBig nFID ){    GetLayerDefn();    CPLString osSQL("SELECT ROWID");    for(int i=0;i<poFeatureDefn->GetFieldCount();i++)    {        osSQL += ",";        const char* pszFieldName =            poFeatureDefn->GetFieldDefn(i)->GetNameRef();        osSQL += EscapeAndQuote(pszFieldName);    }    if (bHiddenGeometryField)    {        osSQL += ",";        osSQL += EscapeAndQuote(GetGeometryColumn());    }    osSQL += " FROM ";    osSQL += osTableId;    osSQL += CPLSPrintf(" WHERE ROWID='" CPL_FRMT_GIB "'", nFID);    CPLPushErrorHandler(CPLQuietErrorHandler);    CPLHTTPResult * psResult = poDS->RunSQL(osSQL);    CPLPopErrorHandler();    if (psResult == NULL)        return NULL;    char* pszLine = (char*) psResult->pabyData;    if (pszLine == NULL || psResult->pszErrBuf != NULL)    {        CPLHTTPDestroyResult(psResult);        return NULL;    }    /* skip header line */    pszLine = OGRGFTGotoNextLine(pszLine);    if (pszLine == NULL || pszLine[0] == 0)    {        CPLHTTPDestroyResult(psResult);        return NULL;    }    int nLen = (int)strlen(pszLine);    if (nLen > 0 && pszLine[nLen-1] == '/n')        pszLine[nLen-1] = '/0';    OGRFeature* poFeature = BuildFeatureFromSQL(pszLine);    CPLHTTPDestroyResult(psResult);    return poFeature;}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:54,


示例6: CPLPushErrorHandler

 void object::test<2>() {     if( GDALHasTriangulation() )     {         double adfX[] = { 0, 1, 2, 3 };         double adfY[] = { 0, 1, 2, 3 };         CPLPushErrorHandler(CPLQuietErrorHandler);         psDT = GDALTriangulationCreateDelaunay(4, adfX, adfY);         CPLPopErrorHandler();         ensure(psDT == nullptr);     } }
开发者ID:jef-n,项目名称:gdal,代码行数:12,


示例7: CPLPushErrorHandler

 void object::test<1>() {     if( GDALHasTriangulation() )     {         double adfX[] = { 0, -5, -5, 5, 5 };         double adfY[] = { 0, -5, 5, -5, 5 };         CPLPushErrorHandler(CPLQuietErrorHandler);         psDT = GDALTriangulationCreateDelaunay(2, adfX, adfY);         CPLPopErrorHandler();         ensure(psDT == NULL);     } }
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:12,


示例8: main

int main( int argc, char **argv ){  QCoreApplication app( argc, argv );  const QStringList args = QCoreApplication::arguments();  bool verbose = false;  for ( const QString &arg : args )  {    if ( arg == QLatin1String( "--verbose" ) )      verbose = true;  }  QgsApplication::init();  if ( !QgsApplication::isRunningFromBuildDir() )  {    char *prefixPath = getenv( "QGIS_PREFIX_PATH" );    QgsApplication::setPrefixPath( prefixPath ? prefixPath : CMAKE_INSTALL_PREFIX, TRUE );  }  if ( verbose )    std::cout << "Synchronizing CRS database with GDAL/PROJ definitions." << std::endl;  CPLPushErrorHandler( showError );  int res = QgsCoordinateReferenceSystem::syncDatabase();  CPLPopErrorHandler();  if ( res == 0 && verbose )  {    std::cout << "No CRS updates were necessary." << std::endl;  }  else if ( res > 0 && verbose )  {    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;  }  QgsApplication::exitQgis();  return 0;}
开发者ID:alexbruy,项目名称:QGIS,代码行数:52,


示例9: gv_manager_get_dataset

GDALDatasetH gv_manager_get_dataset( GvManager *manager, const char * filename){    int       i;    GvDataset *ds;    GDALDatasetH dataset;    /*     * Check for dataset in existing list of open files.  Note that our     * filename check does not account for different possible names for     * one dataset.     */    for( i = 0; i < manager->datasets->len; i++ )    {        ds = (GvDataset *) g_ptr_array_index(manager->datasets, i);        if( EQUAL(GDALGetDescription(ds->dataset),filename) )        {            return ds->dataset;        }    }    /*     * Try to open the dataset, preferably with update access.  We don't     * want to report update access errors so we supress error reporting     * temporarily.      */        CPLErrorReset();    CPLPushErrorHandler( CPLQuietErrorHandler );    dataset = GDALOpen( filename, GA_Update );    CPLPopErrorHandler();    if( dataset == NULL )    {        dataset = GDALOpen( filename, GA_ReadOnly );    }    if( dataset == NULL )        return NULL;    /*      * Add the dataset to the list of managed datasets.      */    ds = g_new(GvDataset,1);    ds->dataset = dataset;    ds->rasters = g_new0(GvRaster *, GDALGetRasterCount(dataset));        g_ptr_array_add( manager->datasets, ds );    return dataset;}
开发者ID:Onjrew,项目名称:OpenEV,代码行数:52,


示例10: GetLayerAndOverwriteIfNecessary

static OGRLayer* GetLayerAndOverwriteIfNecessary(GDALDataset *poDstDS,                                                 const char* pszNewLayerName,                                                 int bOverwrite,                                                 int* pbErrorOccured){    if( pbErrorOccured )        *pbErrorOccured = FALSE;    /* GetLayerByName() can instanciate layers that would have been */    /* 'hidden' otherwise, for example, non-spatial tables in a */    /* Postgis-enabled database, so this apparently useless command is */    /* not useless... (#4012) */    CPLPushErrorHandler(CPLQuietErrorHandler);    OGRLayer* poDstLayer = poDstDS->GetLayerByName(pszNewLayerName);    CPLPopErrorHandler();    CPLErrorReset();    int iLayer = -1;    if (poDstLayer != NULL)    {        int nLayerCount = poDstDS->GetLayerCount();        for( iLayer = 0; iLayer < nLayerCount; iLayer++ )        {            OGRLayer        *poLayer = poDstDS->GetLayer(iLayer);            if (poLayer == poDstLayer)                break;        }        if (iLayer == nLayerCount)            /* shouldn't happen with an ideal driver */            poDstLayer = NULL;    }/* -------------------------------------------------------------------- *//*      If the user requested overwrite, and we have the layer in       *//*      question we need to delete it now so it will get recreated      *//*      (overwritten).                                                  *//* -------------------------------------------------------------------- */    if( poDstLayer != NULL && bOverwrite )    {        if( poDstDS->DeleteLayer( iLayer ) != OGRERR_NONE )        {            fprintf( stderr,                     "DeleteLayer() failed when overwrite requested./n" );            if( pbErrorOccured )                *pbErrorOccured = TRUE;        }        poDstLayer = NULL;    }    return poDstLayer;}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:52,


示例11: msGDALInitialize

void msGDALInitialize( void ){  if( !bGDALInitialized ) {    msAcquireLock( TLOCK_GDAL );    GDALAllRegister();    CPLPushErrorHandler( CPLQuietErrorHandler );    msReleaseLock( TLOCK_GDAL );    bGDALInitialized = 1;  }}
开发者ID:Dafvid,项目名称:mapserver,代码行数:13,


示例12: RGDAL_OpenDataset

SEXPRGDAL_OpenDataset(SEXP filename, SEXP read_only, SEXP silent) {  const char *fn = asString(filename);  GDALAccess RWFlag;  if (asLogical(read_only))    RWFlag = GA_ReadOnly;  else    RWFlag = GA_Update;/* Modification suggested by Even Rouault, 2009-08-08: */  CPLErrorReset();  if (asLogical(silent))    CPLPushErrorHandler(CPLQuietErrorHandler);  else     installErrorHandler();  GDALDataset *pDataset = (GDALDataset *) GDALOpen(fn, RWFlag);  if (pDataset == NULL)    error("%s/n", CPLGetLastErrorMsg());  if (asLogical(silent))    CPLPopErrorHandler();  else    uninstallErrorHandlerAndTriggerError();/* Similarly to SWIG bindings, the following lines will causeRGDAL_OpenDataset() to fail on - uncleared - errors even if pDataset is notNULL. They could also be just removed. While pDataset != NULL, there's somehope ;-) *//*  CPLErr eclass = CPLGetLastErrorType();  if (pDataset != NULL && eclass == CE_Failure) {    GDALClose(pDataset);    pDataset = NULL;    __errorHandler(eclass, CPLGetLastErrorNo(), CPLGetLastErrorMsg());  }*/  SEXP sxpHandle = R_MakeExternalPtr((void *) pDataset,				     mkChar("GDAL Dataset"),				     R_NilValue);  return(sxpHandle);}
开发者ID:jeroenooms,项目名称:rgdal,代码行数:51,


示例13: osChangedSQL

int OGRGFTResultLayer::FetchNextRows(){    if (!EQUALN(osSQL.c_str(), "SELECT", 6))        return FALSE;    aosRows.resize(0);    CPLString osChangedSQL(osSQL);    if (osSQL.ifind(" OFFSET ") == std::string::npos &&        osSQL.ifind(" LIMIT ") == std::string::npos)    {        osChangedSQL += CPLSPrintf(" OFFSET %d LIMIT %d",                                   nOffset, GetFeaturesToFetch());    }    CPLPushErrorHandler(CPLQuietErrorHandler);    CPLHTTPResult * psResult = poDS->RunSQL(osChangedSQL);    CPLPopErrorHandler();    if (psResult == NULL)    {        bEOF = TRUE;        return FALSE;    }    char* pszLine = (char*) psResult->pabyData;    if (pszLine == NULL ||        psResult->pszErrBuf != NULL)    {        CPLError(CE_Failure, CPLE_AppDefined, "RunSQL() failed");        CPLHTTPDestroyResult(psResult);        bEOF = TRUE;        return FALSE;    }    pszLine = OGRGFTGotoNextLine(pszLine);    if (pszLine == NULL)    {        CPLHTTPDestroyResult(psResult);        bEOF = TRUE;        return FALSE;    }    ParseCSVResponse(pszLine, aosRows);    CPLHTTPDestroyResult(psResult);    bEOF = (int)aosRows.size() < GetFeaturesToFetch();    return TRUE;}
开发者ID:0004c,项目名称:node-gdal,代码行数:51,


示例14: osSQLCommand

OGRLayer* OGRPLScenesDataset::ExecuteSQL( const char *pszSQLCommand,                                          OGRGeometry *poSpatialFilter,                                          const char *pszDialect ){    if( EQUALN(pszSQLCommand, "SELECT ", strlen("SELECT ")) )    {        swq_select oSelect;        CPLString osSQLCommand(pszSQLCommand);        size_t nLimitPos = osSQLCommand.ifind(" limit ");        if( nLimitPos != std::string::npos )            osSQLCommand.resize(nLimitPos);        CPLPushErrorHandler(CPLQuietErrorHandler);        OGRErr eErr = oSelect.preparse(osSQLCommand);        CPLPopErrorHandler();        if( eErr != OGRERR_NONE )            return GDALDataset::ExecuteSQL(pszSQLCommand, poSpatialFilter, pszDialect);/* -------------------------------------------------------------------- *//*      ORDER BY optimization on acquired field                         *//* -------------------------------------------------------------------- */        if( oSelect.join_count == 0 && oSelect.poOtherSelect == NULL &&            oSelect.table_count == 1 && oSelect.order_specs == 1 &&            strcmp(oSelect.order_defs[0].field_name, "acquired") == 0 )        {            int idx;            OGRPLScenesLayer* poLayer = NULL;            for(idx = 0; idx < nLayers; idx ++ )            {                if( strcmp( papoLayers[idx]->GetName(),                            oSelect.table_defs[0].table_name) == 0 )                {                    poLayer = papoLayers[idx];                    break;                }            }            if( poLayer != NULL )            {                poLayer->SetAcquiredOrderingFlag(                                        oSelect.order_defs[0].ascending_flag);                OGRLayer* poRet = GDALDataset::ExecuteSQL(pszSQLCommand, poSpatialFilter, pszDialect);                if( poRet )                    oMapResultSetToSourceLayer[poRet] = poLayer;                return poRet;            }        }    }    return GDALDataset::ExecuteSQL(pszSQLCommand, poSpatialFilter, pszDialect);}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:49,


示例15: OGR2SQLITE_ST_Area

staticvoid OGR2SQLITE_ST_Area(sqlite3_context* pContext,                        int argc, sqlite3_value** argv){    OGRGeometry* poGeom = OGR2SQLITE_GetGeom(pContext, argc, argv, NULL);    if( poGeom != NULL )    {        CPLPushErrorHandler(CPLQuietErrorHandler);        sqlite3_result_double( pContext, OGR_G_Area((OGRGeometryH)poGeom) );        CPLPopErrorHandler();    }    else        sqlite3_result_null(pContext);    delete poGeom;}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:15,


示例16: OGR2SQLITE_ST_SRID

staticvoid OGR2SQLITE_ST_SRID(sqlite3_context* pContext,                        int argc, sqlite3_value** argv){    int nSRSId = -1;    OGRGeometry* poGeom = OGR2SQLITE_GetGeom(pContext, argc, argv, &nSRSId);    if( poGeom != NULL )    {        CPLPushErrorHandler(CPLQuietErrorHandler);        sqlite3_result_int( pContext, nSRSId );        CPLPopErrorHandler();    }    else        sqlite3_result_null(pContext);    delete poGeom;}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:16,


示例17: p4s_from_spatial_reference

Rcpp::CharacterVector p4s_from_spatial_reference(OGRSpatialReference *ref) {	Rcpp::CharacterVector proj4string(1);	char *cp;	CPLPushErrorHandler(CPLQuietErrorHandler); // don't break on EPSG's without proj4string	ref->morphFromESRI();	(void) ref->exportToProj4(&cp);	// eliminate trailing white space, the C-way:	if (strlen(cp) > 0)		for (char *cpws = cp + strlen(cp) - 1; cpws != cp && *cpws == ' '; cpws--)			*cpws = '/0';	proj4string[0] = cp;	CPLFree(cp);	CPLPopErrorHandler();	return proj4string;}
开发者ID:rundel,项目名称:sfr,代码行数:17,


示例18: CPLPushErrorHandlerEx

GlobalDebug::GlobalDebug(){    const char* gdal_debug = ::pdal::Utils::getenv("CPL_DEBUG");    if (gdal_debug == 0)    {        pdal::Utils::putenv("CPL_DEBUG=ON");    }    m_gdal_callback = boost::bind(&GlobalDebug::log, this, _1, _2, _3);#if ((GDAL_VERSION_MAJOR == 1 && GDAL_VERSION_MINOR >= 9) || (GDAL_VERSION_MAJOR > 1))     CPLPushErrorHandlerEx(&GlobalDebug::trampoline, this);#else    CPLPushErrorHandler(&GlobalDebug::trampoline);#endif}
开发者ID:mweisman,项目名称:PDAL,代码行数:17,


示例19: CSLAddString

char* OGRCouchDBDataSource::GetETag(const char* pszURI){    // make a head request and only return the etag response header    char* pszEtag = NULL;    char **papszTokens;    char** papszOptions = NULL;    bMustCleanPersistant = TRUE;    papszOptions = CSLAddString(papszOptions, CPLSPrintf("PERSISTENT=CouchDB:%p", this));    papszOptions = CSLAddString(papszOptions, "HEADERS=Content-Type: application/json");    papszOptions = CSLAddString(papszOptions, "NO_BODY=1");        if (osUserPwd.size())    {        CPLString osUserPwdOption("USERPWD=");        osUserPwdOption += osUserPwd;        papszOptions = CSLAddString(papszOptions, osUserPwdOption);    }    CPLDebug("CouchDB", "HEAD %s", pszURI);    CPLString osFullURL(osURL);    osFullURL += pszURI;    CPLPushErrorHandler(CPLQuietErrorHandler);    CPLHTTPResult * psResult = CPLHTTPFetch( osFullURL, papszOptions);    CPLPopErrorHandler();    CSLDestroy(papszOptions);    if (psResult == NULL)        return NULL;    if (CSLFetchNameValue(psResult->papszHeaders, "Etag") != NULL)    {        papszTokens =             CSLTokenizeString2( CSLFetchNameValue(psResult->papszHeaders, "Etag"), "/"/r/n", 0 );                pszEtag = CPLStrdup(papszTokens[0]);        CSLDestroy( papszTokens );    }    CPLHTTPDestroyResult(psResult);    return pszEtag;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:46,


示例20: CPLPushErrorHandler

void gdal::fast_delete_and_close( gdal::dataset_unique_ptr &dataset, GDALDriverH driver, const QString &path ){  // see https://github.com/qgis/QGIS/commit/d024910490a39e65e671f2055c5b6543e06c7042#commitcomment-25194282  // faster if we close the handle AFTER delete, but doesn't work for windows#ifdef Q_OS_WIN  // close dataset handle  dataset.reset();#endif  CPLPushErrorHandler( CPLQuietErrorHandler );  GDALDeleteDataset( driver, path.toUtf8().constData() );  CPLPopErrorHandler();#ifndef Q_OS_WIN  // close dataset handle  dataset.reset();#endif}
开发者ID:CS-SI,项目名称:QGIS,代码行数:18,


示例21: GDALDriver

 // Test that GDALWarp() detects error in flush cache template<> template<> void object::test<9>() {     GDALDriver* poDriver = new GDALDriver();     poDriver->SetDescription("DatasetWithErrorInFlushCache");     poDriver->pfnCreate = DatasetWithErrorInFlushCache::Create;     GetGDALDriverManager()->RegisterDriver( poDriver );     const char* args[] = { "-of", "DatasetWithErrorInFlushCache", NULL };     GDALWarpAppOptions* psOptions = GDALWarpAppOptionsNew((char**)args, NULL);     GDALDatasetH hSrcDS = GDALOpen("../gcore/data/byte.tif", GA_ReadOnly);     CPLErrorReset();     CPLPushErrorHandler(CPLQuietErrorHandler);     GDALDatasetH hOutDS = GDALWarp("/", NULL, 1, &hSrcDS, psOptions, NULL);     CPLPopErrorHandler();     GDALClose(hSrcDS);     GDALWarpAppOptionsFree(psOptions);     ensure(hOutDS == NULL);     ensure(CPLGetLastErrorType() != CE_None);     GetGDALDriverManager()->DeregisterDriver( poDriver );     delete poDriver; }
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:21,


示例22: 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:bbradbury,项目名称:lib_gdal,代码行数:40,


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


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


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


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


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


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


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


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



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


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