Coverage Report

Created: 2026-02-14 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/apps/gdalalg_raster_contour.h
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Project:  GDAL
4
 * Purpose:  gdal "raster contour" subcommand
5
 * Author:   Alessandro Pasotti <elpaso at itopen dot it>
6
 *
7
 ******************************************************************************
8
 * Copyright (c) 2025, Alessandro Pasotti <elpaso at itopen dot it>
9
 *
10
 * SPDX-License-Identifier: MIT
11
 ****************************************************************************/
12
13
#ifndef GDALALG_RASTER_CONTOUR_INCLUDED
14
#define GDALALG_RASTER_CONTOUR_INCLUDED
15
16
#include <limits>
17
18
#include "gdalalg_abstract_pipeline.h"
19
20
//! @cond Doxygen_Suppress
21
22
/************************************************************************/
23
/*                      GDALRasterContourAlgorithm                      */
24
/************************************************************************/
25
26
class GDALRasterContourAlgorithm /* non final */
27
    : public GDALPipelineStepAlgorithm
28
{
29
  public:
30
    static constexpr const char *NAME = "contour";
31
    static constexpr const char *DESCRIPTION =
32
        "Creates a vector contour from a raster elevation model (DEM).";
33
    static constexpr const char *HELP_URL =
34
        "/programs/gdal_raster_contour.html";
35
36
    explicit GDALRasterContourAlgorithm(bool standaloneStep = false);
37
38
    bool IsNativelyStreamingCompatible() const override
39
0
    {
40
0
        return false;
41
0
    }
42
43
    int GetInputType() const override
44
0
    {
45
0
        return GDAL_OF_RASTER;
46
0
    }
47
48
    int GetOutputType() const override
49
0
    {
50
0
        return GDAL_OF_VECTOR;
51
0
    }
52
53
  private:
54
    bool RunStep(GDALPipelineStepRunContext &ctxt) override;
55
    bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override;
56
57
    // gdal_contour specific arguments
58
    int m_band = 1;                     // -b
59
    std::string m_elevAttributeName{};  // -a <name>
60
    std::string m_amin{};               // -amin <value>
61
    std::string m_amax{};               // -amax <value>
62
    bool m_3d = false;                  // -3d
63
                                        // -inodata (skipped)
64
    double m_sNodata =
65
        std::numeric_limits<double>::quiet_NaN();  // -snodata <value>
66
    double m_interval =
67
        std::numeric_limits<double>::quiet_NaN();  // -i <interval>
68
    double m_offset =
69
        std::numeric_limits<double>::quiet_NaN();  // -off <offset>
70
    std::vector<std::string>
71
        m_levels{};     // -fl <level>[,<level>...] MIN/MAX are also supported
72
    int m_expBase = 0;  // -e <base>
73
    bool m_polygonize = false;    // -p
74
    int m_groupTransactions = 0;  // gt <n>
75
};
76
77
/************************************************************************/
78
/*                 GDALRasterContourAlgorithmStandalone                 */
79
/************************************************************************/
80
81
class GDALRasterContourAlgorithmStandalone final
82
    : public GDALRasterContourAlgorithm
83
{
84
  public:
85
    GDALRasterContourAlgorithmStandalone()
86
0
        : GDALRasterContourAlgorithm(/* standaloneStep = */ true)
87
0
    {
88
0
    }
89
90
    ~GDALRasterContourAlgorithmStandalone() override;
91
};
92
93
//! @endcond
94
95
#endif