GDAL

gdalalg_raster_compare.h
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
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 {
37 return false;
38 }
39
40 bool CanBeLastStep() const override
41 {
42 return true;
43 }
44
45 private:
46 bool RunStep(GDALPipelineStepRunContext &ctxt) override;
47
48 bool BinaryComparison(std::vector<std::string> &aosReport,
49 GDALDataset *poRefDS, GDALDataset *poInputDS);
50
51 void DatasetComparison(std::vector<std::string> &aosReport,
52 GDALDataset *poRefDS, GDALDataset *poInputDS,
53 GDALProgressFunc pfnProgress, void *pProgressData);
54
55 static void CRSComparison(std::vector<std::string> &aosReport,
56 GDALDataset *poRefDS, GDALDataset *poInputDS);
57
58 static void GeoTransformComparison(std::vector<std::string> &aosReport,
59 GDALDataset *poRefDS,
60 GDALDataset *poInputDS);
61
62 void BandComparison(std::vector<std::string> &aosReport,
63 const std::string &bandId,
64 bool doBandBasedPixelComparison,
65 GDALRasterBand *poRefBand, GDALRasterBand *poInputBand,
66 GDALProgressFunc pfnProgress, void *pProgressData);
67
68 static void MetadataComparison(std::vector<std::string> &aosReport,
69 const std::string &metadataDomain,
70 CSLConstList aosRef, CSLConstList aosInput);
71
72 GDALArgDatasetValue m_referenceDataset{};
73 bool m_skipAllOptional = false;
74 bool m_skipBinary = false;
75 bool m_skipCRS = false;
76 bool m_skipGeotransform = false;
77 bool m_skipOverview = false;
78 bool m_skipMetadata = false;
79 bool m_skipRPC = false;
80 bool m_skipGeolocation = false;
81 bool m_skipSubdataset = false;
82 // If adding a new skip flag, make sure that m_skipAll takes it into account
83 int m_retCode = 0;
84};
85
86/************************************************************************/
87/* GDALRasterCompareAlgorithmStandalone */
88/************************************************************************/
89
90 class GDALRasterCompareAlgorithmStandalone final
91 : public GDALRasterCompareAlgorithm
92{
93 public:
94 GDALRasterCompareAlgorithmStandalone()
95 : GDALRasterCompareAlgorithm(/* standaloneStep = */ true)
96 {
97 }
98
99 ~GDALRasterCompareAlgorithmStandalone() override;
100};
101
103
104#endif
GDALArgDatasetValue
Value for an argument that points to a GDALDataset.
Definition gdalalgorithm_cpp.h:149
GDALDataset
A set of associated raster bands, usually from one file.
Definition gdal_dataset.h:76
GDALRasterBand
A single raster band (or channel).
Definition gdal_rasterband.h:105
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087