Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: "update" step of "vector pipeline" 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_UPDATE_INCLUDED 14 : #define GDALALG_VECTOR_UPDATE_INCLUDED 15 : 16 : #include "gdalalg_vector_pipeline.h" 17 : 18 : //! @cond Doxygen_Suppress 19 : 20 : /************************************************************************/ 21 : /* GDALVectorUpdateAlgorithm */ 22 : /************************************************************************/ 23 : 24 : class GDALVectorUpdateAlgorithm /* non final */ 25 : : public GDALVectorPipelineStepAlgorithm 26 : { 27 : public: 28 : static constexpr const char *NAME = "update"; 29 : static constexpr const char *DESCRIPTION = 30 : "Update an existing vector dataset with an input vector dataset."; 31 : static constexpr const char *HELP_URL = "/programs/gdal_vector_update.html"; 32 : 33 : explicit GDALVectorUpdateAlgorithm(bool standaloneStep = false); 34 : 35 2 : bool IsNativelyStreamingCompatible() const override 36 : { 37 2 : return false; 38 : } 39 : 40 1 : bool OutputDatasetAllowedBeforeRunningStep() const override 41 : { 42 1 : return true; 43 : } 44 : 45 : protected: 46 : bool RunStep(GDALPipelineStepRunContext &ctxt) override; 47 : 48 : std::string m_activeLayer{}; 49 : 50 : static constexpr const char *MODE_MERGE = "merge"; 51 : static constexpr const char *MODE_UPDATE_ONLY = "update-only"; 52 : static constexpr const char *MODE_APPEND_ONLY = "append-only"; 53 : 54 : std::string m_mode{MODE_MERGE}; 55 : std::vector<std::string> m_key{}; 56 : }; 57 : 58 : /************************************************************************/ 59 : /* GDALVectorUpdateAlgorithmStandalone */ 60 : /************************************************************************/ 61 : 62 42 : class GDALVectorUpdateAlgorithmStandalone final 63 : : public GDALVectorUpdateAlgorithm 64 : { 65 : public: 66 21 : GDALVectorUpdateAlgorithmStandalone() 67 21 : : GDALVectorUpdateAlgorithm(/* standaloneStep = */ true) 68 : { 69 21 : } 70 : 71 : ~GDALVectorUpdateAlgorithmStandalone() override; 72 : 73 : private: 74 : bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override; 75 : }; 76 : 77 : //! @endcond 78 : 79 : #endif /* GDALALG_VECTOR_UPDATE_INCLUDED */