diff --git a/Applications/Segmentation/otbSegmentation.cxx b/Applications/Segmentation/otbSegmentation.cxx index a1604ada0feb5f6d6bc1ab5734247335b544ed4d..5d3f370869b1bfacfe440b417cfaf8e9935c51bd 100644 --- a/Applications/Segmentation/otbSegmentation.cxx +++ b/Applications/Segmentation/otbSegmentation.cxx @@ -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); diff --git a/Code/Common/otbLabelImageToOGRDataSourceFilter.txx b/Code/Common/otbLabelImageToOGRDataSourceFilter.txx index eff3b3aa62a004360370c01dfc058cba0e4123bf..ae9659f30e64a39b54407d67caad70640b883948 100644 --- a/Code/Common/otbLabelImageToOGRDataSourceFilter.txx +++ b/Code/Common/otbLabelImageToOGRDataSourceFilter.txx @@ -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); diff --git a/Code/Common/otbLabelImageToVectorDataFilter.txx b/Code/Common/otbLabelImageToVectorDataFilter.txx index 9451cc2087f258c4200eb9dec8642c43529b45c9..eb770861cfdb4eb2f26351aafe01ffe4c121ed73 100644 --- a/Code/Common/otbLabelImageToVectorDataFilter.txx +++ b/Code/Common/otbLabelImageToVectorDataFilter.txx @@ -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); diff --git a/Code/UtilitiesAdapters/OGRAdapters/otbGeometriesToGeometriesFilter.cxx b/Code/UtilitiesAdapters/OGRAdapters/otbGeometriesToGeometriesFilter.cxx index da141bb8e3f03162c37069b6014d7fba33f175c5..517a1a77030f254bf5e61eec29339c8ba91dff70 100644 --- a/Code/UtilitiesAdapters/OGRAdapters/otbGeometriesToGeometriesFilter.cxx +++ b/Code/UtilitiesAdapters/OGRAdapters/otbGeometriesToGeometriesFilter.cxx @@ -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); diff --git a/Code/UtilitiesAdapters/OGRAdapters/otbOGRDataSourceWrapper.cxx b/Code/UtilitiesAdapters/OGRAdapters/otbOGRDataSourceWrapper.cxx index e20ea7053ed4d33258c60f6dd09b0be40dac17c3..de5f6b99cc5a678ab67bb5c21a334bff129388e9 100644 --- a/Code/UtilitiesAdapters/OGRAdapters/otbOGRDataSourceWrapper.cxx +++ b/Code/UtilitiesAdapters/OGRAdapters/otbOGRDataSourceWrapper.cxx @@ -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 diff --git a/Code/UtilitiesAdapters/OGRAdapters/otbOGRDataSourceWrapper.h b/Code/UtilitiesAdapters/OGRAdapters/otbOGRDataSourceWrapper.h index ca8b120a051fc5f6d8e01dbec422ea96c33ab781..832348cf47c2307a54abe3e73f3bbe1b34edc071 100644 --- a/Code/UtilitiesAdapters/OGRAdapters/otbOGRDataSourceWrapper.h +++ b/Code/UtilitiesAdapters/OGRAdapters/otbOGRDataSourceWrapper.h @@ -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. diff --git a/Examples/Segmentation/StreamingMeanShiftSegmentation.cxx b/Examples/Segmentation/StreamingMeanShiftSegmentation.cxx index db2b6343f8e974d9081ef6a221b2c190940ca863..d7e8433b5719f2d91dc80c017bf5849e114a588e 100644 --- a/Examples/Segmentation/StreamingMeanShiftSegmentation.cxx +++ b/Examples/Segmentation/StreamingMeanShiftSegmentation.cxx @@ -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