Commit 805ac31c authored by Arthur VINCENT's avatar Arthur VINCENT

REFAC : replace CreateOutputDataSource function by its content

parent 5d8950da
Pipeline #2990 failed with stages
in 94 minutes
......@@ -311,7 +311,38 @@ void VectorPrediction<RegressionMode>::DoExecute()
const bool updateMode = !(IsParameterEnabled("out") && HasValue("out"));
auto output = CreateOutputDataSource(source, layer, updateMode);
//~ auto output = CreateOutputDataSource(source, layer, updateMode);
ogr::DataSource::Pointer output;
ogr::DataSource::Pointer buffer = ogr::DataSource::New();
if (updateMode)
{
// Update mode
otbAppLogINFO("Update input vector data.");
// fill temporary buffer for the transfer
otb::ogr::Layer inputLayer = layer;
layer = buffer->CopyLayer(inputLayer, std::string("Buffer"));
// close input data source
source->Clear();
// Re-open input data source in update mode
output = otb::ogr::DataSource::New(GetParameterString("in"), otb::ogr::DataSource::Modes::Update_LayerUpdate);
}
else
{
// Create new OGRDataSource
output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Overwrite);
otb::ogr::Layer newLayer = output->CreateLayer(GetParameterString("out"), const_cast<OGRSpatialReference*>(layer.GetSpatialRef()), layer.GetGeomType());
// Copy existing fields
OGRFeatureDefn& inLayerDefn = layer.GetLayerDefn();
for (int k = 0; k < inLayerDefn.GetFieldCount(); k++)
{
OGRFieldDefn fieldDefn(inLayerDefn.GetFieldDefn(k));
newLayer.CreateField(fieldDefn);
}
}
otb::ogr::Layer outLayer = output->GetLayer(0);
OGRErr errStart = outLayer.ogr().StartTransaction();
......
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