GDAL

gdalalg_raster_contour.h
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
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 {
40 return false;
41 }
42
43 int GetInputType() const override
44 {
45 return GDAL_OF_RASTER;
46 }
47
48 int GetOutputType() const override
49 {
50 return GDAL_OF_VECTOR;
51 }
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 : GDALRasterContourAlgorithm(/* standaloneStep = */ true)
87 {
88 }
89
90 ~GDALRasterContourAlgorithmStandalone() override;
91};
92
94
95#endif
GDAL_OF_RASTER
#define GDAL_OF_RASTER
Allow raster drivers to be used.
Definition gdal.h:1088
GDAL_OF_VECTOR
#define GDAL_OF_VECTOR
Allow vector drivers to be used.
Definition gdal.h:1093