Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: Common code between raster compare and mdim compare 5 : * Author: Even Rouault <even dot rouault at spatialys.com> 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2026, Even Rouault <even dot rouault at spatialys.com> 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #ifndef GDALALG_COMPARE_COMMON_INCLUDED 14 : #define GDALALG_COMPARE_COMMON_INCLUDED 15 : 16 : #include "gdalalgorithm.h" 17 : 18 : #include <algorithm> 19 : #include <string> 20 : #include <vector> 21 : 22 : //! @cond Doxygen_Suppress 23 : 24 : class GDALAlgorithm; 25 : class GDALDataset; 26 : 27 : /************************************************************************/ 28 : /* GDALCompareCommon */ 29 : /************************************************************************/ 30 : 31 1035 : class GDALCompareCommon 32 : { 33 : public: 34 : virtual ~GDALCompareCommon(); 35 : 36 : protected: 37 : GDALCompareCommon(); 38 : 39 : static constexpr const char *METRIC_ALL = "all"; 40 : static constexpr const char *METRIC_NONE = "none"; 41 : static constexpr const char *METRIC_DIFF = "diff"; 42 : static constexpr const char *METRIC_RMSD = "RMSD"; 43 : static constexpr const char *METRIC_PSNR = "PSNR"; 44 : 45 : static constexpr const char *METRIC_DEFAULT = METRIC_DIFF; 46 : std::vector<std::string> m_metrics{METRIC_DEFAULT}; 47 : 48 : GDALArgDatasetValue m_referenceDataset{}; 49 : 50 : std::vector<std::string> m_array{}; 51 : 52 : bool m_skipBinary = false; 53 : int m_retCode = 0; 54 : 55 1091 : bool HasMetric(const char *pszMetric) const 56 : { 57 1091 : CPLAssert(!EQUAL(pszMetric, METRIC_ALL)); 58 1091 : return std::find(m_metrics.begin(), m_metrics.end(), pszMetric) != 59 2897 : m_metrics.end() || 60 1369 : (!EQUAL(pszMetric, METRIC_NONE) && 61 654 : std::find(m_metrics.begin(), m_metrics.end(), METRIC_ALL) != 62 1745 : m_metrics.end()); 63 : } 64 : 65 : static bool BinaryComparison(GDALAlgorithm *alg, 66 : std::vector<std::string> &aosReport, 67 : GDALDataset *poRefDS, GDALDataset *poInputDS); 68 : }; 69 : 70 : //! @endcond 71 : 72 : #endif