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