@@ -32,6 +32,11 @@ GDALVectorSelectAlgorithm::GDALVectorSelectAlgorithm(bool standaloneStep)
3232 : GDALVectorPipelineStepAlgorithm(NAME, DESCRIPTION, HELP_URL,
3333 standaloneStep)
3434{
35+ if (!standaloneStep)
36+ {
37+ AddOutputLayerNameArg (/* hiddenForCLI = */ false ,
38+ /* shortNameOutputLayerAllowed = */ false );
39+ }
3540 AddActiveLayerArg (&m_activeLayer);
3641 AddArg (" fields" , 0 , _ (" Fields to select (or exclude if --exclude)" ),
3742 &m_fields)
@@ -90,11 +95,14 @@ class GDALVectorSelectAlgorithmLayer final
9095 }
9196
9297 public:
93- explicit GDALVectorSelectAlgorithmLayer (OGRLayer &oSrcLayer)
98+ explicit GDALVectorSelectAlgorithmLayer (
99+ OGRLayer &oSrcLayer, const std::string &osOutputLayerName)
94100 : GDALVectorPipelineOutputLayer(oSrcLayer),
95- m_poFeatureDefn(new OGRFeatureDefn(oSrcLayer.GetName()))
101+ m_poFeatureDefn(new OGRFeatureDefn(osOutputLayerName.empty()
102+ ? oSrcLayer.GetName()
103+ : osOutputLayerName.c_str()))
96104 {
97- SetDescription (oSrcLayer. GetDescription ());
105+ SetDescription (m_poFeatureDefn-> GetName ());
98106 SetMetadata (oSrcLayer.GetMetadata ());
99107 m_poFeatureDefn->SetGeomType (wkbNone);
100108 m_poFeatureDefn->Reference ();
@@ -301,8 +309,8 @@ bool GDALVectorSelectAlgorithm::RunStep(GDALPipelineStepRunContext &)
301309 if (m_activeLayer.empty () ||
302310 m_activeLayer == poSrcLayer->GetDescription ())
303311 {
304- auto poLayer =
305- std::make_unique<GDALVectorSelectAlgorithmLayer>( *poSrcLayer);
312+ auto poLayer = std::make_unique<GDALVectorSelectAlgorithmLayer>(
313+ *poSrcLayer, m_outputLayerName );
306314 if (m_exclude)
307315 {
308316 poLayer->ExcludeFields (m_fields);
0 commit comments