Commit c288f6d8 authored by Antoine Regimbeau's avatar Antoine Regimbeau

ENH: create and copy layer concatenation of option

parent e7ce59f3
......@@ -79,10 +79,11 @@ public:
void SetGDALLayerOptions( const GDALOptionType & options );
void AddGDALLayerOptions( const GDALOptionType & options );
static Pointer GetGDALLayerOptionsHelper( const GDALOptionType & options );
protected:
OGRExtendedFilenameToOptions();
OGRExtendedFilenameToOptions( const GDALOptionType & options );
~OGRExtendedFilenameToOptions() override {};
private:
......
......@@ -284,6 +284,12 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer(
// Other mode : Check if the layer already exists.
otb::ogr::Layer layer = GetLayer(name); // won't throw on failure
FileNameHelperType::Pointer layerOptionHelper =
FileNameHelperType::GetGDALLayerOptionsHelper( m_LayerOptions );
layerOptionHelper->AddGDALLayerOptions( papszOptions );
std::vector<std::string> layerOptions =
layerOptionHelper->GetGDALLayerOptions();
switch (m_OpenMode)
{
case Modes::Update_LayerOverwrite:
......@@ -296,7 +302,11 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer(
// Then create it
OGRLayer * ol = m_DataSource->CreateLayer(
name.c_str(), poSpatialRef, eGType, otb::ogr::StringListConverter(papszOptions).to_ogr());
name.c_str() ,
poSpatialRef ,
eGType ,
otb::ogr::StringListConverter( layerOptions ).to_ogr() );
if (!ol)
{
itkGenericExceptionMacro(<< "Failed to create the layer <"<<name
......@@ -319,7 +329,11 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer(
{
// Then create it
OGRLayer * ol = m_DataSource->CreateLayer(
name.c_str(), poSpatialRef, eGType, otb::ogr::StringListConverter(papszOptions).to_ogr());
name.c_str() ,
poSpatialRef ,
eGType ,
otb::ogr::StringListConverter( layerOptions ).to_ogr() );
if (!ol)
{
itkGenericExceptionMacro(<< "Failed to create the layer <"<<name
......@@ -343,7 +357,11 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer(
// Case where the layer does not exists
OGRLayer * ol = m_DataSource->CreateLayer(
name.c_str(), poSpatialRef, eGType, otb::ogr::StringListConverter(papszOptions).to_ogr());
name.c_str() ,
poSpatialRef ,
eGType ,
otb::ogr::StringListConverter( layerOptions ).to_ogr() );
if (!ol)
{
itkGenericExceptionMacro(<< "Failed to create the layer <"<<name
......@@ -384,9 +402,18 @@ otb::ogr::Layer otb::ogr::DataSource::CopyLayer(
default:
break;
}
FileNameHelperType::Pointer layerOptionHelper =
FileNameHelperType::GetGDALLayerOptionsHelper( m_LayerOptions );
layerOptionHelper->AddGDALLayerOptions( papszOptions );
std::vector<std::string> layerOptions =
layerOptionHelper->GetGDALLayerOptions();
OGRLayer * l0 = &srcLayer.ogr();
OGRLayer * ol = m_DataSource->CopyLayer(l0, newName.c_str(), otb::ogr::StringListConverter(papszOptions).to_ogr());
OGRLayer * ol = m_DataSource->CopyLayer(
l0 ,
newName.c_str() ,
otb::ogr::StringListConverter( layerOptions ).to_ogr() );
if (!ol)
{
itkGenericExceptionMacro(<< "Failed to copy the layer <"
......
......@@ -36,6 +36,23 @@ OGRExtendedFilenameToOptions()
}
OGRExtendedFilenameToOptions::
OGRExtendedFilenameToOptions( const GDALOptionType & options ):
m_LayerOptions()
{
this->SetGDALLayerOptions( options );
}
OGRExtendedFilenameToOptions::Pointer
OGRExtendedFilenameToOptions::
GetGDALLayerOptionsHelper( const GDALOptionType & options )
{
Pointer res = new OGRExtendedFilenameToOptions( options );
res->UnRegister();
return res;
}
void
OGRExtendedFilenameToOptions::
SetExtendedFileName(const char *extFname)
......
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