Skip to content
Snippets Groups Projects
Commit db958814 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

ENH: use Start/Commit Transaction for faster OGR output

parent 664de77c
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment