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 : bool m_bWarnedAboutMultiThreadedReadDisabled = false;
48 : std::unique_ptr<GDALRasterAttributeTable> m_poRAT{};
49 :
50 : int DirectIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
51 : int nYSize, void *pData, int nBufXSize, int nBufYSize,
52 : GDALDataType eBufType, GSpacing nPixelSpace,
53 : GSpacing nLineSpace, GDALRasterIOExtraArg *psExtraArg);
54 :
55 : static void DropReferenceVirtualMem(void *pUserData);
56 : CPLVirtualMem *GetVirtualMemAutoInternal(GDALRWFlag eRWFlag,
57 : int *pnPixelSpace,
58 : GIntBig *pnLineSpace,
59 : CSLConstList papszOptions);
60 :
61 : protected:
62 : GTiffDataset *m_poGDS = nullptr;
63 : GDALMultiDomainMetadata m_oGTiffMDMD{};
64 :
65 : double m_dfNoDataValue = DEFAULT_NODATA_VALUE;
66 : bool m_bNoDataSet = false;
67 :
68 : int64_t m_nNoDataValueInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_INT64;
69 : bool m_bNoDataSetAsInt64 = false;
70 :
71 : uint64_t m_nNoDataValueUInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64;
72 : bool m_bNoDataSetAsUInt64 = false;
73 :
74 : void NullBlock(void *pData);
75 : CPLErr FillCacheForOtherBands(int nBlockXOff, int nBlockYOff);
76 : void CacheMaskForBlock(int nBlockXOff, int nBlockYOff);
77 : void ResetNoDataValues(bool bResetDatasetToo);
78 :
79 : int ComputeBlockId(int nBlockXOff, int nBlockYOff) const;
80 :
81 : public:
82 : GTiffRasterBand(GTiffDataset *, int);
83 : ~GTiffRasterBand() override;
84 :
85 3299 : virtual bool IsBaseGTiffClass() const
86 : {
87 3299 : return true;
88 : }
89 :
90 : CPLErr IReadBlock(int, int, void *) override;
91 : CPLErr IWriteBlock(int, int, void *) override;
92 :
93 : virtual GDALSuggestedBlockAccessPattern
94 867 : GetSuggestedBlockAccessPattern() const override
95 : {
96 867 : return GSBAP_RANDOM;
97 : }
98 :
99 : virtual int IGetDataCoverageStatus(int nXOff, int nYOff, int nXSize,
100 : int nYSize, int nMaskFlagStop,
101 : double *pdfDataPct) override;
102 :
103 : CPLErr IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
104 : int nYSize, void *pData, int nBufXSize, int nBufYSize,
105 : GDALDataType eBufType, GSpacing nPixelSpace,
106 : GSpacing nLineSpace,
107 : GDALRasterIOExtraArg *psExtraArg) override final;
108 :
109 : const char *GetDescription() const override final;
110 : void SetDescription(const char *) override final;
111 :
112 : GDALColorInterp GetColorInterpretation() override /*final*/;
113 : GDALColorTable *GetColorTable() override /*final*/;
114 : CPLErr SetColorTable(GDALColorTable *) override final;
115 :
116 : CPLErr SetNoDataValue(double) override final;
117 : CPLErr SetNoDataValueAsInt64(int64_t nNoData) override final;
118 : CPLErr SetNoDataValueAsUInt64(uint64_t nNoData) override final;
119 : double GetNoDataValue(int *pbSuccess = nullptr) override final;
120 : int64_t GetNoDataValueAsInt64(int *pbSuccess = nullptr) override final;
121 : uint64_t GetNoDataValueAsUInt64(int *pbSuccess = nullptr) override final;
122 : CPLErr DeleteNoDataValue() override final;
123 :
124 : double GetOffset(int *pbSuccess = nullptr) override final;
125 : CPLErr SetOffset(double dfNewValue) override final;
126 : double GetScale(int *pbSuccess = nullptr) override final;
127 : CPLErr SetScale(double dfNewValue) override final;
128 : const char *GetUnitType() override final;
129 : CPLErr SetUnitType(const char *pszNewValue) override final;
130 : CPLErr SetColorInterpretation(GDALColorInterp) override;
131 :
132 : char **GetMetadataDomainList() override final;
133 : CPLErr SetMetadata(CSLConstList, const char * = "") override final;
134 : CSLConstList GetMetadata(const char *pszDomain = "") override final;
135 : CPLErr SetMetadataItem(const char *, const char *,
136 : const char * = "") override final;
137 : virtual const char *
138 : GetMetadataItem(const char *pszName,
139 : const char *pszDomain = "") override final;
140 : int GetOverviewCount() override final;
141 : GDALRasterBand *GetOverview(int) override final;
142 :
143 : GDALRasterBand *GetMaskBand() override final;
144 : int GetMaskFlags() override final;
145 : CPLErr CreateMaskBand(int nFlags) override final;
146 : bool IsMaskBand() const override final;
147 : GDALMaskValueRange GetMaskValueRange() const override final;
148 :
149 : virtual CPLVirtualMem *
150 : GetVirtualMemAuto(GDALRWFlag eRWFlag, int *pnPixelSpace,
151 : GIntBig *pnLineSpace,
152 : CSLConstList papszOptions) override final;
153 :
154 : GDALRasterAttributeTable *GetDefaultRAT() override final;
155 : virtual CPLErr
156 : SetDefaultRAT(const GDALRasterAttributeTable *) override final;
157 : CPLErr GetHistogram(double dfMin, double dfMax, int nBuckets,
158 : GUIntBig *panHistogram, int bIncludeOutOfRange,
159 : int bApproxOK, GDALProgressFunc,
160 : void *pProgressData) override final;
161 :
162 : CPLErr GetDefaultHistogram(double *pdfMin, double *pdfMax, int *pnBuckets,
163 : GUIntBig **ppanHistogram, int bForce,
164 : GDALProgressFunc,
165 : void *pProgressData) override final;
166 :
167 : bool MayMultiBlockReadingBeMultiThreaded() const override final;
168 : };
169 :
170 : #endif // GTIFFRASTERBAND_H_INCLUDED
|