本文整理汇总了C++中GDALDriver::Open方法的典型用法代码示例。如果您正苦于以下问题:C++ GDALDriver::Open方法的具体用法?C++ GDALDriver::Open怎么用?C++ GDALDriver::Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GDALDriver
的用法示例。
在下文中一共展示了GDALDriver::Open方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ogrDeleteLayer
SEXP ogrDeleteLayer (SEXP ogrSource, SEXP Layer, SEXP ogrDriver) {
OGRLayer *poLayer;
#ifdef GDALV2
GDALDataset *poDS;
GDALDriver *poDriver;
#else
OGRDataSource *poDS;
OGRSFDriver *poDriver;
#endif
int iLayer = -1;
int flag = 0;
installErrorHandler();
#ifdef GDALV2
poDriver = GetGDALDriverManager()->GetDriverByName(CHAR(STRING_ELT(ogrDriver, 0)));
#else
poDriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(
CHAR(STRING_ELT(ogrDriver, 0)) );
#endif
uninstallErrorHandlerAndTriggerError();
if (poDriver == NULL) {
error("Driver not available");
}
installErrorHandler();
#ifdef GDALV2
poDS=(GDALDataset*) GDALOpenEx(CHAR(STRING_ELT(ogrSource, 0)), GDAL_OF_VECTOR, NULL, NULL, NULL);
if(poDS==NULL) {
error("Cannot open data source");
}
if (!EQUAL(CHAR(STRING_ELT(ogrDriver, 0)),
poDS->GetDriver()->GetDescription())) {
GDALClose( poDS );
poDS = NULL;
}
#else
poDS = poDriver->Open(CHAR(STRING_ELT(ogrSource, 0)),
TRUE);
#endif
uninstallErrorHandlerAndTriggerError();
if (poDS==NULL)
error("Cannot open data source for update");
installErrorHandler();
for(iLayer = 0; iLayer < poDS->GetLayerCount(); iLayer++) {
poLayer = poDS->GetLayer(iLayer);
#ifdef GDALV2
if (poLayer != NULL && EQUAL(poLayer->GetName(),
CHAR(STRING_ELT(Layer, 0)))) {
flag = 1;
break;
}
#else
if (poLayer != NULL && EQUAL(poLayer->GetLayerDefn()->GetName(),
CHAR(STRING_ELT(Layer, 0)))) {
flag = 1;
break;
}
#endif
}
uninstallErrorHandlerAndTriggerError();
installErrorHandler();
if (flag != 0) {
int res = poDS->DeleteLayer(iLayer);
if (res != OGRERR_NONE) {
#ifdef GDALV2
GDALClose( poDS );
#else
OGRDataSource::DestroyDataSource( poDS );
#endif
uninstallErrorHandlerAndTriggerError();
error("ogrDeleteLayer: failed to delete layer");
}
} else {
warning("ogrDeleteLayer: no such layer");
}
#ifdef GDALV2
GDALClose( poDS );
#else
OGRDataSource::DestroyDataSource( poDS );
#endif
uninstallErrorHandlerAndTriggerError();
return(R_NilValue);
}