GDAL

gdalalg_raster_calc.h
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
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 bool CanBeFirstStep() const override
34 {
35 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 std::string m_nodata{};
47 bool m_noCheckSRS{false};
48 bool m_noCheckExtent{false};
49 bool m_noCheckExpression{false};
50 bool m_propagateNoData{false};
51};
52
53/************************************************************************/
54/* GDALRasterCalcAlgorithmStandalone */
55/************************************************************************/
56
57 class GDALRasterCalcAlgorithmStandalone final : public GDALRasterCalcAlgorithm
58{
59 public:
60 GDALRasterCalcAlgorithmStandalone()
61 : GDALRasterCalcAlgorithm(/* standaloneStep = */ true)
62 {
63 }
64
65 ~GDALRasterCalcAlgorithmStandalone() override;
66};
67
69
70#endif /* GDALALG_RASTER_CALC_INCLUDED */