本文整理汇总了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;
//.........这里部分代码省略.........
示例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);
}
示例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);
}