LCOV - code coverage report
Current view: top level - apps - gdalalg_raster_compare.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 10 10 100.0 %
Date: 2026-06-23 16:35:19 Functions: 6 6 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  gdal "raster compare" subcommand
       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_COMPARE_INCLUDED
      14             : #define GDALALG_RASTER_COMPARE_INCLUDED
      15             : 
      16             : #include "gdalrasterpipelinestepalgorithm.h"
      17             : #include "gdalalg_compare_common.h"
      18             : 
      19             : class GDALRasterBand;
      20             : class GDALDataset;
      21             : 
      22             : //! @cond Doxygen_Suppress
      23             : 
      24             : /************************************************************************/
      25             : /*                      GDALRasterCompareAlgorithm                      */
      26             : /************************************************************************/
      27             : 
      28             : class GDALRasterCompareAlgorithm /* non final */
      29             :     : public GDALRasterPipelineStepAlgorithm,
      30             :       public GDALCompareCommon
      31             : {
      32             :   public:
      33             :     static constexpr const char *NAME = "compare";
      34             :     static constexpr const char *DESCRIPTION = "Compare two raster datasets.";
      35             :     static constexpr const char *HELP_URL =
      36             :         "/programs/gdal_raster_compare.html";
      37             : 
      38             :     explicit GDALRasterCompareAlgorithm(bool standaloneStep = false);
      39             : 
      40           8 :     bool IsNativelyStreamingCompatible() const override
      41             :     {
      42           8 :         return false;
      43             :     }
      44             : 
      45          17 :     bool CanBeLastStep() const override
      46             :     {
      47          17 :         return true;
      48             :     }
      49             : 
      50         210 :     int GetOutputType() const override
      51             :     {
      52         210 :         return 0;
      53             :     }
      54             : 
      55             :   private:
      56             :     bool RunStep(GDALPipelineStepRunContext &ctxt) override;
      57             : 
      58             :     void DatasetComparison(std::vector<std::string> &aosReport,
      59             :                            GDALDataset *poRefDS, GDALDataset *poInputDS,
      60             :                            GDALProgressFunc pfnProgress, void *pProgressData);
      61             : 
      62             :     static void CRSComparison(std::vector<std::string> &aosReport,
      63             :                               GDALDataset *poRefDS, GDALDataset *poInputDS);
      64             : 
      65             :     static void GeoTransformComparison(std::vector<std::string> &aosReport,
      66             :                                        GDALDataset *poRefDS,
      67             :                                        GDALDataset *poInputDS);
      68             : 
      69             :     void BandComparison(std::vector<std::string> &aosReport,
      70             :                         const std::string &bandId,
      71             :                         bool doBandBasedPixelComparison,
      72             :                         GDALRasterBand *poRefBand, GDALRasterBand *poInputBand,
      73             :                         GDALProgressFunc pfnProgress, void *pProgressData);
      74             : 
      75             :     static void MetadataComparison(std::vector<std::string> &aosReport,
      76             :                                    const std::string &metadataDomain,
      77             :                                    CSLConstList aosRef, CSLConstList aosInput);
      78             : 
      79             :     bool m_skipAllOptional = false;
      80             :     bool m_skipCRS = false;
      81             :     bool m_skipGeotransform = false;
      82             :     bool m_skipOverview = false;
      83             :     bool m_skipMetadata = false;
      84             :     bool m_skipRPC = false;
      85             :     bool m_skipGeolocation = false;
      86             :     bool m_skipSubdataset = false;
      87             :     // If adding a new skip flag, make sure that m_skipAll takes it into account
      88             : };
      89             : 
      90             : /************************************************************************/
      91             : /*                 GDALRasterCompareAlgorithmStandalone                 */
      92             : /************************************************************************/
      93             : 
      94         502 : class GDALRasterCompareAlgorithmStandalone final
      95             :     : public GDALRasterCompareAlgorithm
      96             : {
      97             :   public:
      98         251 :     GDALRasterCompareAlgorithmStandalone()
      99         251 :         : GDALRasterCompareAlgorithm(/* standaloneStep = */ true)
     100             :     {
     101         251 :     }
     102             : 
     103             :     ~GDALRasterCompareAlgorithmStandalone() override;
     104             : };
     105             : 
     106             : //! @endcond
     107             : 
     108             : #endif

Generated by: LCOV version 1.14