diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx index f0943171d6401fd914afee1714a553f1f903a40b..565abffff3128cba87cd440168af5a1cc696873b 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRDataSourceWrapper.cxx @@ -141,7 +141,7 @@ otb::ogr::DataSource::Pointer otb::ogr::DataSource::OpenDataSource(std::string c { bool update = (mode != Modes::Read); - GDALDataset * source = (GDALDataset *)GDALOpen(datasourceName.c_str(), (update?GA_Update:GA_ReadOnly)); + GDALDataset * source = (GDALDataset *)GDALOpenEx(datasourceName.c_str(), (update? GDAL_OF_UPDATE : GDAL_OF_READONLY) | GDAL_OF_VECTOR,NULL,NULL,NULL); if (!source) { // In read mode, this is a failure @@ -179,7 +179,7 @@ otb::ogr::DataSource::Pointer otb::ogr::DataSource::OpenDataSource(std::string c void DeleteDataSource(std::string const& datasourceName) { // Attempt to delete the datasource if it already exists - GDALDataset * poDS = (GDALDataset *)GDALOpen(datasourceName.c_str(), GA_Update); + GDALDataset * poDS = (GDALDataset *)GDALOpenEx(datasourceName.c_str(), GDAL_OF_UPDATE | GDAL_OF_VECTOR,NULL,NULL,NULL); if (poDS != NULL) { diff --git a/Modules/IO/IOGDAL/src/otbOGRVectorDataIO.cxx b/Modules/IO/IOGDAL/src/otbOGRVectorDataIO.cxx index 2be24e9b784332b88f6dbc67e64741ea575434ee..2e8146f1796346af70ea40ab59db60a4c5888398 100644 --- a/Modules/IO/IOGDAL/src/otbOGRVectorDataIO.cxx +++ b/Modules/IO/IOGDAL/src/otbOGRVectorDataIO.cxx @@ -56,10 +56,11 @@ OGRVectorDataIO::CanReadFile(const char* filename) const { - GDALDataset * poDS = (GDALDataset *)GDALOpen(filename, GA_ReadOnly); + GDALDataset * poDS = (GDALDataset *)GDALOpenEx(filename, GDAL_OF_READONLY | GDAL_OF_VECTOR, NULL, NULL,NULL); if (poDS == NULL) { + std::cerr<<"Can not read file "<<filename<<" with GDALOpen"<<std::endl; return false; } // std::cout << poDS->GetDriver()->GetName() << std::endl; @@ -94,7 +95,7 @@ OGRVectorDataIO GDALClose(m_DataSource); } - m_DataSource = (GDALDataset *)GDALOpen(this->m_FileName.c_str(), GA_ReadOnly); + m_DataSource = (GDALDataset *)GDALOpenEx(this->m_FileName.c_str(), GA_ReadOnly| GDAL_OF_VECTOR,NULL,NULL,NULL); if (m_DataSource == NULL) { @@ -227,7 +228,7 @@ void OGRVectorDataIO::Write(const itk::DataObject* datag, char ** papszOptions) // Erase the dataSource if already exist //TODO investigate the possibility of giving the option OVERWRITE=YES to the CreateDataSource method - GDALDataset * poDS = (GDALDataset *)GDALOpen(this->m_FileName.c_str(), GA_Update); + GDALDataset * poDS = (GDALDataset *)GDALOpenEx(this->m_FileName.c_str(), GDAL_OF_UPDATE | GDAL_OF_VECTOR,NULL,NULL,NULL); if (poDS != NULL) { //Erase the data if possible diff --git a/Modules/IO/TestKernel/src/otbTestHelper.cxx b/Modules/IO/TestKernel/src/otbTestHelper.cxx index 62b83b4f79e7a2a1b01fac3aafadc5ffac9c7f84..85a1bc9d08820c0e6314f09c49c3f3151d2c2675 100644 --- a/Modules/IO/TestKernel/src/otbTestHelper.cxx +++ b/Modules/IO/TestKernel/src/otbTestHelper.cxx @@ -1081,20 +1081,20 @@ int TestHelper::RegressionTestOgrFile(const char *testOgrFilename, const char *b GDALDriver * test_poDriver = NULL; //OGRGeometry * test_poSpatialFilter = NULL; - ref_poDS = (GDALDataset*)GDALOpen(ref_pszDataSource, GA_Update); + ref_poDS = (GDALDataset*)GDALOpenEx(ref_pszDataSource, GDAL_OF_UPDATE | GDAL_OF_VECTOR,NULL,NULL,NULL); if (ref_poDS == NULL && !bReadOnly) { - ref_poDS = (GDALDataset*)GDALOpen(ref_pszDataSource, GA_ReadOnly); + ref_poDS = (GDALDataset*)GDALOpenEx(ref_pszDataSource, GDAL_OF_READONLY | GDAL_OF_VECTOR,NULL,NULL,NULL); if (ref_poDS != NULL && m_ReportErrors) { std::cout << "Had to open REF data source read-only.\n"; bReadOnly = TRUE; } } - test_poDS = (GDALDataset*)GDALOpen(test_pszDataSource, (bReadOnly?GA_ReadOnly:GA_Update)); + test_poDS = (GDALDataset*)GDALOpenEx(test_pszDataSource, (bReadOnly? GDAL_OF_READONLY : GDAL_OF_UPDATE) | GDAL_OF_VECTOR,NULL,NULL,NULL); if (test_poDS == NULL && !bReadOnly) { - test_poDS = (GDALDataset*)GDALOpen(test_pszDataSource, GA_ReadOnly); + test_poDS = (GDALDataset*)GDALOpenEx(test_pszDataSource, GDAL_OF_READONLY | GDAL_OF_VECTOR,NULL,NULL,NULL); if (test_poDS != NULL && m_ReportErrors) { std::cout << "Had to open REF data source read-only.\n";