Commit e7c0579c authored by Julien Michel's avatar Julien Michel

ENH: Changing static class for dedicated namespace, as suggested on otb-developers

parent 60452145
......@@ -147,7 +147,7 @@ public:
* \note No condition is assumed on the non-nullity of \c source.
* \see \c DataSource(GDALDataset *)
*/
static Pointer New(OGRVersionProxy::GDALDatasetType * sourcemode, Modes::type mode = Modes::Read);
static Pointer New(ogr::version_proxy::GDALDatasetType * sourcemode, Modes::type mode = Modes::Read);
//@}
/**\name Projection Reference property */
......@@ -284,7 +284,7 @@ public:
* \throw None
* \post Assumes ownership of the \c source.
*/
void Reset(OGRVersionProxy::GDALDatasetType * source);
void Reset(ogr::version_proxy::GDALDatasetType * source);
/**\name Layers modification */
//@{
......@@ -480,7 +480,7 @@ public:
* \warning You must under no circonstance try to delete the \c GDALDataset
* obtained this way.
*/
OGRVersionProxy::GDALDatasetType & ogr();
ogr::version_proxy::GDALDatasetType & ogr();
protected:
/** Default constructor.
......@@ -496,7 +496,7 @@ protected:
/** Init constructor.
* \post The newly constructed object owns the \c source parameter.
*/
DataSource(OGRVersionProxy::GDALDatasetType * source, Modes::type mode);
DataSource(ogr::version_proxy::GDALDatasetType * source, Modes::type mode);
/** Destructor.
* \post The \c GDALDataset owned is released (if not null).
*/
......@@ -533,7 +533,7 @@ private:
std::string GetDatasetDescription() const;
private:
OGRVersionProxy::GDALDatasetType *m_DataSource;
ogr::version_proxy::GDALDatasetType *m_DataSource;
Modes::type m_OpenMode;
int m_FirstModifiableLayerID;
}; // end class DataSource
......
......@@ -38,7 +38,7 @@
// to the compilation mode of the client code.
inline
otb::OGRVersionProxy::GDALDatasetType & otb::ogr::DataSource::ogr()
otb::ogr::version_proxy::GDALDatasetType & otb::ogr::DataSource::ogr()
{
assert(m_DataSource && "GDALDataset not initialized");
return *m_DataSource;
......
......@@ -105,7 +105,7 @@ public:
* OGRDataSource::ExecuteSQL(). It's actually the constructor called by \c
* DataSource::ExecuteSQL().
*/
Layer(OGRLayer* layer, otb::OGRVersionProxy::GDALDatasetType& sourceInChargeOfLifeTime, bool modifiable);
Layer(OGRLayer* layer, otb::ogr::version_proxy::GDALDatasetType& sourceInChargeOfLifeTime, bool modifiable);
//@}
/**\name Features collection */
......
......@@ -32,25 +32,27 @@ class OGRSFDriver;
namespace otb
{
namespace ogr
{
namespace version_proxy
{
/**
* \brief This class serves as a proxy hiding interface changes in gdal 2.0
* This namespace holds proxy functions hiding interface changes in gdal 2.0
*
* This static class serves as a proxy hiding interface changes in OGR
* This namespace holds proxy functions hiding interface changes in OGR
* dataset between gdal 1.x (x>10) and gdal 2.x. It defines a common
* interface that should be used in place of calling directly the
* wrapped gdal methods.
* wrapped gdal functions.
*
* Whenever GDALDataset and GDALDriver have to be used to open a
* vector dataset (or OGRDataSource an OGRSFDriver for gdal 1.x), one
* should use OGRVersionProxy type members GDALDatasetType and
* should use ogr::version_proxy types GDALDatasetType and
* GDALDriverType.
*
* See static method documentation for details.
* See function documentation for details.
*/
class OGRVersionProxy
{
public:
#ifdef OTB_USE_GDAL_20
typedef GDALDataset GDALDatasetType;
typedef GDALDriver GDALDriverType;
......@@ -60,7 +62,7 @@ public:
#endif
/**
* This method opens a file, possibly in read-only mode, and returns
* This function opens a file, possibly in read-only mode, and returns
* a dataset.
*
* Calls OGRSFDriverRegistrar::Open for gdal 1.x implementation and GDALopenEx for
......@@ -70,10 +72,10 @@ public:
* \param readOnly: If true, dataset is open in read-only mode.
* \return NULL if file could not be open.
*/
static GDALDatasetType * Open(const char * filename, bool readOnly = true);
GDALDatasetType * Open(const char * filename, bool readOnly = true);
/**
* This method closes a dataset.
* This function closes a dataset.
*
* Calls OGRDataSource::DestroyDataSource for gdal 1.x
* implementation and GDALClose for gdal 2.x implementation.
......@@ -81,10 +83,10 @@ public:
* \param dataset Pointer to the dataset to close. Will not be
* checked for null pointer.
*/
static void Close(GDALDatasetType * dataset);
void Close(GDALDatasetType * dataset);
/**
* This method creates a new dataset.
* This function creates a new dataset.
*
* Calls OGRSFDriver::CreateDataSource for gdal 1.x implementation
* and GDALDriver::Create with (0,0) raster size for gdal 2.x
......@@ -97,11 +99,11 @@ public:
*
* \return NULL if dataset could not be created.
*/
static GDALDatasetType * Create(GDALDriverType * driver, const char * name);
GDALDatasetType * Create(GDALDriverType * driver, const char * name);
/**
* This method physically deletes an existing dataset.
* This function physically deletes an existing dataset.
*
* Calls OGRDataSource::DeleteDataSource for gdal 1.x implementation
* and GDALDriver::Delete for gdal 2.x implementation.
......@@ -111,10 +113,10 @@ public:
*
* \param name Name of the dataset to destroy.
*/
static bool Delete(GDALDriverType * driver, const char * name);
bool Delete(GDALDriverType * driver, const char * name);
/**
* This method returns a pointer to the driver from its name.
* This function returns a pointer to the driver from its name.
*
* Calls OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName() for
* gdal 1.x implementation and
......@@ -125,7 +127,7 @@ public:
*
* \return NULL if no driver could be retrieved.
*/
static GDALDriverType * GetDriverByName(const char * name);
GDALDriverType * GetDriverByName(const char * name);
/**
* Test driver and dataset for a given capability.
......@@ -143,7 +145,7 @@ public:
*
* \return True if the capability is supported.
*/
static bool TestCapability(const GDALDriverType * driver, const GDALDatasetType * dataset, const char * capability);
bool TestCapability(const GDALDriverType * driver, const GDALDatasetType * dataset, const char * capability);
/**
* Sync dataset to disk.
......@@ -156,19 +158,19 @@ public:
*
* \return True if sync went on without any error.
*/
static bool SyncToDisk(GDALDatasetType * dataset);
bool SyncToDisk(GDALDatasetType * dataset);
/**
* \return The name of the dataset class behind the implementation
* (OGRDataSource for gdal 1.x and GdalDataset for gdal 2.x)
*/
static std::string GetDatasetClassName();
std::string GetDatasetClassName();
/**
* \return The name of the driver class behind the implementation
* (OGRSFDriver for gdal 1.x and GDALDriver for gdal 2.x)
*/
static std::string GetDriverClassName();
std::string GetDriverClassName();
/**
* Return the list of files composing the dataset.
......@@ -182,7 +184,7 @@ public:
*
* \return A vector of string containing the list of files.
*/
static std::vector<std::string> GetFileListAsStringVector(GDALDatasetType * dataset);
std::vector<std::string> GetFileListAsStringVector(GDALDatasetType * dataset);
/**
* Return the list of available drivers.
......@@ -193,14 +195,10 @@ public:
*
* \return A vector of string containing the list of available drivers.
*/
static std::vector<std::string> GetAvailableDriversAsStringVector();
private:
OGRVersionProxy(); // purposely not implemented
OGRVersionProxy(const OGRVersionProxy&); // purposely not implemented
void operator=(const OGRVersionProxy&); // purposely not implemented
};
std::vector<std::string> GetAvailableDriversAsStringVector();
}
}
} // end namespace otb
#endif
......@@ -44,13 +44,13 @@ bool otb::ogr::DataSource::Clear()
return true;
}
void otb::ogr::DataSource::Reset(otb::OGRVersionProxy::GDALDatasetType * source)
void otb::ogr::DataSource::Reset(otb::ogr::version_proxy::GDALDatasetType * source)
{
if (m_DataSource) {
// OGR makes a pointless check for non-nullity in
// GDALDataset::DestroyDataSource (pointless because "delete 0" is
// perfectly valid -> it's a no-op)
OGRVersionProxy::Close(m_DataSource); // void, noexcept
ogr::version_proxy::Close(m_DataSource); // void, noexcept
}
m_DataSource = source;
}
......@@ -118,15 +118,15 @@ otb::ogr::DataSource::DataSource()
{
Drivers::Init();
OGRVersionProxy::GDALDriverType * d = OGRVersionProxy::GetDriverByName("Memory");
ogr::version_proxy::GDALDriverType * d = ogr::version_proxy::GetDriverByName("Memory");
assert(d && "OGR Memory driver not found");
m_DataSource = OGRVersionProxy::Create(d,"in-memory");
m_DataSource = ogr::version_proxy::Create(d,"in-memory");
if (!m_DataSource) {
itkExceptionMacro(<< "Failed to create OGRMemDataSource: " << CPLGetLastErrorMsg());
}
}
otb::ogr::DataSource::DataSource(otb::OGRVersionProxy::GDALDatasetType * source, Modes::type mode)
otb::ogr::DataSource::DataSource(otb::ogr::version_proxy::GDALDatasetType * source, Modes::type mode)
: m_DataSource(source),
m_OpenMode(mode),
m_FirstModifiableLayerID(0)
......@@ -138,7 +138,7 @@ otb::ogr::DataSource::Pointer otb::ogr::DataSource::OpenDataSource(std::string c
{
bool update = (mode != Modes::Read);
OGRVersionProxy::GDALDatasetType * source = OGRVersionProxy::Open(datasourceName.c_str(),!update);
ogr::version_proxy::GDALDatasetType * source = ogr::version_proxy::Open(datasourceName.c_str(),!update);
if (!source)
{
// In read mode, this is a failure
......@@ -157,14 +157,14 @@ otb::ogr::DataSource::Pointer otb::ogr::DataSource::OpenDataSource(std::string c
<<datasourceName<<">.");
}
OGRVersionProxy::GDALDriverType * d = OGRVersionProxy::GetDriverByName(driverName);
ogr::version_proxy::GDALDriverType * d = ogr::version_proxy::GetDriverByName(driverName);
if(!d)
{
itkGenericExceptionMacro(<<"Could not create OGR driver "<<driverName<<", check your OGR configuration for available drivers.");
}
source = OGRVersionProxy::Create(d,datasourceName.c_str());
source = ogr::version_proxy::Create(d,datasourceName.c_str());
if (!source) {
itkGenericExceptionMacro(<< "Failed to create GDALDataset <"<<datasourceName
<<"> (driver name: <" << driverName<<">: " << CPLGetLastErrorMsg());
......@@ -176,30 +176,30 @@ 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
otb::OGRVersionProxy::GDALDatasetType * poDS = otb::OGRVersionProxy::Open(datasourceName.c_str(),false);
otb::ogr::version_proxy::GDALDatasetType * poDS = otb::ogr::version_proxy::Open(datasourceName.c_str(),false);
if (poDS != NULL)
{
otb::OGRVersionProxy::GDALDriverType * ogrDriver = poDS->GetDriver();
otb::ogr::version_proxy::GDALDriverType * ogrDriver = poDS->GetDriver();
//Erase the data if possible
if (otb::OGRVersionProxy::TestCapability(ogrDriver,poDS,ODrCDeleteDataSource))
if (otb::ogr::version_proxy::TestCapability(ogrDriver,poDS,ODrCDeleteDataSource))
{
//Delete datasource
bool ret = otb::OGRVersionProxy::Delete(ogrDriver,datasourceName.c_str());
bool ret = otb::ogr::version_proxy::Delete(ogrDriver,datasourceName.c_str());
if (!ret)
{
otb::OGRVersionProxy::Close(poDS);
otb::ogr::version_proxy::Close(poDS);
itkGenericExceptionMacro(<< "Deletion of data source " << datasourceName
<< " failed: " << CPLGetLastErrorMsg());
}
}
else
{
otb::OGRVersionProxy::Close(poDS);
otb::ogr::version_proxy::Close(poDS);
itkGenericExceptionMacro(<< "Cannot delete data source " << datasourceName);
}
otb::OGRVersionProxy::Close(poDS);
otb::ogr::version_proxy::Close(poDS);
} // if (poDS != NULL)
}
......@@ -223,7 +223,7 @@ otb::ogr::DataSource::New(std::string const& datasourceName, Modes::type mode)
/*static*/
otb::ogr::DataSource::Pointer
otb::ogr::DataSource::New(otb::OGRVersionProxy::GDALDatasetType * source, Modes::type mode)
otb::ogr::DataSource::New(otb::ogr::version_proxy::GDALDatasetType * source, Modes::type mode)
{
Pointer res = new DataSource(source, mode);
res->UnRegister();
......@@ -693,13 +693,13 @@ void otb::ogr::DataSource::PrintSelf(
bool otb::ogr::DataSource::HasCapability(std::string const& capabilityName) const
{
assert(m_DataSource && "Datasource not initialized");
return otb::OGRVersionProxy::TestCapability(m_DataSource->GetDriver(),m_DataSource,capabilityName.c_str());
return otb::ogr::version_proxy::TestCapability(m_DataSource->GetDriver(),m_DataSource,capabilityName.c_str());
}
void otb::ogr::DataSource::SyncToDisk()
{
assert(m_DataSource && "Datasource not initialized");
bool ret = otb::OGRVersionProxy::SyncToDisk(m_DataSource);
bool ret = otb::ogr::version_proxy::SyncToDisk(m_DataSource);
if(!ret)
{
......@@ -711,7 +711,7 @@ void otb::ogr::DataSource::SyncToDisk()
std::string otb::ogr::DataSource::GetDatasetDescription() const
{
std::vector<std::string> files = otb::OGRVersionProxy::GetFileListAsStringVector(m_DataSource);
std::vector<std::string> files = otb::ogr::version_proxy::GetFileListAsStringVector(m_DataSource);
std::string description = "";
for(std::vector<std::string>::const_iterator it = files.begin();it!=files.end();++it)
description+=(*it)+", ";
......
......@@ -60,8 +60,8 @@ otb::ogr::Layer::Layer(OGRLayer* layer, bool modifiable)
{
}
otb::ogr::Layer::Layer(OGRLayer* layer, otb::OGRVersionProxy::GDALDatasetType& sourceInChargeOfLifeTime, bool modifiable)
: m_Layer(layer, boost::bind(&otb::OGRVersionProxy::GDALDatasetType::ReleaseResultSet, boost::ref(sourceInChargeOfLifeTime), _1))
otb::ogr::Layer::Layer(OGRLayer* layer, otb::ogr::version_proxy::GDALDatasetType& sourceInChargeOfLifeTime, bool modifiable)
: m_Layer(layer, boost::bind(&otb::ogr::version_proxy::GDALDatasetType::ReleaseResultSet, boost::ref(sourceInChargeOfLifeTime), _1))
, m_Modifiable(modifiable)
{
assert(layer && "A null OGRlayer cannot belong to an OGRDataSource" );
......
......@@ -28,19 +28,22 @@
namespace otb
{
namespace ogr
{
namespace version_proxy
{
OGRVersionProxy::GDALDatasetType * OGRVersionProxy::Open(const char * filename, bool readOnly)
GDALDatasetType * Open(const char * filename, bool readOnly)
{
return OGRSFDriverRegistrar::Open(filename,!readOnly);
}
void OGRVersionProxy::Close(GDALDatasetType * dataset)
void Close(GDALDatasetType * dataset)
{
OGRDataSource::DestroyDataSource(dataset);
}
OGRVersionProxy::GDALDatasetType * OGRVersionProxy::Create(GDALDriverType * driver, const char * name)
GDALDatasetType * Create(GDALDriverType * driver, const char * name)
{
GDALDatasetType * ds = driver->CreateDataSource(name);
......@@ -50,35 +53,35 @@ OGRVersionProxy::GDALDatasetType * OGRVersionProxy::Create(GDALDriverType * driv
return ds;
}
bool OGRVersionProxy::Delete(GDALDriverType * driver, const char * name)
bool Delete(GDALDriverType * driver, const char * name)
{
OGRErr ret = driver->DeleteDataSource(name);
return (ret == OGRERR_NONE);
}
OGRVersionProxy::GDALDriverType * OGRVersionProxy::GetDriverByName(const char * name)
GDALDriverType * GetDriverByName(const char * name)
{
return OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(name);
}
bool OGRVersionProxy::TestCapability(const GDALDriverType * driver, const GDALDatasetType *, const char * capability)
bool TestCapability(const GDALDriverType * driver, const GDALDatasetType *, const char * capability)
{
// Class OGRDataSource is not const correct
return const_cast<GDALDriverType * >(driver)->TestCapability(capability);
}
std::string OGRVersionProxy::GetDatasetClassName()
std::string GetDatasetClassName()
{
return std::string("OGRDataSource");
}
std::string OGRVersionProxy::GetDriverClassName()
std::string GetDriverClassName()
{
return std::string("OGRSFDriver");
}
std::vector<std::string> OGRVersionProxy::GetFileListAsStringVector(GDALDatasetType * dataset)
std::vector<std::string> GetFileListAsStringVector(GDALDatasetType * dataset)
{
std::vector<std::string> ret;
......@@ -87,14 +90,14 @@ std::vector<std::string> OGRVersionProxy::GetFileListAsStringVector(GDALDatasetT
return ret;
}
bool OGRVersionProxy::SyncToDisk(GDALDatasetType * dataset)
bool SyncToDisk(GDALDatasetType * dataset)
{
const OGRErr res= dataset->SyncToDisk();
return (res == OGRERR_NONE);
}
std::vector<std::string> OGRVersionProxy::GetAvailableDriversAsStringVector()
std::vector<std::string> GetAvailableDriversAsStringVector()
{
std::vector<std::string> ret;
......@@ -108,4 +111,6 @@ std::vector<std::string> OGRVersionProxy::GetAvailableDriversAsStringVector()
return ret;
}
}
}
} // end namespace
......@@ -28,47 +28,50 @@
namespace otb
{
namespace ogr
{
namespace version_proxy
{
OGRVersionProxy::GDALDatasetType * OGRVersionProxy::Open(const char * filename, bool readOnly)
GDALDatasetType * Open(const char * filename, bool readOnly)
{
return (GDALDatasetType *)GDALOpenEx(filename, (readOnly? GDAL_OF_READONLY : GDAL_OF_UPDATE) | GDAL_OF_VECTOR,NULL,NULL,NULL);
}
void OGRVersionProxy::Close(GDALDatasetType * dataset)
void Close(GDALDatasetType * dataset)
{
GDALClose(dataset);
}
OGRVersionProxy::GDALDatasetType * OGRVersionProxy::Create(GDALDriverType * driver, const char * name)
GDALDatasetType * Create(GDALDriverType * driver, const char * name)
{
return driver->Create(name,0,0,0,GDT_Unknown,NULL);
}
bool OGRVersionProxy::Delete(GDALDriverType * driver, const char * name)
bool Delete(GDALDriverType * driver, const char * name)
{
OGRErr ret = driver->Delete(name);
return (ret == OGRERR_NONE);
}
OGRVersionProxy::GDALDriverType * OGRVersionProxy::GetDriverByName(const char * name)
GDALDriverType * GetDriverByName(const char * name)
{
return GetGDALDriverManager()->GetDriverByName(name);
}
bool OGRVersionProxy::TestCapability(const GDALDriverType *, const GDALDatasetType * dataset, const char * capability)
bool TestCapability(const GDALDriverType *, const GDALDatasetType * dataset, const char * capability)
{
// Const correctness problem in GDALDataset class
return const_cast<GDALDatasetType *>(dataset)->TestCapability(capability);
}
std::string OGRVersionProxy::GetDatasetClassName()
std::string GetDatasetClassName()
{
return std::string("GDALDataset");
}
std::string OGRVersionProxy::GetDriverClassName()
std::string GetDriverClassName()
{
return std::string("GDALDriver");
}
......@@ -100,7 +103,7 @@ private:
};
}
std::vector<std::string> OGRVersionProxy::GetFileListAsStringVector(GDALDatasetType * dataset)
std::vector<std::string> GetFileListAsStringVector(GDALDatasetType * dataset)
{
std::vector<std::string> ret;
......@@ -120,14 +123,14 @@ std::vector<std::string> OGRVersionProxy::GetFileListAsStringVector(GDALDatasetT
return ret;
}
bool OGRVersionProxy::SyncToDisk(GDALDatasetType * dataset)
bool SyncToDisk(GDALDatasetType * dataset)
{
dataset->FlushCache();
return true;
}
std::vector<std::string> OGRVersionProxy::GetAvailableDriversAsStringVector()
std::vector<std::string> GetAvailableDriversAsStringVector()
{
std::vector<std::string> ret;
......@@ -141,4 +144,6 @@ std::vector<std::string> OGRVersionProxy::GetAvailableDriversAsStringVector()
return ret;
}
}
}
} // end namespace
......@@ -64,14 +64,14 @@ public:
unsigned int ProcessNodeWrite(InternalTreeNodeType * source,
OGRVersionProxy::GDALDatasetType * m_DataSource,
ogr::version_proxy::GDALDatasetType * m_DataSource,
OGRGeometryCollection * ogrCollection,
OGRLayer * ogrCurrentLayer,
OGRSpatialReference * oSRS);
/** Return a list of OGRLayer * */
std::vector<OGRLayer*> ConvertDataTreeNodeToOGRLayers(InternalTreeNodeType * source,
OGRVersionProxy::GDALDatasetType * dummyDatasource,
ogr::version_proxy::GDALDatasetType * dummyDatasource,
OGRLayer* ogrCurrentLayer,
OGRSpatialReference * oSRS);
......
......@@ -116,7 +116,7 @@ private:
std::string GetOGRDriverName(std::string name) const;
OGRVersionProxy::GDALDatasetType * m_DataSource;
ogr::version_proxy::GDALDatasetType * m_DataSource;
};
......
......@@ -649,7 +649,7 @@ void OGRIOHelper
unsigned int OGRIOHelper
::ProcessNodeWrite(InternalTreeNodeType * source,
OGRVersionProxy::GDALDatasetType * m_DataSource,
ogr::version_proxy::GDALDatasetType * m_DataSource,
OGRGeometryCollection * ogrCollection,
OGRLayer * ogrCurrentLayer,
OGRSpatialReference * oSRS)
......@@ -1025,7 +1025,7 @@ unsigned int OGRIOHelper
**/
std::vector<OGRLayer*> OGRIOHelper
::ConvertDataTreeNodeToOGRLayers(InternalTreeNodeType * source,
OGRVersionProxy::GDALDatasetType * inMemoryDataSource,
ogr::version_proxy::GDALDatasetType * inMemoryDataSource,
OGRLayer* ogrCurrentLayer,
OGRSpatialReference * oSRS)
{
......@@ -1034,8 +1034,8 @@ std::vector<OGRLayer*> OGRIOHelper
if (inMemoryDataSource == NULL)
{
const char * driverName = "Memory";
OGRVersionProxy::GDALDriverType * ogrDriver = OGRVersionProxy::GetDriverByName(driverName);
inMemoryDataSource = OGRVersionProxy::Create(ogrDriver,"tempDataSource");
ogr::version_proxy::GDALDriverType * ogrDriver = ogr::version_proxy::GetDriverByName(driverName);
inMemoryDataSource = ogr::version_proxy::Create(ogrDriver,"tempDataSource");
}
std::vector<OGRLayer*> ogrLayerVector;
......
......@@ -46,7 +46,7 @@ OGRVectorDataIO::~OGRVectorDataIO()
{
if (m_DataSource != NULL)
{
otb::OGRVersionProxy::Close(m_DataSource);
otb::ogr::version_proxy::Close(m_DataSource);
}
}
......@@ -54,7 +54,7 @@ OGRVectorDataIO::~OGRVectorDataIO()
bool
OGRVectorDataIO::CanReadFile(const char* filename) const
{
otb::OGRVersionProxy::GDALDatasetType * poDS = OGRVersionProxy::Open(filename, true);
otb::ogr::version_proxy::GDALDatasetType * poDS = ogr::version_proxy::Open(filename, true);
if (poDS == NULL)
{
......@@ -62,7 +62,7 @@ OGRVectorDataIO::CanReadFile(const char* filename) const
return false;
}
// std::cout << poDS->GetDriver()->GetName() << std::endl;
OGRVersionProxy::Close(poDS);
ogr::version_proxy::Close(poDS);
return true;
}
......@@ -90,10 +90,10 @@ OGRVectorDataIO
if (m_DataSource != NULL)
{
OGRVersionProxy::Close(m_DataSource);
ogr::version_proxy::Close(m_DataSource);
}
m_DataSource = OGRVersionProxy::Open(this->m_FileName.c_str(),true);
m_DataSource = ogr::version_proxy::Open(this->m_FileName.c_str(),true);
if (m_DataSource == NULL)
{
......@@ -210,8 +210,8 @@ void OGRVectorDataIO::Write(const itk::DataObject* datag, char ** /** unused */)
//Find first the OGR driver
OGRVersionProxy::GDALDriverType * ogrDriver =
OGRVersionProxy::GetDriverByName(this->GetOGRDriverName(this->m_FileName).data());
ogr::version_proxy::GDALDriverType * ogrDriver =
ogr::version_proxy::GetDriverByName(this->GetOGRDriverName(this->m_FileName).data());
if (ogrDriver == NULL)
{
......@@ -221,25 +221,25 @@ void OGRVectorDataIO::Write(const itk::DataObject* datag, char ** /** unused */)
// free an existing previous data source, if any
if (m_DataSource != NULL)
{
OGRVersionProxy::Close(m_DataSource);
ogr::version_proxy::Close(m_DataSource);
}
// Erase the dataSource if already exist
//TODO investigate the possibility of giving the option OVERWRITE=YES to the CreateDataSource method
OGRVersionProxy::GDALDatasetType * poDS = OGRVersionProxy::Open(this->m_FileName.c_str(),false);
ogr::version_proxy::GDALDatasetType * poDS = ogr::version_proxy::Open(this->m_FileName.c_str(),false);
if (poDS != NULL)
{
//Erase the data if possible
if (OGRVersionProxy::TestCapability(ogrDriver,poDS,ODrCDeleteDataSource))
if (ogr::version_proxy::TestCapability(ogrDriver,poDS,ODrCDeleteDataSource))
{
//Delete datasource
OGRVersionProxy::Delete(ogrDriver,m_FileName.c_str());
ogr::version_proxy::Delete(ogrDriver,m_FileName.c_str());
}
}
OGRVersionProxy::Close(poDS);
ogr::version_proxy::Close(poDS);
// m_DataSource = OGRSFDriverRegistrar::Open(this->m_FileName.c_str(), TRUE);
m_DataSource = OGRVersionProxy::Create(ogrDriver,this->m_FileName.c_str());
m_DataSource = ogr::version_proxy::Create(ogrDriver,this->m_FileName.c_str());
// check the created data source
if (m_DataSource == NULL)
......@@ -294,7 +294,7 @@ void OGRVectorDataIO::Write(const itk::DataObject* datag, char ** /** unused */)
otbMsgDevMacro( << "layerKept " << layerKept );
(void)layerKept; // keep compiler happy
otb::OGRVersionProxy::Close(m_DataSource);
otb::ogr::version_proxy::Close(m_DataSource);
m_DataSource = NULL;
if (oSRS != NULL)
......
......@@ -1069,27 +1069,27 @@ int TestHelper::RegressionTestOgrFile(const char *testOgrFilename, const char *b
/* -------------------------------------------------------------------- */
/* Open data source. */
/* -------------------------------------------------------------------- */