/src/gdal/apps/gdalalg_compare_common.h
Line | Count | Source |
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 | | 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 | | bool HasMetric(const char *pszMetric) const |
56 | 0 | { |
57 | 0 | CPLAssert(!EQUAL(pszMetric, METRIC_ALL)); |
58 | 0 | return std::find(m_metrics.begin(), m_metrics.end(), pszMetric) != |
59 | 0 | m_metrics.end() || |
60 | 0 | (!EQUAL(pszMetric, METRIC_NONE) && |
61 | 0 | std::find(m_metrics.begin(), m_metrics.end(), METRIC_ALL) != |
62 | 0 | m_metrics.end()); |
63 | 0 | } |
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 |