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 10 : bool IsNativelyStreamingCompatible() const override 41 : { 42 10 : return false; 43 : } 44 : 45 18 : bool CanBeLastStep() const override 46 : { 47 18 : return true; 48 : } 49 : 50 432 : int GetOutputType() const override 51 : { 52 432 : 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 : bool m_skipAllOptional = false; 76 : bool m_skipCRS = false; 77 : bool m_skipGeotransform = false; 78 : bool m_skipOverview = false; 79 : bool m_skipMetadata = false; 80 : bool m_skipRPC = false; 81 : bool m_skipGeolocation = false; 82 : bool m_skipSubdataset = false; 83 : // If adding a new skip flag, make sure that m_skipAll takes it into account 84 : }; 85 : 86 : /************************************************************************/ 87 : /* GDALRasterCompareAlgorithmStandalone */ 88 : /************************************************************************/ 89 : 90 516 : class GDALRasterCompareAlgorithmStandalone final 91 : : public GDALRasterCompareAlgorithm 92 : { 93 : public: 94 258 : GDALRasterCompareAlgorithmStandalone() 95 258 : : GDALRasterCompareAlgorithm(/* standaloneStep = */ true) 96 : { 97 258 : } 98 : 99 : ~GDALRasterCompareAlgorithmStandalone() override; 100 : }; 101 : 102 : //! @endcond 103 : 104 : #endif