Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: gdal "vector concat" subcommand 5 : * Author: Even Rouault <even dot rouault at spatialys.com> 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2025, Even Rouault <even dot rouault at spatialys.com> 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #ifndef GDALALG_VECTOR_CONCAT_INCLUDED 14 : #define GDALALG_VECTOR_CONCAT_INCLUDED 15 : 16 : #include "gdalalg_vector_pipeline.h" 17 : 18 : #include "ogrsf_frmts.h" 19 : 20 : //! @cond Doxygen_Suppress 21 : 22 : /************************************************************************/ 23 : /* GDALVectorConcatAlgorithm */ 24 : /************************************************************************/ 25 : 26 : class GDALVectorConcatAlgorithm /* non final */ 27 : : public GDALVectorPipelineStepAlgorithm 28 : { 29 : public: 30 : static constexpr const char *NAME = "concat"; 31 : static constexpr const char *DESCRIPTION = "Concatenate vector datasets."; 32 : static constexpr const char *HELP_URL = "/programs/gdal_vector_concat.html"; 33 : 34 : explicit GDALVectorConcatAlgorithm(bool bStandalone = false); 35 : 36 11 : bool CanBeFirstStep() const override 37 : { 38 11 : return true; 39 : } 40 : 41 : private: 42 : bool RunStep(GDALPipelineStepRunContext &ctxt) override; 43 : bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override; 44 : 45 : std::string m_layerNameTemplate{}; 46 : std::string m_sourceLayerFieldName{}; 47 : std::string m_sourceLayerFieldContent{}; 48 : std::string m_mode = "merge-per-layer-name"; 49 : std::string m_fieldStrategy = "union"; 50 : std::string m_srsCrs{}; 51 : std::string m_dstCrs{}; 52 : 53 : std::vector<std::unique_ptr<OGRLayer>> m_tempLayersKeeper{}; 54 : }; 55 : 56 : /************************************************************************/ 57 : /* GDALVectorConcatAlgorithmStandalone */ 58 : /************************************************************************/ 59 : 60 54 : class GDALVectorConcatAlgorithmStandalone final 61 : : public GDALVectorConcatAlgorithm 62 : { 63 : public: 64 27 : GDALVectorConcatAlgorithmStandalone() 65 27 : : GDALVectorConcatAlgorithm(/* standaloneStep = */ true) 66 : { 67 27 : } 68 : 69 : ~GDALVectorConcatAlgorithmStandalone() override; 70 : }; 71 : 72 : //! @endcond 73 : 74 : #endif