Coverage Report

Created: 2026-09-14 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/apps/gdalalg_raster_nodata_to_alpha.h
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Project:  GDAL
4
 * Purpose:  "nodata-to-alpha" step of "raster pipeline"
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_NODATA_TO_ALPHA_INCLUDED
14
#define GDALALG_RASTER_NODATA_TO_ALPHA_INCLUDED
15
16
#include "gdalrasterpipelinestepalgorithm.h"
17
#include "gdal_dataset.h"
18
19
//! @cond Doxygen_Suppress
20
21
/************************************************************************/
22
/*                   GDALRasterNoDataToAlphaAlgorithm                   */
23
/************************************************************************/
24
25
class GDALRasterNoDataToAlphaAlgorithm /* non final */
26
    : public GDALRasterPipelineStepAlgorithm
27
{
28
  public:
29
    static constexpr const char *NAME = "nodata-to-alpha";
30
    static constexpr const char *DESCRIPTION =
31
        "Replace nodata value(s) with an alpha band.";
32
    static constexpr const char *HELP_URL =
33
        "/programs/gdal_raster_nodata_to_alpha.html";
34
35
    explicit GDALRasterNoDataToAlphaAlgorithm(bool standaloneStep = false);
36
37
  private:
38
    bool RunStep(GDALPipelineStepRunContext &ctxt) override;
39
40
    std::vector<double> m_nodata{};
41
42
    // Work variables
43
    // Reference-counting releaser: the output VRT references it and
44
    // outlives this algorithm.
45
    std::unique_ptr<GDALDataset, GDALDatasetUniquePtrReleaser> m_tempDS{};
46
};
47
48
/************************************************************************/
49
/*              GDALRasterNoDataToAlphaAlgorithmStandalone              */
50
/************************************************************************/
51
52
class GDALRasterNoDataToAlphaAlgorithmStandalone final
53
    : public GDALRasterNoDataToAlphaAlgorithm
54
{
55
  public:
56
    GDALRasterNoDataToAlphaAlgorithmStandalone()
57
0
        : GDALRasterNoDataToAlphaAlgorithm(/* standaloneStep = */ true)
58
0
    {
59
0
    }
60
61
    ~GDALRasterNoDataToAlphaAlgorithmStandalone() override;
62
};
63
64
//! @endcond
65
66
#endif /* GDALALG_RASTER_NODATA_TO_ALPHA_INCLUDED */