Coverage Report

Created: 2026-04-01 06:20

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 "gdalalg_raster_pipeline.h"
17
18
//! @cond Doxygen_Suppress
19
20
/************************************************************************/
21
/*                      GDALRasterCompareAlgorithm                      */
22
/************************************************************************/
23
24
class GDALRasterCompareAlgorithm /* non final */
25
    : public GDALRasterPipelineStepAlgorithm
26
{
27
  public:
28
    static constexpr const char *NAME = "compare";
29
    static constexpr const char *DESCRIPTION = "Compare two raster datasets.";
30
    static constexpr const char *HELP_URL =
31
        "/programs/gdal_raster_compare.html";
32
33
    explicit GDALRasterCompareAlgorithm(bool standaloneStep = false);
34
35
    bool IsNativelyStreamingCompatible() const override
36
0
    {
37
0
        return false;
38
0
    }
39
40
    bool CanBeLastStep() const override
41
0
    {
42
0
        return true;
43
0
    }
44
45
    int GetOutputType() const override
46
0
    {
47
0
        return 0;
48
0
    }
49
50
  private:
51
    bool RunStep(GDALPipelineStepRunContext &ctxt) override;
52
53
    bool BinaryComparison(std::vector<std::string> &aosReport,
54
                          GDALDataset *poRefDS, GDALDataset *poInputDS);
55
56
    void DatasetComparison(std::vector<std::string> &aosReport,
57
                           GDALDataset *poRefDS, GDALDataset *poInputDS,
58
                           GDALProgressFunc pfnProgress, void *pProgressData);
59
60
    static void CRSComparison(std::vector<std::string> &aosReport,
61
                              GDALDataset *poRefDS, GDALDataset *poInputDS);
62
63
    static void GeoTransformComparison(std::vector<std::string> &aosReport,
64
                                       GDALDataset *poRefDS,
65
                                       GDALDataset *poInputDS);
66
67
    void BandComparison(std::vector<std::string> &aosReport,
68
                        const std::string &bandId,
69
                        bool doBandBasedPixelComparison,
70
                        GDALRasterBand *poRefBand, GDALRasterBand *poInputBand,
71
                        GDALProgressFunc pfnProgress, void *pProgressData);
72
73
    static void MetadataComparison(std::vector<std::string> &aosReport,
74
                                   const std::string &metadataDomain,
75
                                   CSLConstList aosRef, CSLConstList aosInput);
76
77
    GDALArgDatasetValue m_referenceDataset{};
78
    bool m_skipAllOptional = false;
79
    bool m_skipBinary = 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
    int m_retCode = 0;
89
};
90
91
/************************************************************************/
92
/*                 GDALRasterCompareAlgorithmStandalone                 */
93
/************************************************************************/
94
95
class GDALRasterCompareAlgorithmStandalone final
96
    : public GDALRasterCompareAlgorithm
97
{
98
  public:
99
    GDALRasterCompareAlgorithmStandalone()
100
0
        : GDALRasterCompareAlgorithm(/* standaloneStep = */ true)
101
0
    {
102
0
    }
103
104
    ~GDALRasterCompareAlgorithmStandalone() override;
105
};
106
107
//! @endcond
108
109
#endif