Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: "filter" step of "vector pipeline" 5 : * Author: Even Rouault <even dot rouault at spatialys.com> 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2024, Even Rouault <even dot rouault at spatialys.com> 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #ifndef GDALALG_VECTOR_FILTER_INCLUDED 14 : #define GDALALG_VECTOR_FILTER_INCLUDED 15 : 16 : #include "gdalvectorpipelinestepalgorithm.h" 17 : 18 : //! @cond Doxygen_Suppress 19 : 20 : /************************************************************************/ 21 : /* GDALVectorFilterAlgorithm */ 22 : /************************************************************************/ 23 : 24 : class GDALVectorFilterAlgorithm /* non final */ 25 : : public GDALVectorPipelineStepAlgorithm 26 : { 27 : public: 28 : static constexpr const char *NAME = "filter"; 29 : static constexpr const char *DESCRIPTION = "Filter a vector dataset."; 30 : static constexpr const char *HELP_URL = "/programs/gdal_vector_filter.html"; 31 : 32 : explicit GDALVectorFilterAlgorithm(bool standaloneStep = false); 33 : 34 18 : bool IsNativelyStreamingCompatible() const override 35 : { 36 18 : return !m_updateExtent; 37 : } 38 : 39 : private: 40 : bool RunStep(GDALPipelineStepRunContext &ctxt) override; 41 : 42 : std::vector<std::string> 43 : CompleteWhere(const GDALAlgorithmArg &layerArg, 44 : const std::string ¤tValue) const; 45 : 46 : std::string m_activeLayer{}; 47 : std::vector<double> m_bbox{}; 48 : std::string m_bboxCrs{}; 49 : std::string m_geometry{}; 50 : std::string m_geometryCrs{}; 51 : std::string m_where{}; 52 : bool m_updateExtent = false; 53 : }; 54 : 55 : /************************************************************************/ 56 : /* GDALVectorFilterAlgorithmStandalone */ 57 : /************************************************************************/ 58 : 59 144 : class GDALVectorFilterAlgorithmStandalone final 60 : : public GDALVectorFilterAlgorithm 61 : { 62 : public: 63 72 : GDALVectorFilterAlgorithmStandalone() 64 72 : : GDALVectorFilterAlgorithm(/* standaloneStep = */ true) 65 : { 66 72 : } 67 : 68 : ~GDALVectorFilterAlgorithmStandalone() override; 69 : }; 70 : 71 : //! @endcond 72 : 73 : #endif /* GDALALG_VECTOR_FILTER_INCLUDED */