Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: "calc" step of "raster pipeline" 5 : * Author: Daniel Baston 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2025, ISciences LLC 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #ifndef GDALALG_RASTER_CALC_INCLUDED 14 : #define GDALALG_RASTER_CALC_INCLUDED 15 : 16 : #include "gdalalg_raster_pipeline.h" 17 : 18 : //! @cond Doxygen_Suppress 19 : 20 : /************************************************************************/ 21 : /* GDALRasterCalcAlgorithm */ 22 : /************************************************************************/ 23 : 24 : class GDALRasterCalcAlgorithm : public GDALRasterPipelineStepAlgorithm 25 : { 26 : public: 27 : explicit GDALRasterCalcAlgorithm(bool standaloneStep = false) noexcept; 28 : 29 : static constexpr const char *NAME = "calc"; 30 : static constexpr const char *DESCRIPTION = "Perform raster algebra"; 31 : static constexpr const char *HELP_URL = "/programs/gdal_raster_calc.html"; 32 : 33 12 : bool CanBeFirstStep() const override 34 : { 35 12 : return true; 36 : } 37 : 38 : private: 39 : bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override; 40 : bool RunStep(GDALPipelineStepRunContext &ctxt) override; 41 : 42 : std::vector<std::string> m_expr{}; 43 : std::string m_dialect{"muparser"}; 44 : bool m_flatten{false}; 45 : std::string m_type{}; 46 : bool m_NoCheckSRS{false}; 47 : bool m_NoCheckExtent{false}; 48 : bool m_noCheckExpression{false}; 49 : }; 50 : 51 : /************************************************************************/ 52 : /* GDALRasterCalcAlgorithmStandalone */ 53 : /************************************************************************/ 54 : 55 144 : class GDALRasterCalcAlgorithmStandalone final : public GDALRasterCalcAlgorithm 56 : { 57 : public: 58 72 : GDALRasterCalcAlgorithmStandalone() 59 72 : : GDALRasterCalcAlgorithm(/* standaloneStep = */ true) 60 : { 61 72 : } 62 : 63 : ~GDALRasterCalcAlgorithmStandalone() override; 64 : }; 65 : 66 : //! @endcond 67 : 68 : #endif /* GDALALG_RASTER_CALC_INCLUDED */