LCOV - code coverage report
Current view: top level - apps - gdalalg_raster_info.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 15 15 100.0 %
Date: 2025-08-01 10:10:57 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  gdal "raster info" subcommand
       5             :  * Author:   Even Rouault <even dot rouault at spatialys.com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2024, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #ifndef GDALALG_RASTER_INFO_INCLUDED
      14             : #define GDALALG_RASTER_INFO_INCLUDED
      15             : 
      16             : #include "gdalalg_raster_pipeline.h"
      17             : 
      18             : //! @cond Doxygen_Suppress
      19             : 
      20             : /************************************************************************/
      21             : /*                       GDALRasterInfoAlgorithm                        */
      22             : /************************************************************************/
      23             : 
      24             : class GDALRasterInfoAlgorithm /* non final */
      25             :     : public GDALRasterPipelineStepAlgorithm
      26             : {
      27             :   public:
      28             :     static constexpr const char *NAME = "info";
      29             :     static constexpr const char *DESCRIPTION =
      30             :         "Return information on a raster dataset.";
      31             :     static constexpr const char *HELP_URL = "/programs/gdal_raster_info.html";
      32             : 
      33             :     explicit GDALRasterInfoAlgorithm(bool standaloneStep = false,
      34             :                                      bool openForMixedRasterVector = false);
      35             : 
      36          21 :     GDALDataset *GetDatasetRef()
      37             :     {
      38          21 :         return m_inputDataset.empty() ? nullptr
      39          21 :                                       : m_inputDataset[0].GetDatasetRef();
      40             :     }
      41             : 
      42           1 :     void SetDataset(GDALDataset *poDS)
      43             :     {
      44           1 :         auto arg = GetArg(GDAL_ARG_NAME_INPUT);
      45           1 :         if (arg)
      46             :         {
      47           1 :             auto &val = arg->Get<std::vector<GDALArgDatasetValue>>();
      48           1 :             val.resize(1);
      49           1 :             val[0].Set(poDS);
      50           1 :             arg->SetSkipIfAlreadySet();
      51             :         }
      52           1 :     }
      53             : 
      54             :   private:
      55             :     bool RunStep(GDALPipelineStepRunContext &ctxt) override;
      56             : 
      57             :     bool m_minMax = false;
      58             :     bool m_stats = false;
      59             :     bool m_approxStats = false;
      60             :     bool m_hist = false;
      61             :     bool m_noGCP = false;
      62             :     bool m_noMD = false;
      63             :     bool m_noCT = false;
      64             :     bool m_noFL = false;
      65             :     bool m_noMask = false;
      66             :     bool m_noNodata = false;
      67             :     bool m_checksum = false;
      68             :     bool m_listMDD = false;
      69             :     std::string m_mdd{};
      70             :     int m_subDS = 0;
      71             : };
      72             : 
      73             : /************************************************************************/
      74             : /*                 GDALRasterInfoAlgorithmStandalone                    */
      75             : /************************************************************************/
      76             : 
      77          82 : class GDALRasterInfoAlgorithmStandalone final : public GDALRasterInfoAlgorithm
      78             : {
      79             :   public:
      80          41 :     GDALRasterInfoAlgorithmStandalone()
      81          41 :         : GDALRasterInfoAlgorithm(/* standaloneStep = */ true)
      82             :     {
      83          41 :     }
      84             : 
      85             :     ~GDALRasterInfoAlgorithmStandalone() override;
      86             : };
      87             : 
      88             : //! @endcond
      89             : 
      90             : #endif

Generated by: LCOV version 1.14