Coverage Report

Created: 2026-02-14 06:52

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