Coverage Report

Created: 2026-07-25 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/apps/gdalalg_raster_compare.h
Line
Count
Source
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
    bool IsNativelyStreamingCompatible() const override
41
0
    {
42
0
        return false;
43
0
    }
44
45
    bool CanBeLastStep() const override
46
0
    {
47
0
        return true;
48
0
    }
49
50
    int GetOutputType() const override
51
0
    {
52
0
        return 0;
53
0
    }
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
class GDALRasterCompareAlgorithmStandalone final
95
    : public GDALRasterCompareAlgorithm
96
{
97
  public:
98
    GDALRasterCompareAlgorithmStandalone()
99
0
        : GDALRasterCompareAlgorithm(/* standaloneStep = */ true)
100
0
    {
101
0
    }
102
103
    ~GDALRasterCompareAlgorithmStandalone() override;
104
};
105
106
//! @endcond
107
108
#endif