Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: GDAL Core 4 : * Purpose: Declaration of GDALPamMDArray class 5 : * Author: Even Rouault <even.rouault at spatialys.com> 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2019, Even Rouault <even.rouault at spatialys.com> 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #ifndef GDAL_PAM_MULTIDIM_H_INCLUDED 14 : #define GDAL_PAM_MULTIDIM_H_INCLUDED 15 : 16 : #include "cpl_port.h" 17 : 18 : #include "gdal_multidim.h" 19 : 20 : #include <memory> 21 : #include <string> 22 : 23 : //! @cond Doxygen_Suppress 24 : 25 : /* ******************************************************************** */ 26 : /* GDALPamMultiDim */ 27 : /* ******************************************************************** */ 28 : 29 : /** Class that serializes/deserializes metadata on multidimensional objects. 30 : * Currently SRS on GDALMDArray. 31 : */ 32 : class CPL_DLL GDALPamMultiDim final 33 : { 34 : struct Private; 35 : std::unique_ptr<Private> d; 36 : 37 : void Load(); 38 : void Save(); 39 : 40 : public: 41 : explicit GDALPamMultiDim(const std::string &osFilename); 42 : ~GDALPamMultiDim(); 43 : 44 : std::shared_ptr<OGRSpatialReference> 45 : GetSpatialRef(const std::string &osArrayFullName, 46 : const std::string &osContext); 47 : 48 : void SetSpatialRef(const std::string &osArrayFullName, 49 : const std::string &osContext, 50 : const OGRSpatialReference *poSRS); 51 : 52 : CPLErr GetStatistics(const std::string &osArrayFullName, 53 : const std::string &osContext, bool bApproxOK, 54 : double *pdfMin, double *pdfMax, double *pdfMean, 55 : double *pdfStdDev, GUInt64 *pnValidCount); 56 : 57 : void SetStatistics(const std::string &osArrayFullName, 58 : const std::string &osContext, bool bApproxStats, 59 : double dfMin, double dfMax, double dfMean, 60 : double dfStdDev, GUInt64 nValidCount); 61 : 62 : void ClearStatistics(); 63 : 64 : void ClearStatistics(const std::string &osArrayFullName, 65 : const std::string &osContext); 66 : 67 : std::string GetOverviewFilename(const std::string &osArrayFullName, 68 : const std::string &osContext); 69 : std::string GenerateOverviewFilename(const std::string &osArrayFullName, 70 : const std::string &osContext); 71 : 72 : static std::shared_ptr<GDALPamMultiDim> 73 : GetPAM(const std::shared_ptr<GDALMDArray> &poParent); 74 : }; 75 : 76 : /* ******************************************************************** */ 77 : /* GDALPamMDArray */ 78 : /* ******************************************************************** */ 79 : 80 : /** Class that relies on GDALPamMultiDim to serializes/deserializes metadata. */ 81 : class CPL_DLL GDALPamMDArray : public GDALMDArray 82 : { 83 : std::shared_ptr<GDALPamMultiDim> m_poPam; 84 : 85 : protected: 86 : GDALPamMDArray(const std::string &osParentName, const std::string &osName, 87 : const std::shared_ptr<GDALPamMultiDim> &poPam, 88 : const std::string &osContext = std::string()); 89 : 90 : bool SetStatistics(bool bApproxStats, double dfMin, double dfMax, 91 : double dfMean, double dfStdDev, GUInt64 nValidCount, 92 : CSLConstList papszOptions) override; 93 : 94 : public: 95 793 : const std::shared_ptr<GDALPamMultiDim> &GetPAM() const 96 : { 97 793 : return m_poPam; 98 : } 99 : 100 : CPLErr GetStatistics(bool bApproxOK, bool bForce, double *pdfMin, 101 : double *pdfMax, double *pdfMean, double *padfStdDev, 102 : GUInt64 *pnValidCount, GDALProgressFunc pfnProgress, 103 : void *pProgressData) override; 104 : 105 : void ClearStatistics() override; 106 : 107 : bool SetSpatialRef(const OGRSpatialReference *poSRS) override; 108 : 109 : std::shared_ptr<OGRSpatialReference> GetSpatialRef() const override; 110 : }; 111 : 112 : //! @endcond 113 : 114 : #endif