LCOV - code coverage report
Current view: top level - apps - gdalalg_raster_contour.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 10 10 100.0 %
Date: 2025-06-19 12:30:01 Functions: 6 6 100.0 %

          Line data    Source code
       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             : 
      20             : //! @cond Doxygen_Suppress
      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           1 :     bool IsNativelyStreamingCompatible() const override
      39             :     {
      40           1 :         return false;
      41             :     }
      42             : 
      43           1 :     int GetInputType() const override
      44             :     {
      45           1 :         return GDAL_OF_RASTER;
      46             :     }
      47             : 
      48           1 :     int GetOutputType() const override
      49             :     {
      50           1 :         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          40 : class GDALRasterContourAlgorithmStandalone final
      82             :     : public GDALRasterContourAlgorithm
      83             : {
      84             :   public:
      85          20 :     GDALRasterContourAlgorithmStandalone()
      86          20 :         : GDALRasterContourAlgorithm(/* standaloneStep = */ true)
      87             :     {
      88          20 :     }
      89             : 
      90             :     ~GDALRasterContourAlgorithmStandalone() override;
      91             : };
      92             : 
      93             : //! @endcond
      94             : 
      95             : #endif

Generated by: LCOV version 1.14