diff --git a/Modules/Learning/Sampling/src/otbSampleAugmentationFilter.cxx b/Modules/Learning/Sampling/src/otbSampleAugmentationFilter.cxx index 5778de0d9324b7a022cab8569c3b25a48260cfc8..46e37ebe3183f805e77613168896ce0bd7fea2ca 100644 --- a/Modules/Learning/Sampling/src/otbSampleAugmentationFilter.cxx +++ b/Modules/Learning/Sampling/src/otbSampleAugmentationFilter.cxx @@ -204,6 +204,13 @@ SampleAugmentationFilter auto featureCount = outputLayer.GetFeatureCount(false); auto templateFeature = this->SelectTemplateFeature(inputLayer, classField, label); + + OGRErr err = outputLayer.ogr().StartTransaction(); + if (err != OGRERR_NONE) + { + itkExceptionMacro(<< "Unable to start transaction for OGR layer " << outputLayer.ogr().GetName() << "."); + } + for(const auto& sample : samples) { ogr::Feature dstFeature(outputLayer.GetLayerDefn()); @@ -220,6 +227,11 @@ SampleAugmentationFilter } outputLayer.CreateFeature( dstFeature ); } + err = outputLayer.ogr().CommitTransaction(); + if (err != OGRERR_NONE) + { + itkExceptionMacro(<< "Unable to commit transaction for OGR layer " << outputLayer.ogr().GetName() << "."); + } } std::set<size_t>