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 "gdalrasterpipelinestepalgorithm.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 20 : bool CanBeFirstStep() const override 34 : { 35 20 : return true; 36 : } 37 : 38 11 : bool CanBeMiddleStep() const override 39 : { 40 11 : return true; 41 : } 42 : 43 : private: 44 : bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override; 45 : bool RunStep(GDALPipelineStepRunContext &ctxt) override; 46 : 47 : std::vector<std::string> m_expr{}; 48 : std::string m_dialect{"muparser"}; 49 : bool m_flatten{false}; 50 : std::string m_type{}; 51 : std::string m_nodata{}; 52 : bool m_noCheckCRS{false}; 53 : bool m_noCheckExtent{false}; 54 : bool m_noCheckExpression{false}; 55 : bool m_propagateNoData{false}; 56 : }; 57 : 58 : /************************************************************************/ 59 : /* GDALRasterCalcAlgorithmStandalone */ 60 : /************************************************************************/ 61 : 62 276 : class GDALRasterCalcAlgorithmStandalone final : public GDALRasterCalcAlgorithm 63 : { 64 : public: 65 138 : GDALRasterCalcAlgorithmStandalone() 66 138 : : GDALRasterCalcAlgorithm(/* standaloneStep = */ true) 67 : { 68 138 : } 69 : 70 : ~GDALRasterCalcAlgorithmStandalone() override; 71 : }; 72 : 73 : //! @endcond 74 : 75 : #endif /* GDALALG_RASTER_CALC_INCLUDED */