Coverage Report

Created: 2025-12-31 06:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/gcore/gdalproxydataset.cpp
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Project:  GDAL Core
4
 * Purpose:  A dataset and raster band classes that act as proxy for underlying
5
 *           GDALDataset* and GDALRasterBand*
6
 * Author:   Even Rouault <even dot rouault at spatialys.com>
7
 *
8
 ******************************************************************************
9
 * Copyright (c) 2008-2014, Even Rouault <even dot rouault at spatialys.com>
10
 *
11
 * SPDX-License-Identifier: MIT
12
 ****************************************************************************/
13
14
#include "cpl_port.h"
15
#include "gdal_proxy.h"
16
17
#include <cstddef>
18
19
#include "cpl_error.h"
20
#include "cpl_progress.h"
21
#include "cpl_virtualmem.h"
22
#include "gdal.h"
23
#include "gdal_priv.h"
24
25
/*! @cond Doxygen_Suppress */
26
/* ******************************************************************** */
27
/*                        GDALProxyDataset                              */
28
/* ******************************************************************** */
29
30
#define D_PROXY_METHOD_WITH_RET(retType, retErrValue, methodName, argList,     \
31
                                argParams)                                     \
32
    retType GDALProxyDataset::methodName argList                               \
33
0
    {                                                                          \
34
0
        retType ret;                                                           \
35
0
        GDALDataset *poUnderlyingDataset = RefUnderlyingDataset();             \
36
0
        if (poUnderlyingDataset)                                               \
37
0
        {                                                                      \
38
0
            ret = poUnderlyingDataset->methodName argParams;                   \
39
0
            UnrefUnderlyingDataset(poUnderlyingDataset);                       \
40
0
        }                                                                      \
41
0
        else                                                                   \
42
0
        {                                                                      \
43
0
            ret = retErrValue;                                                 \
44
0
        }                                                                      \
45
0
        return ret;                                                            \
46
0
    }
Unexecuted instantiation: GDALProxyDataset::Close(int (*)(double, char const*, void*), void*)
Unexecuted instantiation: GDALProxyDataset::GetCloseReportsProgress() const
Unexecuted instantiation: GDALProxyDataset::BlockBasedRasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, int, int const*, long long, long long, long long, GDALRasterIOExtraArg*)
Unexecuted instantiation: GDALProxyDataset::IBuildOverviews(char const*, int, int const*, int, int const*, int (*)(double, char const*, void*), void*, char const* const*)
Unexecuted instantiation: GDALProxyDataset::GetCompressionFormats(int, int, int, int, int, int const*)
Unexecuted instantiation: GDALProxyDataset::ReadCompressedData(char const*, int, int, int, int, int, int const*, void**, unsigned long*, char**)
Unexecuted instantiation: GDALProxyDataset::FlushCache(bool)
Unexecuted instantiation: GDALProxyDataset::GetMetadataDomainList()
Unexecuted instantiation: GDALProxyDataset::GetMetadata(char const*)
Unexecuted instantiation: GDALProxyDataset::SetMetadata(char**, char const*)
Unexecuted instantiation: GDALProxyDataset::GetMetadataItem(char const*, char const*)
Unexecuted instantiation: GDALProxyDataset::SetMetadataItem(char const*, char const*, char const*)
Unexecuted instantiation: GDALProxyDataset::GetSpatialRef() const
Unexecuted instantiation: GDALProxyDataset::SetSpatialRef(OGRSpatialReference const*)
Unexecuted instantiation: GDALProxyDataset::GetGeoTransform(GDALGeoTransform&) const
Unexecuted instantiation: GDALProxyDataset::SetGeoTransform(GDALGeoTransform const&)
Unexecuted instantiation: GDALProxyDataset::GetInternalHandle(char const*)
Unexecuted instantiation: GDALProxyDataset::GetDriver()
Unexecuted instantiation: GDALProxyDataset::GetFileList()
Unexecuted instantiation: GDALProxyDataset::GetGCPCount()
Unexecuted instantiation: GDALProxyDataset::GetGCPSpatialRef() const
Unexecuted instantiation: GDALProxyDataset::GetGCPs()
Unexecuted instantiation: GDALProxyDataset::SetGCPs(int, GDAL_GCP const*, OGRSpatialReference const*)
Unexecuted instantiation: GDALProxyDataset::AdviseRead(int, int, int, int, int, int, GDALDataType, int, int*, char**)
Unexecuted instantiation: GDALProxyDataset::CreateMaskBand(int)
47
48
CPLErr GDALProxyDataset::IRasterIO(
49
    GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize,
50
    void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType,
51
    int nBandCount, BANDMAP_TYPE panBandMap, GSpacing nPixelSpace,
52
    GSpacing nLineSpace, GSpacing nBandSpace, GDALRasterIOExtraArg *psExtraArg)
53
0
{
54
0
    CPLErr ret;
55
0
    GDALDataset *poUnderlyingDataset = RefUnderlyingDataset();
56
0
    if (poUnderlyingDataset)
57
0
    {
58
        /* --------------------------------------------------------------------
59
         */
60
        /*      Do some validation of parameters. */
61
        /* --------------------------------------------------------------------
62
         */
63
0
        if (nXOff + nXSize > poUnderlyingDataset->GetRasterXSize() ||
64
0
            nYOff + nYSize > poUnderlyingDataset->GetRasterYSize())
65
0
        {
66
0
            ReportError(CE_Failure, CPLE_IllegalArg,
67
0
                        "Access window out of range in RasterIO().  Requested\n"
68
0
                        "(%d,%d) of size %dx%d on raster of %dx%d.",
69
0
                        nXOff, nYOff, nXSize, nYSize,
70
0
                        poUnderlyingDataset->GetRasterXSize(),
71
0
                        poUnderlyingDataset->GetRasterYSize());
72
0
            ret = CE_Failure;
73
0
        }
74
0
        else if (panBandMap == nullptr &&
75
0
                 nBandCount > poUnderlyingDataset->GetRasterCount())
76
0
        {
77
0
            ReportError(CE_Failure, CPLE_IllegalArg,
78
0
                        "%s: nBandCount cannot be greater than %d", "IRasterIO",
79
0
                        poUnderlyingDataset->GetRasterCount());
80
0
            ret = CE_Failure;
81
0
        }
82
0
        else
83
0
        {
84
0
            ret = CE_None;
85
0
            for (int i = 0; i < nBandCount && ret == CE_None; ++i)
86
0
            {
87
0
                int iBand = (panBandMap != nullptr) ? panBandMap[i] : i + 1;
88
0
                if (iBand < 1 || iBand > poUnderlyingDataset->GetRasterCount())
89
0
                {
90
0
                    ReportError(CE_Failure, CPLE_IllegalArg,
91
0
                                "%s: panBandMap[%d] = %d, this band does not "
92
0
                                "exist on dataset.",
93
0
                                "IRasterIO", i, iBand);
94
0
                    ret = CE_Failure;
95
0
                }
96
97
0
                if (ret == CE_None &&
98
0
                    poUnderlyingDataset->GetRasterBand(iBand) == nullptr)
99
0
                {
100
0
                    ReportError(CE_Failure, CPLE_IllegalArg,
101
0
                                "%s: panBandMap[%d]=%d, this band should exist "
102
0
                                "but is NULL!",
103
0
                                "IRasterIO", i, iBand);
104
0
                    ret = CE_Failure;
105
0
                }
106
0
            }
107
0
            if (ret != CE_Failure)
108
0
            {
109
0
                ret = poUnderlyingDataset->IRasterIO(
110
0
                    eRWFlag, nXOff, nYOff, nXSize, nYSize, pData, nBufXSize,
111
0
                    nBufYSize, eBufType, nBandCount, panBandMap, nPixelSpace,
112
0
                    nLineSpace, nBandSpace, psExtraArg);
113
0
            }
114
0
        }
115
0
        UnrefUnderlyingDataset(poUnderlyingDataset);
116
0
    }
117
0
    else
118
0
    {
119
0
        ret = CE_Failure;
120
0
    }
121
0
    return ret;
122
0
}
123
124
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, Close,
125
                        (GDALProgressFunc pfnProgress, void *pProgressData),
126
                        (pfnProgress, pProgressData))
127
128
D_PROXY_METHOD_WITH_RET(bool, false, GetCloseReportsProgress, () const, ())
129
130
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, BlockBasedRasterIO,
131
                        (GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
132
                         int nYSize, void *pData, int nBufXSize, int nBufYSize,
133
                         GDALDataType eBufType, int nBandCount,
134
                         const int *panBandMap, GSpacing nPixelSpace,
135
                         GSpacing nLineSpace, GSpacing nBandSpace,
136
                         GDALRasterIOExtraArg *psExtraArg),
137
                        (eRWFlag, nXOff, nYOff, nXSize, nYSize, pData,
138
                         nBufXSize, nBufYSize, eBufType, nBandCount, panBandMap,
139
                         nPixelSpace, nLineSpace, nBandSpace, psExtraArg))
140
141
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, IBuildOverviews,
142
                        (const char *pszResampling, int nOverviews,
143
                         const int *panOverviewList, int nListBands,
144
                         const int *panBandList, GDALProgressFunc pfnProgress,
145
                         void *pProgressData, CSLConstList papszOptions),
146
                        (pszResampling, nOverviews, panOverviewList, nListBands,
147
                         panBandList, pfnProgress, pProgressData, papszOptions))
148
149
D_PROXY_METHOD_WITH_RET(CPLStringList, CPLStringList(), GetCompressionFormats,
150
                        (int nXOff, int nYOff, int nXSize, int nYSize,
151
                         int nBandCount, const int *panBandList),
152
                        (nXOff, nYOff, nXSize, nYSize, nBandCount, panBandList))
153
154
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, ReadCompressedData,
155
                        (const char *pszFormat, int nXOff, int nYOff,
156
                         int nXSize, int nYSize, int nBandCount,
157
                         const int *panBandList, void **ppBuffer,
158
                         size_t *pnBufferSize, char **ppszDetailedFormat),
159
                        (pszFormat, nXOff, nYOff, nXSize, nYSize, nBandCount,
160
                         panBandList, ppBuffer, pnBufferSize,
161
                         ppszDetailedFormat))
162
163
D_PROXY_METHOD_WITH_RET(CPLErr, CE_None, FlushCache, (bool bAtClosing),
164
                        (bAtClosing))
165
166
D_PROXY_METHOD_WITH_RET(char **, nullptr, GetMetadataDomainList, (), ())
167
D_PROXY_METHOD_WITH_RET(char **, nullptr, GetMetadata, (const char *pszDomain),
168
                        (pszDomain))
169
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetMetadata,
170
                        (char **papszMetadata, const char *pszDomain),
171
                        (papszMetadata, pszDomain))
172
D_PROXY_METHOD_WITH_RET(const char *, nullptr, GetMetadataItem,
173
                        (const char *pszName, const char *pszDomain),
174
                        (pszName, pszDomain))
175
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetMetadataItem,
176
                        (const char *pszName, const char *pszValue,
177
                         const char *pszDomain),
178
                        (pszName, pszValue, pszDomain))
179
180
D_PROXY_METHOD_WITH_RET(const OGRSpatialReference *, nullptr, GetSpatialRef,
181
                        () const, ())
182
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetSpatialRef,
183
                        (const OGRSpatialReference *poSRS), (poSRS))
184
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, GetGeoTransform,
185
                        (GDALGeoTransform & gt) const, (gt))
186
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetGeoTransform,
187
                        (const GDALGeoTransform &gt), (gt))
188
189
D_PROXY_METHOD_WITH_RET(void *, nullptr, GetInternalHandle, (const char *arg1),
190
                        (arg1))
191
D_PROXY_METHOD_WITH_RET(GDALDriver *, nullptr, GetDriver, (), ())
192
D_PROXY_METHOD_WITH_RET(char **, nullptr, GetFileList, (), ())
193
D_PROXY_METHOD_WITH_RET(int, 0, GetGCPCount, (), ())
194
D_PROXY_METHOD_WITH_RET(const OGRSpatialReference *, nullptr, GetGCPSpatialRef,
195
                        () const, ())
196
D_PROXY_METHOD_WITH_RET(const GDAL_GCP *, nullptr, GetGCPs, (), ())
197
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetGCPs,
198
                        (int nGCPCount, const GDAL_GCP *pasGCPList,
199
                         const OGRSpatialReference *poGCP_SRS),
200
                        (nGCPCount, pasGCPList, poGCP_SRS))
201
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, AdviseRead,
202
                        (int nXOff, int nYOff, int nXSize, int nYSize,
203
                         int nBufXSize, int nBufYSize, GDALDataType eDT,
204
                         int nBandCount, int *panBandList, char **papszOptions),
205
                        (nXOff, nYOff, nXSize, nYSize, nBufXSize, nBufYSize,
206
                         eDT, nBandCount, panBandList, papszOptions))
207
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, CreateMaskBand, (int nFlagsIn),
208
                        (nFlagsIn))
209
210
/************************************************************************/
211
/*                    UnrefUnderlyingDataset()                        */
212
/************************************************************************/
213
214
void GDALProxyDataset::UnrefUnderlyingDataset(
215
    GDALDataset * /* poUnderlyingDataset */) const
216
0
{
217
0
}
218
219
/* ******************************************************************** */
220
/*                        GDALProxyRasterBand                           */
221
/* ******************************************************************** */
222
223
#define RB_PROXY_METHOD_WITH_RET(retType, retErrValue, methodName, argList,    \
224
                                 argParams)                                    \
225
    retType GDALProxyRasterBand::methodName argList                            \
226
0
    {                                                                          \
227
0
        retType ret;                                                           \
228
0
        GDALRasterBand *poSrcBand = RefUnderlyingRasterBand();                 \
229
0
        if (poSrcBand)                                                         \
230
0
        {                                                                      \
231
0
            ret = poSrcBand->methodName argParams;                             \
232
0
            UnrefUnderlyingRasterBand(poSrcBand);                              \
233
0
        }                                                                      \
234
0
        else                                                                   \
235
0
        {                                                                      \
236
0
            ret = retErrValue;                                                 \
237
0
        }                                                                      \
238
0
        return ret;                                                            \
239
0
    }
Unexecuted instantiation: GDALProxyRasterBand::GetMetadataDomainList()
Unexecuted instantiation: GDALProxyRasterBand::GetMetadata(char const*)
Unexecuted instantiation: GDALProxyRasterBand::SetMetadata(char**, char const*)
Unexecuted instantiation: GDALProxyRasterBand::SetMetadataItem(char const*, char const*, char const*)
Unexecuted instantiation: GDALProxyRasterBand::GetLockedBlockRef(int, int, int)
Unexecuted instantiation: GDALProxyRasterBand::TryGetLockedBlockRef(int, int)
Unexecuted instantiation: GDALProxyRasterBand::FlushBlock(int, int, int)
Unexecuted instantiation: GDALProxyRasterBand::GetCategoryNames()
Unexecuted instantiation: GDALProxyRasterBand::GetNoDataValue(int*)
Unexecuted instantiation: GDALProxyRasterBand::GetMinimum(int*)
Unexecuted instantiation: GDALProxyRasterBand::GetMaximum(int*)
Unexecuted instantiation: GDALProxyRasterBand::GetOffset(int*)
Unexecuted instantiation: GDALProxyRasterBand::GetScale(int*)
Unexecuted instantiation: GDALProxyRasterBand::GetUnitType()
Unexecuted instantiation: GDALProxyRasterBand::GetColorInterpretation()
Unexecuted instantiation: GDALProxyRasterBand::GetColorTable()
Unexecuted instantiation: GDALProxyRasterBand::Fill(double, double)
Unexecuted instantiation: GDALProxyRasterBand::SetCategoryNames(char**)
Unexecuted instantiation: GDALProxyRasterBand::SetNoDataValue(double)
Unexecuted instantiation: GDALProxyRasterBand::DeleteNoDataValue()
Unexecuted instantiation: GDALProxyRasterBand::SetColorTable(GDALColorTable*)
Unexecuted instantiation: GDALProxyRasterBand::SetColorInterpretation(GDALColorInterp)
Unexecuted instantiation: GDALProxyRasterBand::SetOffset(double)
Unexecuted instantiation: GDALProxyRasterBand::SetScale(double)
Unexecuted instantiation: GDALProxyRasterBand::SetUnitType(char const*)
Unexecuted instantiation: GDALProxyRasterBand::GetStatistics(int, int, double*, double*, double*, double*)
Unexecuted instantiation: GDALProxyRasterBand::ComputeStatistics(int, double*, double*, double*, double*, int (*)(double, char const*, void*), void*)
Unexecuted instantiation: GDALProxyRasterBand::SetStatistics(double, double, double, double)
Unexecuted instantiation: GDALProxyRasterBand::ComputeRasterMinMax(int, double*)
Unexecuted instantiation: GDALProxyRasterBand::HasArbitraryOverviews()
Unexecuted instantiation: GDALProxyRasterBand::GetOverviewCount()
Unexecuted instantiation: GDALProxyRasterBand::GetOverview(int)
Unexecuted instantiation: GDALProxyRasterBand::GetRasterSampleOverview(unsigned long long)
Unexecuted instantiation: GDALProxyRasterBand::BuildOverviews(char const*, int, int const*, int (*)(double, char const*, void*), void*, char const* const*)
Unexecuted instantiation: GDALProxyRasterBand::AdviseRead(int, int, int, int, int, int, GDALDataType, char**)
Unexecuted instantiation: GDALProxyRasterBand::GetHistogram(double, double, int, unsigned long long*, int, int, int (*)(double, char const*, void*), void*)
Unexecuted instantiation: GDALProxyRasterBand::GetDefaultHistogram(double*, double*, int*, unsigned long long**, int, int (*)(double, char const*, void*), void*)
Unexecuted instantiation: GDALProxyRasterBand::SetDefaultHistogram(double, double, int, unsigned long long*)
Unexecuted instantiation: GDALProxyRasterBand::GetDefaultRAT()
Unexecuted instantiation: GDALProxyRasterBand::SetDefaultRAT(GDALRasterAttributeTable const*)
Unexecuted instantiation: GDALProxyRasterBand::GetMaskBand()
Unexecuted instantiation: GDALProxyRasterBand::GetMaskFlags()
Unexecuted instantiation: GDALProxyRasterBand::CreateMaskBand(int)
Unexecuted instantiation: GDALProxyRasterBand::IsMaskBand() const
Unexecuted instantiation: GDALProxyRasterBand::GetMaskValueRange() const
Unexecuted instantiation: GDALProxyRasterBand::GetVirtualMemAuto(GDALRWFlag, int*, long long*, char**)
Unexecuted instantiation: GDALProxyRasterBand::InterpolateAtPoint(double, double, GDALRIOResampleAlg, double*, double*) const
240
241
#define RB_PROXY_METHOD_WITH_RET_WITH_INIT_BLOCK(                              \
242
    retType, retErrValue, methodName, argList, argParams)                      \
243
    retType GDALProxyRasterBand::methodName argList                            \
244
0
    {                                                                          \
245
0
        retType ret;                                                           \
246
0
        GDALRasterBand *poSrcBand = RefUnderlyingRasterBand();                 \
247
0
        if (poSrcBand)                                                         \
248
0
        {                                                                      \
249
0
            if (!poSrcBand->InitBlockInfo())                                   \
250
0
                ret = CE_Failure;                                              \
251
0
            else                                                               \
252
0
            {                                                                  \
253
0
                int nSrcBlockXSize, nSrcBlockYSize;                            \
254
0
                poSrcBand->GetBlockSize(&nSrcBlockXSize, &nSrcBlockYSize);     \
255
0
                if (poSrcBand->GetRasterDataType() != GetRasterDataType())     \
256
0
                {                                                              \
257
0
                    CPLError(                                                  \
258
0
                        CE_Failure, CPLE_AppDefined,                           \
259
0
                        "Inconsistent datatype between proxy and source");     \
260
0
                    ret = CE_Failure;                                          \
261
0
                }                                                              \
262
0
                else if (nSrcBlockXSize != nBlockXSize ||                      \
263
0
                         nSrcBlockYSize != nBlockYSize)                        \
264
0
                {                                                              \
265
0
                    CPLError(CE_Failure, CPLE_AppDefined,                      \
266
0
                             "Inconsistent block dimensions between proxy "    \
267
0
                             "and source");                                    \
268
0
                    ret = CE_Failure;                                          \
269
0
                }                                                              \
270
0
                else                                                           \
271
0
                {                                                              \
272
0
                    ret = poSrcBand->methodName argParams;                     \
273
0
                }                                                              \
274
0
            }                                                                  \
275
0
            UnrefUnderlyingRasterBand(poSrcBand);                              \
276
0
        }                                                                      \
277
0
        else                                                                   \
278
0
        {                                                                      \
279
0
            ret = retErrValue;                                                 \
280
0
        }                                                                      \
281
0
        return ret;                                                            \
282
0
    }
Unexecuted instantiation: GDALProxyRasterBand::IReadBlock(int, int, void*)
Unexecuted instantiation: GDALProxyRasterBand::IWriteBlock(int, int, void*)
283
284
RB_PROXY_METHOD_WITH_RET_WITH_INIT_BLOCK(CPLErr, CE_Failure, IReadBlock,
285
                                         (int nXBlockOff, int nYBlockOff,
286
                                          void *pImage),
287
                                         (nXBlockOff, nYBlockOff, pImage))
288
RB_PROXY_METHOD_WITH_RET_WITH_INIT_BLOCK(CPLErr, CE_Failure, IWriteBlock,
289
                                         (int nXBlockOff, int nYBlockOff,
290
                                          void *pImage),
291
                                         (nXBlockOff, nYBlockOff, pImage))
292
293
CPLErr GDALProxyRasterBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
294
                                      int nXSize, int nYSize, void *pData,
295
                                      int nBufXSize, int nBufYSize,
296
                                      GDALDataType eBufType,
297
                                      GSpacing nPixelSpace, GSpacing nLineSpace,
298
                                      GDALRasterIOExtraArg *psExtraArg)
299
0
{
300
0
    CPLErr ret;
301
0
    GDALRasterBand *poSrcBand = RefUnderlyingRasterBand();
302
0
    if (poSrcBand)
303
0
    {
304
        /* --------------------------------------------------------------------
305
         */
306
        /*      Do some validation of parameters. */
307
        /* --------------------------------------------------------------------
308
         */
309
0
        if (nXOff + nXSize > poSrcBand->GetXSize() ||
310
0
            nYOff + nYSize > poSrcBand->GetYSize())
311
0
        {
312
0
            ReportError(CE_Failure, CPLE_IllegalArg,
313
0
                        "Access window out of range in RasterIO().  Requested\n"
314
0
                        "(%d,%d) of size %dx%d on raster of %dx%d.",
315
0
                        nXOff, nYOff, nXSize, nYSize, poSrcBand->GetXSize(),
316
0
                        poSrcBand->GetYSize());
317
0
            ret = CE_Failure;
318
0
        }
319
0
        else
320
0
        {
321
0
            ret = poSrcBand->IRasterIO(eRWFlag, nXOff, nYOff, nXSize, nYSize,
322
0
                                       pData, nBufXSize, nBufYSize, eBufType,
323
0
                                       nPixelSpace, nLineSpace, psExtraArg);
324
0
        }
325
0
        UnrefUnderlyingRasterBand(poSrcBand);
326
0
    }
327
0
    else
328
0
    {
329
0
        ret = CE_Failure;
330
0
    }
331
0
    return ret;
332
0
}
333
334
int GDALProxyRasterBand::IGetDataCoverageStatus(int nXOff, int nYOff,
335
                                                int nXSize, int nYSize,
336
                                                int nMaskFlagStop,
337
                                                double *pdfDataPct)
338
0
{
339
0
    if (pdfDataPct)
340
0
        *pdfDataPct = 0.0;
341
0
    int ret = GDAL_DATA_COVERAGE_STATUS_UNIMPLEMENTED |
342
0
              GDAL_DATA_COVERAGE_STATUS_EMPTY;
343
0
    GDALRasterBand *poSrcBand = RefUnderlyingRasterBand();
344
0
    if (poSrcBand)
345
0
    {
346
0
        ret = poSrcBand->GetDataCoverageStatus(nXOff, nYOff, nXSize, nYSize,
347
0
                                               nMaskFlagStop, pdfDataPct);
348
0
        UnrefUnderlyingRasterBand(poSrcBand);
349
0
    }
350
0
    return ret;
351
0
}
352
353
RB_PROXY_METHOD_WITH_RET(char **, nullptr, GetMetadataDomainList, (), ())
354
RB_PROXY_METHOD_WITH_RET(char **, nullptr, GetMetadata, (const char *pszDomain),
355
                         (pszDomain))
356
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetMetadata,
357
                         (char **papszMetadata, const char *pszDomain),
358
                         (papszMetadata, pszDomain))
359
360
const char *GDALProxyRasterBand::GetMetadataItem(const char *pszKey,
361
                                                 const char *pszDomain)
362
0
{
363
0
    const char *pszRet = nullptr;
364
0
    GDALRasterBand *poSrcBand = RefUnderlyingRasterBand();
365
0
    if (poSrcBand)
366
0
    {
367
0
        if (!m_bEnablePixelTypeSignedByteWarning)
368
0
            poSrcBand->EnablePixelTypeSignedByteWarning(false);
369
0
        pszRet = poSrcBand->GetMetadataItem(pszKey, pszDomain);
370
0
        poSrcBand->EnablePixelTypeSignedByteWarning(true);
371
0
        UnrefUnderlyingRasterBand(poSrcBand);
372
0
    }
373
0
    return pszRet;
374
0
}
375
376
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetMetadataItem,
377
                         (const char *pszName, const char *pszValue,
378
                          const char *pszDomain),
379
                         (pszName, pszValue, pszDomain))
380
381
RB_PROXY_METHOD_WITH_RET(GDALRasterBlock *, nullptr, GetLockedBlockRef,
382
                         (int nXBlockOff, int nYBlockOff, int bJustInitialize),
383
                         (nXBlockOff, nYBlockOff, bJustInitialize))
384
385
RB_PROXY_METHOD_WITH_RET(GDALRasterBlock *, nullptr, TryGetLockedBlockRef,
386
                         (int nXBlockOff, int nYBlockOff),
387
                         (nXBlockOff, nYBlockOff))
388
389
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, FlushBlock,
390
                         (int nXBlockOff, int nYBlockOff, int bWriteDirtyBlock),
391
                         (nXBlockOff, nYBlockOff, bWriteDirtyBlock))
392
393
CPLErr GDALProxyRasterBand::FlushCache(bool bAtClosing)
394
0
{
395
    // We need to make sure that all cached bocks at the proxy level are
396
    // first flushed
397
0
    CPLErr ret = GDALRasterBand::FlushCache(bAtClosing);
398
0
    if (ret == CE_None)
399
0
    {
400
0
        GDALRasterBand *poSrcBand = RefUnderlyingRasterBand();
401
0
        if (poSrcBand)
402
0
        {
403
0
            ret = poSrcBand->FlushCache(bAtClosing);
404
0
            UnrefUnderlyingRasterBand(poSrcBand);
405
0
        }
406
0
        else
407
0
        {
408
0
            ret = CE_Failure;
409
0
        }
410
0
    }
411
0
    return ret;
412
0
}
413
414
RB_PROXY_METHOD_WITH_RET(char **, nullptr, GetCategoryNames, (), ())
415
RB_PROXY_METHOD_WITH_RET(double, 0, GetNoDataValue, (int *pbSuccess),
416
                         (pbSuccess))
417
RB_PROXY_METHOD_WITH_RET(double, 0, GetMinimum, (int *pbSuccess), (pbSuccess))
418
RB_PROXY_METHOD_WITH_RET(double, 0, GetMaximum, (int *pbSuccess), (pbSuccess))
419
RB_PROXY_METHOD_WITH_RET(double, 0, GetOffset, (int *pbSuccess), (pbSuccess))
420
RB_PROXY_METHOD_WITH_RET(double, 0, GetScale, (int *pbSuccess), (pbSuccess))
421
RB_PROXY_METHOD_WITH_RET(const char *, nullptr, GetUnitType, (), ())
422
RB_PROXY_METHOD_WITH_RET(GDALColorInterp, GCI_Undefined, GetColorInterpretation,
423
                         (), ())
424
RB_PROXY_METHOD_WITH_RET(GDALColorTable *, nullptr, GetColorTable, (), ())
425
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, Fill,
426
                         (double dfRealValue, double dfImaginaryValue),
427
                         (dfRealValue, dfImaginaryValue))
428
429
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetCategoryNames, (char **arg),
430
                         (arg))
431
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetNoDataValue, (double arg),
432
                         (arg))
433
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, DeleteNoDataValue, (), ())
434
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetColorTable,
435
                         (GDALColorTable * arg), (arg))
436
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetColorInterpretation,
437
                         (GDALColorInterp arg), (arg))
438
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetOffset, (double arg), (arg))
439
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetScale, (double arg), (arg))
440
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetUnitType, (const char *arg),
441
                         (arg))
442
443
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, GetStatistics,
444
                         (int bApproxOK, int bForce, double *pdfMin,
445
                          double *pdfMax, double *pdfMean, double *padfStdDev),
446
                         (bApproxOK, bForce, pdfMin, pdfMax, pdfMean,
447
                          padfStdDev))
448
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, ComputeStatistics,
449
                         (int bApproxOK, double *pdfMin, double *pdfMax,
450
                          double *pdfMean, double *pdfStdDev,
451
                          GDALProgressFunc pfn, void *pProgressData),
452
                         (bApproxOK, pdfMin, pdfMax, pdfMean, pdfStdDev, pfn,
453
                          pProgressData))
454
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetStatistics,
455
                         (double dfMin, double dfMax, double dfMean,
456
                          double dfStdDev),
457
                         (dfMin, dfMax, dfMean, dfStdDev))
458
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, ComputeRasterMinMax,
459
                         (int arg1, double *arg2), (arg1, arg2))
460
461
RB_PROXY_METHOD_WITH_RET(int, 0, HasArbitraryOverviews, (), ())
462
RB_PROXY_METHOD_WITH_RET(int, 0, GetOverviewCount, (), ())
463
RB_PROXY_METHOD_WITH_RET(GDALRasterBand *, nullptr, GetOverview, (int arg1),
464
                         (arg1))
465
RB_PROXY_METHOD_WITH_RET(GDALRasterBand *, nullptr, GetRasterSampleOverview,
466
                         (GUIntBig arg1), (arg1))
467
468
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, BuildOverviews,
469
                         (const char *arg1, int arg2, const int *arg3,
470
                          GDALProgressFunc arg4, void *arg5,
471
                          CSLConstList papszOptions),
472
                         (arg1, arg2, arg3, arg4, arg5, papszOptions))
473
474
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, AdviseRead,
475
                         (int nXOff, int nYOff, int nXSize, int nYSize,
476
                          int nBufXSize, int nBufYSize, GDALDataType eDT,
477
                          char **papszOptions),
478
                         (nXOff, nYOff, nXSize, nYSize, nBufXSize, nBufYSize,
479
                          eDT, papszOptions))
480
481
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, GetHistogram,
482
                         (double dfMin, double dfMax, int nBuckets,
483
                          GUIntBig *panHistogram, int bIncludeOutOfRange,
484
                          int bApproxOK, GDALProgressFunc pfn,
485
                          void *pProgressData),
486
                         (dfMin, dfMax, nBuckets, panHistogram,
487
                          bIncludeOutOfRange, bApproxOK, pfn, pProgressData))
488
489
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, GetDefaultHistogram,
490
                         (double *pdfMin, double *pdfMax, int *pnBuckets,
491
                          GUIntBig **ppanHistogram, int bForce,
492
                          GDALProgressFunc pfn, void *pProgressData),
493
                         (pdfMin, pdfMax, pnBuckets, ppanHistogram, bForce, pfn,
494
                          pProgressData))
495
496
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetDefaultHistogram,
497
                         (double dfMin, double dfMax, int nBuckets,
498
                          GUIntBig *panHistogram),
499
                         (dfMin, dfMax, nBuckets, panHistogram))
500
501
RB_PROXY_METHOD_WITH_RET(GDALRasterAttributeTable *, nullptr, GetDefaultRAT, (),
502
                         ())
503
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetDefaultRAT,
504
                         (const GDALRasterAttributeTable *arg1), (arg1))
505
506
RB_PROXY_METHOD_WITH_RET(GDALRasterBand *, nullptr, GetMaskBand, (), ())
507
RB_PROXY_METHOD_WITH_RET(int, 0, GetMaskFlags, (), ())
508
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, CreateMaskBand, (int nFlagsIn),
509
                         (nFlagsIn))
510
RB_PROXY_METHOD_WITH_RET(bool, false, IsMaskBand, () const, ())
511
RB_PROXY_METHOD_WITH_RET(GDALMaskValueRange, GMVR_UNKNOWN, GetMaskValueRange,
512
                         () const, ())
513
514
RB_PROXY_METHOD_WITH_RET(CPLVirtualMem *, nullptr, GetVirtualMemAuto,
515
                         (GDALRWFlag eRWFlag, int *pnPixelSpace,
516
                          GIntBig *pnLineSpace, char **papszOptions),
517
                         (eRWFlag, pnPixelSpace, pnLineSpace, papszOptions))
518
519
RB_PROXY_METHOD_WITH_RET(
520
    CPLErr, CE_Failure, InterpolateAtPoint,
521
    (double dfPixel, double dfLine, GDALRIOResampleAlg eInterpolation,
522
     double *pdfRealValue, double *pdfImagValue = nullptr) const,
523
    (dfPixel, dfLine, eInterpolation, pdfRealValue, pdfImagValue))
524
525
void GDALProxyRasterBand::EnablePixelTypeSignedByteWarning(bool b)
526
0
{
527
0
    GDALRasterBand *poSrcBand = RefUnderlyingRasterBand();
528
0
    if (poSrcBand)
529
0
    {
530
0
        poSrcBand->EnablePixelTypeSignedByteWarning(b);
531
0
        UnrefUnderlyingRasterBand(poSrcBand);
532
0
    }
533
0
}
534
535
/************************************************************************/
536
/*                 UnrefUnderlyingRasterBand()                        */
537
/************************************************************************/
538
539
void GDALProxyRasterBand::UnrefUnderlyingRasterBand(
540
    GDALRasterBand * /* poUnderlyingRasterBand */) const
541
0
{
542
0
}
543
544
/*! @endcond */