Line data Source code
1 : /******************************************************************************
2 : *
3 : * Project: GeoTIFF Driver
4 : * Purpose: GDAL GeoTIFF support.
5 : * Author: Frank Warmerdam, warmerdam@pobox.com
6 : *
7 : ******************************************************************************
8 : * Copyright (c) 1998, 2002, Frank Warmerdam <warmerdam@pobox.com>
9 : * Copyright (c) 2007-2015, Even Rouault <even dot rouault at spatialys dot com>
10 : *
11 : * SPDX-License-Identifier: MIT
12 : ****************************************************************************/
13 :
14 : #ifndef GTIFFRASTERBAND_H_INCLUDED
15 : #define GTIFFRASTERBAND_H_INCLUDED
16 :
17 : #include "gdal_pam.h"
18 : #include "gdal_rat.h"
19 :
20 : #include "gtiff.h"
21 :
22 : #include <set>
23 :
24 : /************************************************************************/
25 : /* ==================================================================== */
26 : /* GTiffRasterBand */
27 : /* ==================================================================== */
28 : /************************************************************************/
29 :
30 : class GTiffDataset;
31 :
32 : class GTiffRasterBand CPL_NON_FINAL : public GDALPamRasterBand
33 : {
34 : CPL_DISALLOW_COPY_ASSIGN(GTiffRasterBand)
35 :
36 : friend class GTiffDataset;
37 :
38 : double m_dfOffset = 0;
39 : double m_dfScale = 1;
40 : CPLString m_osUnitType{};
41 : CPLString m_osDescription{};
42 : GDALColorInterp m_eBandInterp = GCI_Undefined;
43 : std::set<GTiffRasterBand **> m_aSetPSelf{};
44 : bool m_bHaveOffsetScale = false;
45 : bool m_bRATSet = false;
46 : bool m_bRATTriedReadingFromPAM = false;
47 : std::unique_ptr<GDALRasterAttributeTable> m_poRAT{};
48 :
49 : int DirectIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
50 : int nYSize, void *pData, int nBufXSize, int nBufYSize,
51 : GDALDataType eBufType, GSpacing nPixelSpace,
52 : GSpacing nLineSpace, GDALRasterIOExtraArg *psExtraArg);
53 :
54 : static void DropReferenceVirtualMem(void *pUserData);
55 : CPLVirtualMem *GetVirtualMemAutoInternal(GDALRWFlag eRWFlag,
56 : int *pnPixelSpace,
57 : GIntBig *pnLineSpace,
58 : char **papszOptions);
59 :
60 : protected:
61 : GTiffDataset *m_poGDS = nullptr;
62 : GDALMultiDomainMetadata m_oGTiffMDMD{};
63 :
64 : double m_dfNoDataValue = DEFAULT_NODATA_VALUE;
65 : bool m_bNoDataSet = false;
66 :
67 : int64_t m_nNoDataValueInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_INT64;
68 : bool m_bNoDataSetAsInt64 = false;
69 :
70 : uint64_t m_nNoDataValueUInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64;
71 : bool m_bNoDataSetAsUInt64 = false;
72 :
73 : void NullBlock(void *pData);
74 : CPLErr FillCacheForOtherBands(int nBlockXOff, int nBlockYOff);
75 : void CacheMaskForBlock(int nBlockXOff, int nBlockYOff);
76 : void ResetNoDataValues(bool bResetDatasetToo);
77 :
78 : int ComputeBlockId(int nBlockXOff, int nBlockYOff) const;
79 :
80 : public:
81 : GTiffRasterBand(GTiffDataset *, int);
82 : ~GTiffRasterBand() override;
83 :
84 3256 : virtual bool IsBaseGTiffClass() const
85 : {
86 3256 : return true;
87 : }
88 :
89 : CPLErr IReadBlock(int, int, void *) override;
90 : CPLErr IWriteBlock(int, int, void *) override;
91 :
92 : virtual GDALSuggestedBlockAccessPattern
93 821 : GetSuggestedBlockAccessPattern() const override
94 : {
95 821 : return GSBAP_RANDOM;
96 : }
97 :
98 : virtual int IGetDataCoverageStatus(int nXOff, int nYOff, int nXSize,
99 : int nYSize, int nMaskFlagStop,
100 : double *pdfDataPct) override;
101 :
102 : CPLErr IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
103 : int nYSize, void *pData, int nBufXSize, int nBufYSize,
104 : GDALDataType eBufType, GSpacing nPixelSpace,
105 : GSpacing nLineSpace,
106 : GDALRasterIOExtraArg *psExtraArg) override final;
107 :
108 : const char *GetDescription() const override final;
109 : void SetDescription(const char *) override final;
110 :
111 : GDALColorInterp GetColorInterpretation() override /*final*/;
112 : GDALColorTable *GetColorTable() override /*final*/;
113 : CPLErr SetColorTable(GDALColorTable *) override final;
114 :
115 : CPLErr SetNoDataValue(double) override final;
116 : CPLErr SetNoDataValueAsInt64(int64_t nNoData) override final;
117 : CPLErr SetNoDataValueAsUInt64(uint64_t nNoData) override final;
118 : double GetNoDataValue(int *pbSuccess = nullptr) override final;
119 : int64_t GetNoDataValueAsInt64(int *pbSuccess = nullptr) override final;
120 : uint64_t GetNoDataValueAsUInt64(int *pbSuccess = nullptr) override final;
121 : CPLErr DeleteNoDataValue() override final;
122 :
123 : double GetOffset(int *pbSuccess = nullptr) override final;
124 : CPLErr SetOffset(double dfNewValue) override final;
125 : double GetScale(int *pbSuccess = nullptr) override final;
126 : CPLErr SetScale(double dfNewValue) override final;
127 : const char *GetUnitType() override final;
128 : CPLErr SetUnitType(const char *pszNewValue) override final;
129 : CPLErr SetColorInterpretation(GDALColorInterp) override;
130 :
131 : char **GetMetadataDomainList() override final;
132 : CPLErr SetMetadata(char **, const char * = "") override final;
133 : char **GetMetadata(const char *pszDomain = "") override final;
134 : CPLErr SetMetadataItem(const char *, const char *,
135 : const char * = "") override final;
136 : virtual const char *
137 : GetMetadataItem(const char *pszName,
138 : const char *pszDomain = "") override final;
139 : int GetOverviewCount() override final;
140 : GDALRasterBand *GetOverview(int) override final;
141 :
142 : GDALRasterBand *GetMaskBand() override final;
143 : int GetMaskFlags() override final;
144 : CPLErr CreateMaskBand(int nFlags) override final;
145 : bool IsMaskBand() const override final;
146 : GDALMaskValueRange GetMaskValueRange() const override final;
147 :
148 : virtual CPLVirtualMem *
149 : GetVirtualMemAuto(GDALRWFlag eRWFlag, int *pnPixelSpace,
150 : GIntBig *pnLineSpace, char **papszOptions) override final;
151 :
152 : GDALRasterAttributeTable *GetDefaultRAT() override final;
153 : virtual CPLErr
154 : SetDefaultRAT(const GDALRasterAttributeTable *) override final;
155 : CPLErr GetHistogram(double dfMin, double dfMax, int nBuckets,
156 : GUIntBig *panHistogram, int bIncludeOutOfRange,
157 : int bApproxOK, GDALProgressFunc,
158 : void *pProgressData) override final;
159 :
160 : CPLErr GetDefaultHistogram(double *pdfMin, double *pdfMax, int *pnBuckets,
161 : GUIntBig **ppanHistogram, int bForce,
162 : GDALProgressFunc,
163 : void *pProgressData) override final;
164 : };
165 :
166 : #endif // GTIFFRASTERBAND_H_INCLUDED
|