GDAL

gdalalg_raster_polygonize.h
1/******************************************************************************
2 *
3 * Project: GDAL
4 * Purpose: gdal "raster polygonize" subcommand
5 * Author: Even Rouault <even dot rouault at spatialys.com>
6 *
7 ******************************************************************************
8 * Copyright (c) 2025, Even Rouault <even dot rouault at spatialys.com>
9 *
10 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
13#ifndef GDALALG_RASTER_POLYGONIZE_INCLUDED
14#define GDALALG_RASTER_POLYGONIZE_INCLUDED
15
16#include "gdalalg_abstract_pipeline.h"
17
19
20/************************************************************************/
21/* GDALRasterPolygonizeAlgorithm */
22/************************************************************************/
23
24 class GDALRasterPolygonizeAlgorithm /* non final */
25 : public GDALPipelineStepAlgorithm
26{
27 public:
28 static constexpr const char *NAME = "polygonize";
29 static constexpr const char *DESCRIPTION =
30 "Create a polygon feature dataset from a raster band.";
31 static constexpr const char *HELP_URL =
32 "/programs/gdal_raster_polygonize.html";
33
34 explicit GDALRasterPolygonizeAlgorithm(bool standaloneStep = false);
35
36 bool IsNativelyStreamingCompatible() const override
37 {
38 return false;
39 }
40
41 int GetInputType() const override
42 {
43 return GDAL_OF_RASTER;
44 }
45
46 int GetOutputType() const override
47 {
48 return GDAL_OF_VECTOR;
49 }
50
51 bool
52 CanHandleNextStep(GDALPipelineStepAlgorithm *poNextStep) const override;
53
54 private:
55 bool RunStep(GDALPipelineStepRunContext &ctxt) override;
56 bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override;
57
58 // polygonize specific arguments
59 int m_band = 1;
60 std::string m_attributeName = "DN";
61 bool m_connectDiagonalPixels = false;
62
63 // hidden
64 int m_commitInterval = 0;
65};
66
67/************************************************************************/
68/* GDALRasterPolygonizeAlgorithmStandalone */
69/************************************************************************/
70
71 class GDALRasterPolygonizeAlgorithmStandalone final
72 : public GDALRasterPolygonizeAlgorithm
73{
74 public:
75 GDALRasterPolygonizeAlgorithmStandalone()
76 : GDALRasterPolygonizeAlgorithm(/* standaloneStep = */ true)
77 {
78 }
79
80 ~GDALRasterPolygonizeAlgorithmStandalone() override;
81};
82
84
85#endif
GDAL_OF_RASTER
#define GDAL_OF_RASTER
Allow raster drivers to be used.
Definition gdal.h:1086
GDAL_OF_VECTOR
#define GDAL_OF_VECTOR
Allow vector drivers to be used.
Definition gdal.h:1091