File: gdalalg_raster_polygonize.h

package info (click to toggle)
gdal 3.12.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 92,292 kB
  • sloc: cpp: 1,223,498; ansic: 206,434; python: 26,278; java: 6,001; xml: 4,769; sh: 3,855; cs: 2,513; yacc: 1,306; makefile: 214
file content (85 lines) | stat: -rw-r--r-- 2,524 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/******************************************************************************
 *
 * Project:  GDAL
 * Purpose:  gdal "raster polygonize" subcommand
 * Author:   Even Rouault <even dot rouault at spatialys.com>
 *
 ******************************************************************************
 * Copyright (c) 2025, Even Rouault <even dot rouault at spatialys.com>
 *
 * SPDX-License-Identifier: MIT
 ****************************************************************************/

#ifndef GDALALG_RASTER_POLYGONIZE_INCLUDED
#define GDALALG_RASTER_POLYGONIZE_INCLUDED

#include "gdalalg_abstract_pipeline.h"

//! @cond Doxygen_Suppress

/************************************************************************/
/*                     GDALRasterPolygonizeAlgorithm                    */
/************************************************************************/

class GDALRasterPolygonizeAlgorithm /* non final */
    : public GDALPipelineStepAlgorithm
{
  public:
    static constexpr const char *NAME = "polygonize";
    static constexpr const char *DESCRIPTION =
        "Create a polygon feature dataset from a raster band.";
    static constexpr const char *HELP_URL =
        "/programs/gdal_raster_polygonize.html";

    explicit GDALRasterPolygonizeAlgorithm(bool standaloneStep = false);

    bool IsNativelyStreamingCompatible() const override
    {
        return false;
    }

    int GetInputType() const override
    {
        return GDAL_OF_RASTER;
    }

    int GetOutputType() const override
    {
        return GDAL_OF_VECTOR;
    }

    bool
    CanHandleNextStep(GDALPipelineStepAlgorithm *poNextStep) const override;

  private:
    bool RunStep(GDALPipelineStepRunContext &ctxt) override;
    bool RunImpl(GDALProgressFunc pfnProgress, void *pProgressData) override;

    // polygonize specific arguments
    int m_band = 1;
    std::string m_attributeName = "DN";
    bool m_connectDiagonalPixels = false;

    // hidden
    int m_commitInterval = 0;
};

/************************************************************************/
/*                 GDALRasterPolygonizeAlgorithmStandalone              */
/************************************************************************/

class GDALRasterPolygonizeAlgorithmStandalone final
    : public GDALRasterPolygonizeAlgorithm
{
  public:
    GDALRasterPolygonizeAlgorithmStandalone()
        : GDALRasterPolygonizeAlgorithm(/* standaloneStep = */ true)
    {
    }

    ~GDALRasterPolygonizeAlgorithmStandalone() override;
};

//! @endcond

#endif