LCOV - code coverage report
Current view: top level - apps - gdalalg_raster_nodata_to_alpha.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 4 4 100.0 %
Date: 2026-09-11 05:09:32 Functions: 3 3 100.0 %

          Line data    Source code
       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         102 : class GDALRasterNoDataToAlphaAlgorithmStandalone final
      53             :     : public GDALRasterNoDataToAlphaAlgorithm
      54             : {
      55             :   public:
      56          51 :     GDALRasterNoDataToAlphaAlgorithmStandalone()
      57          51 :         : GDALRasterNoDataToAlphaAlgorithm(/* standaloneStep = */ true)
      58             :     {
      59          51 :     }
      60             : 
      61             :     ~GDALRasterNoDataToAlphaAlgorithmStandalone() override;
      62             : };
      63             : 
      64             : //! @endcond
      65             : 
      66             : #endif /* GDALALG_RASTER_NODATA_TO_ALPHA_INCLUDED */

Generated by: LCOV version 1.14