Commit 1ad221bc authored by Julien Malik's avatar Julien Malik

ENH: change protoype of OGRDataSource::CreateLayer

parent 0ff9b289
......@@ -457,7 +457,7 @@ private:
// datasource is blank
layer = ogrDS->CreateLayer(GetParameterString("mode.vector.layername"),
&oSRS,wkbMultiPolygon,
otb::ogr::StringListConverter(GetParameterStringList("mode.vector.ogroptions")).to_ogr());
GetParameterStringList("mode.vector.ogroptions"));
// And create the field
OGRFieldDefn field(this->GetParameterString("mode.vector.fieldname").c_str(),OFTInteger);
layer.CreateField(field,true);
......
......@@ -206,7 +206,7 @@ LabelImageToOGRDataSourceFilter<TInputImage>
//Create the output layer for GDALPolygonize().
ogr::DataSource::Pointer ogrDS = ogr::DataSource::New();
OGRLayerType outputLayer = ogrDS->CreateLayer("layer",NULL,wkbPolygon,NULL);
OGRLayerType outputLayer = ogrDS->CreateLayer("layer",NULL,wkbPolygon);
OGRFieldDefn field(m_FieldName.c_str(),OFTInteger);
outputLayer.CreateField(field, true);
......
......@@ -184,7 +184,7 @@ LabelImageToVectorDataFilter<TInputImage, TPrecision>
//Create the output layer for GDALPolygonize().
ogr::DataSource::Pointer ogrDS = ogr::DataSource::New();
OGRLayerType outputLayer = ogrDS->CreateLayer("layer",NULL,wkbPolygon,NULL);
OGRLayerType outputLayer = ogrDS->CreateLayer("layer",NULL,wkbPolygon);
OGRFieldDefn field(m_FieldName.c_str(),OFTInteger);
outputLayer.CreateField(field, true);
......
......@@ -59,7 +59,7 @@ struct ProcessVisitor : boost::static_visitor<>
sourceLayer.GetName(),
m_filter.DoDefineNewLayerSpatialReference(sourceLayer),
m_filter.DoDefineNewLayerGeometryType(sourceLayer),
otb::ogr::StringListConverter(m_filter.DoDefineNewLayerOptions(sourceLayer)).to_ogr()
m_filter.DoDefineNewLayerOptions(sourceLayer)
);
m_filter.DoDefineNewLayerFields(sourceLayer, destLayer);
m_filter.DoProcessLayer(sourceLayer, destLayer);
......
......@@ -345,7 +345,7 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer(
std::string const& name,
OGRSpatialReference * poSpatialRef/* = NULL */,
OGRwkbGeometryType eGType/* = wkbUnknown */,
char ** papszOptions/* = NULL */)
std::vector<std::string> const& papszOptions/* = NULL */)
{
assert(m_DataSource && "Datasource not initialized");
......@@ -362,8 +362,16 @@ otb::ogr::Layer otb::ogr::DataSource::CreateLayer(
break;
}
// Make a local copy
std::vector<std::string> options(papszOptions);
if (m_OpenMode == Modes::Update_LayerOverwrite)
{
options.push_back("OVERWRITE=YES");
}
char** papszOptionsChar = otb::ogr::StringListConverter(options).to_ogr();
OGRLayer * ol = m_DataSource->CreateLayer(
name.c_str(), poSpatialRef, eGType, papszOptions);
name.c_str(), poSpatialRef, eGType, papszOptionsChar);
if (!ol)
{
itkGenericExceptionMacro(<< "Failed to create the layer <"<<name
......
......@@ -311,7 +311,7 @@ public:
std::string const& name,
OGRSpatialReference * poSpatialRef = NULL,
OGRwkbGeometryType eGType = wkbUnknown,
char ** papszOptions = NULL);
std::vector<std::string> const& papszOptions = std::vector<std::string>());
/**
* Deletes the i-th layer from the data source.
......
......@@ -158,7 +158,7 @@ int main(int argc, char *argv[])
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
otb::ogr::Layer ogrLayer = ogrDS->CreateLayer(layerName,&oSRS,wkbMultiPolygon,NULL);
otb::ogr::Layer ogrLayer = ogrDS->CreateLayer(layerName,&oSRS,wkbMultiPolygon);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
......
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