Commit 1c53a131 authored by Julien Michel's avatar Julien Michel

BUG: GdalOpenEx should be used to open vector data

parent 91d7a1ee
......@@ -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)
{
......
......@@ -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
......
......@@ -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";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment