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


C++ GDALDriver::GetName方法代码示例

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


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

示例1: ogrInfo

// extern "C" {
SEXP ogrInfo(SEXP ogrsourcename, SEXP Layer) {
    // return FIDs, nFields, fieldInfo

    SEXP ans, vec1, vec2, vec3,/*mat,*/drv, dvec;
    SEXP itemlist, itemnames, itemwidth, itemtype, itemTypeNames;
    SEXP itemlistmaxcount;
#ifdef GDALV2
    SEXP dFIDs;
#endif
    /*SEXP geotype;*/

    int nFIDs, nFields, iField, *nCount, pc=0;

#ifdef GDALV2
    GDALDriver *poDriver;
    GDALDataset *poDS;
#else
    OGRDataSource *poDS;
    OGRSFDriver *poDriver;
#endif
    OGRLayer *poLayer;
    OGRFeature *poFeature;
    OGRFeatureDefn *poDefn;
    /*  OGRGeometry *poGeom;*/

    installErrorHandler();
#ifdef GDALV2
    poDS=(GDALDataset*) GDALOpenEx(CHAR(STRING_ELT(ogrsourcename, 0)), GDAL_OF_VECTOR, NULL, NULL, NULL);
    if(poDS==NULL) {
        uninstallErrorHandlerAndTriggerError();
        error("Cannot open data source");
    }
    poDriver = poDS->GetDriver();
#else
    poDS=OGRSFDriverRegistrar::Open(CHAR(STRING_ELT(ogrsourcename, 0)),
                                    FALSE, &poDriver);
#endif
    uninstallErrorHandlerAndTriggerError();

    if(poDS==NULL) {
        installErrorHandler();
#ifdef GDALV2
        GDALClose( poDS );
#else
        OGRDataSource::DestroyDataSource( poDS );
#endif
        uninstallErrorHandlerAndTriggerError();
//    delete poDS;
        error("Cannot open file");
    }

    installErrorHandler();
    poLayer = poDS->GetLayerByName(CHAR(STRING_ELT(Layer, 0)));
    uninstallErrorHandlerAndTriggerError();

    if(poLayer == NULL) {
        installErrorHandler();
#ifdef GDALV2
        GDALClose( poDS );
#else
        OGRDataSource::DestroyDataSource( poDS );
#endif
        uninstallErrorHandlerAndTriggerError();
//    delete poDS;
        error("Cannot open layer");
    }

    // allocate a list for return values
    PROTECT(ans=allocVector(VECSXP,6));
    pc++;

    PROTECT(drv=allocVector(STRSXP,1));
    pc++;
    installErrorHandler();
#ifdef GDALV2
    SET_STRING_ELT(drv, 0, mkChar(poDriver->GetDescription()));
#else
    SET_STRING_ELT(drv, 0, mkChar(poDriver->GetName()));
#endif
    uninstallErrorHandlerAndTriggerError();
    SET_VECTOR_ELT(ans,3,drv);

    PROTECT(vec1=allocVector(INTSXP,1));
    pc++;
    installErrorHandler();
#ifdef GDALV2
    GIntBig nFIDs64 = poLayer->GetFeatureCount();
    nFIDs = (nFIDs64 > INT_MAX) ? INT_MAX :
            (nFIDs64 < INT_MIN) ? INT_MIN : (int) nFIDs64;
    if ((GIntBig) nFIDs != nFIDs64) {
        warning("ogrInfo: feature count overflow");
        INTEGER(vec1)[0]=NA_INTEGER;
        PROTECT(dFIDs=NEW_NUMERIC(1));
        pc++;
        NUMERIC_POINTER(dFIDs)[0] = (double) nFIDs64;
        setAttrib(vec1, install("dFIDs"), dFIDs);
    } else {
        // store number of FIDs
        INTEGER(vec1)[0]=nFIDs;
//.........这里部分代码省略.........
开发者ID:rforge,项目名称:rgdal,代码行数:101,代码来源:ogrsource.cpp

示例2: ogrCheckExists

SEXP ogrCheckExists (SEXP ogrSource, SEXP Layer) {
    OGRLayer *poLayer;
#ifdef GDALV2
    GDALDataset *poDS;
    GDALDriver *poDriver;
#else
    OGRDataSource *poDS;
    OGRSFDriver *poDriver;
#endif
    SEXP ans, drv;
    int pc=0;
    PROTECT(ans=NEW_LOGICAL(1));
    pc++;

    installErrorHandler();
#ifdef GDALV2
    poDS=(GDALDataset*) GDALOpenEx(CHAR(STRING_ELT(ogrSource, 0)), GDAL_OF_VECTOR, NULL, NULL, NULL);
    if (poDS != NULL) poDriver = poDS->GetDriver();
#else
    poDS=OGRSFDriverRegistrar::Open(CHAR(STRING_ELT(ogrSource, 0)),
                                    FALSE, &poDriver);
#endif
    uninstallErrorHandlerAndTriggerError();

    if (poDS==NULL) {
//      installErrorHandler();
//      OGRDataSource::DestroyDataSource( poDS );
//      uninstallErrorHandlerAndTriggerError();
//    delete poDS;
        LOGICAL_POINTER(ans)[0] = FALSE;
        UNPROTECT(pc);
        return(ans);
    }

    installErrorHandler();
    poLayer = poDS->GetLayerByName(CHAR(STRING_ELT(Layer, 0)));
    uninstallErrorHandlerAndTriggerError();

    if (poLayer == NULL) {
        installErrorHandler();
#ifdef GDALV2
        GDALClose( poDS );
#else
        OGRDataSource::DestroyDataSource( poDS );
#endif
        uninstallErrorHandlerAndTriggerError();
//    delete poDS;
        LOGICAL_POINTER(ans)[0] = FALSE;
        UNPROTECT(pc);
        return(ans);
    }

    LOGICAL_POINTER(ans)[0] = TRUE;

    PROTECT(drv=allocVector(STRSXP,1));
    pc++;
    installErrorHandler();
#ifdef GDALV2
    SET_STRING_ELT(drv, 0, mkChar(poDriver->GetDescription()));
#else
    SET_STRING_ELT(drv, 0, mkChar(poDriver->GetName()));
#endif
    uninstallErrorHandlerAndTriggerError();
    setAttrib(ans, install("driver"), drv);

    installErrorHandler();
#ifdef GDALV2
    GDALClose( poDS );
#else
    OGRDataSource::DestroyDataSource( poDS );
#endif
    uninstallErrorHandlerAndTriggerError();
//    delete poDS;
    UNPROTECT(pc);
    return(ans);
}
开发者ID:rforge,项目名称:rgdal,代码行数:76,代码来源:ogrsource.cpp

示例3: ogrListLayers

SEXP ogrListLayers (SEXP ogrSource) {
#ifdef GDALV2
    GDALDataset *poDS;
    GDALDriver *poDriver;
#else
    OGRDataSource *poDS;
    OGRSFDriver *poDriver;
#endif
    OGRLayer *poLayer;
    int i, nlayers;
    SEXP ans, debug;
    int pc=0;

    installErrorHandler();
#ifdef GDALV2
    poDS=(GDALDataset*) GDALOpenEx(CHAR(STRING_ELT(ogrSource, 0)), GDAL_OF_VECTOR, NULL, NULL, NULL);
    if(poDS==NULL) {
        uninstallErrorHandlerAndTriggerError();
        error("Cannot open data source");
    }
    poDriver = poDS->GetDriver();
#else
    poDS=OGRSFDriverRegistrar::Open(CHAR(STRING_ELT(ogrSource, 0)),
                                    FALSE, &poDriver);
#endif
    uninstallErrorHandlerAndTriggerError();

    if(poDS==NULL) {
        error("Cannot open data source");
    }

    debug = getAttrib(ogrSource, mkString("debug"));
    installErrorHandler();
    nlayers = poDS->GetLayerCount();
    uninstallErrorHandlerAndTriggerError();
    if (LOGICAL_POINTER(debug)[0] == TRUE)
        Rprintf("ogrListLayers: nlayers %d\n", nlayers);

    PROTECT(ans=NEW_CHARACTER(nlayers+1));
    pc++;

    for (i=0; i<nlayers; i++) {
        installErrorHandler();
        poLayer = poDS->GetLayer(i);

        if(poLayer == NULL) {
            if (LOGICAL_POINTER(debug)[0] == TRUE) {
                SET_STRING_ELT(ans, i, mkChar(""));
                Rprintf("ogrListLayers: NULL layer %d\n", i);
            } else {
                uninstallErrorHandlerAndTriggerError();
                error("Cannot open layer");
            }
        } else {
            SET_STRING_ELT(ans, i, mkChar(poLayer->GetLayerDefn()->GetName()));
        }
        uninstallErrorHandlerAndTriggerError();
    }

    installErrorHandler();
#ifdef GDALV2
    SET_STRING_ELT(ans, nlayers, mkChar(poDriver->GetDescription()));
#else
    SET_STRING_ELT(ans, nlayers, mkChar(poDriver->GetName()));
#endif
    uninstallErrorHandlerAndTriggerError();

    installErrorHandler();
#ifdef GDALV2
    GDALClose( poDS );
#else
    OGRDataSource::DestroyDataSource( poDS );
#endif
    uninstallErrorHandlerAndTriggerError();

    UNPROTECT(pc);
    return(ans);

}
开发者ID:rforge,项目名称:rgdal,代码行数:79,代码来源:ogrsource.cpp


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