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


C++ OGRDataSource::Release方法代码示例

本文整理汇总了C++中OGRDataSource::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRDataSource::Release方法的具体用法?C++ OGRDataSource::Release怎么用?C++ OGRDataSource::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OGRDataSource的用法示例。


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

示例1: VectortoRaster

int Raster::VectortoRaster(const char * sVectorSourcePath,
                           const char * sRasterOutputPath,
                           double dCellWidth,
                           const char * psFieldName){

    OGRRegisterAll();
    OGRDataSource * pDSVectorInput;
    pDSVectorInput = OGRSFDriverRegistrar::Open( sVectorSourcePath, FALSE );
    if (pDSVectorInput == NULL)
        return INPUT_FILE_ERROR;

    // Get the extents of the file before passing it off to the function that actually burns
    // the geometries
    // -------------------------------------------------------
    // Note: we're just grabbing the first layer here. If we get into needing multiple layers
    // Then we'll need to re-think this.
    OGRLayer * poLayer = pDSVectorInput->GetLayer(0);

    if (poLayer == NULL)
        return VECTOR_LAYER_NOT_FOUND;

    OGREnvelope psExtent;
    poLayer->GetExtent(&psExtent, TRUE);

    double dMaxY, dMaxX, dMinY, dMinX;
    double cellWidth =  fabs(dCellWidth);

    dMaxY = ceil(psExtent.MaxY / cellWidth) * cellWidth;
    dMaxX = ceil(psExtent.MaxX / cellWidth) * cellWidth;
    dMinY = floor(psExtent.MinY / cellWidth) * cellWidth;
    dMinX = floor(psExtent.MinX / cellWidth) * cellWidth;

    int nRows = (int)((dMaxY - dMinY) / cellWidth);
    int nCols = (int)((dMaxX - dMinX) / cellWidth);
\
    // We're going to create them without projections. The projections get set later.
    double fNoDataValue = (double) -std::numeric_limits<float>::max();
    GDALDataType nDType = GDT_Float32;
    double dCellHeight = -dCellWidth;
    RasterMeta TemplateRaster(psExtent.MaxY, psExtent.MinX, nRows, nCols, &dCellHeight, &dCellWidth, &fNoDataValue, "GTiff", &nDType, "");

    pDSVectorInput->Release();
    return VectortoRaster(sVectorSourcePath, sRasterOutputPath, psFieldName, &TemplateRaster);

}
开发者ID:JamesSLC,项目名称:rasterman,代码行数:45,代码来源:raster_vector2raster.cpp

示例2: OGR2SQLITE_ogr_datasource_load_layers

static
void OGR2SQLITE_ogr_datasource_load_layers(sqlite3_context* pContext,
        int argc, sqlite3_value** argv)
{
    sqlite3* hDB = (sqlite3*) sqlite3_user_data(pContext);

    if( (argc < 1 || argc > 3) || sqlite3_value_type (argv[0]) != SQLITE_TEXT )
    {
        sqlite3_result_int (pContext, 0);
        return;
    }
    const char* pszDataSource = (const char*) sqlite3_value_text(argv[0]);

    int bUpdate = FALSE;
    if( argc >= 2 )
    {
        if( sqlite3_value_type(argv[1]) != SQLITE_INTEGER )
        {
            sqlite3_result_int (pContext, 0);
            return;
        }
        bUpdate = sqlite3_value_int(argv[1]);
    }

    const char* pszPrefix = NULL;
    if( argc >= 3 )
    {
        if( sqlite3_value_type(argv[2]) != SQLITE_TEXT )
        {
            sqlite3_result_int (pContext, 0);
            return;
        }
        pszPrefix = (const char*) sqlite3_value_text(argv[2]);
    }

    OGRDataSource* poDS = (OGRDataSource*)OGROpenShared(pszDataSource, bUpdate, NULL);
    if( poDS == NULL )
    {
        CPLError(CE_Failure, CPLE_AppDefined, "Cannot open %s", pszDataSource);
        sqlite3_result_int (pContext, 0);
        return;
    }

    CPLString osEscapedDataSource = OGRSQLiteEscape(pszDataSource);
    for(int i=0; i<poDS->GetLayerCount(); i++)
    {
        const char* pszLayerName = poDS->GetLayer(i)->GetName();
        CPLString osEscapedLayerName = OGRSQLiteEscape(pszLayerName);
        CPLString osTableName;
        if( pszPrefix != NULL )
        {
            osTableName = pszPrefix;
            osTableName += "_";
            osTableName += OGRSQLiteEscapeName(pszLayerName);
        }
        else
        {
            osTableName = OGRSQLiteEscapeName(pszLayerName);
        }

        char* pszErrMsg = NULL;
        if( sqlite3_exec(hDB, CPLSPrintf(
                             "CREATE VIRTUAL TABLE \"%s\" USING VirtualOGR('%s', %d, '%s')",
                             osTableName.c_str(),
                             osEscapedDataSource.c_str(),
                             bUpdate,
                             osEscapedLayerName.c_str()),
                         NULL, NULL, &pszErrMsg) != SQLITE_OK )
        {
            CPLError(CE_Failure, CPLE_AppDefined,
                     "Cannot create table \"%s\" : %s",
                     osTableName.c_str(), pszErrMsg);
            sqlite3_free(pszErrMsg);
        }
    }

    poDS->Release();
    sqlite3_result_int (pContext, 1);
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:79,代码来源:ogrsqlitesqlfunctions.cpp


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