Coverage Report

Created: 2025-06-13 06:18

/src/gdal/gcore/gdalproxydataset.cpp
Line
Count
Source (jump to first uncovered line)
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::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(double*)
Unexecuted instantiation: GDALProxyDataset::SetGeoTransform(double*)
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, BlockBasedRasterIO,
125
                        (GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
126
                         int nYSize, void *pData, int nBufXSize, int nBufYSize,
127
                         GDALDataType eBufType, int nBandCount,
128
                         const int *panBandMap, GSpacing nPixelSpace,
129
                         GSpacing nLineSpace, GSpacing nBandSpace,
130
                         GDALRasterIOExtraArg *psExtraArg),
131
                        (eRWFlag, nXOff, nYOff, nXSize, nYSize, pData,
132
                         nBufXSize, nBufYSize, eBufType, nBandCount, panBandMap,
133
                         nPixelSpace, nLineSpace, nBandSpace, psExtraArg))
134
135
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, IBuildOverviews,
136
                        (const char *pszResampling, int nOverviews,
137
                         const int *panOverviewList, int nListBands,
138
                         const int *panBandList, GDALProgressFunc pfnProgress,
139
                         void *pProgressData, CSLConstList papszOptions),
140
                        (pszResampling, nOverviews, panOverviewList, nListBands,
141
                         panBandList, pfnProgress, pProgressData, papszOptions))
142
143
D_PROXY_METHOD_WITH_RET(CPLStringList, CPLStringList(), GetCompressionFormats,
144
                        (int nXOff, int nYOff, int nXSize, int nYSize,
145
                         int nBandCount, const int *panBandList),
146
                        (nXOff, nYOff, nXSize, nYSize, nBandCount, panBandList))
147
148
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, ReadCompressedData,
149
                        (const char *pszFormat, int nXOff, int nYOff,
150
                         int nXSize, int nYSize, int nBandCount,
151
                         const int *panBandList, void **ppBuffer,
152
                         size_t *pnBufferSize, char **ppszDetailedFormat),
153
                        (pszFormat, nXOff, nYOff, nXSize, nYSize, nBandCount,
154
                         panBandList, ppBuffer, pnBufferSize,
155
                         ppszDetailedFormat))
156
157
D_PROXY_METHOD_WITH_RET(CPLErr, CE_None, FlushCache, (bool bAtClosing),
158
                        (bAtClosing))
159
160
D_PROXY_METHOD_WITH_RET(char **, nullptr, GetMetadataDomainList, (), ())
161
D_PROXY_METHOD_WITH_RET(char **, nullptr, GetMetadata, (const char *pszDomain),
162
                        (pszDomain))
163
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetMetadata,
164
                        (char **papszMetadata, const char *pszDomain),
165
                        (papszMetadata, pszDomain))
166
D_PROXY_METHOD_WITH_RET(const char *, nullptr, GetMetadataItem,
167
                        (const char *pszName, const char *pszDomain),
168
                        (pszName, pszDomain))
169
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetMetadataItem,
170
                        (const char *pszName, const char *pszValue,
171
                         const char *pszDomain),
172
                        (pszName, pszValue, pszDomain))
173
174
D_PROXY_METHOD_WITH_RET(const OGRSpatialReference *, nullptr, GetSpatialRef,
175
                        () const, ())
176
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetSpatialRef,
177
                        (const OGRSpatialReference *poSRS), (poSRS))
178
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, GetGeoTransform,
179
                        (double *padfGeoTransform), (padfGeoTransform))
180
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetGeoTransform,
181
                        (double *padfGeoTransform), (padfGeoTransform))
182
183
D_PROXY_METHOD_WITH_RET(void *, nullptr, GetInternalHandle, (const char *arg1),
184
                        (arg1))
185
D_PROXY_METHOD_WITH_RET(GDALDriver *, nullptr, GetDriver, (), ())
186
D_PROXY_METHOD_WITH_RET(char **, nullptr, GetFileList, (), ())
187
D_PROXY_METHOD_WITH_RET(int, 0, GetGCPCount, (), ())
188
D_PROXY_METHOD_WITH_RET(const OGRSpatialReference *, nullptr, GetGCPSpatialRef,
189
                        () const, ())
190
D_PROXY_METHOD_WITH_RET(const GDAL_GCP *, nullptr, GetGCPs, (), ())
191
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetGCPs,
192
                        (int nGCPCount, const GDAL_GCP *pasGCPList,
193
                         const OGRSpatialReference *poGCP_SRS),
194
                        (nGCPCount, pasGCPList, poGCP_SRS))
195
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, AdviseRead,
196
                        (int nXOff, int nYOff, int nXSize, int nYSize,
197
                         int nBufXSize, int nBufYSize, GDALDataType eDT,
198
                         int nBandCount, int *panBandList, char **papszOptions),
199
                        (nXOff, nYOff, nXSize, nYSize, nBufXSize, nBufYSize,
200
                         eDT, nBandCount, panBandList, papszOptions))
201
D_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, CreateMaskBand, (int nFlagsIn),
202
                        (nFlagsIn))
203
204
/************************************************************************/
205
/*                    UnrefUnderlyingDataset()                        */
206
/************************************************************************/
207
208
void GDALProxyDataset::UnrefUnderlyingDataset(
209
    GDALDataset * /* poUnderlyingDataset */) const
210
0
{
211
0
}
212
213
/* ******************************************************************** */
214
/*                        GDALProxyRasterBand                           */
215
/* ******************************************************************** */
216
217
#define RB_PROXY_METHOD_WITH_RET(retType, retErrValue, methodName, argList,    \
218
                                 argParams)                                    \
219
    retType GDALProxyRasterBand::methodName argList                            \
220
0
    {                                                                          \
221
0
        retType ret;                                                           \
222
0
        GDALRasterBand *poSrcBand = RefUnderlyingRasterBand();                 \
223
0
        if (poSrcBand)                                                         \
224
0
        {                                                                      \
225
0
            ret = poSrcBand->methodName argParams;                             \
226
0
            UnrefUnderlyingRasterBand(poSrcBand);                              \
227
0
        }                                                                      \
228
0
        else                                                                   \
229
0
        {                                                                      \
230
0
            ret = retErrValue;                                                 \
231
0
        }                                                                      \
232
0
        return ret;                                                            \
233
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
234
235
#define RB_PROXY_METHOD_WITH_RET_WITH_INIT_BLOCK(                              \
236
    retType, retErrValue, methodName, argList, argParams)                      \
237
    retType GDALProxyRasterBand::methodName argList                            \
238
0
    {                                                                          \
239
0
        retType ret;                                                           \
240
0
        GDALRasterBand *poSrcBand = RefUnderlyingRasterBand();                 \
241
0
        if (poSrcBand)                                                         \
242
0
        {                                                                      \
243
0
            if (!poSrcBand->InitBlockInfo())                                   \
244
0
                ret = CE_Failure;                                              \
245
0
            else                                                               \
246
0
            {                                                                  \
247
0
                int nSrcBlockXSize, nSrcBlockYSize;                            \
248
0
                poSrcBand->GetBlockSize(&nSrcBlockXSize, &nSrcBlockYSize);     \
249
0
                if (poSrcBand->GetRasterDataType() != GetRasterDataType())     \
250
0
                {                                                              \
251
0
                    CPLError(                                                  \
252
0
                        CE_Failure, CPLE_AppDefined,                           \
253
0
                        "Inconsistent datatype between proxy and source");     \
254
0
                    ret = CE_Failure;                                          \
255
0
                }                                                              \
256
0
                else if (nSrcBlockXSize != nBlockXSize ||                      \
257
0
                         nSrcBlockYSize != nBlockYSize)                        \
258
0
                {                                                              \
259
0
                    CPLError(CE_Failure, CPLE_AppDefined,                      \
260
0
                             "Inconsistent block dimensions between proxy "    \
261
0
                             "and source");                                    \
262
0
                    ret = CE_Failure;                                          \
263
0
                }                                                              \
264
0
                else                                                           \
265
0
                {                                                              \
266
0
                    ret = poSrcBand->methodName argParams;                     \
267
0
                }                                                              \
268
0
            }                                                                  \
269
0
            UnrefUnderlyingRasterBand(poSrcBand);                              \
270
0
        }                                                                      \
271
0
        else                                                                   \
272
0
        {                                                                      \
273
0
            ret = retErrValue;                                                 \
274
0
        }                                                                      \
275
0
        return ret;                                                            \
276
0
    }
Unexecuted instantiation: GDALProxyRasterBand::IReadBlock(int, int, void*)
Unexecuted instantiation: GDALProxyRasterBand::IWriteBlock(int, int, void*)
277
278
RB_PROXY_METHOD_WITH_RET_WITH_INIT_BLOCK(CPLErr, CE_Failure, IReadBlock,
279
                                         (int nXBlockOff, int nYBlockOff,
280
                                          void *pImage),
281
                                         (nXBlockOff, nYBlockOff, pImage))
282
RB_PROXY_METHOD_WITH_RET_WITH_INIT_BLOCK(CPLErr, CE_Failure, IWriteBlock,
283
                                         (int nXBlockOff, int nYBlockOff,
284
                                          void *pImage),
285
                                         (nXBlockOff, nYBlockOff, pImage))
286
287
CPLErr GDALProxyRasterBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
288
                                      int nXSize, int nYSize, void *pData,
289
                                      int nBufXSize, int nBufYSize,
290
                                      GDALDataType eBufType,
291
                                      GSpacing nPixelSpace, GSpacing nLineSpace,
292
                                      GDALRasterIOExtraArg *psExtraArg)
293
0
{
294
0
    CPLErr ret;
295
0
    GDALRasterBand *poSrcBand = RefUnderlyingRasterBand();
296
0
    if (poSrcBand)
297
0
    {
298
        /* --------------------------------------------------------------------
299
         */
300
        /*      Do some validation of parameters. */
301
        /* --------------------------------------------------------------------
302
         */
303
0
        if (nXOff + nXSize > poSrcBand->GetXSize() ||
304
0
            nYOff + nYSize > poSrcBand->GetYSize())
305
0
        {
306
0
            ReportError(CE_Failure, CPLE_IllegalArg,
307
0
                        "Access window out of range in RasterIO().  Requested\n"
308
0
                        "(%d,%d) of size %dx%d on raster of %dx%d.",
309
0
                        nXOff, nYOff, nXSize, nYSize, poSrcBand->GetXSize(),
310
0
                        poSrcBand->GetYSize());
311
0
            ret = CE_Failure;
312
0
        }
313
0
        else
314
0
        {
315
0
            ret = poSrcBand->IRasterIO(eRWFlag, nXOff, nYOff, nXSize, nYSize,
316
0
                                       pData, nBufXSize, nBufYSize, eBufType,
317
0
                                       nPixelSpace, nLineSpace, psExtraArg);
318
0
        }
319
0
        UnrefUnderlyingRasterBand(poSrcBand);
320
0
    }
321
0
    else
322
0
    {
323
0
        ret = CE_Failure;
324
0
    }
325
0
    return ret;
326
0
}
327
328
int GDALProxyRasterBand::IGetDataCoverageStatus(int nXOff, int nYOff,
329
                                                int nXSize, int nYSize,
330
                                                int nMaskFlagStop,
331
                                                double *pdfDataPct)
332
0
{
333
0
    if (pdfDataPct)
334
0
        *pdfDataPct = 0.0;
335
0
    int ret = GDAL_DATA_COVERAGE_STATUS_UNIMPLEMENTED |
336
0
              GDAL_DATA_COVERAGE_STATUS_EMPTY;
337
0
    GDALRasterBand *poSrcBand = RefUnderlyingRasterBand();
338
0
    if (poSrcBand)
339
0
    {
340
0
        ret = poSrcBand->GetDataCoverageStatus(nXOff, nYOff, nXSize, nYSize,
341
0
                                               nMaskFlagStop, pdfDataPct);
342
0
        UnrefUnderlyingRasterBand(poSrcBand);
343
0
    }
344
0
    return ret;
345
0
}
346
347
RB_PROXY_METHOD_WITH_RET(char **, nullptr, GetMetadataDomainList, (), ())
348
RB_PROXY_METHOD_WITH_RET(char **, nullptr, GetMetadata, (const char *pszDomain),
349
                         (pszDomain))
350
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetMetadata,
351
                         (char **papszMetadata, const char *pszDomain),
352
                         (papszMetadata, pszDomain))
353
354
const char *GDALProxyRasterBand::GetMetadataItem(const char *pszKey,
355
                                                 const char *pszDomain)
356
0
{
357
0
    const char *pszRet = nullptr;
358
0
    GDALRasterBand *poSrcBand = RefUnderlyingRasterBand();
359
0
    if (poSrcBand)
360
0
    {
361
0
        if (!m_bEnablePixelTypeSignedByteWarning)
362
0
            poSrcBand->EnablePixelTypeSignedByteWarning(false);
363
0
        pszRet = poSrcBand->GetMetadataItem(pszKey, pszDomain);
364
0
        poSrcBand->EnablePixelTypeSignedByteWarning(true);
365
0
        UnrefUnderlyingRasterBand(poSrcBand);
366
0
    }
367
0
    return pszRet;
368
0
}
369
370
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetMetadataItem,
371
                         (const char *pszName, const char *pszValue,
372
                          const char *pszDomain),
373
                         (pszName, pszValue, pszDomain))
374
375
RB_PROXY_METHOD_WITH_RET(GDALRasterBlock *, nullptr, GetLockedBlockRef,
376
                         (int nXBlockOff, int nYBlockOff, int bJustInitialize),
377
                         (nXBlockOff, nYBlockOff, bJustInitialize))
378
379
RB_PROXY_METHOD_WITH_RET(GDALRasterBlock *, nullptr, TryGetLockedBlockRef,
380
                         (int nXBlockOff, int nYBlockOff),
381
                         (nXBlockOff, nYBlockOff))
382
383
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, FlushBlock,
384
                         (int nXBlockOff, int nYBlockOff, int bWriteDirtyBlock),
385
                         (nXBlockOff, nYBlockOff, bWriteDirtyBlock))
386
387
CPLErr GDALProxyRasterBand::FlushCache(bool bAtClosing)
388
0
{
389
    // We need to make sure that all cached bocks at the proxy level are
390
    // first flushed
391
0
    CPLErr ret = GDALRasterBand::FlushCache(bAtClosing);
392
0
    if (ret == CE_None)
393
0
    {
394
0
        GDALRasterBand *poSrcBand = RefUnderlyingRasterBand();
395
0
        if (poSrcBand)
396
0
        {
397
0
            ret = poSrcBand->FlushCache(bAtClosing);
398
0
            UnrefUnderlyingRasterBand(poSrcBand);
399
0
        }
400
0
        else
401
0
        {
402
0
            ret = CE_Failure;
403
0
        }
404
0
    }
405
0
    return ret;
406
0
}
407
408
RB_PROXY_METHOD_WITH_RET(char **, nullptr, GetCategoryNames, (), ())
409
RB_PROXY_METHOD_WITH_RET(double, 0, GetNoDataValue, (int *pbSuccess),
410
                         (pbSuccess))
411
RB_PROXY_METHOD_WITH_RET(double, 0, GetMinimum, (int *pbSuccess), (pbSuccess))
412
RB_PROXY_METHOD_WITH_RET(double, 0, GetMaximum, (int *pbSuccess), (pbSuccess))
413
RB_PROXY_METHOD_WITH_RET(double, 0, GetOffset, (int *pbSuccess), (pbSuccess))
414
RB_PROXY_METHOD_WITH_RET(double, 0, GetScale, (int *pbSuccess), (pbSuccess))
415
RB_PROXY_METHOD_WITH_RET(const char *, nullptr, GetUnitType, (), ())
416
RB_PROXY_METHOD_WITH_RET(GDALColorInterp, GCI_Undefined, GetColorInterpretation,
417
                         (), ())
418
RB_PROXY_METHOD_WITH_RET(GDALColorTable *, nullptr, GetColorTable, (), ())
419
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, Fill,
420
                         (double dfRealValue, double dfImaginaryValue),
421
                         (dfRealValue, dfImaginaryValue))
422
423
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetCategoryNames, (char **arg),
424
                         (arg))
425
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetNoDataValue, (double arg),
426
                         (arg))
427
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, DeleteNoDataValue, (), ())
428
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetColorTable,
429
                         (GDALColorTable * arg), (arg))
430
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetColorInterpretation,
431
                         (GDALColorInterp arg), (arg))
432
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetOffset, (double arg), (arg))
433
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetScale, (double arg), (arg))
434
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetUnitType, (const char *arg),
435
                         (arg))
436
437
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, GetStatistics,
438
                         (int bApproxOK, int bForce, double *pdfMin,
439
                          double *pdfMax, double *pdfMean, double *padfStdDev),
440
                         (bApproxOK, bForce, pdfMin, pdfMax, pdfMean,
441
                          padfStdDev))
442
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, ComputeStatistics,
443
                         (int bApproxOK, double *pdfMin, double *pdfMax,
444
                          double *pdfMean, double *pdfStdDev,
445
                          GDALProgressFunc pfn, void *pProgressData),
446
                         (bApproxOK, pdfMin, pdfMax, pdfMean, pdfStdDev, pfn,
447
                          pProgressData))
448
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetStatistics,
449
                         (double dfMin, double dfMax, double dfMean,
450
                          double dfStdDev),
451
                         (dfMin, dfMax, dfMean, dfStdDev))
452
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, ComputeRasterMinMax,
453
                         (int arg1, double *arg2), (arg1, arg2))
454
455
RB_PROXY_METHOD_WITH_RET(int, 0, HasArbitraryOverviews, (), ())
456
RB_PROXY_METHOD_WITH_RET(int, 0, GetOverviewCount, (), ())
457
RB_PROXY_METHOD_WITH_RET(GDALRasterBand *, nullptr, GetOverview, (int arg1),
458
                         (arg1))
459
RB_PROXY_METHOD_WITH_RET(GDALRasterBand *, nullptr, GetRasterSampleOverview,
460
                         (GUIntBig arg1), (arg1))
461
462
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, BuildOverviews,
463
                         (const char *arg1, int arg2, const int *arg3,
464
                          GDALProgressFunc arg4, void *arg5,
465
                          CSLConstList papszOptions),
466
                         (arg1, arg2, arg3, arg4, arg5, papszOptions))
467
468
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, AdviseRead,
469
                         (int nXOff, int nYOff, int nXSize, int nYSize,
470
                          int nBufXSize, int nBufYSize, GDALDataType eDT,
471
                          char **papszOptions),
472
                         (nXOff, nYOff, nXSize, nYSize, nBufXSize, nBufYSize,
473
                          eDT, papszOptions))
474
475
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, GetHistogram,
476
                         (double dfMin, double dfMax, int nBuckets,
477
                          GUIntBig *panHistogram, int bIncludeOutOfRange,
478
                          int bApproxOK, GDALProgressFunc pfn,
479
                          void *pProgressData),
480
                         (dfMin, dfMax, nBuckets, panHistogram,
481
                          bIncludeOutOfRange, bApproxOK, pfn, pProgressData))
482
483
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, GetDefaultHistogram,
484
                         (double *pdfMin, double *pdfMax, int *pnBuckets,
485
                          GUIntBig **ppanHistogram, int bForce,
486
                          GDALProgressFunc pfn, void *pProgressData),
487
                         (pdfMin, pdfMax, pnBuckets, ppanHistogram, bForce, pfn,
488
                          pProgressData))
489
490
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetDefaultHistogram,
491
                         (double dfMin, double dfMax, int nBuckets,
492
                          GUIntBig *panHistogram),
493
                         (dfMin, dfMax, nBuckets, panHistogram))
494
495
RB_PROXY_METHOD_WITH_RET(GDALRasterAttributeTable *, nullptr, GetDefaultRAT, (),
496
                         ())
497
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, SetDefaultRAT,
498
                         (const GDALRasterAttributeTable *arg1), (arg1))
499
500
RB_PROXY_METHOD_WITH_RET(GDALRasterBand *, nullptr, GetMaskBand, (), ())
501
RB_PROXY_METHOD_WITH_RET(int, 0, GetMaskFlags, (), ())
502
RB_PROXY_METHOD_WITH_RET(CPLErr, CE_Failure, CreateMaskBand, (int nFlagsIn),
503
                         (nFlagsIn))
504
RB_PROXY_METHOD_WITH_RET(bool, false, IsMaskBand, () const, ())
505
RB_PROXY_METHOD_WITH_RET(GDALMaskValueRange, GMVR_UNKNOWN, GetMaskValueRange,
506
                         () const, ())
507
508
RB_PROXY_METHOD_WITH_RET(CPLVirtualMem *, nullptr, GetVirtualMemAuto,
509
                         (GDALRWFlag eRWFlag, int *pnPixelSpace,
510
                          GIntBig *pnLineSpace, char **papszOptions),
511
                         (eRWFlag, pnPixelSpace, pnLineSpace, papszOptions))
512
513
RB_PROXY_METHOD_WITH_RET(
514
    CPLErr, CE_Failure, InterpolateAtPoint,
515
    (double dfPixel, double dfLine, GDALRIOResampleAlg eInterpolation,
516
     double *pdfRealValue, double *pdfImagValue = nullptr) const,
517
    (dfPixel, dfLine, eInterpolation, pdfRealValue, pdfImagValue))
518
519
void GDALProxyRasterBand::EnablePixelTypeSignedByteWarning(bool b)
520
0
{
521
0
    GDALRasterBand *poSrcBand = RefUnderlyingRasterBand();
522
0
    if (poSrcBand)
523
0
    {
524
0
        poSrcBand->EnablePixelTypeSignedByteWarning(b);
525
0
        UnrefUnderlyingRasterBand(poSrcBand);
526
0
    }
527
0
}
528
529
/************************************************************************/
530
/*                 UnrefUnderlyingRasterBand()                        */
531
/************************************************************************/
532
533
void GDALProxyRasterBand::UnrefUnderlyingRasterBand(
534
    GDALRasterBand * /* poUnderlyingRasterBand */) const
535
0
{
536
0
}
537
538
/*! @endcond */