Coverage Report

Created: 2025-06-22 06:59

/src/gdal/gcore/gdal_priv.h
Line
Count
Source (jump to first uncovered line)
1
/******************************************************************************
2
 *
3
 * Name:     gdal_priv.h
4
 * Project:  GDAL Core
5
 * Purpose:  GDAL Core C++/Private declarations.
6
 * Author:   Frank Warmerdam, warmerdam@pobox.com
7
 *
8
 ******************************************************************************
9
 * Copyright (c) 1998, Frank Warmerdam
10
 * Copyright (c) 2007-2014, Even Rouault <even dot rouault at spatialys.com>
11
 *
12
 * SPDX-License-Identifier: MIT
13
 ****************************************************************************/
14
15
#ifndef GDAL_PRIV_H_INCLUDED
16
#define GDAL_PRIV_H_INCLUDED
17
18
/**
19
 * \file gdal_priv.h
20
 *
21
 * C++ GDAL entry points.
22
 */
23
24
/* -------------------------------------------------------------------- */
25
/*      Predeclare various classes before pulling in gdal.h, the        */
26
/*      public declarations.                                            */
27
/* -------------------------------------------------------------------- */
28
class GDALMajorObject;
29
class GDALDataset;
30
class GDALRasterBand;
31
class GDALDriver;
32
class GDALRasterAttributeTable;
33
class GDALProxyDataset;
34
class GDALProxyRasterBand;
35
class GDALAsyncReader;
36
class GDALRelationship;
37
class GDALAlgorithm;
38
39
/* -------------------------------------------------------------------- */
40
/*      Pull in the public declarations.  This gets the C apis, and     */
41
/*      also various constants.  However, we will still get to          */
42
/*      provide the real class definitions for the GDAL classes.        */
43
/* -------------------------------------------------------------------- */
44
45
#include "gdal.h"
46
#include "gdal_frmts.h"
47
#include "gdalsubdatasetinfo.h"
48
#include "cpl_vsi.h"
49
#include "cpl_conv.h"
50
#include "cpl_string.h"
51
#include "cpl_minixml.h"
52
#include "cpl_multiproc.h"
53
#include "cpl_atomic_ops.h"
54
55
#include <stdarg.h>
56
57
#include <algorithm>
58
#include <cmath>
59
#include <complex>
60
#include <cstdint>
61
#include <iterator>
62
#include <limits>
63
#include <map>
64
#include <memory>
65
#include <set>
66
#if __cplusplus >= 202002L
67
#include <span>
68
#endif
69
#include <type_traits>
70
#include <vector>
71
72
#include "ogr_core.h"
73
#include "ogr_feature.h"
74
75
//! @cond Doxygen_Suppress
76
0
#define GMO_VALID 0x0001
77
0
#define GMO_IGNORE_UNIMPLEMENTED 0x0002
78
#define GMO_SUPPORT_MD 0x0004
79
#define GMO_SUPPORT_MDMD 0x0008
80
0
#define GMO_MD_DIRTY 0x0010
81
0
#define GMO_PAM_CLASS 0x0020
82
83
//! @endcond
84
85
/************************************************************************/
86
/*                       GDALMultiDomainMetadata                        */
87
/************************************************************************/
88
89
//! @cond Doxygen_Suppress
90
class CPL_DLL GDALMultiDomainMetadata
91
{
92
  private:
93
    CPLStringList aosDomainList{};
94
95
    struct Comparator
96
    {
97
        bool operator()(const char *a, const char *b) const
98
0
        {
99
0
            return STRCASECMP(a, b) < 0;
100
0
        }
101
    };
102
103
    std::map<const char *, CPLStringList, Comparator> oMetadata{};
104
105
  public:
106
    GDALMultiDomainMetadata();
107
108
    /** Copy constructor */
109
    GDALMultiDomainMetadata(const GDALMultiDomainMetadata &) = default;
110
111
    /** Copy assignment operator */
112
    GDALMultiDomainMetadata &
113
0
    operator=(const GDALMultiDomainMetadata &) = default;
114
115
    /** Move constructor */
116
    GDALMultiDomainMetadata(GDALMultiDomainMetadata &&) = default;
117
118
    /** Move assignment operator */
119
    GDALMultiDomainMetadata &operator=(GDALMultiDomainMetadata &&) = default;
120
121
    ~GDALMultiDomainMetadata();
122
123
    int XMLInit(const CPLXMLNode *psMetadata, int bMerge);
124
    CPLXMLNode *Serialize() const;
125
126
    CSLConstList GetDomainList() const
127
0
    {
128
0
        return aosDomainList.List();
129
0
    }
130
131
    char **GetMetadata(const char *pszDomain = "");
132
    CPLErr SetMetadata(CSLConstList papszMetadata, const char *pszDomain = "");
133
    const char *GetMetadataItem(const char *pszName,
134
                                const char *pszDomain = "");
135
    CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
136
                           const char *pszDomain = "");
137
138
    void Clear();
139
140
    inline void clear()
141
0
    {
142
0
        Clear();
143
0
    }
144
};
145
146
//! @endcond
147
148
/* ******************************************************************** */
149
/*                           GDALMajorObject                            */
150
/*                                                                      */
151
/*      Base class providing metadata, description and other            */
152
/*      services shared by major objects.                               */
153
/* ******************************************************************** */
154
155
/** Object with metadata. */
156
class CPL_DLL GDALMajorObject
157
{
158
  protected:
159
    //! @cond Doxygen_Suppress
160
    int nFlags;  // GMO_* flags.
161
    CPLString sDescription{};
162
    GDALMultiDomainMetadata oMDMD{};
163
164
    //! @endcond
165
166
    char **BuildMetadataDomainList(char **papszList, int bCheckNonEmpty,
167
                                   ...) CPL_NULL_TERMINATED;
168
169
    /** Copy constructor */
170
    GDALMajorObject(const GDALMajorObject &) = default;
171
172
    /** Copy assignment operator */
173
    GDALMajorObject &operator=(const GDALMajorObject &) = default;
174
175
    /** Move constructor */
176
    GDALMajorObject(GDALMajorObject &&) = default;
177
178
    /** Move assignment operator */
179
    GDALMajorObject &operator=(GDALMajorObject &&) = default;
180
181
  public:
182
    GDALMajorObject();
183
    virtual ~GDALMajorObject();
184
185
    int GetMOFlags() const;
186
    void SetMOFlags(int nFlagsIn);
187
188
    virtual const char *GetDescription() const;
189
    virtual void SetDescription(const char *);
190
191
    virtual char **GetMetadataDomainList();
192
193
    virtual char **GetMetadata(const char *pszDomain = "");
194
    virtual CPLErr SetMetadata(char **papszMetadata,
195
                               const char *pszDomain = "");
196
    virtual const char *GetMetadataItem(const char *pszName,
197
                                        const char *pszDomain = "");
198
    virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
199
                                   const char *pszDomain = "");
200
201
    /** Convert a GDALMajorObject* to a GDALMajorObjectH.
202
     * @since GDAL 2.3
203
     */
204
    static inline GDALMajorObjectH ToHandle(GDALMajorObject *poMajorObject)
205
0
    {
206
0
        return static_cast<GDALMajorObjectH>(poMajorObject);
207
0
    }
208
209
    /** Convert a GDALMajorObjectH to a GDALMajorObject*.
210
     * @since GDAL 2.3
211
     */
212
    static inline GDALMajorObject *FromHandle(GDALMajorObjectH hMajorObject)
213
0
    {
214
0
        return static_cast<GDALMajorObject *>(hMajorObject);
215
0
    }
216
};
217
218
/* ******************************************************************** */
219
/*                         GDALDefaultOverviews                         */
220
/* ******************************************************************** */
221
222
//! @cond Doxygen_Suppress
223
class GDALOpenInfo;
224
225
class CPL_DLL GDALDefaultOverviews
226
{
227
    friend class GDALDataset;
228
229
    GDALDataset *poDS;
230
    GDALDataset *poODS;
231
232
    CPLString osOvrFilename{};
233
234
    bool bOvrIsAux;
235
236
    bool bCheckedForMask;
237
    bool bOwnMaskDS;
238
    GDALDataset *poMaskDS;
239
240
    // For "overview datasets" we record base level info so we can
241
    // find our way back to get overview masks.
242
    GDALDataset *poBaseDS;
243
244
    // Stuff for deferred initialize/overviewscans.
245
    bool bCheckedForOverviews;
246
    void OverviewScan();
247
    char *pszInitName;
248
    bool bInitNameIsOVR;
249
    char **papszInitSiblingFiles;
250
251
  public:
252
    GDALDefaultOverviews();
253
    ~GDALDefaultOverviews();
254
255
    void Initialize(GDALDataset *poDSIn, const char *pszName = nullptr,
256
                    CSLConstList papszSiblingFiles = nullptr,
257
                    bool bNameIsOVR = false);
258
259
    void Initialize(GDALDataset *poDSIn, GDALOpenInfo *poOpenInfo,
260
                    const char *pszName = nullptr,
261
                    bool bTransferSiblingFilesIfLoaded = true);
262
263
    void TransferSiblingFiles(char **papszSiblingFiles);
264
265
    int IsInitialized();
266
267
    int CloseDependentDatasets();
268
269
    // Overview Related
270
271
    int GetOverviewCount(int nBand);
272
    GDALRasterBand *GetOverview(int nBand, int iOverview);
273
274
    CPLErr BuildOverviews(const char *pszBasename, const char *pszResampling,
275
                          int nOverviews, const int *panOverviewList,
276
                          int nBands, const int *panBandList,
277
                          GDALProgressFunc pfnProgress, void *pProgressData,
278
                          CSLConstList papszOptions);
279
280
    CPLErr BuildOverviewsSubDataset(const char *pszPhysicalFile,
281
                                    const char *pszResampling, int nOverviews,
282
                                    const int *panOverviewList, int nBands,
283
                                    const int *panBandList,
284
                                    GDALProgressFunc pfnProgress,
285
                                    void *pProgressData,
286
                                    CSLConstList papszOptions);
287
288
    CPLErr BuildOverviewsMask(const char *pszResampling, int nOverviews,
289
                              const int *panOverviewList,
290
                              GDALProgressFunc pfnProgress, void *pProgressData,
291
                              CSLConstList papszOptions);
292
293
    CPLErr CleanOverviews();
294
295
    // Mask Related
296
297
    CPLErr CreateMaskBand(int nFlags, int nBand = -1);
298
    GDALRasterBand *GetMaskBand(int nBand);
299
    int GetMaskFlags(int nBand);
300
301
    int HaveMaskFile(char **papszSiblings = nullptr,
302
                     const char *pszBasename = nullptr);
303
304
    char **GetSiblingFiles()
305
0
    {
306
0
        return papszInitSiblingFiles;
307
0
    }
308
309
  private:
310
    CPL_DISALLOW_COPY_ASSIGN(GDALDefaultOverviews)
311
};
312
313
//! @endcond
314
315
/* ******************************************************************** */
316
/*                             GDALOpenInfo                             */
317
/* ******************************************************************** */
318
319
/** Class for dataset open functions. */
320
class CPL_DLL GDALOpenInfo
321
{
322
    bool bHasGotSiblingFiles = false;
323
    char **papszSiblingFiles = nullptr;
324
    int nHeaderBytesTried = 0;
325
326
  public:
327
    GDALOpenInfo(const char *pszFile, int nOpenFlagsIn,
328
                 const char *const *papszSiblingFiles = nullptr);
329
    ~GDALOpenInfo(void);
330
331
    /** Filename */
332
    char *pszFilename = nullptr;
333
334
    /** Result of CPLGetExtension(pszFilename); */
335
    std::string osExtension{};
336
337
    /** Open options */
338
    char **papszOpenOptions = nullptr;
339
340
    /** Access flag */
341
    GDALAccess eAccess = GA_ReadOnly;
342
    /** Open flags */
343
    int nOpenFlags = 0;
344
345
    /** Whether stat()'ing the file was successful */
346
    bool bStatOK = false;
347
    /** Whether the file is a directory */
348
    bool bIsDirectory = false;
349
350
    /** Pointer to the file */
351
    VSILFILE *fpL = nullptr;
352
353
    /** Number of bytes in pabyHeader */
354
    int nHeaderBytes = 0;
355
    /** Buffer with first bytes of the file */
356
    GByte *pabyHeader = nullptr;
357
358
    /** Allowed drivers (NULL for all) */
359
    const char *const *papszAllowedDrivers = nullptr;
360
361
    int TryToIngest(int nBytes);
362
    char **GetSiblingFiles();
363
    char **StealSiblingFiles();
364
    bool AreSiblingFilesLoaded() const;
365
366
    bool IsSingleAllowedDriver(const char *pszDriverName) const;
367
368
    /** Return whether the extension of the file is equal to pszExt, using
369
     * case-insensitive comparison.
370
     * @since 3.11 */
371
    inline bool IsExtensionEqualToCI(const char *pszExt) const
372
0
    {
373
0
        return EQUAL(osExtension.c_str(), pszExt);
374
0
    }
375
376
  private:
377
    CPL_DISALLOW_COPY_ASSIGN(GDALOpenInfo)
378
};
379
380
/* ******************************************************************** */
381
/*                             gdal::GCP                                */
382
/* ******************************************************************** */
383
384
namespace gdal
385
{
386
/** C++ wrapper over the C GDAL_GCP structure.
387
 *
388
 * It has the same binary layout, and thus a gdal::GCP pointer can be cast as a
389
 * GDAL_GCP pointer.
390
 *
391
 * @since 3.9
392
 */
393
class CPL_DLL GCP
394
{
395
  public:
396
    explicit GCP(const char *pszId = "", const char *pszInfo = "",
397
                 double dfPixel = 0, double dfLine = 0, double dfX = 0,
398
                 double dfY = 0, double dfZ = 0);
399
    ~GCP();
400
    GCP(const GCP &);
401
    explicit GCP(const GDAL_GCP &other);
402
    GCP &operator=(const GCP &);
403
    GCP(GCP &&);
404
    GCP &operator=(GCP &&);
405
406
    /** Returns the "id" member. */
407
    inline const char *Id() const
408
0
    {
409
0
        return gcp.pszId;
410
0
    }
411
412
    void SetId(const char *pszId);
413
414
    /** Returns the "info" member. */
415
    inline const char *Info() const
416
0
    {
417
0
        return gcp.pszInfo;
418
0
    }
419
420
    void SetInfo(const char *pszInfo);
421
422
    /** Returns the "pixel" member. */
423
    inline double Pixel() const
424
0
    {
425
0
        return gcp.dfGCPPixel;
426
0
    }
427
428
    /** Returns a reference to the "pixel" member. */
429
    inline double &Pixel()
430
0
    {
431
0
        return gcp.dfGCPPixel;
432
0
    }
433
434
    /** Returns the "line" member. */
435
    inline double Line() const
436
0
    {
437
0
        return gcp.dfGCPLine;
438
0
    }
439
440
    /** Returns a reference to the "line" member. */
441
    inline double &Line()
442
0
    {
443
0
        return gcp.dfGCPLine;
444
0
    }
445
446
    /** Returns the "X" member. */
447
    inline double X() const
448
0
    {
449
0
        return gcp.dfGCPX;
450
0
    }
451
452
    /** Returns a reference to the "X" member. */
453
    inline double &X()
454
0
    {
455
0
        return gcp.dfGCPX;
456
0
    }
457
458
    /** Returns the "Y" member. */
459
    inline double Y() const
460
0
    {
461
0
        return gcp.dfGCPY;
462
0
    }
463
464
    /** Returns a reference to the "Y" member. */
465
    inline double &Y()
466
0
    {
467
0
        return gcp.dfGCPY;
468
0
    }
469
470
    /** Returns the "Z" member. */
471
    inline double Z() const
472
0
    {
473
0
        return gcp.dfGCPZ;
474
0
    }
475
476
    /** Returns a reference to the "Z" member. */
477
    inline double &Z()
478
0
    {
479
0
        return gcp.dfGCPZ;
480
0
    }
481
482
    /** Casts as a C GDAL_GCP pointer */
483
    inline const GDAL_GCP *c_ptr() const
484
0
    {
485
0
        return &gcp;
486
0
    }
487
488
    static const GDAL_GCP *c_ptr(const std::vector<GCP> &asGCPs);
489
490
    static std::vector<GCP> fromC(const GDAL_GCP *pasGCPList, int nGCPCount);
491
492
  private:
493
    GDAL_GCP gcp;
494
};
495
496
} /* namespace gdal */
497
498
/* ******************************************************************** */
499
/*                             GDALDataset                              */
500
/* ******************************************************************** */
501
502
class OGRLayer;
503
class OGRGeometry;
504
class OGRSpatialReference;
505
class OGRStyleTable;
506
class swq_select;
507
class swq_select_parse_options;
508
class GDALGroup;
509
510
//! @cond Doxygen_Suppress
511
typedef struct GDALSQLParseInfo GDALSQLParseInfo;
512
//! @endcond
513
514
//! @cond Doxygen_Suppress
515
#ifdef GDAL_COMPILATION
516
#define OPTIONAL_OUTSIDE_GDAL(val)
517
#else
518
#define OPTIONAL_OUTSIDE_GDAL(val) = val
519
#endif
520
//! @endcond
521
522
//! @cond Doxygen_Suppress
523
// This macro can be defined to check that GDALDataset::IRasterIO()
524
// implementations do not alter the passed panBandList. It is not defined
525
// by default (and should not!), hence int* is used.
526
#if defined(GDAL_BANDMAP_TYPE_CONST_SAFE)
527
#define BANDMAP_TYPE const int *
528
#else
529
#define BANDMAP_TYPE int *
530
#endif
531
//! @endcond
532
533
/** A set of associated raster bands, usually from one file. */
534
class CPL_DLL GDALDataset : public GDALMajorObject
535
{
536
    friend GDALDatasetH CPL_STDCALL
537
    GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags,
538
               const char *const *papszAllowedDrivers,
539
               const char *const *papszOpenOptions,
540
               const char *const *papszSiblingFiles);
541
    friend CPLErr CPL_STDCALL GDALClose(GDALDatasetH hDS);
542
543
    friend class GDALDriver;
544
    friend class GDALDefaultOverviews;
545
    friend class GDALProxyDataset;
546
    friend class GDALDriverManager;
547
548
    CPL_INTERNAL void AddToDatasetOpenList();
549
550
    CPL_INTERNAL void UnregisterFromSharedDataset();
551
552
    CPL_INTERNAL static void ReportErrorV(const char *pszDSName,
553
                                          CPLErr eErrClass, CPLErrorNum err_no,
554
                                          const char *fmt, va_list args);
555
556
  protected:
557
    //! @cond Doxygen_Suppress
558
    GDALDriver *poDriver = nullptr;
559
    GDALAccess eAccess = GA_ReadOnly;
560
561
    // Stored raster information.
562
    int nRasterXSize = 512;
563
    int nRasterYSize = 512;
564
    int nBands = 0;
565
    GDALRasterBand **papoBands = nullptr;
566
567
    static constexpr int OPEN_FLAGS_CLOSED = -1;
568
    int nOpenFlags =
569
        0;  // set to OPEN_FLAGS_CLOSED after Close() has been called
570
571
    int nRefCount = 1;
572
    bool bForceCachedIO = false;
573
    bool bShared = false;
574
    bool bIsInternal = true;
575
    bool bSuppressOnClose = false;
576
577
    mutable std::map<std::string, std::unique_ptr<OGRFieldDomain>>
578
        m_oMapFieldDomains{};
579
580
    GDALDataset(void);
581
    explicit GDALDataset(int bForceCachedIO);
582
583
    void RasterInitialize(int, int);
584
    void SetBand(int nNewBand, GDALRasterBand *poBand);
585
    void SetBand(int nNewBand, std::unique_ptr<GDALRasterBand> poBand);
586
587
    GDALDefaultOverviews oOvManager{};
588
589
    virtual CPLErr IBuildOverviews(const char *pszResampling, int nOverviews,
590
                                   const int *panOverviewList, int nListBands,
591
                                   const int *panBandList,
592
                                   GDALProgressFunc pfnProgress,
593
                                   void *pProgressData,
594
                                   CSLConstList papszOptions);
595
596
    virtual CPLErr
597
    IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize,
598
              void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType,
599
              int nBandCount, BANDMAP_TYPE panBandMap, GSpacing nPixelSpace,
600
              GSpacing nLineSpace, GSpacing nBandSpace,
601
              GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
602
603
    /* This method should only be be overloaded by GDALProxyDataset */
604
    virtual CPLErr
605
    BlockBasedRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
606
                       int nYSize, void *pData, int nBufXSize, int nBufYSize,
607
                       GDALDataType eBufType, int nBandCount,
608
                       const int *panBandMap, GSpacing nPixelSpace,
609
                       GSpacing nLineSpace, GSpacing nBandSpace,
610
                       GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
611
    CPLErr BlockBasedFlushCache(bool bAtClosing);
612
613
    CPLErr
614
    BandBasedRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
615
                      int nYSize, void *pData, int nBufXSize, int nBufYSize,
616
                      GDALDataType eBufType, int nBandCount,
617
                      const int *panBandMap, GSpacing nPixelSpace,
618
                      GSpacing nLineSpace, GSpacing nBandSpace,
619
                      GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
620
621
    CPLErr
622
    RasterIOResampled(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
623
                      int nYSize, void *pData, int nBufXSize, int nBufYSize,
624
                      GDALDataType eBufType, int nBandCount,
625
                      const int *panBandMap, GSpacing nPixelSpace,
626
                      GSpacing nLineSpace, GSpacing nBandSpace,
627
                      GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
628
629
    CPLErr ValidateRasterIOOrAdviseReadParameters(
630
        const char *pszCallingFunc, int *pbStopProcessingOnCENone, int nXOff,
631
        int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize,
632
        int nBandCount, const int *panBandMap);
633
634
    CPLErr TryOverviewRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
635
                               int nXSize, int nYSize, void *pData,
636
                               int nBufXSize, int nBufYSize,
637
                               GDALDataType eBufType, int nBandCount,
638
                               const int *panBandMap, GSpacing nPixelSpace,
639
                               GSpacing nLineSpace, GSpacing nBandSpace,
640
                               GDALRasterIOExtraArg *psExtraArg, int *pbTried);
641
642
    void ShareLockWithParentDataset(GDALDataset *poParentDataset);
643
644
    bool m_bCanBeReopened = false;
645
646
    virtual bool CanBeCloned(int nScopeFlags, bool bCanShareState) const;
647
648
    friend class GDALThreadSafeDataset;
649
    friend class MEMDataset;
650
    virtual std::unique_ptr<GDALDataset> Clone(int nScopeFlags,
651
                                               bool bCanShareState) const;
652
653
    //! @endcond
654
655
    void CleanupPostFileClosing();
656
657
    virtual int CloseDependentDatasets();
658
    //! @cond Doxygen_Suppress
659
    int ValidateLayerCreationOptions(const char *const *papszLCO);
660
661
    char **papszOpenOptions = nullptr;
662
663
    friend class GDALRasterBand;
664
665
    // The below methods related to read write mutex are fragile logic, and
666
    // should not be used by out-of-tree code if possible.
667
    int EnterReadWrite(GDALRWFlag eRWFlag);
668
    void LeaveReadWrite();
669
    void InitRWLock();
670
671
    void TemporarilyDropReadWriteLock();
672
    void ReacquireReadWriteLock();
673
674
    void DisableReadWriteMutex();
675
676
    int AcquireMutex();
677
    void ReleaseMutex();
678
679
    bool IsAllBands(int nBandCount, const int *panBandList) const;
680
    //! @endcond
681
682
  public:
683
    ~GDALDataset() override;
684
685
    virtual CPLErr Close();
686
687
    int GetRasterXSize() const;
688
    int GetRasterYSize() const;
689
    int GetRasterCount() const;
690
    GDALRasterBand *GetRasterBand(int);
691
    const GDALRasterBand *GetRasterBand(int) const;
692
693
    /**
694
     * @brief SetQueryLoggerFunc
695
     * @param pfnQueryLoggerFuncIn query logger function callback
696
     * @param poQueryLoggerArgIn arguments passed to the query logger function
697
     * @return true on success
698
     */
699
    virtual bool SetQueryLoggerFunc(GDALQueryLoggerFunc pfnQueryLoggerFuncIn,
700
                                    void *poQueryLoggerArgIn);
701
702
    /** Class returned by GetBands() that act as a container for raster bands.
703
     */
704
    class CPL_DLL Bands
705
    {
706
      private:
707
        friend class GDALDataset;
708
        GDALDataset *m_poSelf;
709
710
0
        CPL_INTERNAL explicit Bands(GDALDataset *poSelf) : m_poSelf(poSelf)
711
0
        {
712
0
        }
713
714
        class CPL_DLL Iterator
715
        {
716
            struct Private;
717
            std::unique_ptr<Private> m_poPrivate;
718
719
          public:
720
            Iterator(GDALDataset *poDS, bool bStart);
721
            Iterator(const Iterator &oOther);  // declared but not defined.
722
                                               // Needed for gcc 5.4 at least
723
            Iterator(Iterator &&oOther) noexcept;  // declared but not defined.
724
                // Needed for gcc 5.4 at least
725
            ~Iterator();
726
            GDALRasterBand *operator*();
727
            Iterator &operator++();
728
            bool operator!=(const Iterator &it) const;
729
        };
730
731
      public:
732
        const Iterator begin() const;
733
734
        const Iterator end() const;
735
736
        size_t size() const;
737
738
        GDALRasterBand *operator[](int iBand);
739
        GDALRasterBand *operator[](size_t iBand);
740
    };
741
742
    Bands GetBands();
743
744
    virtual CPLErr FlushCache(bool bAtClosing = false);
745
    virtual CPLErr DropCache();
746
747
    virtual GIntBig GetEstimatedRAMUsage();
748
749
    virtual const OGRSpatialReference *GetSpatialRef() const;
750
    virtual CPLErr SetSpatialRef(const OGRSpatialReference *poSRS);
751
752
    // Compatibility layer
753
    const char *GetProjectionRef(void) const;
754
    CPLErr SetProjection(const char *pszProjection);
755
756
    virtual CPLErr GetGeoTransform(double *padfTransform);
757
    virtual CPLErr SetGeoTransform(double *padfTransform);
758
759
    virtual CPLErr GetExtent(OGREnvelope *psExtent,
760
                             const OGRSpatialReference *poCRS = nullptr) const;
761
    virtual CPLErr GetExtentWGS84LongLat(OGREnvelope *psExtent) const;
762
763
    CPLErr GeolocationToPixelLine(
764
        double dfGeolocX, double dfGeolocY, const OGRSpatialReference *poSRS,
765
        double *pdfPixel, double *pdfLine,
766
        CSLConstList papszTransformerOptions = nullptr) const;
767
768
    virtual CPLErr AddBand(GDALDataType eType, char **papszOptions = nullptr);
769
770
    virtual void *GetInternalHandle(const char *pszHandleName);
771
    virtual GDALDriver *GetDriver(void);
772
    virtual char **GetFileList(void);
773
774
    virtual const char *GetDriverName();
775
776
    virtual const OGRSpatialReference *GetGCPSpatialRef() const;
777
    virtual int GetGCPCount();
778
    virtual const GDAL_GCP *GetGCPs();
779
    virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList,
780
                           const OGRSpatialReference *poGCP_SRS);
781
782
    // Compatibility layer
783
    const char *GetGCPProjection();
784
    CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList,
785
                   const char *pszGCPProjection);
786
787
    virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize,
788
                              int nBufXSize, int nBufYSize, GDALDataType eDT,
789
                              int nBandCount, int *panBandList,
790
                              char **papszOptions);
791
792
    virtual CPLErr CreateMaskBand(int nFlagsIn);
793
794
    virtual GDALAsyncReader *
795
    BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize, void *pBuf,
796
                     int nBufXSize, int nBufYSize, GDALDataType eBufType,
797
                     int nBandCount, int *panBandMap, int nPixelSpace,
798
                     int nLineSpace, int nBandSpace, char **papszOptions);
799
    virtual void EndAsyncReader(GDALAsyncReader *poARIO);
800
801
    //! @cond Doxygen_Suppress
802
    struct RawBinaryLayout
803
    {
804
        enum class Interleaving
805
        {
806
            UNKNOWN,
807
            BIP,
808
            BIL,
809
            BSQ
810
        };
811
        std::string osRawFilename{};
812
        Interleaving eInterleaving = Interleaving::UNKNOWN;
813
        GDALDataType eDataType = GDT_Unknown;
814
        bool bLittleEndianOrder = false;
815
816
        vsi_l_offset nImageOffset = 0;
817
        GIntBig nPixelOffset = 0;
818
        GIntBig nLineOffset = 0;
819
        GIntBig nBandOffset = 0;
820
    };
821
822
    virtual bool GetRawBinaryLayout(RawBinaryLayout &);
823
    //! @endcond
824
825
#ifndef DOXYGEN_SKIP
826
    CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
827
                    int nYSize, void *pData, int nBufXSize, int nBufYSize,
828
                    GDALDataType eBufType, int nBandCount,
829
                    const int *panBandMap, GSpacing nPixelSpace,
830
                    GSpacing nLineSpace, GSpacing nBandSpace,
831
                    GDALRasterIOExtraArg *psExtraArg
832
                        OPTIONAL_OUTSIDE_GDAL(nullptr)) CPL_WARN_UNUSED_RESULT;
833
#else
834
    CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
835
                    int nYSize, void *pData, int nBufXSize, int nBufYSize,
836
                    GDALDataType eBufType, int nBandCount,
837
                    const int *panBandMap, GSpacing nPixelSpace,
838
                    GSpacing nLineSpace, GSpacing nBandSpace,
839
                    GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
840
#endif
841
842
    virtual CPLStringList GetCompressionFormats(int nXOff, int nYOff,
843
                                                int nXSize, int nYSize,
844
                                                int nBandCount,
845
                                                const int *panBandList);
846
    virtual CPLErr ReadCompressedData(const char *pszFormat, int nXOff,
847
                                      int nYOff, int nXSize, int nYSize,
848
                                      int nBands, const int *panBandList,
849
                                      void **ppBuffer, size_t *pnBufferSize,
850
                                      char **ppszDetailedFormat);
851
852
    int Reference();
853
    int Dereference();
854
    int ReleaseRef();
855
856
    /** Return access mode.
857
     * @return access mode.
858
     */
859
    GDALAccess GetAccess() const
860
0
    {
861
0
        return eAccess;
862
0
    }
863
864
    int GetShared() const;
865
    void MarkAsShared();
866
867
    void MarkSuppressOnClose();
868
    void UnMarkSuppressOnClose();
869
870
    /** Return MarkSuppressOnClose flag.
871
    * @return MarkSuppressOnClose flag.
872
    */
873
    bool IsMarkedSuppressOnClose() const
874
0
    {
875
0
        return bSuppressOnClose;
876
0
    }
877
878
    /** Return open options.
879
     * @return open options.
880
     */
881
    char **GetOpenOptions()
882
0
    {
883
0
        return papszOpenOptions;
884
0
    }
885
886
    bool IsThreadSafe(int nScopeFlags) const;
887
888
#ifndef DOXYGEN_SKIP
889
    /** Return open options.
890
     * @return open options.
891
     */
892
    CSLConstList GetOpenOptions() const
893
0
    {
894
0
        return papszOpenOptions;
895
0
    }
896
#endif
897
898
    static GDALDataset **GetOpenDatasets(int *pnDatasetCount);
899
900
#ifndef DOXYGEN_SKIP
901
    CPLErr
902
    BuildOverviews(const char *pszResampling, int nOverviews,
903
                   const int *panOverviewList, int nListBands,
904
                   const int *panBandList, GDALProgressFunc pfnProgress,
905
                   void *pProgressData,
906
                   CSLConstList papszOptions OPTIONAL_OUTSIDE_GDAL(nullptr));
907
#else
908
    CPLErr BuildOverviews(const char *pszResampling, int nOverviews,
909
                          const int *panOverviewList, int nListBands,
910
                          const int *panBandList, GDALProgressFunc pfnProgress,
911
                          void *pProgressData, CSLConstList papszOptions);
912
#endif
913
914
#ifndef DOXYGEN_XML
915
    void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,
916
                     ...) const CPL_PRINT_FUNC_FORMAT(4, 5);
917
918
    static void ReportError(const char *pszDSName, CPLErr eErrClass,
919
                            CPLErrorNum err_no, const char *fmt, ...)
920
        CPL_PRINT_FUNC_FORMAT(4, 5);
921
#endif
922
923
    char **GetMetadata(const char *pszDomain = "") override;
924
925
// Only defined when Doxygen enabled
926
#ifdef DOXYGEN_SKIP
927
    CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override;
928
    CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
929
                           const char *pszDomain) override;
930
#endif
931
932
    char **GetMetadataDomainList() override;
933
934
    virtual void ClearStatistics();
935
936
    /** Convert a GDALDataset* to a GDALDatasetH.
937
     * @since GDAL 2.3
938
     */
939
    static inline GDALDatasetH ToHandle(GDALDataset *poDS)
940
0
    {
941
0
        return static_cast<GDALDatasetH>(poDS);
942
0
    }
943
944
    /** Convert a GDALDatasetH to a GDALDataset*.
945
     * @since GDAL 2.3
946
     */
947
    static inline GDALDataset *FromHandle(GDALDatasetH hDS)
948
0
    {
949
0
        return static_cast<GDALDataset *>(hDS);
950
0
    }
951
952
    /** @see GDALOpenEx().
953
     * @since GDAL 2.3
954
     */
955
    static GDALDataset *Open(const char *pszFilename,
956
                             unsigned int nOpenFlags = 0,
957
                             const char *const *papszAllowedDrivers = nullptr,
958
                             const char *const *papszOpenOptions = nullptr,
959
                             const char *const *papszSiblingFiles = nullptr)
960
0
    {
961
0
        return FromHandle(GDALOpenEx(pszFilename, nOpenFlags,
962
0
                                     papszAllowedDrivers, papszOpenOptions,
963
0
                                     papszSiblingFiles));
964
0
    }
965
966
    /** Object returned by GetFeatures() iterators */
967
    struct FeatureLayerPair
968
    {
969
        /** Unique pointer to a OGRFeature. */
970
        OGRFeatureUniquePtr feature{};
971
972
        /** Layer to which the feature belongs to. */
973
        OGRLayer *layer = nullptr;
974
    };
975
976
    //! @cond Doxygen_Suppress
977
    // SetEnableOverviews() only to be used by GDALOverviewDataset
978
    void SetEnableOverviews(bool bEnable);
979
980
    // Only to be used by driver's GetOverviewCount() method.
981
    bool AreOverviewsEnabled() const;
982
983
    static void ReportUpdateNotSupportedByDriver(const char *pszDriverName);
984
    //! @endcond
985
986
  private:
987
    class Private;
988
    Private *m_poPrivate;
989
990
    CPL_INTERNAL OGRLayer *BuildLayerFromSelectInfo(
991
        swq_select *psSelectInfo, OGRGeometry *poSpatialFilter,
992
        const char *pszDialect, swq_select_parse_options *poSelectParseOptions);
993
    CPLStringList oDerivedMetadataList{};
994
995
  public:
996
    virtual int GetLayerCount();
997
    virtual OGRLayer *GetLayer(int iLayer);
998
999
    virtual bool IsLayerPrivate(int iLayer) const;
1000
1001
    /** Class returned by GetLayers() that acts as a range of layers.
1002
     * @since GDAL 2.3
1003
     */
1004
    class CPL_DLL Layers
1005
    {
1006
      private:
1007
        friend class GDALDataset;
1008
        GDALDataset *m_poSelf;
1009
1010
0
        CPL_INTERNAL explicit Layers(GDALDataset *poSelf) : m_poSelf(poSelf)
1011
0
        {
1012
0
        }
1013
1014
      public:
1015
        /** Layer iterator.
1016
         * @since GDAL 2.3
1017
         */
1018
        class CPL_DLL Iterator
1019
        {
1020
            struct Private;
1021
            std::unique_ptr<Private> m_poPrivate;
1022
1023
          public:
1024
            using value_type = OGRLayer *; /**< value_type */
1025
            using reference = OGRLayer *;  /**< reference */
1026
            using difference_type = void;  /**< difference_type */
1027
            using pointer = void;          /**< pointer */
1028
            using iterator_category =
1029
                std::input_iterator_tag; /**< iterator_category */
1030
1031
            Iterator(); /**< Default constructor */
1032
            Iterator(GDALDataset *poDS, bool bStart); /**< Constructor */
1033
            Iterator(const Iterator &oOther);         /**< Copy constructor */
1034
            Iterator(Iterator &&oOther) noexcept;     /**< Move constructor */
1035
            ~Iterator();                              /**< Destructor */
1036
1037
            Iterator &
1038
            operator=(const Iterator &oOther); /**< Assignment operator */
1039
            Iterator &operator=(
1040
                Iterator &&oOther) noexcept; /**< Move assignment operator */
1041
1042
            OGRLayer *operator*() const; /**< Dereference operator */
1043
            Iterator &operator++();      /**< Pre-increment operator */
1044
            Iterator operator++(int);    /**< Post-increment operator */
1045
            bool operator!=(const Iterator &it)
1046
                const; /**< Difference comparison operator */
1047
        };
1048
1049
        Iterator begin() const;
1050
        Iterator end() const;
1051
1052
        size_t size() const;
1053
1054
        OGRLayer *operator[](int iLayer);
1055
        OGRLayer *operator[](size_t iLayer);
1056
        OGRLayer *operator[](const char *pszLayername);
1057
    };
1058
1059
    Layers GetLayers();
1060
1061
    virtual OGRLayer *GetLayerByName(const char *);
1062
1063
    int GetLayerIndex(const char *pszName);
1064
1065
    virtual OGRErr DeleteLayer(int iLayer);
1066
1067
    virtual void ResetReading();
1068
    virtual OGRFeature *GetNextFeature(OGRLayer **ppoBelongingLayer,
1069
                                       double *pdfProgressPct,
1070
                                       GDALProgressFunc pfnProgress,
1071
                                       void *pProgressData);
1072
1073
    /** Class returned by GetFeatures() that act as a container for vector
1074
     * features. */
1075
    class CPL_DLL Features
1076
    {
1077
      private:
1078
        friend class GDALDataset;
1079
        GDALDataset *m_poSelf;
1080
1081
0
        CPL_INTERNAL explicit Features(GDALDataset *poSelf) : m_poSelf(poSelf)
1082
0
        {
1083
0
        }
1084
1085
        class CPL_DLL Iterator
1086
        {
1087
            struct Private;
1088
            std::unique_ptr<Private> m_poPrivate;
1089
1090
          public:
1091
            Iterator(GDALDataset *poDS, bool bStart);
1092
            Iterator(const Iterator &oOther);  // declared but not defined.
1093
                                               // Needed for gcc 5.4 at least
1094
            Iterator(Iterator &&oOther) noexcept;  // declared but not defined.
1095
                // Needed for gcc 5.4 at least
1096
            ~Iterator();
1097
            const FeatureLayerPair &operator*() const;
1098
            Iterator &operator++();
1099
            bool operator!=(const Iterator &it) const;
1100
        };
1101
1102
      public:
1103
        const Iterator begin() const;
1104
1105
        const Iterator end() const;
1106
    };
1107
1108
    Features GetFeatures();
1109
1110
    virtual int TestCapability(const char *);
1111
1112
    virtual std::vector<std::string>
1113
    GetFieldDomainNames(CSLConstList papszOptions = nullptr) const;
1114
1115
    virtual const OGRFieldDomain *GetFieldDomain(const std::string &name) const;
1116
1117
    virtual bool AddFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
1118
                                std::string &failureReason);
1119
1120
    virtual bool DeleteFieldDomain(const std::string &name,
1121
                                   std::string &failureReason);
1122
1123
    virtual bool UpdateFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
1124
                                   std::string &failureReason);
1125
1126
    virtual std::vector<std::string>
1127
    GetRelationshipNames(CSLConstList papszOptions = nullptr) const;
1128
1129
    virtual const GDALRelationship *
1130
    GetRelationship(const std::string &name) const;
1131
1132
    virtual bool
1133
    AddRelationship(std::unique_ptr<GDALRelationship> &&relationship,
1134
                    std::string &failureReason);
1135
1136
    virtual bool DeleteRelationship(const std::string &name,
1137
                                    std::string &failureReason);
1138
1139
    virtual bool
1140
    UpdateRelationship(std::unique_ptr<GDALRelationship> &&relationship,
1141
                       std::string &failureReason);
1142
1143
    //! @cond Doxygen_Suppress
1144
    OGRLayer *CreateLayer(const char *pszName);
1145
1146
    OGRLayer *CreateLayer(const char *pszName, std::nullptr_t);
1147
    //! @endcond
1148
1149
    OGRLayer *CreateLayer(const char *pszName,
1150
                          const OGRSpatialReference *poSpatialRef,
1151
                          OGRwkbGeometryType eGType = wkbUnknown,
1152
                          CSLConstList papszOptions = nullptr);
1153
1154
    OGRLayer *CreateLayer(const char *pszName,
1155
                          const OGRGeomFieldDefn *poGeomFieldDefn,
1156
                          CSLConstList papszOptions = nullptr);
1157
1158
    virtual OGRLayer *CopyLayer(OGRLayer *poSrcLayer, const char *pszNewName,
1159
                                char **papszOptions = nullptr);
1160
1161
    virtual OGRStyleTable *GetStyleTable();
1162
    virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable);
1163
1164
    virtual void SetStyleTable(OGRStyleTable *poStyleTable);
1165
1166
    virtual OGRLayer *ExecuteSQL(const char *pszStatement,
1167
                                 OGRGeometry *poSpatialFilter,
1168
                                 const char *pszDialect);
1169
    virtual void ReleaseResultSet(OGRLayer *poResultsSet);
1170
    virtual OGRErr AbortSQL();
1171
1172
    int GetRefCount() const;
1173
    int GetSummaryRefCount() const;
1174
    OGRErr Release();
1175
1176
    virtual OGRErr StartTransaction(int bForce = FALSE);
1177
    virtual OGRErr CommitTransaction();
1178
    virtual OGRErr RollbackTransaction();
1179
1180
    virtual std::shared_ptr<GDALGroup> GetRootGroup() const;
1181
1182
    static std::string BuildFilename(const char *pszFilename,
1183
                                     const char *pszReferencePath,
1184
                                     bool bRelativeToReferencePath);
1185
1186
    //! @cond Doxygen_Suppress
1187
    static int IsGenericSQLDialect(const char *pszDialect);
1188
1189
    // Semi-public methods. Only to be used by in-tree drivers.
1190
    GDALSQLParseInfo *
1191
    BuildParseInfo(swq_select *psSelectInfo,
1192
                   swq_select_parse_options *poSelectParseOptions);
1193
    static void DestroyParseInfo(GDALSQLParseInfo *psParseInfo);
1194
    OGRLayer *ExecuteSQL(const char *pszStatement, OGRGeometry *poSpatialFilter,
1195
                         const char *pszDialect,
1196
                         swq_select_parse_options *poSelectParseOptions);
1197
1198
    static constexpr const char *const apszSpecialSubDatasetSyntax[] = {
1199
        "NITF_IM:{ANY}:{FILENAME}", "PDF:{ANY}:{FILENAME}",
1200
        "RASTERLITE:{FILENAME},{ANY}", "TILEDB:\"{FILENAME}\":{ANY}",
1201
        "TILEDB:{FILENAME}:{ANY}"};
1202
1203
    //! @endcond
1204
1205
  protected:
1206
    virtual OGRLayer *ICreateLayer(const char *pszName,
1207
                                   const OGRGeomFieldDefn *poGeomFieldDefn,
1208
                                   CSLConstList papszOptions);
1209
1210
    //! @cond Doxygen_Suppress
1211
    OGRErr ProcessSQLCreateIndex(const char *);
1212
    OGRErr ProcessSQLDropIndex(const char *);
1213
    OGRErr ProcessSQLDropTable(const char *);
1214
    OGRErr ProcessSQLAlterTableAddColumn(const char *);
1215
    OGRErr ProcessSQLAlterTableDropColumn(const char *);
1216
    OGRErr ProcessSQLAlterTableAlterColumn(const char *);
1217
    OGRErr ProcessSQLAlterTableRenameColumn(const char *);
1218
1219
    OGRStyleTable *m_poStyleTable = nullptr;
1220
1221
    friend class GDALProxyPoolDataset;
1222
    //! @endcond
1223
1224
  private:
1225
    CPL_DISALLOW_COPY_ASSIGN(GDALDataset)
1226
};
1227
1228
//! @cond Doxygen_Suppress
1229
struct CPL_DLL GDALDatasetUniquePtrDeleter
1230
{
1231
    void operator()(GDALDataset *poDataset) const
1232
0
    {
1233
0
        GDALClose(poDataset);
1234
0
    }
1235
};
1236
1237
//! @endcond
1238
1239
//! @cond Doxygen_Suppress
1240
struct CPL_DLL GDALDatasetUniquePtrReleaser
1241
{
1242
    void operator()(GDALDataset *poDataset) const
1243
0
    {
1244
0
        if (poDataset)
1245
0
            poDataset->Release();
1246
0
    }
1247
};
1248
1249
//! @endcond
1250
1251
/** Unique pointer type for GDALDataset.
1252
 * Appropriate for use on datasets open in non-shared mode and onto which
1253
 * reference counter has not been manually modified.
1254
 * @since GDAL 2.3
1255
 */
1256
using GDALDatasetUniquePtr =
1257
    std::unique_ptr<GDALDataset, GDALDatasetUniquePtrDeleter>;
1258
1259
/* ******************************************************************** */
1260
/*                           GDALRasterBlock                            */
1261
/* ******************************************************************** */
1262
1263
/** A single raster block in the block cache.
1264
 *
1265
 * And the global block manager that manages a least-recently-used list of
1266
 * blocks from various datasets/bands */
1267
class CPL_DLL GDALRasterBlock
1268
{
1269
    friend class GDALAbstractBandBlockCache;
1270
1271
    GDALDataType eType;
1272
1273
    bool bDirty;
1274
    volatile int nLockCount;
1275
1276
    int nXOff;
1277
    int nYOff;
1278
1279
    int nXSize;
1280
    int nYSize;
1281
1282
    void *pData;
1283
1284
    GDALRasterBand *poBand;
1285
1286
    GDALRasterBlock *poNext;
1287
    GDALRasterBlock *poPrevious;
1288
1289
    bool bMustDetach;
1290
1291
    CPL_INTERNAL void Detach_unlocked(void);
1292
    CPL_INTERNAL void Touch_unlocked(void);
1293
1294
    CPL_INTERNAL void RecycleFor(int nXOffIn, int nYOffIn);
1295
1296
  public:
1297
    GDALRasterBlock(GDALRasterBand *, int, int);
1298
    GDALRasterBlock(int nXOffIn, int nYOffIn); /* only for lookup purpose */
1299
    virtual ~GDALRasterBlock();
1300
1301
    CPLErr Internalize(void);
1302
    void Touch(void);
1303
    void MarkDirty(void);
1304
    void MarkClean(void);
1305
1306
    /** Increment the lock count */
1307
    int AddLock(void)
1308
0
    {
1309
0
        return CPLAtomicInc(&nLockCount);
1310
0
    }
1311
1312
    /** Decrement the lock count */
1313
    int DropLock(void)
1314
0
    {
1315
0
        return CPLAtomicDec(&nLockCount);
1316
0
    }
1317
1318
    void Detach();
1319
1320
    CPLErr Write();
1321
1322
    /** Return the data type
1323
     * @return data type
1324
     */
1325
    GDALDataType GetDataType() const
1326
0
    {
1327
0
        return eType;
1328
0
    }
1329
1330
    /** Return the x offset of the top-left corner of the block
1331
     * @return x offset
1332
     */
1333
    int GetXOff() const
1334
0
    {
1335
0
        return nXOff;
1336
0
    }
1337
1338
    /** Return the y offset of the top-left corner of the block
1339
     * @return y offset
1340
     */
1341
    int GetYOff() const
1342
0
    {
1343
0
        return nYOff;
1344
0
    }
1345
1346
    /** Return the width of the block
1347
     * @return width
1348
     */
1349
    int GetXSize() const
1350
0
    {
1351
0
        return nXSize;
1352
0
    }
1353
1354
    /** Return the height of the block
1355
     * @return height
1356
     */
1357
    int GetYSize() const
1358
0
    {
1359
0
        return nYSize;
1360
0
    }
1361
1362
    /** Return the dirty flag
1363
     * @return dirty flag
1364
     */
1365
    int GetDirty() const
1366
0
    {
1367
0
        return bDirty;
1368
0
    }
1369
1370
    /** Return the data buffer
1371
     * @return data buffer
1372
     */
1373
    void *GetDataRef(void)
1374
0
    {
1375
0
        return pData;
1376
0
    }
1377
1378
    /** Return the block size in bytes
1379
     * @return block size.
1380
     */
1381
    GPtrDiff_t GetBlockSize() const
1382
0
    {
1383
0
        return static_cast<GPtrDiff_t>(nXSize) * nYSize *
1384
0
               GDALGetDataTypeSizeBytes(eType);
1385
0
    }
1386
1387
    int TakeLock();
1388
    int DropLockForRemovalFromStorage();
1389
1390
    /// @brief Accessor to source GDALRasterBand object.
1391
    /// @return source raster band of the raster block.
1392
    GDALRasterBand *GetBand()
1393
0
    {
1394
0
        return poBand;
1395
0
    }
1396
1397
    static void FlushDirtyBlocks();
1398
    static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE);
1399
    static void Verify();
1400
1401
    static void EnterDisableDirtyBlockFlush();
1402
    static void LeaveDisableDirtyBlockFlush();
1403
1404
#ifdef notdef
1405
    static void CheckNonOrphanedBlocks(GDALRasterBand *poBand);
1406
    void DumpBlock();
1407
    static void DumpAll();
1408
#endif
1409
1410
    /* Should only be called by GDALDestroyDriverManager() */
1411
    //! @cond Doxygen_Suppress
1412
    CPL_INTERNAL static void DestroyRBMutex();
1413
    //! @endcond
1414
1415
  private:
1416
    CPL_DISALLOW_COPY_ASSIGN(GDALRasterBlock)
1417
};
1418
1419
/* ******************************************************************** */
1420
/*                             GDALColorTable                           */
1421
/* ******************************************************************** */
1422
1423
/** A color table / palette. */
1424
1425
class CPL_DLL GDALColorTable
1426
{
1427
    GDALPaletteInterp eInterp;
1428
1429
    std::vector<GDALColorEntry> aoEntries{};
1430
1431
  public:
1432
    explicit GDALColorTable(GDALPaletteInterp = GPI_RGB);
1433
1434
    /** Copy constructor */
1435
0
    GDALColorTable(const GDALColorTable &) = default;
1436
1437
    /** Copy assignment operator */
1438
    GDALColorTable &operator=(const GDALColorTable &) = default;
1439
1440
    /** Move constructor */
1441
    GDALColorTable(GDALColorTable &&) = default;
1442
1443
    /** Move assignment operator */
1444
    GDALColorTable &operator=(GDALColorTable &&) = default;
1445
1446
    ~GDALColorTable();
1447
1448
    GDALColorTable *Clone() const;
1449
    int IsSame(const GDALColorTable *poOtherCT) const;
1450
1451
    GDALPaletteInterp GetPaletteInterpretation() const;
1452
1453
    int GetColorEntryCount() const;
1454
    const GDALColorEntry *GetColorEntry(int i) const;
1455
    int GetColorEntryAsRGB(int i, GDALColorEntry *poEntry) const;
1456
    void SetColorEntry(int i, const GDALColorEntry *poEntry);
1457
    int CreateColorRamp(int nStartIndex, const GDALColorEntry *psStartColor,
1458
                        int nEndIndex, const GDALColorEntry *psEndColor);
1459
    bool IsIdentity() const;
1460
1461
    static std::unique_ptr<GDALColorTable>
1462
    LoadFromFile(const char *pszFilename);
1463
1464
    /** Convert a GDALColorTable* to a GDALRasterBandH.
1465
     * @since GDAL 2.3
1466
     */
1467
    static inline GDALColorTableH ToHandle(GDALColorTable *poCT)
1468
0
    {
1469
0
        return static_cast<GDALColorTableH>(poCT);
1470
0
    }
1471
1472
    /** Convert a GDALColorTableH to a GDALColorTable*.
1473
     * @since GDAL 2.3
1474
     */
1475
    static inline GDALColorTable *FromHandle(GDALColorTableH hCT)
1476
0
    {
1477
0
        return static_cast<GDALColorTable *>(hCT);
1478
0
    }
1479
};
1480
1481
/* ******************************************************************** */
1482
/*                       GDALAbstractBandBlockCache                     */
1483
/* ******************************************************************** */
1484
1485
//! @cond Doxygen_Suppress
1486
1487
//! This manages how a raster band store its cached block.
1488
// only used by GDALRasterBand implementation.
1489
1490
class GDALAbstractBandBlockCache
1491
{
1492
    // List of blocks that can be freed or recycled, and its lock
1493
    CPLLock *hSpinLock = nullptr;
1494
    GDALRasterBlock *psListBlocksToFree = nullptr;
1495
1496
    // Band keep alive counter, and its lock & condition
1497
    CPLCond *hCond = nullptr;
1498
    CPLMutex *hCondMutex = nullptr;
1499
    volatile int nKeepAliveCounter = 0;
1500
1501
    volatile int m_nDirtyBlocks = 0;
1502
1503
    CPL_DISALLOW_COPY_ASSIGN(GDALAbstractBandBlockCache)
1504
1505
  protected:
1506
    GDALRasterBand *poBand;
1507
1508
    int m_nInitialDirtyBlocksInFlushCache = 0;
1509
    int m_nLastTick = -1;
1510
    size_t m_nWriteDirtyBlocksDisabled = 0;
1511
1512
    void FreeDanglingBlocks();
1513
    void UnreferenceBlockBase();
1514
1515
    void StartDirtyBlockFlushingLog();
1516
    void UpdateDirtyBlockFlushingLog();
1517
    void EndDirtyBlockFlushingLog();
1518
1519
  public:
1520
    explicit GDALAbstractBandBlockCache(GDALRasterBand *poBand);
1521
    virtual ~GDALAbstractBandBlockCache();
1522
1523
    GDALRasterBlock *CreateBlock(int nXBlockOff, int nYBlockOff);
1524
    void AddBlockToFreeList(GDALRasterBlock *poBlock);
1525
    void IncDirtyBlocks(int nInc);
1526
    void WaitCompletionPendingTasks();
1527
1528
    void EnableDirtyBlockWriting()
1529
0
    {
1530
0
        --m_nWriteDirtyBlocksDisabled;
1531
0
    }
1532
1533
    void DisableDirtyBlockWriting()
1534
0
    {
1535
0
        ++m_nWriteDirtyBlocksDisabled;
1536
0
    }
1537
1538
    bool HasDirtyBlocks() const
1539
0
    {
1540
0
        return m_nDirtyBlocks > 0;
1541
0
    }
1542
1543
    virtual bool Init() = 0;
1544
    virtual bool IsInitOK() = 0;
1545
    virtual CPLErr FlushCache() = 0;
1546
    virtual CPLErr AdoptBlock(GDALRasterBlock *poBlock) = 0;
1547
    virtual GDALRasterBlock *TryGetLockedBlockRef(int nXBlockOff,
1548
                                                  int nYBlockYOff) = 0;
1549
    virtual CPLErr UnreferenceBlock(GDALRasterBlock *poBlock) = 0;
1550
    virtual CPLErr FlushBlock(int nXBlockOff, int nYBlockOff,
1551
                              int bWriteDirtyBlock) = 0;
1552
};
1553
1554
GDALAbstractBandBlockCache *
1555
GDALArrayBandBlockCacheCreate(GDALRasterBand *poBand);
1556
GDALAbstractBandBlockCache *
1557
GDALHashSetBandBlockCacheCreate(GDALRasterBand *poBand);
1558
1559
//! @endcond
1560
1561
/* ******************************************************************** */
1562
/*                            GDALRasterBand                            */
1563
/* ******************************************************************** */
1564
1565
class GDALMDArray;
1566
class GDALDoublePointsCache;
1567
1568
/** Range of values found in a mask band */
1569
typedef enum
1570
{
1571
    GMVR_UNKNOWN, /*! Unknown (can also be used for any values between 0 and 255
1572
                     for a Byte band) */
1573
    GMVR_0_AND_1_ONLY,   /*! Only 0 and 1 */
1574
    GMVR_0_AND_255_ONLY, /*! Only 0 and 255 */
1575
} GDALMaskValueRange;
1576
1577
/** Suggested/most efficient access pattern to blocks. */
1578
typedef int GDALSuggestedBlockAccessPattern;
1579
1580
/** Unknown, or no particular read order is suggested. */
1581
constexpr GDALSuggestedBlockAccessPattern GSBAP_UNKNOWN = 0;
1582
1583
/** Random access to blocks is efficient. */
1584
constexpr GDALSuggestedBlockAccessPattern GSBAP_RANDOM = 1;
1585
1586
/** Reading by strips from top to bottom is the most efficient. */
1587
constexpr GDALSuggestedBlockAccessPattern GSBAP_TOP_TO_BOTTOM = 2;
1588
1589
/** Reading by strips from bottom to top is the most efficient. */
1590
constexpr GDALSuggestedBlockAccessPattern GSBAP_BOTTOM_TO_TOP = 3;
1591
1592
/** Reading the largest chunk from the raster is the most efficient (can be
1593
 * combined with above values). */
1594
constexpr GDALSuggestedBlockAccessPattern GSBAP_LARGEST_CHUNK_POSSIBLE = 0x100;
1595
1596
class GDALComputedRasterBand;
1597
1598
/** A single raster band (or channel). */
1599
1600
class CPL_DLL GDALRasterBand : public GDALMajorObject
1601
{
1602
  private:
1603
    friend class GDALArrayBandBlockCache;
1604
    friend class GDALHashSetBandBlockCache;
1605
    friend class GDALRasterBlock;
1606
    friend class GDALDataset;
1607
1608
    CPLErr eFlushBlockErr = CE_None;
1609
    GDALAbstractBandBlockCache *poBandBlockCache = nullptr;
1610
1611
    CPL_INTERNAL void SetFlushBlockErr(CPLErr eErr);
1612
    CPL_INTERNAL CPLErr UnreferenceBlock(GDALRasterBlock *poBlock);
1613
    CPL_INTERNAL void IncDirtyBlocks(int nInc);
1614
1615
    CPL_INTERNAL CPLErr RasterIOInternal(
1616
        GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize,
1617
        void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType,
1618
        GSpacing nPixelSpace, GSpacing nLineSpace,
1619
        GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
1620
1621
  protected:
1622
    //! @cond Doxygen_Suppress
1623
    GDALDataset *poDS = nullptr;
1624
    int nBand = 0; /* 1 based */
1625
1626
    int nRasterXSize = 0;
1627
    int nRasterYSize = 0;
1628
1629
    GDALDataType eDataType = GDT_Byte;
1630
    GDALAccess eAccess = GA_ReadOnly;
1631
1632
    /* stuff related to blocking, and raster cache */
1633
    int nBlockXSize = -1;
1634
    int nBlockYSize = -1;
1635
    int nBlocksPerRow = 0;
1636
    int nBlocksPerColumn = 0;
1637
1638
    int nBlockReads = 0;
1639
    int bForceCachedIO = 0;
1640
1641
    friend class GDALComputedRasterBand;
1642
    friend class GDALComputedDataset;
1643
1644
    class GDALRasterBandOwnedOrNot
1645
    {
1646
      public:
1647
0
        GDALRasterBandOwnedOrNot() = default;
1648
1649
        GDALRasterBandOwnedOrNot(GDALRasterBandOwnedOrNot &&) = default;
1650
1651
        void reset()
1652
0
        {
1653
0
            m_poBandOwned.reset();
1654
0
            m_poBandRef = nullptr;
1655
0
        }
1656
1657
        void resetNotOwned(GDALRasterBand *poBand)
1658
0
        {
1659
0
            m_poBandOwned.reset();
1660
0
            m_poBandRef = poBand;
1661
0
        }
1662
1663
        void reset(std::unique_ptr<GDALRasterBand> poBand)
1664
0
        {
1665
0
            m_poBandOwned = std::move(poBand);
1666
0
            m_poBandRef = nullptr;
1667
0
        }
1668
1669
        const GDALRasterBand *get() const
1670
0
        {
1671
0
            return static_cast<const GDALRasterBand *>(*this);
1672
0
        }
1673
1674
        GDALRasterBand *get()
1675
0
        {
1676
0
            return static_cast<GDALRasterBand *>(*this);
1677
0
        }
1678
1679
        bool IsOwned() const
1680
0
        {
1681
0
            return m_poBandOwned != nullptr;
1682
0
        }
1683
1684
        operator const GDALRasterBand *() const
1685
0
        {
1686
0
            return m_poBandOwned ? m_poBandOwned.get() : m_poBandRef;
1687
0
        }
1688
1689
        operator GDALRasterBand *()
1690
0
        {
1691
0
            return m_poBandOwned ? m_poBandOwned.get() : m_poBandRef;
1692
0
        }
1693
1694
      private:
1695
        CPL_DISALLOW_COPY_ASSIGN(GDALRasterBandOwnedOrNot)
1696
        std::unique_ptr<GDALRasterBand> m_poBandOwned{};
1697
        GDALRasterBand *m_poBandRef = nullptr;
1698
    };
1699
1700
    GDALRasterBandOwnedOrNot poMask{};
1701
    bool m_bEnablePixelTypeSignedByteWarning =
1702
        true;  // Remove me in GDAL 4.0. See GetMetadataItem() implementation
1703
    int nMaskFlags = 0;
1704
1705
    void InvalidateMaskBand();
1706
1707
    friend class GDALProxyRasterBand;
1708
    friend class GDALDefaultOverviews;
1709
1710
    CPLErr
1711
    RasterIOResampled(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1712
                      int nYSize, void *pData, int nBufXSize, int nBufYSize,
1713
                      GDALDataType eBufType, GSpacing nPixelSpace,
1714
                      GSpacing nLineSpace,
1715
                      GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
1716
1717
    int EnterReadWrite(GDALRWFlag eRWFlag);
1718
    void LeaveReadWrite();
1719
    void InitRWLock();
1720
    void SetValidPercent(GUIntBig nSampleCount, GUIntBig nValidCount);
1721
1722
    mutable GDALDoublePointsCache *m_poPointsCache = nullptr;
1723
1724
    //! @endcond
1725
1726
  protected:
1727
    virtual CPLErr IReadBlock(int nBlockXOff, int nBlockYOff, void *pData) = 0;
1728
    virtual CPLErr IWriteBlock(int nBlockXOff, int nBlockYOff, void *pData);
1729
1730
    virtual CPLErr
1731
    IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize,
1732
              void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType,
1733
              GSpacing nPixelSpace, GSpacing nLineSpace,
1734
              GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
1735
1736
    virtual int IGetDataCoverageStatus(int nXOff, int nYOff, int nXSize,
1737
                                       int nYSize, int nMaskFlagStop,
1738
                                       double *pdfDataPct);
1739
1740
    virtual bool
1741
    EmitErrorMessageIfWriteNotSupported(const char *pszCaller) const;
1742
1743
    //! @cond Doxygen_Suppress
1744
    CPLErr
1745
    OverviewRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1746
                     int nYSize, void *pData, int nBufXSize, int nBufYSize,
1747
                     GDALDataType eBufType, GSpacing nPixelSpace,
1748
                     GSpacing nLineSpace,
1749
                     GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
1750
1751
    CPLErr TryOverviewRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
1752
                               int nXSize, int nYSize, void *pData,
1753
                               int nBufXSize, int nBufYSize,
1754
                               GDALDataType eBufType, GSpacing nPixelSpace,
1755
                               GSpacing nLineSpace,
1756
                               GDALRasterIOExtraArg *psExtraArg, int *pbTried);
1757
1758
    CPLErr SplitRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1759
                         int nYSize, void *pData, int nBufXSize, int nBufYSize,
1760
                         GDALDataType eBufType, GSpacing nPixelSpace,
1761
                         GSpacing nLineSpace, GDALRasterIOExtraArg *psExtraArg)
1762
        CPL_WARN_UNUSED_RESULT;
1763
1764
    int InitBlockInfo();
1765
1766
    void AddBlockToFreeList(GDALRasterBlock *);
1767
1768
    bool HasBlockCache() const
1769
0
    {
1770
0
        return poBandBlockCache != nullptr;
1771
0
    }
1772
1773
    bool HasDirtyBlocks() const
1774
0
    {
1775
0
        return poBandBlockCache && poBandBlockCache->HasDirtyBlocks();
1776
0
    }
1777
1778
    //! @endcond
1779
1780
  public:
1781
    GDALRasterBand();
1782
    explicit GDALRasterBand(int bForceCachedIO);
1783
1784
    //! @cond Doxygen_Suppress
1785
    GDALRasterBand(GDALRasterBand &&) = default;
1786
    //! @endcond
1787
1788
    ~GDALRasterBand() override;
1789
1790
    int GetXSize() const;
1791
    int GetYSize() const;
1792
    int GetBand() const;
1793
    GDALDataset *GetDataset() const;
1794
1795
    GDALDataType GetRasterDataType(void) const;
1796
    void GetBlockSize(int *pnXSize, int *pnYSize) const;
1797
    CPLErr GetActualBlockSize(int nXBlockOff, int nYBlockOff, int *pnXValid,
1798
                              int *pnYValid) const;
1799
1800
    virtual GDALSuggestedBlockAccessPattern
1801
    GetSuggestedBlockAccessPattern() const;
1802
1803
    GDALAccess GetAccess();
1804
1805
#ifndef DOXYGEN_SKIP
1806
    CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1807
                    int nYSize, void *pData, int nBufXSize, int nBufYSize,
1808
                    GDALDataType eBufType, GSpacing nPixelSpace,
1809
                    GSpacing nLineSpace,
1810
                    GDALRasterIOExtraArg *psExtraArg
1811
                        OPTIONAL_OUTSIDE_GDAL(nullptr)) CPL_WARN_UNUSED_RESULT;
1812
#else
1813
    CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1814
                    int nYSize, void *pData, int nBufXSize, int nBufYSize,
1815
                    GDALDataType eBufType, GSpacing nPixelSpace,
1816
                    GSpacing nLineSpace,
1817
                    GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
1818
#endif
1819
1820
    template <class T>
1821
    CPLErr ReadRaster(T *pData, size_t nArrayEltCount = 0, double dfXOff = 0,
1822
                      double dfYOff = 0, double dfXSize = 0, double dfYSize = 0,
1823
                      size_t nBufXSize = 0, size_t nBufYSize = 0,
1824
                      GDALRIOResampleAlg eResampleAlg = GRIORA_NearestNeighbour,
1825
                      GDALProgressFunc pfnProgress = nullptr,
1826
                      void *pProgressData = nullptr) const;
1827
1828
    template <class T>
1829
    CPLErr ReadRaster(std::vector<T> &vData, double dfXOff = 0,
1830
                      double dfYOff = 0, double dfXSize = 0, double dfYSize = 0,
1831
                      size_t nBufXSize = 0, size_t nBufYSize = 0,
1832
                      GDALRIOResampleAlg eResampleAlg = GRIORA_NearestNeighbour,
1833
                      GDALProgressFunc pfnProgress = nullptr,
1834
                      void *pProgressData = nullptr) const;
1835
1836
#if __cplusplus >= 202002L
1837
    //! @cond Doxygen_Suppress
1838
    template <class T>
1839
    inline CPLErr
1840
    ReadRaster(std::span<T> pData, double dfXOff = 0, double dfYOff = 0,
1841
               double dfXSize = 0, double dfYSize = 0, size_t nBufXSize = 0,
1842
               size_t nBufYSize = 0,
1843
               GDALRIOResampleAlg eResampleAlg = GRIORA_NearestNeighbour,
1844
               GDALProgressFunc pfnProgress = nullptr,
1845
               void *pProgressData = nullptr) const
1846
    {
1847
        return ReadRaster(pData.data(), pData.size(), dfXOff, dfYOff, dfXSize,
1848
                          dfYSize, nBufXSize, nBufYSize, eResampleAlg,
1849
                          pfnProgress, pProgressData);
1850
    }
1851
1852
    //! @endcond
1853
#endif
1854
1855
    GDALComputedRasterBand
1856
    operator+(const GDALRasterBand &other) const CPL_WARN_UNUSED_RESULT;
1857
    GDALComputedRasterBand operator+(double cst) const CPL_WARN_UNUSED_RESULT;
1858
    friend GDALComputedRasterBand CPL_DLL
1859
    operator+(double cst, const GDALRasterBand &other) CPL_WARN_UNUSED_RESULT;
1860
1861
    GDALComputedRasterBand
1862
    operator-(const GDALRasterBand &other) const CPL_WARN_UNUSED_RESULT;
1863
    GDALComputedRasterBand operator-(double cst) const CPL_WARN_UNUSED_RESULT;
1864
    friend GDALComputedRasterBand CPL_DLL
1865
    operator-(double cst, const GDALRasterBand &other) CPL_WARN_UNUSED_RESULT;
1866
1867
    GDALComputedRasterBand
1868
    operator*(const GDALRasterBand &other) const CPL_WARN_UNUSED_RESULT;
1869
    GDALComputedRasterBand operator*(double cst) const CPL_WARN_UNUSED_RESULT;
1870
    friend GDALComputedRasterBand CPL_DLL
1871
    operator*(double cst, const GDALRasterBand &other) CPL_WARN_UNUSED_RESULT;
1872
1873
    GDALComputedRasterBand
1874
    operator/(const GDALRasterBand &other) const CPL_WARN_UNUSED_RESULT;
1875
    GDALComputedRasterBand operator/(double cst) const CPL_WARN_UNUSED_RESULT;
1876
    friend GDALComputedRasterBand CPL_DLL
1877
    operator/(double cst, const GDALRasterBand &other) CPL_WARN_UNUSED_RESULT;
1878
1879
    GDALComputedRasterBand
1880
    operator>(const GDALRasterBand &other) const CPL_WARN_UNUSED_RESULT;
1881
    GDALComputedRasterBand operator>(double cst) const CPL_WARN_UNUSED_RESULT;
1882
    friend GDALComputedRasterBand CPL_DLL
1883
    operator>(double cst, const GDALRasterBand &other) CPL_WARN_UNUSED_RESULT;
1884
1885
    GDALComputedRasterBand
1886
    operator>=(const GDALRasterBand &other) const CPL_WARN_UNUSED_RESULT;
1887
    GDALComputedRasterBand operator>=(double cst) const CPL_WARN_UNUSED_RESULT;
1888
    friend GDALComputedRasterBand CPL_DLL
1889
    operator>=(double cst, const GDALRasterBand &other) CPL_WARN_UNUSED_RESULT;
1890
1891
    GDALComputedRasterBand
1892
    operator<(const GDALRasterBand &other) const CPL_WARN_UNUSED_RESULT;
1893
    GDALComputedRasterBand operator<(double cst) const CPL_WARN_UNUSED_RESULT;
1894
    friend GDALComputedRasterBand CPL_DLL
1895
    operator<(double cst, const GDALRasterBand &other) CPL_WARN_UNUSED_RESULT;
1896
1897
    GDALComputedRasterBand
1898
    operator<=(const GDALRasterBand &other) const CPL_WARN_UNUSED_RESULT;
1899
    GDALComputedRasterBand operator<=(double cst) const CPL_WARN_UNUSED_RESULT;
1900
    friend GDALComputedRasterBand CPL_DLL
1901
    operator<=(double cst, const GDALRasterBand &other) CPL_WARN_UNUSED_RESULT;
1902
1903
    GDALComputedRasterBand
1904
    operator==(const GDALRasterBand &other) const CPL_WARN_UNUSED_RESULT;
1905
    GDALComputedRasterBand operator==(double cst) const CPL_WARN_UNUSED_RESULT;
1906
    friend GDALComputedRasterBand CPL_DLL
1907
    operator==(double cst, const GDALRasterBand &other) CPL_WARN_UNUSED_RESULT;
1908
1909
    GDALComputedRasterBand
1910
    operator!=(const GDALRasterBand &other) const CPL_WARN_UNUSED_RESULT;
1911
    GDALComputedRasterBand operator!=(double cst) const CPL_WARN_UNUSED_RESULT;
1912
    friend GDALComputedRasterBand CPL_DLL
1913
    operator!=(double cst, const GDALRasterBand &other) CPL_WARN_UNUSED_RESULT;
1914
1915
#if defined(__GNUC__)
1916
#pragma GCC diagnostic push
1917
#pragma GCC diagnostic ignored "-Weffc++"
1918
#endif
1919
1920
    GDALComputedRasterBand
1921
    operator&&(const GDALRasterBand &other) const CPL_WARN_UNUSED_RESULT;
1922
    GDALComputedRasterBand operator&&(bool cst) const CPL_WARN_UNUSED_RESULT;
1923
    friend GDALComputedRasterBand CPL_DLL
1924
    operator&&(bool cst, const GDALRasterBand &other) CPL_WARN_UNUSED_RESULT;
1925
1926
    GDALComputedRasterBand
1927
    operator||(const GDALRasterBand &other) const CPL_WARN_UNUSED_RESULT;
1928
    GDALComputedRasterBand operator||(bool cst) const CPL_WARN_UNUSED_RESULT;
1929
    friend GDALComputedRasterBand CPL_DLL
1930
    operator||(bool cst, const GDALRasterBand &other) CPL_WARN_UNUSED_RESULT;
1931
1932
#if defined(__GNUC__)
1933
#pragma GCC diagnostic pop
1934
#endif
1935
1936
    GDALComputedRasterBand operator!() const CPL_WARN_UNUSED_RESULT;
1937
1938
    GDALComputedRasterBand AsType(GDALDataType) const CPL_WARN_UNUSED_RESULT;
1939
1940
    CPLErr ReadBlock(int nXBlockOff, int nYBlockOff,
1941
                     void *pImage) CPL_WARN_UNUSED_RESULT;
1942
1943
    CPLErr WriteBlock(int nXBlockOff, int nYBlockOff,
1944
                      void *pImage) CPL_WARN_UNUSED_RESULT;
1945
1946
    // This method should only be overloaded by GDALProxyRasterBand
1947
    virtual GDALRasterBlock *
1948
    GetLockedBlockRef(int nXBlockOff, int nYBlockOff,
1949
                      int bJustInitialize = FALSE) CPL_WARN_UNUSED_RESULT;
1950
1951
    // This method should only be overloaded by GDALProxyRasterBand
1952
    virtual GDALRasterBlock *
1953
    TryGetLockedBlockRef(int nXBlockOff,
1954
                         int nYBlockYOff) CPL_WARN_UNUSED_RESULT;
1955
1956
    // This method should only be overloaded by GDALProxyRasterBand
1957
    virtual CPLErr FlushBlock(int nXBlockOff, int nYBlockOff,
1958
                              int bWriteDirtyBlock = TRUE);
1959
1960
    unsigned char *
1961
    GetIndexColorTranslationTo(/* const */ GDALRasterBand *poReferenceBand,
1962
                               unsigned char *pTranslationTable = nullptr,
1963
                               int *pApproximateMatching = nullptr);
1964
1965
    // New OpengIS CV_SampleDimension stuff.
1966
1967
    virtual CPLErr FlushCache(bool bAtClosing = false);
1968
    virtual CPLErr DropCache();
1969
    virtual char **GetCategoryNames();
1970
    virtual double GetNoDataValue(int *pbSuccess = nullptr);
1971
    virtual int64_t GetNoDataValueAsInt64(int *pbSuccess = nullptr);
1972
    virtual uint64_t GetNoDataValueAsUInt64(int *pbSuccess = nullptr);
1973
    virtual double GetMinimum(int *pbSuccess = nullptr);
1974
    virtual double GetMaximum(int *pbSuccess = nullptr);
1975
    virtual double GetOffset(int *pbSuccess = nullptr);
1976
    virtual double GetScale(int *pbSuccess = nullptr);
1977
    virtual const char *GetUnitType();
1978
    virtual GDALColorInterp GetColorInterpretation();
1979
    virtual GDALColorTable *GetColorTable();
1980
    virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
1981
1982
    virtual CPLErr SetCategoryNames(char **papszNames);
1983
    virtual CPLErr SetNoDataValue(double dfNoData);
1984
    virtual CPLErr SetNoDataValueAsInt64(int64_t nNoData);
1985
    virtual CPLErr SetNoDataValueAsUInt64(uint64_t nNoData);
1986
    CPLErr SetNoDataValueAsString(const char *pszNoData,
1987
                                  bool *pbCannotBeExactlyRepresented = nullptr);
1988
    virtual CPLErr DeleteNoDataValue();
1989
    virtual CPLErr SetColorTable(GDALColorTable *poCT);
1990
    virtual CPLErr SetColorInterpretation(GDALColorInterp eColorInterp);
1991
    virtual CPLErr SetOffset(double dfNewOffset);
1992
    virtual CPLErr SetScale(double dfNewScale);
1993
    virtual CPLErr SetUnitType(const char *pszNewValue);
1994
1995
    virtual CPLErr GetStatistics(int bApproxOK, int bForce, double *pdfMin,
1996
                                 double *pdfMax, double *pdfMean,
1997
                                 double *padfStdDev);
1998
    virtual CPLErr ComputeStatistics(int bApproxOK, double *pdfMin,
1999
                                     double *pdfMax, double *pdfMean,
2000
                                     double *pdfStdDev, GDALProgressFunc,
2001
                                     void *pProgressData);
2002
    virtual CPLErr SetStatistics(double dfMin, double dfMax, double dfMean,
2003
                                 double dfStdDev);
2004
    virtual CPLErr ComputeRasterMinMax(int bApproxOK, double *adfMinMax);
2005
    virtual CPLErr ComputeRasterMinMaxLocation(double *pdfMin, double *pdfMax,
2006
                                               int *pnMinX, int *pnMinY,
2007
                                               int *pnMaxX, int *pnMaxY);
2008
2009
// Only defined when Doxygen enabled
2010
#ifdef DOXYGEN_SKIP
2011
    CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override;
2012
    CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
2013
                           const char *pszDomain) override;
2014
#endif
2015
    virtual const char *GetMetadataItem(const char *pszName,
2016
                                        const char *pszDomain = "") override;
2017
2018
    virtual int HasArbitraryOverviews();
2019
    virtual int GetOverviewCount();
2020
    virtual GDALRasterBand *GetOverview(int i);
2021
    virtual GDALRasterBand *GetRasterSampleOverview(GUIntBig);
2022
    virtual CPLErr BuildOverviews(const char *pszResampling, int nOverviews,
2023
                                  const int *panOverviewList,
2024
                                  GDALProgressFunc pfnProgress,
2025
                                  void *pProgressData,
2026
                                  CSLConstList papszOptions);
2027
2028
    virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize,
2029
                              int nBufXSize, int nBufYSize,
2030
                              GDALDataType eBufType, char **papszOptions);
2031
2032
    virtual CPLErr GetHistogram(double dfMin, double dfMax, int nBuckets,
2033
                                GUIntBig *panHistogram, int bIncludeOutOfRange,
2034
                                int bApproxOK, GDALProgressFunc,
2035
                                void *pProgressData);
2036
2037
    virtual CPLErr GetDefaultHistogram(double *pdfMin, double *pdfMax,
2038
                                       int *pnBuckets, GUIntBig **ppanHistogram,
2039
                                       int bForce, GDALProgressFunc,
2040
                                       void *pProgressData);
2041
    virtual CPLErr SetDefaultHistogram(double dfMin, double dfMax, int nBuckets,
2042
                                       GUIntBig *panHistogram);
2043
2044
    virtual GDALRasterAttributeTable *GetDefaultRAT();
2045
    virtual CPLErr SetDefaultRAT(const GDALRasterAttributeTable *poRAT);
2046
2047
    virtual GDALRasterBand *GetMaskBand();
2048
    virtual int GetMaskFlags();
2049
    virtual CPLErr CreateMaskBand(int nFlagsIn);
2050
    virtual bool IsMaskBand() const;
2051
    virtual GDALMaskValueRange GetMaskValueRange() const;
2052
2053
    virtual CPLVirtualMem *
2054
    GetVirtualMemAuto(GDALRWFlag eRWFlag, int *pnPixelSpace,
2055
                      GIntBig *pnLineSpace,
2056
                      char **papszOptions) CPL_WARN_UNUSED_RESULT;
2057
2058
    int GetDataCoverageStatus(int nXOff, int nYOff, int nXSize, int nYSize,
2059
                              int nMaskFlagStop = 0,
2060
                              double *pdfDataPct = nullptr);
2061
2062
    std::shared_ptr<GDALMDArray> AsMDArray() const;
2063
2064
    CPLErr InterpolateAtGeolocation(
2065
        double dfGeolocX, double dfGeolocY, const OGRSpatialReference *poSRS,
2066
        GDALRIOResampleAlg eInterpolation, double *pdfRealValue,
2067
        double *pdfImagValue = nullptr,
2068
        CSLConstList papszTransformerOptions = nullptr) const;
2069
2070
    virtual CPLErr InterpolateAtPoint(double dfPixel, double dfLine,
2071
                                      GDALRIOResampleAlg eInterpolation,
2072
                                      double *pdfRealValue,
2073
                                      double *pdfImagValue = nullptr) const;
2074
2075
#ifndef DOXYGEN_XML
2076
    void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,
2077
                     ...) const CPL_PRINT_FUNC_FORMAT(4, 5);
2078
#endif
2079
2080
    //! @cond Doxygen_Suppress
2081
    static void ThrowIfNotSameDimensions(const GDALRasterBand &first,
2082
                                         const GDALRasterBand &second);
2083
2084
    //! @endcond
2085
2086
    /** Convert a GDALRasterBand* to a GDALRasterBandH.
2087
     * @since GDAL 2.3
2088
     */
2089
    static inline GDALRasterBandH ToHandle(GDALRasterBand *poBand)
2090
0
    {
2091
0
        return static_cast<GDALRasterBandH>(poBand);
2092
0
    }
2093
2094
    /** Convert a GDALRasterBandH to a GDALRasterBand*.
2095
     * @since GDAL 2.3
2096
     */
2097
    static inline GDALRasterBand *FromHandle(GDALRasterBandH hBand)
2098
0
    {
2099
0
        return static_cast<GDALRasterBand *>(hBand);
2100
0
    }
2101
2102
    //! @cond Doxygen_Suppress
2103
    // Remove me in GDAL 4.0. See GetMetadataItem() implementation
2104
    // Internal use in GDAL only !
2105
    virtual void EnablePixelTypeSignedByteWarning(bool b)
2106
#ifndef GDAL_COMPILATION
2107
        CPL_WARN_DEPRECATED("Do not use that method outside of GDAL!")
2108
#endif
2109
            ;
2110
2111
    //! @endcond
2112
2113
  private:
2114
    CPL_DISALLOW_COPY_ASSIGN(GDALRasterBand)
2115
};
2116
2117
//! @cond Doxygen_Suppress
2118
#define GDAL_EXTERN_TEMPLATE_READ_RASTER(T)                                    \
2119
    extern template CPLErr GDALRasterBand::ReadRaster<T>(                      \
2120
        T * pData, size_t nArrayEltCount, double dfXOff, double dfYOff,        \
2121
        double dfXSize, double dfYSize, size_t nBufXSize, size_t nBufYSize,    \
2122
        GDALRIOResampleAlg eResampleAlg, GDALProgressFunc pfnProgress,         \
2123
        void *pProgressData) const;
2124
2125
GDAL_EXTERN_TEMPLATE_READ_RASTER(uint8_t)
2126
GDAL_EXTERN_TEMPLATE_READ_RASTER(int8_t)
2127
GDAL_EXTERN_TEMPLATE_READ_RASTER(uint16_t)
2128
GDAL_EXTERN_TEMPLATE_READ_RASTER(int16_t)
2129
GDAL_EXTERN_TEMPLATE_READ_RASTER(uint32_t)
2130
GDAL_EXTERN_TEMPLATE_READ_RASTER(int32_t)
2131
GDAL_EXTERN_TEMPLATE_READ_RASTER(uint64_t)
2132
GDAL_EXTERN_TEMPLATE_READ_RASTER(int64_t)
2133
#ifdef CPL_FLOAT_H_INCLUDED
2134
GDAL_EXTERN_TEMPLATE_READ_RASTER(GFloat16)
2135
#endif
2136
GDAL_EXTERN_TEMPLATE_READ_RASTER(float)
2137
GDAL_EXTERN_TEMPLATE_READ_RASTER(double)
2138
// Not allowed by C++ standard
2139
// GDAL_EXTERN_TEMPLATE_READ_RASTER(std::complex<int16_t>)
2140
// GDAL_EXTERN_TEMPLATE_READ_RASTER(std::complex<int32_t>)
2141
GDAL_EXTERN_TEMPLATE_READ_RASTER(std::complex<float>)
2142
GDAL_EXTERN_TEMPLATE_READ_RASTER(std::complex<double>)
2143
2144
#define GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(T)                             \
2145
    extern template CPLErr GDALRasterBand::ReadRaster<T>(                      \
2146
        std::vector<T> & vData, double dfXOff, double dfYOff, double dfXSize,  \
2147
        double dfYSize, size_t nBufXSize, size_t nBufYSize,                    \
2148
        GDALRIOResampleAlg eResampleAlg, GDALProgressFunc pfnProgress,         \
2149
        void *pProgressData) const;
2150
2151
GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(uint8_t)
2152
GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(int8_t)
2153
GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(uint16_t)
2154
GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(int16_t)
2155
GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(uint32_t)
2156
GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(int32_t)
2157
GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(uint64_t)
2158
GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(int64_t)
2159
#ifdef CPL_FLOAT_H_INCLUDED
2160
GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(GFloat16)
2161
#endif
2162
GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(float)
2163
GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(double)
2164
// Not allowed by C++ standard
2165
// GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(std::complex<int16_t>)
2166
// GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(std::complex<int32_t>)
2167
GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(std::complex<float>)
2168
GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(std::complex<double>)
2169
2170
//! @endcond
2171
2172
/* ******************************************************************** */
2173
/*                       GDALComputedRasterBand                         */
2174
/* ******************************************************************** */
2175
2176
/** Class represented the result of an operation on one or two input bands.
2177
 *
2178
 * Such class is instantiated only by operators on GDALRasterBand.
2179
 * The resulting band is lazy evaluated.
2180
 *
2181
 * @since 3.12
2182
 */
2183
class CPL_DLL GDALComputedRasterBand final : public GDALRasterBand
2184
{
2185
  public:
2186
    /** Destructor */
2187
    ~GDALComputedRasterBand() override;
2188
2189
    //! @cond Doxygen_Suppress
2190
    enum class Operation
2191
    {
2192
        OP_ADD,
2193
        OP_SUBTRACT,
2194
        OP_MULTIPLY,
2195
        OP_DIVIDE,
2196
        OP_MIN,
2197
        OP_MAX,
2198
        OP_MEAN,
2199
        OP_GT,
2200
        OP_GE,
2201
        OP_LT,
2202
        OP_LE,
2203
        OP_EQ,
2204
        OP_NE,
2205
        OP_LOGICAL_AND,
2206
        OP_LOGICAL_OR,
2207
        OP_CAST,
2208
        OP_TERNARY,
2209
    };
2210
2211
    GDALComputedRasterBand(
2212
        Operation op, const std::vector<const GDALRasterBand *> &bands,
2213
        double constant = std::numeric_limits<double>::quiet_NaN());
2214
    GDALComputedRasterBand(Operation op, double constant,
2215
                           const GDALRasterBand &band);
2216
    GDALComputedRasterBand(Operation op, const GDALRasterBand &band,
2217
                           double constant);
2218
    GDALComputedRasterBand(Operation op, const GDALRasterBand &band,
2219
                           GDALDataType dt);
2220
2221
    // Semi-public for gdal::min(), gdal::max()
2222
    GDALComputedRasterBand(Operation op, const GDALRasterBand &firstBand,
2223
                           const GDALRasterBand &secondBand);
2224
2225
    GDALComputedRasterBand(GDALComputedRasterBand &&) = default;
2226
2227
    //! @endcond
2228
2229
    double GetNoDataValue(int *pbSuccess = nullptr) override;
2230
2231
    /** Convert a GDALComputedRasterBand* to a GDALComputedRasterBandH.
2232
     */
2233
    static inline GDALComputedRasterBandH
2234
    ToHandle(GDALComputedRasterBand *poBand)
2235
0
    {
2236
0
        return static_cast<GDALComputedRasterBandH>(poBand);
2237
0
    }
2238
2239
    /** Convert a GDALComputedRasterBandH to a GDALComputedRasterBand*.
2240
     */
2241
    static inline GDALComputedRasterBand *
2242
    FromHandle(GDALComputedRasterBandH hBand)
2243
0
    {
2244
0
        return static_cast<GDALComputedRasterBand *>(hBand);
2245
0
    }
2246
2247
  protected:
2248
    friend class GDALRasterBand;
2249
2250
    CPLErr IReadBlock(int, int, void *) override;
2251
2252
    CPLErr IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
2253
                     int nYSize, void *pData, int nBufXSize, int nBufYSize,
2254
                     GDALDataType eBufType, GSpacing nPixelSpace,
2255
                     GSpacing nLineSpace,
2256
                     GDALRasterIOExtraArg *psExtraArg) override;
2257
2258
  private:
2259
    friend class GDALComputedDataset;
2260
    std::unique_ptr<GDALDataset, GDALDatasetUniquePtrReleaser> m_poOwningDS{};
2261
    bool m_bHasNoData{false};
2262
    double m_dfNoDataValue{0};
2263
2264
    GDALComputedRasterBand(const GDALComputedRasterBand &, bool);
2265
    GDALComputedRasterBand(const GDALComputedRasterBand &) = delete;
2266
    GDALComputedRasterBand &operator=(const GDALComputedRasterBand &) = delete;
2267
    GDALComputedRasterBand &operator=(GDALComputedRasterBand &&) = delete;
2268
};
2269
2270
namespace gdal
2271
{
2272
2273
GDALComputedRasterBand CPL_DLL IfThenElse(const GDALRasterBand &condBand,
2274
                                          const GDALRasterBand &thenBand,
2275
                                          const GDALRasterBand &elseBand);
2276
2277
//! @cond Doxygen_Suppress
2278
2279
GDALComputedRasterBand CPL_DLL IfThenElse(const GDALRasterBand &condBand,
2280
                                          double thenValue,
2281
                                          const GDALRasterBand &elseBand);
2282
2283
GDALComputedRasterBand CPL_DLL IfThenElse(const GDALRasterBand &condBand,
2284
                                          const GDALRasterBand &thenBand,
2285
                                          double elseValue);
2286
2287
GDALComputedRasterBand CPL_DLL IfThenElse(const GDALRasterBand &condBand,
2288
                                          double thenValue, double elseValue);
2289
2290
//! @endcond
2291
2292
using std::max;
2293
using std::min;
2294
2295
GDALComputedRasterBand CPL_DLL min(const GDALRasterBand &first,
2296
                                   const GDALRasterBand &second);
2297
2298
//! @cond Doxygen_Suppress
2299
2300
namespace detail
2301
{
2302
2303
template <typename U, typename Enable> struct minDealFirstArg;
2304
2305
template <typename U>
2306
struct minDealFirstArg<
2307
    U, typename std::enable_if<std::is_arithmetic<U>::value>::type>
2308
{
2309
    inline static void process(std::vector<const GDALRasterBand *> &,
2310
                               double &constant, const U &first)
2311
    {
2312
        if (std::isnan(constant) || static_cast<double>(first) < constant)
2313
            constant = static_cast<double>(first);
2314
    }
2315
};
2316
2317
template <typename U>
2318
struct minDealFirstArg<
2319
    U, typename std::enable_if<!std::is_arithmetic<U>::value>::type>
2320
{
2321
    inline static void process(std::vector<const GDALRasterBand *> &bands,
2322
                               double &, const U &first)
2323
    {
2324
        if (!bands.empty())
2325
            GDALRasterBand::ThrowIfNotSameDimensions(first, *(bands.front()));
2326
        bands.push_back(&first);
2327
    }
2328
};
2329
2330
inline static GDALComputedRasterBand
2331
minInternal(std::vector<const GDALRasterBand *> &bands, double constant)
2332
0
{
2333
0
    return GDALComputedRasterBand(GDALComputedRasterBand::Operation::OP_MIN,
2334
0
                                  bands, constant);
2335
0
}
Unexecuted instantiation: ogrutils.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ograpispy.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalallregister.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrregisterall.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrgeojsondriver.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrgeojsonseqdriver.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogresrijsondriver.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrtopojsondriver.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrshapedriver.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrsfdriverregistrar.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrlayer.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrlayerarrow.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrdatasource.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrsfdriver.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ograrrowarrayhelper.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_misc.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalopeninfo.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdaldriver.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdaldrivermanager.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdaldataset.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalrasterband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalrasterblock.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalcolortable.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalmajorobject.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdaldefaultoverviews.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalmultidomainmetadata.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalpamproxydb.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalallvalidmaskband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalnodatamaskband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalnodatavaluesmaskband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalproxypool.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdaldefaultasync.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalvirtualmem.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdaloverviewdataset.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalrescaledalphaband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalabstractbandblockcache.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalarraybandblockcache.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalhashsetbandblockcache.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalsubdatasetinfo.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalthreadsafedataset.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: overview.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: rasterio.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalmultidim.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalmultidim_gridded.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalmultidim_gltorthorectification.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalmultidim_meshgrid.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalmultidim_subsetdimension.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalpythondriverloader.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_translate_lib.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalwarp_lib.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalgeoloc.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdaltransformer.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalwarper.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalwarpoperation.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: rasterfill.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_interpolateatpoint.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrfeaturequery.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmregisterall.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmdbdriver.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmdbnetwork.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmfiledriver.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmfilenetwork.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmlayer.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmgenericnetwork.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmgraph.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmnetwork.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmresultlayer.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmrule.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: cogdriver.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: geotiff.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gt_overview.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: memdataset.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrmemlayer.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtdriver.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtfilters.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtrasterband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtrawrasterband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtsourcedrasterband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtsources.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtwarped.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtdataset.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: pixelfunctions.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtpansharpened.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtprocesseddataset.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtprocesseddatasetfunctions.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtmultidim.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrgeojsondatasource.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrgeojsonlayer.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrgeojsonreader.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrgeojsonutils.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrgeojsonwritelayer.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogresrijsonreader.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrtopojsonreader.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrshapedatasource.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrshapelayer.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogr_gensql.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrunionlayer.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrlayerpool.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalalgorithm.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalalgorithmregistry.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalcomputedrasterband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalpamdataset.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalpamrasterband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_rat.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalproxydataset.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: rawdataset.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: tilematrixset.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: tiff_common.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalalg_main.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalbuildvrt_lib.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogr2ogr_lib.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_crs.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_rpc.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_tps.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalapplyverticalshiftgrid.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalcutline.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalpansharpen.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalrasterize.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffdataset.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffdataset_read.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffdataset_write.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffjpegoverviewds.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffoddbitsband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffrasterband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffrasterband_read.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffrasterband_write.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffrgbaband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffsplitband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffsplitbitmapband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtderivedrasterband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: shape2ogr.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrwarpedlayer.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrlayerdecorator.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrlayerwithtranslatefeature.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_rat_vat_dbf.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalexif.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_mdreader.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_alos.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_digital_globe.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_eros.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_geo_eye.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_kompsat.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_landsat.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_orb_view.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_pleiades.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_rapid_eye.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_rdk1.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_spot.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffbitmapband.cpp:gdal::detail::minInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
2336
2337
template <typename U, typename... V>
2338
GDALComputedRasterBand minInternal(std::vector<const GDALRasterBand *> &bands,
2339
                                   double constant, const U &first, V &&...rest)
2340
{
2341
    minDealFirstArg<U, void>::process(bands, constant, first);
2342
    return minInternal(bands, constant, std::forward<V>(rest)...);
2343
}
2344
2345
}  // namespace detail
2346
2347
template <typename U, typename... V>
2348
inline GDALComputedRasterBand min(const U &first, V &&...rest)
2349
{
2350
    std::vector<const GDALRasterBand *> bands;
2351
    return detail::minInternal(bands, std::numeric_limits<double>::quiet_NaN(),
2352
                               first, std::forward<V>(rest)...);
2353
}
2354
2355
//! @endcond
2356
2357
GDALComputedRasterBand CPL_DLL max(const GDALRasterBand &first,
2358
                                   const GDALRasterBand &second);
2359
2360
//! @cond Doxygen_Suppress
2361
2362
namespace detail
2363
{
2364
2365
template <typename U, typename Enable> struct maxDealFirstArg;
2366
2367
template <typename U>
2368
struct maxDealFirstArg<
2369
    U, typename std::enable_if<std::is_arithmetic<U>::value>::type>
2370
{
2371
    inline static void process(std::vector<const GDALRasterBand *> &,
2372
                               double &constant, const U &first)
2373
    {
2374
        if (std::isnan(constant) || static_cast<double>(first) > constant)
2375
            constant = static_cast<double>(first);
2376
    }
2377
};
2378
2379
template <typename U>
2380
struct maxDealFirstArg<
2381
    U, typename std::enable_if<!std::is_arithmetic<U>::value>::type>
2382
{
2383
    inline static void process(std::vector<const GDALRasterBand *> &bands,
2384
                               double &, const U &first)
2385
    {
2386
        if (!bands.empty())
2387
            GDALRasterBand::ThrowIfNotSameDimensions(first, *(bands.front()));
2388
        bands.push_back(&first);
2389
    }
2390
};
2391
2392
inline static GDALComputedRasterBand
2393
maxInternal(std::vector<const GDALRasterBand *> &bands, double constant)
2394
0
{
2395
0
    return GDALComputedRasterBand(GDALComputedRasterBand::Operation::OP_MAX,
2396
0
                                  bands, constant);
2397
0
}
Unexecuted instantiation: ogrutils.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ograpispy.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalallregister.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrregisterall.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrgeojsondriver.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrgeojsonseqdriver.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogresrijsondriver.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrtopojsondriver.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrshapedriver.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrsfdriverregistrar.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrlayer.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrlayerarrow.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrdatasource.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrsfdriver.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ograrrowarrayhelper.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_misc.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalopeninfo.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdaldriver.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdaldrivermanager.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdaldataset.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalrasterband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalrasterblock.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalcolortable.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalmajorobject.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdaldefaultoverviews.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalmultidomainmetadata.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalpamproxydb.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalallvalidmaskband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalnodatamaskband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalnodatavaluesmaskband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalproxypool.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdaldefaultasync.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalvirtualmem.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdaloverviewdataset.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalrescaledalphaband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalabstractbandblockcache.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalarraybandblockcache.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalhashsetbandblockcache.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalsubdatasetinfo.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalthreadsafedataset.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: overview.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: rasterio.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalmultidim.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalmultidim_gridded.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalmultidim_gltorthorectification.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalmultidim_meshgrid.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalmultidim_subsetdimension.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalpythondriverloader.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_translate_lib.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalwarp_lib.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalgeoloc.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdaltransformer.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalwarper.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalwarpoperation.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: rasterfill.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_interpolateatpoint.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrfeaturequery.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmregisterall.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmdbdriver.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmdbnetwork.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmfiledriver.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmfilenetwork.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmlayer.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmgenericnetwork.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmgraph.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmnetwork.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmresultlayer.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gnmrule.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: cogdriver.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: geotiff.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gt_overview.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: memdataset.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrmemlayer.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtdriver.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtfilters.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtrasterband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtrawrasterband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtsourcedrasterband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtsources.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtwarped.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtdataset.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: pixelfunctions.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtpansharpened.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtprocesseddataset.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtprocesseddatasetfunctions.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtmultidim.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrgeojsondatasource.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrgeojsonlayer.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrgeojsonreader.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrgeojsonutils.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrgeojsonwritelayer.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogresrijsonreader.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrtopojsonreader.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrshapedatasource.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrshapelayer.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogr_gensql.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrunionlayer.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrlayerpool.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalalgorithm.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalalgorithmregistry.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalcomputedrasterband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalpamdataset.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalpamrasterband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_rat.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalproxydataset.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: rawdataset.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: tilematrixset.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: tiff_common.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalalg_main.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalbuildvrt_lib.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogr2ogr_lib.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_crs.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_rpc.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_tps.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalapplyverticalshiftgrid.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalcutline.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalpansharpen.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalrasterize.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffdataset.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffdataset_read.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffdataset_write.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffjpegoverviewds.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffoddbitsband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffrasterband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffrasterband_read.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffrasterband_write.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffrgbaband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffsplitband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffsplitbitmapband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: vrtderivedrasterband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: shape2ogr.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrwarpedlayer.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrlayerdecorator.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: ogrlayerwithtranslatefeature.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_rat_vat_dbf.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdalexif.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gdal_mdreader.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_alos.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_digital_globe.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_eros.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_geo_eye.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_kompsat.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_landsat.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_orb_view.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_pleiades.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_rapid_eye.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_rdk1.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: reader_spot.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
Unexecuted instantiation: gtiffbitmapband.cpp:gdal::detail::maxInternal(std::__1::vector<GDALRasterBand const*, std::__1::allocator<GDALRasterBand const*> >&, double)
2398
2399
template <typename U, typename... V>
2400
GDALComputedRasterBand maxInternal(std::vector<const GDALRasterBand *> &bands,
2401
                                   double constant, const U &first, V &&...rest)
2402
{
2403
    maxDealFirstArg<U, void>::process(bands, constant, first);
2404
    return maxInternal(bands, constant, std::forward<V>(rest)...);
2405
}
2406
2407
}  // namespace detail
2408
2409
template <typename U, typename... V>
2410
inline GDALComputedRasterBand max(const U &first, V &&...rest)
2411
{
2412
    std::vector<const GDALRasterBand *> bands;
2413
    return detail::maxInternal(bands, std::numeric_limits<double>::quiet_NaN(),
2414
                               first, std::forward<V>(rest)...);
2415
}
2416
2417
//! @endcond
2418
2419
GDALComputedRasterBand CPL_DLL mean(const GDALRasterBand &first,
2420
                                    const GDALRasterBand &second);
2421
2422
//! @cond Doxygen_Suppress
2423
inline GDALComputedRasterBand
2424
meanInternal(std::vector<const GDALRasterBand *> &bands)
2425
0
{
2426
0
    return GDALComputedRasterBand(GDALComputedRasterBand::Operation::OP_MEAN,
2427
0
                                  bands);
2428
0
}
2429
2430
template <typename U, typename... V>
2431
inline GDALComputedRasterBand
2432
meanInternal(std::vector<const GDALRasterBand *> &bands, const U &first,
2433
             V &&...rest)
2434
{
2435
    if (!bands.empty())
2436
        GDALRasterBand::ThrowIfNotSameDimensions(first, *(bands.front()));
2437
    bands.push_back(&first);
2438
    return meanInternal(bands, std::forward<V>(rest)...);
2439
}
2440
2441
template <typename... Args> inline GDALComputedRasterBand mean(Args &&...args)
2442
{
2443
    std::vector<const GDALRasterBand *> bands;
2444
    return meanInternal(bands, std::forward<Args>(args)...);
2445
}
2446
2447
//! @endcond
2448
2449
}  // namespace gdal
2450
2451
//! @cond Doxygen_Suppress
2452
/* ******************************************************************** */
2453
/*                         GDALAllValidMaskBand                         */
2454
/* ******************************************************************** */
2455
2456
class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
2457
{
2458
  protected:
2459
    CPLErr IReadBlock(int, int, void *) override;
2460
2461
    CPLErr IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
2462
                     int nYSize, void *pData, int nBufXSize, int nBufYSize,
2463
                     GDALDataType eBufType, GSpacing nPixelSpace,
2464
                     GSpacing nLineSpace,
2465
                     GDALRasterIOExtraArg *psExtraArg) override;
2466
2467
    bool
2468
    EmitErrorMessageIfWriteNotSupported(const char *pszCaller) const override;
2469
2470
    CPL_DISALLOW_COPY_ASSIGN(GDALAllValidMaskBand)
2471
2472
  public:
2473
    explicit GDALAllValidMaskBand(GDALRasterBand *);
2474
    ~GDALAllValidMaskBand() override;
2475
2476
    GDALRasterBand *GetMaskBand() override;
2477
    int GetMaskFlags() override;
2478
2479
    bool IsMaskBand() const override
2480
0
    {
2481
0
        return true;
2482
0
    }
2483
2484
    GDALMaskValueRange GetMaskValueRange() const override
2485
0
    {
2486
0
        return GMVR_0_AND_255_ONLY;
2487
0
    }
2488
2489
    CPLErr ComputeStatistics(int bApproxOK, double *pdfMin, double *pdfMax,
2490
                             double *pdfMean, double *pdfStdDev,
2491
                             GDALProgressFunc, void *pProgressData) override;
2492
};
2493
2494
/* ******************************************************************** */
2495
/*                         GDALNoDataMaskBand                           */
2496
/* ******************************************************************** */
2497
2498
class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
2499
{
2500
    friend class GDALRasterBand;
2501
    double m_dfNoDataValue = 0;
2502
    int64_t m_nNoDataValueInt64 = 0;
2503
    uint64_t m_nNoDataValueUInt64 = 0;
2504
    GDALRasterBand *m_poParent = nullptr;
2505
2506
    CPL_DISALLOW_COPY_ASSIGN(GDALNoDataMaskBand)
2507
2508
  protected:
2509
    CPLErr IReadBlock(int, int, void *) override;
2510
    CPLErr IRasterIO(GDALRWFlag, int, int, int, int, void *, int, int,
2511
                     GDALDataType, GSpacing, GSpacing,
2512
                     GDALRasterIOExtraArg *psExtraArg) override;
2513
2514
    bool
2515
    EmitErrorMessageIfWriteNotSupported(const char *pszCaller) const override;
2516
2517
  public:
2518
    explicit GDALNoDataMaskBand(GDALRasterBand *);
2519
    explicit GDALNoDataMaskBand(GDALRasterBand *, double dfNoDataValue);
2520
    ~GDALNoDataMaskBand() override;
2521
2522
    bool IsMaskBand() const override
2523
0
    {
2524
0
        return true;
2525
0
    }
2526
2527
    GDALMaskValueRange GetMaskValueRange() const override
2528
0
    {
2529
0
        return GMVR_0_AND_255_ONLY;
2530
0
    }
2531
2532
    static bool IsNoDataInRange(double dfNoDataValue, GDALDataType eDataType);
2533
};
2534
2535
/* ******************************************************************** */
2536
/*                  GDALNoDataValuesMaskBand                            */
2537
/* ******************************************************************** */
2538
2539
class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
2540
{
2541
    double *padfNodataValues;
2542
2543
    CPL_DISALLOW_COPY_ASSIGN(GDALNoDataValuesMaskBand)
2544
2545
  protected:
2546
    CPLErr IReadBlock(int, int, void *) override;
2547
2548
    bool
2549
    EmitErrorMessageIfWriteNotSupported(const char *pszCaller) const override;
2550
2551
  public:
2552
    explicit GDALNoDataValuesMaskBand(GDALDataset *);
2553
    ~GDALNoDataValuesMaskBand() override;
2554
2555
    bool IsMaskBand() const override
2556
0
    {
2557
0
        return true;
2558
0
    }
2559
2560
    GDALMaskValueRange GetMaskValueRange() const override
2561
0
    {
2562
0
        return GMVR_0_AND_255_ONLY;
2563
0
    }
2564
};
2565
2566
/* ******************************************************************** */
2567
/*                         GDALRescaledAlphaBand                        */
2568
/* ******************************************************************** */
2569
2570
class GDALRescaledAlphaBand : public GDALRasterBand
2571
{
2572
    GDALRasterBand *poParent;
2573
    void *pTemp;
2574
2575
    CPL_DISALLOW_COPY_ASSIGN(GDALRescaledAlphaBand)
2576
2577
  protected:
2578
    CPLErr IReadBlock(int, int, void *) override;
2579
    CPLErr IRasterIO(GDALRWFlag, int, int, int, int, void *, int, int,
2580
                     GDALDataType, GSpacing, GSpacing,
2581
                     GDALRasterIOExtraArg *psExtraArg) override;
2582
2583
    bool
2584
    EmitErrorMessageIfWriteNotSupported(const char *pszCaller) const override;
2585
2586
  public:
2587
    explicit GDALRescaledAlphaBand(GDALRasterBand *);
2588
    ~GDALRescaledAlphaBand() override;
2589
2590
    bool IsMaskBand() const override
2591
0
    {
2592
0
        return true;
2593
0
    }
2594
};
2595
2596
//! @endcond
2597
2598
/* ******************************************************************** */
2599
/*                          GDALIdentifyEnum                            */
2600
/* ******************************************************************** */
2601
2602
/**
2603
 * Enumeration used by GDALDriver::pfnIdentify().
2604
 *
2605
 * @since GDAL 2.1
2606
 */
2607
typedef enum
2608
{
2609
    /** Identify could not determine if the file is recognized or not by the
2610
       probed driver. */
2611
    GDAL_IDENTIFY_UNKNOWN = -1,
2612
    /** Identify determined the file is not recognized by the probed driver. */
2613
    GDAL_IDENTIFY_FALSE = 0,
2614
    /** Identify determined the file is recognized by the probed driver. */
2615
    GDAL_IDENTIFY_TRUE = 1
2616
} GDALIdentifyEnum;
2617
2618
/* ******************************************************************** */
2619
/*                              GDALDriver                              */
2620
/* ******************************************************************** */
2621
2622
/**
2623
 * \brief Format specific driver.
2624
 *
2625
 * An instance of this class is created for each supported format, and
2626
 * manages information about the format.
2627
 *
2628
 * This roughly corresponds to a file format, though some
2629
 * drivers may be gateways to many formats through a secondary
2630
 * multi-library.
2631
 */
2632
2633
class CPL_DLL GDALDriver : public GDALMajorObject
2634
{
2635
  public:
2636
    GDALDriver();
2637
    ~GDALDriver() override;
2638
2639
    CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
2640
                           const char *pszDomain = "") override;
2641
2642
    /* -------------------------------------------------------------------- */
2643
    /*      Public C++ methods.                                             */
2644
    /* -------------------------------------------------------------------- */
2645
    GDALDataset *Create(const char *pszName, int nXSize, int nYSize, int nBands,
2646
                        GDALDataType eType,
2647
                        CSLConstList papszOptions) CPL_WARN_UNUSED_RESULT;
2648
2649
    GDALDataset *
2650
    CreateMultiDimensional(const char *pszName,
2651
                           CSLConstList papszRootGroupOptions,
2652
                           CSLConstList papszOptions) CPL_WARN_UNUSED_RESULT;
2653
2654
    CPLErr Delete(const char *pszName);
2655
    CPLErr Rename(const char *pszNewName, const char *pszOldName);
2656
    CPLErr CopyFiles(const char *pszNewName, const char *pszOldName);
2657
2658
    GDALDataset *CreateCopy(const char *, GDALDataset *, int,
2659
                            CSLConstList papszOptions,
2660
                            GDALProgressFunc pfnProgress,
2661
                            void *pProgressData) CPL_WARN_UNUSED_RESULT;
2662
2663
    bool CanVectorTranslateFrom(const char *pszDestName,
2664
                                GDALDataset *poSourceDS,
2665
                                CSLConstList papszVectorTranslateArguments,
2666
                                char ***ppapszFailureReasons);
2667
2668
    /**
2669
     * \brief Returns TRUE if the given open option is supported by the driver.
2670
     * @param pszOpenOptionName name of the open option to be checked
2671
     * @return TRUE if the driver supports the open option
2672
     * @since GDAL 3.11
2673
     */
2674
    bool HasOpenOption(const char *pszOpenOptionName) const;
2675
2676
    GDALDataset *
2677
    VectorTranslateFrom(const char *pszDestName, GDALDataset *poSourceDS,
2678
                        CSLConstList papszVectorTranslateArguments,
2679
                        GDALProgressFunc pfnProgress,
2680
                        void *pProgressData) CPL_WARN_UNUSED_RESULT;
2681
2682
    /* -------------------------------------------------------------------- */
2683
    /*      The following are semiprivate, not intended to be accessed      */
2684
    /*      by anyone but the formats instantiating and populating the      */
2685
    /*      drivers.                                                        */
2686
    /* -------------------------------------------------------------------- */
2687
    //! @cond Doxygen_Suppress
2688
2689
    // Not aimed at being used outside of GDAL. Use GDALDataset::Open() instead
2690
    GDALDataset *Open(GDALOpenInfo *poOpenInfo, bool bSetOpenOptions);
2691
2692
    typedef GDALDataset *(*OpenCallback)(GDALOpenInfo *);
2693
2694
    OpenCallback pfnOpen = nullptr;
2695
2696
    virtual OpenCallback GetOpenCallback()
2697
0
    {
2698
0
        return pfnOpen;
2699
0
    }
2700
2701
    typedef GDALDataset *(*CreateCallback)(const char *pszName, int nXSize,
2702
                                           int nYSize, int nBands,
2703
                                           GDALDataType eType,
2704
                                           char **papszOptions);
2705
2706
    CreateCallback pfnCreate = nullptr;
2707
2708
    virtual CreateCallback GetCreateCallback()
2709
0
    {
2710
0
        return pfnCreate;
2711
0
    }
2712
2713
    GDALDataset *(*pfnCreateEx)(GDALDriver *, const char *pszName, int nXSize,
2714
                                int nYSize, int nBands, GDALDataType eType,
2715
                                char **papszOptions) = nullptr;
2716
2717
    typedef GDALDataset *(*CreateMultiDimensionalCallback)(
2718
        const char *pszName, CSLConstList papszRootGroupOptions,
2719
        CSLConstList papszOptions);
2720
2721
    CreateMultiDimensionalCallback pfnCreateMultiDimensional = nullptr;
2722
2723
    virtual CreateMultiDimensionalCallback GetCreateMultiDimensionalCallback()
2724
0
    {
2725
0
        return pfnCreateMultiDimensional;
2726
0
    }
2727
2728
    typedef CPLErr (*DeleteCallback)(const char *pszName);
2729
    DeleteCallback pfnDelete = nullptr;
2730
2731
    virtual DeleteCallback GetDeleteCallback()
2732
0
    {
2733
0
        return pfnDelete;
2734
0
    }
2735
2736
    typedef GDALDataset *(*CreateCopyCallback)(const char *, GDALDataset *, int,
2737
                                               char **,
2738
                                               GDALProgressFunc pfnProgress,
2739
                                               void *pProgressData);
2740
2741
    CreateCopyCallback pfnCreateCopy = nullptr;
2742
2743
    virtual CreateCopyCallback GetCreateCopyCallback()
2744
0
    {
2745
0
        return pfnCreateCopy;
2746
0
    }
2747
2748
    void *pDriverData = nullptr;
2749
2750
    void (*pfnUnloadDriver)(GDALDriver *) = nullptr;
2751
2752
    /** Identify() if the file is recognized or not by the driver.
2753
2754
       Return GDAL_IDENTIFY_TRUE (1) if the passed file is certainly recognized
2755
       by the driver. Return GDAL_IDENTIFY_FALSE (0) if the passed file is
2756
       certainly NOT recognized by the driver. Return GDAL_IDENTIFY_UNKNOWN (-1)
2757
       if the passed file may be or may not be recognized by the driver, and
2758
       that a potentially costly test must be done with pfnOpen.
2759
    */
2760
    int (*pfnIdentify)(GDALOpenInfo *) = nullptr;
2761
    int (*pfnIdentifyEx)(GDALDriver *, GDALOpenInfo *) = nullptr;
2762
2763
    typedef CPLErr (*RenameCallback)(const char *pszNewName,
2764
                                     const char *pszOldName);
2765
    RenameCallback pfnRename = nullptr;
2766
2767
    virtual RenameCallback GetRenameCallback()
2768
0
    {
2769
0
        return pfnRename;
2770
0
    }
2771
2772
    typedef CPLErr (*CopyFilesCallback)(const char *pszNewName,
2773
                                        const char *pszOldName);
2774
    CopyFilesCallback pfnCopyFiles = nullptr;
2775
2776
    virtual CopyFilesCallback GetCopyFilesCallback()
2777
0
    {
2778
0
        return pfnCopyFiles;
2779
0
    }
2780
2781
    // Used for legacy OGR drivers, and Python drivers
2782
    GDALDataset *(*pfnOpenWithDriverArg)(GDALDriver *,
2783
                                         GDALOpenInfo *) = nullptr;
2784
2785
    /* For legacy OGR drivers */
2786
    GDALDataset *(*pfnCreateVectorOnly)(GDALDriver *, const char *pszName,
2787
                                        char **papszOptions) = nullptr;
2788
    CPLErr (*pfnDeleteDataSource)(GDALDriver *, const char *pszName) = nullptr;
2789
2790
    /** Whether pfnVectorTranslateFrom() can be run given the source dataset
2791
     * and the non-positional arguments of GDALVectorTranslate() stored
2792
     * in papszVectorTranslateArguments.
2793
     */
2794
    bool (*pfnCanVectorTranslateFrom)(
2795
        const char *pszDestName, GDALDataset *poSourceDS,
2796
        CSLConstList papszVectorTranslateArguments,
2797
        char ***ppapszFailureReasons) = nullptr;
2798
2799
    /** Creates a copy from the specified source dataset, using the
2800
     * non-positional arguments of GDALVectorTranslate() stored
2801
     * in papszVectorTranslateArguments.
2802
     */
2803
    GDALDataset *(*pfnVectorTranslateFrom)(
2804
        const char *pszDestName, GDALDataset *poSourceDS,
2805
        CSLConstList papszVectorTranslateArguments,
2806
        GDALProgressFunc pfnProgress, void *pProgressData) = nullptr;
2807
2808
    /**
2809
     * Returns a (possibly null) pointer to the Subdataset informational function
2810
     * from the subdataset file name.
2811
     */
2812
    GDALSubdatasetInfo *(*pfnGetSubdatasetInfoFunc)(const char *pszFileName) =
2813
        nullptr;
2814
2815
    typedef GDALAlgorithm *(*InstantiateAlgorithmCallback)(
2816
        const std::vector<std::string> &aosPath);
2817
    InstantiateAlgorithmCallback pfnInstantiateAlgorithm = nullptr;
2818
2819
    virtual InstantiateAlgorithmCallback GetInstantiateAlgorithmCallback()
2820
0
    {
2821
0
        return pfnInstantiateAlgorithm;
2822
0
    }
2823
2824
    /** Instantiate an algorithm by its full path (omitting leading "gdal").
2825
     * For example {"driver", "pdf", "list-layers"}
2826
     */
2827
    GDALAlgorithm *
2828
    InstantiateAlgorithm(const std::vector<std::string> &aosPath);
2829
2830
    /** Declare an algorithm by its full path (omitting leading "gdal").
2831
     * For example {"driver", "pdf", "list-layers"}
2832
     */
2833
    void DeclareAlgorithm(const std::vector<std::string> &aosPath);
2834
2835
    //! @endcond
2836
2837
    /* -------------------------------------------------------------------- */
2838
    /*      Helper methods.                                                 */
2839
    /* -------------------------------------------------------------------- */
2840
    //! @cond Doxygen_Suppress
2841
    GDALDataset *DefaultCreateCopy(const char *, GDALDataset *, int,
2842
                                   CSLConstList papszOptions,
2843
                                   GDALProgressFunc pfnProgress,
2844
                                   void *pProgressData) CPL_WARN_UNUSED_RESULT;
2845
2846
    static CPLErr DefaultCreateCopyMultiDimensional(
2847
        GDALDataset *poSrcDS, GDALDataset *poDstDS, bool bStrict,
2848
        CSLConstList /*papszOptions*/, GDALProgressFunc pfnProgress,
2849
        void *pProgressData);
2850
2851
    static CPLErr DefaultCopyMasks(GDALDataset *poSrcDS, GDALDataset *poDstDS,
2852
                                   int bStrict);
2853
    static CPLErr DefaultCopyMasks(GDALDataset *poSrcDS, GDALDataset *poDstDS,
2854
                                   int bStrict, CSLConstList papszOptions,
2855
                                   GDALProgressFunc pfnProgress,
2856
                                   void *pProgressData);
2857
2858
    CPLErr QuietDeleteForCreateCopy(const char *pszFilename,
2859
                                    GDALDataset *poSrcDS);
2860
2861
    //! @endcond
2862
    static CPLErr QuietDelete(const char *pszName,
2863
                              CSLConstList papszAllowedDrivers = nullptr);
2864
2865
    //! @cond Doxygen_Suppress
2866
    static CPLErr DefaultRename(const char *pszNewName, const char *pszOldName);
2867
    static CPLErr DefaultCopyFiles(const char *pszNewName,
2868
                                   const char *pszOldName);
2869
    static void DefaultCopyMetadata(GDALDataset *poSrcDS, GDALDataset *poDstDS,
2870
                                    CSLConstList papszOptions,
2871
                                    CSLConstList papszExcludedDomains);
2872
2873
    //! @endcond
2874
2875
    /** Convert a GDALDriver* to a GDALDriverH.
2876
     * @since GDAL 2.3
2877
     */
2878
    static inline GDALDriverH ToHandle(GDALDriver *poDriver)
2879
0
    {
2880
0
        return static_cast<GDALDriverH>(poDriver);
2881
0
    }
2882
2883
    /** Convert a GDALDriverH to a GDALDriver*.
2884
     * @since GDAL 2.3
2885
     */
2886
    static inline GDALDriver *FromHandle(GDALDriverH hDriver)
2887
0
    {
2888
0
        return static_cast<GDALDriver *>(hDriver);
2889
0
    }
2890
2891
  private:
2892
    CPL_DISALLOW_COPY_ASSIGN(GDALDriver)
2893
};
2894
2895
/************************************************************************/
2896
/*                       GDALPluginDriverProxy                          */
2897
/************************************************************************/
2898
2899
// clang-format off
2900
/** Proxy for a plugin driver.
2901
 *
2902
 * Such proxy must be registered with
2903
 * GDALDriverManager::DeclareDeferredPluginDriver().
2904
 *
2905
 * If the real driver defines any of the following metadata items, the
2906
 * proxy driver should also define them with the same value:
2907
 * <ul>
2908
 * <li>GDAL_DMD_LONGNAME</li>
2909
 * <li>GDAL_DMD_EXTENSIONS</li>
2910
 * <li>GDAL_DMD_EXTENSION</li>
2911
 * <li>GDAL_DMD_OPENOPTIONLIST</li>
2912
 * <li>GDAL_DMD_SUBDATASETS</li>
2913
 * <li>GDAL_DMD_CONNECTION_PREFIX</li>
2914
 * <li>GDAL_DCAP_RASTER</li>
2915
 * <li>GDAL_DCAP_MULTIDIM_RASTER</li>
2916
 * <li>GDAL_DCAP_VECTOR</li>
2917
 * <li>GDAL_DCAP_GNM</li>
2918
 * <li>GDAL_DCAP_MULTIPLE_VECTOR_LAYERS</li>
2919
 * <li>GDAL_DCAP_NONSPATIAL</li>
2920
 * <li>GDAL_DCAP_VECTOR_TRANSLATE_FROM</li>
2921
 * </ul>
2922
 *
2923
 * The pfnIdentify and pfnGetSubdatasetInfoFunc callbacks, if they are
2924
 * defined in the real driver, should also be set on the proxy driver.
2925
 *
2926
 * Furthermore, the following metadata items must be defined if the real
2927
 * driver sets the corresponding callback:
2928
 * <ul>
2929
 * <li>GDAL_DCAP_OPEN: must be set to YES if the real driver defines pfnOpen</li>
2930
 * <li>GDAL_DCAP_CREATE: must be set to YES if the real driver defines pfnCreate</li>
2931
 * <li>GDAL_DCAP_CREATE_MULTIDIMENSIONAL: must be set to YES if the real driver defines pfnCreateMultiDimensional</li>
2932
 * <li>GDAL_DCAP_CREATECOPY: must be set to YES if the real driver defines pfnCreateCopy</li>
2933
 * </ul>
2934
 *
2935
 * @since 3.9
2936
 */
2937
// clang-format on
2938
2939
class GDALPluginDriverProxy : public GDALDriver
2940
{
2941
    const std::string m_osPluginFileName;
2942
    std::string m_osPluginFullPath{};
2943
    std::unique_ptr<GDALDriver> m_poRealDriver{};
2944
    std::set<std::string> m_oSetMetadataItems{};
2945
2946
    GDALDriver *GetRealDriver();
2947
2948
    CPL_DISALLOW_COPY_ASSIGN(GDALPluginDriverProxy)
2949
2950
  protected:
2951
    friend class GDALDriverManager;
2952
2953
    //! @cond Doxygen_Suppress
2954
    void SetPluginFullPath(const std::string &osFullPath)
2955
0
    {
2956
0
        m_osPluginFullPath = osFullPath;
2957
0
    }
2958
2959
    //! @endcond
2960
2961
  public:
2962
    explicit GDALPluginDriverProxy(const std::string &osPluginFileName);
2963
2964
    /** Return the plugin file name (not a full path) */
2965
    const std::string &GetPluginFileName() const
2966
0
    {
2967
0
        return m_osPluginFileName;
2968
0
    }
2969
2970
    //! @cond Doxygen_Suppress
2971
    OpenCallback GetOpenCallback() override;
2972
2973
    CreateCallback GetCreateCallback() override;
2974
2975
    CreateMultiDimensionalCallback GetCreateMultiDimensionalCallback() override;
2976
2977
    CreateCopyCallback GetCreateCopyCallback() override;
2978
2979
    DeleteCallback GetDeleteCallback() override;
2980
2981
    RenameCallback GetRenameCallback() override;
2982
2983
    CopyFilesCallback GetCopyFilesCallback() override;
2984
2985
    InstantiateAlgorithmCallback GetInstantiateAlgorithmCallback() override;
2986
    //! @endcond
2987
2988
    CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
2989
                           const char *pszDomain = "") override;
2990
2991
    char **GetMetadata(const char *pszDomain) override;
2992
2993
    const char *GetMetadataItem(const char *pszName,
2994
                                const char *pszDomain = "") override;
2995
};
2996
2997
/* ******************************************************************** */
2998
/*                          GDALDriverManager                           */
2999
/* ******************************************************************** */
3000
3001
/**
3002
 * Class for managing the registration of file format drivers.
3003
 *
3004
 * Use GetGDALDriverManager() to fetch the global singleton instance of
3005
 * this class.
3006
 */
3007
3008
class CPL_DLL GDALDriverManager : public GDALMajorObject
3009
{
3010
    int nDrivers = 0;
3011
    GDALDriver **papoDrivers = nullptr;
3012
    std::map<CPLString, GDALDriver *> oMapNameToDrivers{};
3013
    std::string m_osPluginPath{};
3014
    std::string m_osDriversIniPath{};
3015
    mutable std::string m_osLastTriedDirectory{};
3016
    std::set<std::string> m_oSetPluginFileNames{};
3017
    bool m_bInDeferredDriverLoading = false;
3018
    std::map<std::string, std::unique_ptr<GDALDriver>> m_oMapRealDrivers{};
3019
    std::vector<std::unique_ptr<GDALDriver>> m_aoHiddenDrivers{};
3020
3021
    GDALDriver *GetDriver_unlocked(int iDriver)
3022
0
    {
3023
0
        return (iDriver >= 0 && iDriver < nDrivers) ? papoDrivers[iDriver]
3024
0
                                                    : nullptr;
3025
0
    }
3026
3027
    GDALDriver *GetDriverByName_unlocked(const char *pszName) const;
3028
3029
    static void CleanupPythonDrivers();
3030
3031
    std::string GetPluginFullPath(const char *pszFilename) const;
3032
3033
    int RegisterDriver(GDALDriver *, bool bHidden);
3034
3035
    CPL_DISALLOW_COPY_ASSIGN(GDALDriverManager)
3036
3037
  protected:
3038
    friend class GDALPluginDriverProxy;
3039
    friend GDALDatasetH CPL_STDCALL
3040
    GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags,
3041
               const char *const *papszAllowedDrivers,
3042
               const char *const *papszOpenOptions,
3043
               const char *const *papszSiblingFiles);
3044
3045
    //! @cond Doxygen_Suppress
3046
    static char **GetSearchPaths(const char *pszGDAL_DRIVER_PATH);
3047
    //! @endcond
3048
3049
  public:
3050
    GDALDriverManager();
3051
    ~GDALDriverManager();
3052
3053
    int GetDriverCount(void) const;
3054
    GDALDriver *GetDriver(int);
3055
    GDALDriver *GetDriverByName(const char *);
3056
3057
    int RegisterDriver(GDALDriver *);
3058
    void DeregisterDriver(GDALDriver *);
3059
3060
    // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
3061
    void AutoLoadDrivers();
3062
    void AutoSkipDrivers();
3063
    void ReorderDrivers();
3064
    static CPLErr LoadPlugin(const char *name);
3065
3066
    static void AutoLoadPythonDrivers();
3067
3068
    void DeclareDeferredPluginDriver(GDALPluginDriverProxy *poProxyDriver);
3069
3070
    //! @cond Doxygen_Suppress
3071
    int GetDriverCount(bool bIncludeHidden) const;
3072
    GDALDriver *GetDriver(int iDriver, bool bIncludeHidden);
3073
    bool IsKnownDriver(const char *pszDriverName) const;
3074
    GDALDriver *GetHiddenDriverByName(const char *pszName);
3075
    //! @endcond
3076
};
3077
3078
CPL_C_START
3079
GDALDriverManager CPL_DLL *GetGDALDriverManager(void);
3080
CPL_C_END
3081
3082
/* ******************************************************************** */
3083
/*                          GDALAsyncReader                             */
3084
/* ******************************************************************** */
3085
3086
/**
3087
 * Class used as a session object for asynchronous requests.  They are
3088
 * created with GDALDataset::BeginAsyncReader(), and destroyed with
3089
 * GDALDataset::EndAsyncReader().
3090
 */
3091
class CPL_DLL GDALAsyncReader
3092
{
3093
3094
    CPL_DISALLOW_COPY_ASSIGN(GDALAsyncReader)
3095
3096
  protected:
3097
    //! @cond Doxygen_Suppress
3098
    GDALDataset *poDS;
3099
    int nXOff;
3100
    int nYOff;
3101
    int nXSize;
3102
    int nYSize;
3103
    void *pBuf;
3104
    int nBufXSize;
3105
    int nBufYSize;
3106
    GDALDataType eBufType;
3107
    int nBandCount;
3108
    int *panBandMap;
3109
    int nPixelSpace;
3110
    int nLineSpace;
3111
    int nBandSpace;
3112
    //! @endcond
3113
3114
  public:
3115
    GDALAsyncReader();
3116
    virtual ~GDALAsyncReader();
3117
3118
    /** Return dataset.
3119
     * @return dataset
3120
     */
3121
    GDALDataset *GetGDALDataset()
3122
0
    {
3123
0
        return poDS;
3124
0
    }
3125
3126
    /** Return x offset.
3127
     * @return x offset.
3128
     */
3129
    int GetXOffset() const
3130
0
    {
3131
0
        return nXOff;
3132
0
    }
3133
3134
    /** Return y offset.
3135
     * @return y offset.
3136
     */
3137
    int GetYOffset() const
3138
0
    {
3139
0
        return nYOff;
3140
0
    }
3141
3142
    /** Return width.
3143
     * @return width
3144
     */
3145
    int GetXSize() const
3146
0
    {
3147
0
        return nXSize;
3148
0
    }
3149
3150
    /** Return height.
3151
     * @return height
3152
     */
3153
    int GetYSize() const
3154
0
    {
3155
0
        return nYSize;
3156
0
    }
3157
3158
    /** Return buffer.
3159
     * @return buffer
3160
     */
3161
    void *GetBuffer()
3162
0
    {
3163
0
        return pBuf;
3164
0
    }
3165
3166
    /** Return buffer width.
3167
     * @return buffer width.
3168
     */
3169
    int GetBufferXSize() const
3170
0
    {
3171
0
        return nBufXSize;
3172
0
    }
3173
3174
    /** Return buffer height.
3175
     * @return buffer height.
3176
     */
3177
    int GetBufferYSize() const
3178
0
    {
3179
0
        return nBufYSize;
3180
0
    }
3181
3182
    /** Return buffer data type.
3183
     * @return buffer data type.
3184
     */
3185
    GDALDataType GetBufferType() const
3186
0
    {
3187
0
        return eBufType;
3188
0
    }
3189
3190
    /** Return band count.
3191
     * @return band count
3192
     */
3193
    int GetBandCount() const
3194
0
    {
3195
0
        return nBandCount;
3196
0
    }
3197
3198
    /** Return band map.
3199
     * @return band map.
3200
     */
3201
    int *GetBandMap()
3202
0
    {
3203
0
        return panBandMap;
3204
0
    }
3205
3206
    /** Return pixel spacing.
3207
     * @return pixel spacing.
3208
     */
3209
    int GetPixelSpace() const
3210
0
    {
3211
0
        return nPixelSpace;
3212
0
    }
3213
3214
    /** Return line spacing.
3215
     * @return line spacing.
3216
     */
3217
    int GetLineSpace() const
3218
0
    {
3219
0
        return nLineSpace;
3220
0
    }
3221
3222
    /** Return band spacing.
3223
     * @return band spacing.
3224
     */
3225
    int GetBandSpace() const
3226
0
    {
3227
0
        return nBandSpace;
3228
0
    }
3229
3230
    virtual GDALAsyncStatusType
3231
    GetNextUpdatedRegion(double dfTimeout, int *pnBufXOff, int *pnBufYOff,
3232
                         int *pnBufXSize, int *pnBufYSize) = 0;
3233
    virtual int LockBuffer(double dfTimeout = -1.0);
3234
    virtual void UnlockBuffer();
3235
};
3236
3237
/* ******************************************************************** */
3238
/*                       Multidimensional array API                     */
3239
/* ******************************************************************** */
3240
3241
class GDALMDArray;
3242
class GDALAttribute;
3243
class GDALDimension;
3244
class GDALEDTComponent;
3245
3246
/* ******************************************************************** */
3247
/*                         GDALExtendedDataType                         */
3248
/* ******************************************************************** */
3249
3250
/**
3251
 * Class used to represent potentially complex data types.
3252
 * Several classes of data types are supported: numeric (based on GDALDataType),
3253
 * compound or string.
3254
 *
3255
 * @since GDAL 3.1
3256
 */
3257
class CPL_DLL GDALExtendedDataType
3258
{
3259
  public:
3260
    ~GDALExtendedDataType();
3261
3262
    GDALExtendedDataType(const GDALExtendedDataType &);
3263
3264
    GDALExtendedDataType &operator=(const GDALExtendedDataType &);
3265
    GDALExtendedDataType &operator=(GDALExtendedDataType &&);
3266
3267
    static GDALExtendedDataType Create(GDALDataType eType);
3268
    static GDALExtendedDataType
3269
    Create(const std::string &osName, GDALDataType eBaseType,
3270
           std::unique_ptr<GDALRasterAttributeTable>);
3271
    static GDALExtendedDataType
3272
    Create(const std::string &osName, size_t nTotalSize,
3273
           std::vector<std::unique_ptr<GDALEDTComponent>> &&components);
3274
    static GDALExtendedDataType
3275
    CreateString(size_t nMaxStringLength = 0,
3276
                 GDALExtendedDataTypeSubType eSubType = GEDTST_NONE);
3277
3278
    bool operator==(const GDALExtendedDataType &) const;
3279
3280
    /** Non-equality operator */
3281
    bool operator!=(const GDALExtendedDataType &other) const
3282
0
    {
3283
0
        return !(operator==(other));
3284
0
    }
3285
3286
    /** Return type name.
3287
     *
3288
     * This is the same as the C function GDALExtendedDataTypeGetName()
3289
     */
3290
    const std::string &GetName() const
3291
0
    {
3292
0
        return m_osName;
3293
0
    }
3294
3295
    /** Return type class.
3296
     *
3297
     * This is the same as the C function GDALExtendedDataTypeGetClass()
3298
     */
3299
    GDALExtendedDataTypeClass GetClass() const
3300
0
    {
3301
0
        return m_eClass;
3302
0
    }
3303
3304
    /** Return numeric data type (only valid when GetClass() == GEDTC_NUMERIC)
3305
     *
3306
     * This is the same as the C function
3307
     * GDALExtendedDataTypeGetNumericDataType()
3308
     */
3309
    GDALDataType GetNumericDataType() const
3310
0
    {
3311
0
        return m_eNumericDT;
3312
0
    }
3313
3314
    /** Return subtype.
3315
     *
3316
     * This is the same as the C function GDALExtendedDataTypeGetSubType()
3317
     *
3318
     * @since 3.4
3319
     */
3320
    GDALExtendedDataTypeSubType GetSubType() const
3321
0
    {
3322
0
        return m_eSubType;
3323
0
    }
3324
3325
    /** Return the components of the data type (only valid when GetClass() ==
3326
     * GEDTC_COMPOUND)
3327
     *
3328
     * This is the same as the C function GDALExtendedDataTypeGetComponents()
3329
     */
3330
    const std::vector<std::unique_ptr<GDALEDTComponent>> &GetComponents() const
3331
0
    {
3332
0
        return m_aoComponents;
3333
0
    }
3334
3335
    /** Return data type size in bytes.
3336
     *
3337
     * For a string, this will be size of a char* pointer.
3338
     *
3339
     * This is the same as the C function GDALExtendedDataTypeGetSize()
3340
     */
3341
    size_t GetSize() const
3342
0
    {
3343
0
        return m_nSize;
3344
0
    }
3345
3346
    /** Return the maximum length of a string in bytes.
3347
     *
3348
     * 0 indicates unknown/unlimited string.
3349
     */
3350
    size_t GetMaxStringLength() const
3351
0
    {
3352
0
        return m_nMaxStringLength;
3353
0
    }
3354
3355
    /** Return associated raster attribute table, when there is one.
3356
     *
3357
     * For the netCDF driver, the RAT will capture enumerated types, with
3358
     * a "value" column with an integer value and a "name" column with the
3359
     * associated name.
3360
     *
3361
     * This is the same as the C function GDALExtendedDataTypeGetRAT()
3362
     *
3363
     * @since 3.12
3364
     */
3365
    const GDALRasterAttributeTable *GetRAT() const
3366
0
    {
3367
0
        return m_poRAT.get();
3368
0
    }
3369
3370
    bool CanConvertTo(const GDALExtendedDataType &other) const;
3371
3372
    bool NeedsFreeDynamicMemory() const;
3373
3374
    void FreeDynamicMemory(void *pBuffer) const;
3375
3376
    static bool CopyValue(const void *pSrc, const GDALExtendedDataType &srcType,
3377
                          void *pDst, const GDALExtendedDataType &dstType);
3378
3379
    static bool CopyValues(const void *pSrc,
3380
                           const GDALExtendedDataType &srcType,
3381
                           GPtrDiff_t nSrcStrideInElts, void *pDst,
3382
                           const GDALExtendedDataType &dstType,
3383
                           GPtrDiff_t nDstStrideInElts, size_t nValues);
3384
3385
  private:
3386
    GDALExtendedDataType(size_t nMaxStringLength,
3387
                         GDALExtendedDataTypeSubType eSubType);
3388
    explicit GDALExtendedDataType(GDALDataType eType);
3389
    GDALExtendedDataType(const std::string &osName, GDALDataType eBaseType,
3390
                         std::unique_ptr<GDALRasterAttributeTable>);
3391
    GDALExtendedDataType(
3392
        const std::string &osName, size_t nTotalSize,
3393
        std::vector<std::unique_ptr<GDALEDTComponent>> &&components);
3394
3395
    std::string m_osName{};
3396
    GDALExtendedDataTypeClass m_eClass = GEDTC_NUMERIC;
3397
    GDALExtendedDataTypeSubType m_eSubType = GEDTST_NONE;
3398
    GDALDataType m_eNumericDT = GDT_Unknown;
3399
    std::vector<std::unique_ptr<GDALEDTComponent>> m_aoComponents{};
3400
    size_t m_nSize = 0;
3401
    size_t m_nMaxStringLength = 0;
3402
    std::unique_ptr<GDALRasterAttributeTable> m_poRAT{};
3403
};
3404
3405
/* ******************************************************************** */
3406
/*                            GDALEDTComponent                          */
3407
/* ******************************************************************** */
3408
3409
/**
3410
 * Class for a component of a compound extended data type.
3411
 *
3412
 * @since GDAL 3.1
3413
 */
3414
class CPL_DLL GDALEDTComponent
3415
{
3416
  public:
3417
    ~GDALEDTComponent();
3418
    GDALEDTComponent(const std::string &name, size_t offset,
3419
                     const GDALExtendedDataType &type);
3420
    GDALEDTComponent(const GDALEDTComponent &);
3421
3422
    bool operator==(const GDALEDTComponent &) const;
3423
3424
    /** Return the name.
3425
     *
3426
     * This is the same as the C function GDALEDTComponentGetName().
3427
     */
3428
    const std::string &GetName() const
3429
0
    {
3430
0
        return m_osName;
3431
0
    }
3432
3433
    /** Return the offset (in bytes) of the component in the compound data type.
3434
     *
3435
     * This is the same as the C function GDALEDTComponentGetOffset().
3436
     */
3437
    size_t GetOffset() const
3438
0
    {
3439
0
        return m_nOffset;
3440
0
    }
3441
3442
    /** Return the data type of the component.
3443
     *
3444
     * This is the same as the C function GDALEDTComponentGetType().
3445
     */
3446
    const GDALExtendedDataType &GetType() const
3447
0
    {
3448
0
        return m_oType;
3449
0
    }
3450
3451
  private:
3452
    std::string m_osName;
3453
    size_t m_nOffset;
3454
    GDALExtendedDataType m_oType;
3455
};
3456
3457
/* ******************************************************************** */
3458
/*                            GDALIHasAttribute                         */
3459
/* ******************************************************************** */
3460
3461
/**
3462
 * Interface used to get a single GDALAttribute or a set of GDALAttribute
3463
 *
3464
 * @since GDAL 3.1
3465
 */
3466
class CPL_DLL GDALIHasAttribute
3467
{
3468
  protected:
3469
    std::shared_ptr<GDALAttribute>
3470
    GetAttributeFromAttributes(const std::string &osName) const;
3471
3472
  public:
3473
    virtual ~GDALIHasAttribute();
3474
3475
    virtual std::shared_ptr<GDALAttribute>
3476
    GetAttribute(const std::string &osName) const;
3477
3478
    virtual std::vector<std::shared_ptr<GDALAttribute>>
3479
    GetAttributes(CSLConstList papszOptions = nullptr) const;
3480
3481
    virtual std::shared_ptr<GDALAttribute>
3482
    CreateAttribute(const std::string &osName,
3483
                    const std::vector<GUInt64> &anDimensions,
3484
                    const GDALExtendedDataType &oDataType,
3485
                    CSLConstList papszOptions = nullptr);
3486
3487
    virtual bool DeleteAttribute(const std::string &osName,
3488
                                 CSLConstList papszOptions = nullptr);
3489
};
3490
3491
/* ******************************************************************** */
3492
/*                               GDALGroup                              */
3493
/* ******************************************************************** */
3494
3495
/* clang-format off */
3496
/**
3497
 * Class modeling a named container of GDALAttribute, GDALMDArray, OGRLayer or
3498
 * other GDALGroup. Hence GDALGroup can describe a hierarchy of objects.
3499
 *
3500
 * This is based on the <a href="https://portal.opengeospatial.org/files/81716#_hdf5_group">HDF5 group
3501
 * concept</a>
3502
 *
3503
 * @since GDAL 3.1
3504
 */
3505
/* clang-format on */
3506
3507
class CPL_DLL GDALGroup : public GDALIHasAttribute
3508
{
3509
  protected:
3510
    //! @cond Doxygen_Suppress
3511
    std::string m_osName{};
3512
3513
    // This is actually a path of the form "/parent_path/{m_osName}"
3514
    std::string m_osFullName{};
3515
3516
    // Used for example by GDALSubsetGroup to distinguish a derived group
3517
    //from its original, without altering its name
3518
    const std::string m_osContext{};
3519
3520
    // List of types owned by the group.
3521
    std::vector<std::shared_ptr<GDALExtendedDataType>> m_apoTypes{};
3522
3523
    //! Weak pointer to this
3524
    std::weak_ptr<GDALGroup> m_pSelf{};
3525
3526
    //! Can be set to false by the owing group, when deleting this object
3527
    bool m_bValid = true;
3528
3529
    GDALGroup(const std::string &osParentName, const std::string &osName,
3530
              const std::string &osContext = std::string());
3531
3532
    const GDALGroup *
3533
    GetInnerMostGroup(const std::string &osPathOrArrayOrDim,
3534
                      std::shared_ptr<GDALGroup> &curGroupHolder,
3535
                      std::string &osLastPart) const;
3536
3537
    void BaseRename(const std::string &osNewName);
3538
3539
    bool CheckValidAndErrorOutIfNot() const;
3540
3541
    void SetSelf(const std::shared_ptr<GDALGroup> &self)
3542
0
    {
3543
0
        m_pSelf = self;
3544
0
    }
3545
3546
    virtual void NotifyChildrenOfRenaming()
3547
0
    {
3548
0
    }
3549
3550
    virtual void NotifyChildrenOfDeletion()
3551
0
    {
3552
0
    }
3553
3554
    //! @endcond
3555
3556
  public:
3557
    virtual ~GDALGroup();
3558
3559
    /** Return the name of the group.
3560
     *
3561
     * This is the same as the C function GDALGroupGetName().
3562
     */
3563
    const std::string &GetName() const
3564
0
    {
3565
0
        return m_osName;
3566
0
    }
3567
3568
    /** Return the full name of the group.
3569
     *
3570
     * This is the same as the C function GDALGroupGetFullName().
3571
     */
3572
    const std::string &GetFullName() const
3573
0
    {
3574
0
        return m_osFullName;
3575
0
    }
3576
3577
    /** Return data types associated with the group (typically enumerations)
3578
     *
3579
     * This is the same as the C function GDALGroupGetDataTypeCount() and GDALGroupGetDataType()
3580
     *
3581
     * @since 3.12
3582
     */
3583
    const std::vector<std::shared_ptr<GDALExtendedDataType>> &
3584
    GetDataTypes() const
3585
0
    {
3586
0
        return m_apoTypes;
3587
0
    }
3588
3589
    virtual std::vector<std::string>
3590
    GetMDArrayNames(CSLConstList papszOptions = nullptr) const;
3591
    virtual std::shared_ptr<GDALMDArray>
3592
    OpenMDArray(const std::string &osName,
3593
                CSLConstList papszOptions = nullptr) const;
3594
3595
    std::vector<std::string> GetMDArrayFullNamesRecursive(
3596
        CSLConstList papszGroupOptions = nullptr,
3597
        CSLConstList papszArrayOptions = nullptr) const;
3598
3599
    virtual std::vector<std::string>
3600
    GetGroupNames(CSLConstList papszOptions = nullptr) const;
3601
    virtual std::shared_ptr<GDALGroup>
3602
    OpenGroup(const std::string &osName,
3603
              CSLConstList papszOptions = nullptr) const;
3604
3605
    virtual std::vector<std::string>
3606
    GetVectorLayerNames(CSLConstList papszOptions = nullptr) const;
3607
    virtual OGRLayer *
3608
    OpenVectorLayer(const std::string &osName,
3609
                    CSLConstList papszOptions = nullptr) const;
3610
3611
    virtual std::vector<std::shared_ptr<GDALDimension>>
3612
    GetDimensions(CSLConstList papszOptions = nullptr) const;
3613
3614
    virtual std::shared_ptr<GDALGroup>
3615
    CreateGroup(const std::string &osName, CSLConstList papszOptions = nullptr);
3616
3617
    virtual bool DeleteGroup(const std::string &osName,
3618
                             CSLConstList papszOptions = nullptr);
3619
3620
    virtual std::shared_ptr<GDALDimension>
3621
    CreateDimension(const std::string &osName, const std::string &osType,
3622
                    const std::string &osDirection, GUInt64 nSize,
3623
                    CSLConstList papszOptions = nullptr);
3624
3625
    virtual std::shared_ptr<GDALMDArray> CreateMDArray(
3626
        const std::string &osName,
3627
        const std::vector<std::shared_ptr<GDALDimension>> &aoDimensions,
3628
        const GDALExtendedDataType &oDataType,
3629
        CSLConstList papszOptions = nullptr);
3630
3631
    virtual bool DeleteMDArray(const std::string &osName,
3632
                               CSLConstList papszOptions = nullptr);
3633
3634
    GUInt64 GetTotalCopyCost() const;
3635
3636
    virtual bool CopyFrom(const std::shared_ptr<GDALGroup> &poDstRootGroup,
3637
                          GDALDataset *poSrcDS,
3638
                          const std::shared_ptr<GDALGroup> &poSrcGroup,
3639
                          bool bStrict, GUInt64 &nCurCost,
3640
                          const GUInt64 nTotalCost,
3641
                          GDALProgressFunc pfnProgress, void *pProgressData,
3642
                          CSLConstList papszOptions = nullptr);
3643
3644
    virtual CSLConstList GetStructuralInfo() const;
3645
3646
    std::shared_ptr<GDALMDArray>
3647
    OpenMDArrayFromFullname(const std::string &osFullName,
3648
                            CSLConstList papszOptions = nullptr) const;
3649
3650
    std::shared_ptr<GDALAttribute>
3651
    OpenAttributeFromFullname(const std::string &osFullName,
3652
                              CSLConstList papszOptions = nullptr) const;
3653
3654
    std::shared_ptr<GDALMDArray>
3655
    ResolveMDArray(const std::string &osName, const std::string &osStartingPath,
3656
                   CSLConstList papszOptions = nullptr) const;
3657
3658
    std::shared_ptr<GDALGroup>
3659
    OpenGroupFromFullname(const std::string &osFullName,
3660
                          CSLConstList papszOptions = nullptr) const;
3661
3662
    std::shared_ptr<GDALDimension>
3663
    OpenDimensionFromFullname(const std::string &osFullName) const;
3664
3665
    virtual void ClearStatistics();
3666
3667
    virtual bool Rename(const std::string &osNewName);
3668
3669
    std::shared_ptr<GDALGroup>
3670
    SubsetDimensionFromSelection(const std::string &osSelection) const;
3671
3672
    //! @cond Doxygen_Suppress
3673
    virtual void ParentRenamed(const std::string &osNewParentFullName);
3674
3675
    virtual void Deleted();
3676
3677
    virtual void ParentDeleted();
3678
3679
    const std::string &GetContext() const
3680
0
    {
3681
0
        return m_osContext;
3682
0
    }
3683
3684
    //! @endcond
3685
3686
    //! @cond Doxygen_Suppress
3687
    static constexpr GUInt64 COPY_COST = 1000;
3688
    //! @endcond
3689
};
3690
3691
/* ******************************************************************** */
3692
/*                          GDALAbstractMDArray                         */
3693
/* ******************************************************************** */
3694
3695
/**
3696
 * Abstract class, implemented by GDALAttribute and GDALMDArray.
3697
 *
3698
 * @since GDAL 3.1
3699
 */
3700
class CPL_DLL GDALAbstractMDArray
3701
{
3702
  protected:
3703
    //! @cond Doxygen_Suppress
3704
    std::string m_osName{};
3705
3706
    // This is actually a path of the form "/parent_path/{m_osName}"
3707
    std::string m_osFullName{};
3708
    std::weak_ptr<GDALAbstractMDArray> m_pSelf{};
3709
3710
    //! Can be set to false by the owing object, when deleting this object
3711
    bool m_bValid = true;
3712
3713
    GDALAbstractMDArray(const std::string &osParentName,
3714
                        const std::string &osName);
3715
3716
    void SetSelf(const std::shared_ptr<GDALAbstractMDArray> &self)
3717
0
    {
3718
0
        m_pSelf = self;
3719
0
    }
3720
3721
    bool CheckValidAndErrorOutIfNot() const;
3722
3723
    bool CheckReadWriteParams(const GUInt64 *arrayStartIdx, const size_t *count,
3724
                              const GInt64 *&arrayStep,
3725
                              const GPtrDiff_t *&bufferStride,
3726
                              const GDALExtendedDataType &bufferDataType,
3727
                              const void *buffer,
3728
                              const void *buffer_alloc_start,
3729
                              size_t buffer_alloc_size,
3730
                              std::vector<GInt64> &tmp_arrayStep,
3731
                              std::vector<GPtrDiff_t> &tmp_bufferStride) const;
3732
3733
    virtual bool
3734
    IRead(const GUInt64 *arrayStartIdx,    // array of size GetDimensionCount()
3735
          const size_t *count,             // array of size GetDimensionCount()
3736
          const GInt64 *arrayStep,         // step in elements
3737
          const GPtrDiff_t *bufferStride,  // stride in elements
3738
          const GDALExtendedDataType &bufferDataType,
3739
          void *pDstBuffer) const = 0;
3740
3741
    virtual bool
3742
    IWrite(const GUInt64 *arrayStartIdx,    // array of size GetDimensionCount()
3743
           const size_t *count,             // array of size GetDimensionCount()
3744
           const GInt64 *arrayStep,         // step in elements
3745
           const GPtrDiff_t *bufferStride,  // stride in elements
3746
           const GDALExtendedDataType &bufferDataType, const void *pSrcBuffer);
3747
3748
    void BaseRename(const std::string &osNewName);
3749
3750
    virtual void NotifyChildrenOfRenaming()
3751
0
    {
3752
0
    }
3753
3754
    virtual void NotifyChildrenOfDeletion()
3755
0
    {
3756
0
    }
3757
3758
    //! @endcond
3759
3760
  public:
3761
    virtual ~GDALAbstractMDArray();
3762
3763
    /** Return the name of an array or attribute.
3764
     *
3765
     * This is the same as the C function GDALMDArrayGetName() or
3766
     * GDALAttributeGetName().
3767
     */
3768
    const std::string &GetName() const
3769
0
    {
3770
0
        return m_osName;
3771
0
    }
3772
3773
    /** Return the name of an array or attribute.
3774
     *
3775
     * This is the same as the C function GDALMDArrayGetFullName() or
3776
     * GDALAttributeGetFullName().
3777
     */
3778
    const std::string &GetFullName() const
3779
0
    {
3780
0
        return m_osFullName;
3781
0
    }
3782
3783
    GUInt64 GetTotalElementsCount() const;
3784
3785
    virtual size_t GetDimensionCount() const;
3786
3787
    virtual const std::vector<std::shared_ptr<GDALDimension>> &
3788
    GetDimensions() const = 0;
3789
3790
    virtual const GDALExtendedDataType &GetDataType() const = 0;
3791
3792
    virtual std::vector<GUInt64> GetBlockSize() const;
3793
3794
    virtual std::vector<size_t>
3795
    GetProcessingChunkSize(size_t nMaxChunkMemory) const;
3796
3797
    /* clang-format off */
3798
    /** Type of pfnFunc argument of ProcessPerChunk().
3799
     * @param array Array on which ProcessPerChunk was called.
3800
     * @param chunkArrayStartIdx Values representing the starting index to use
3801
     *                           in each dimension (in [0, aoDims[i].GetSize()-1] range)
3802
     *                           for the current chunk.
3803
     *                           Will be nullptr for a zero-dimensional array.
3804
     * @param chunkCount         Values representing the number of values to use in
3805
     *                           each dimension for the current chunk.
3806
     *                           Will be nullptr for a zero-dimensional array.
3807
     * @param iCurChunk          Number of current chunk being processed.
3808
     *                           In [1, nChunkCount] range.
3809
     * @param nChunkCount        Total number of chunks to process.
3810
     * @param pUserData          User data.
3811
     * @return return true in case of success.
3812
     */
3813
    typedef bool (*FuncProcessPerChunkType)(
3814
                        GDALAbstractMDArray *array,
3815
                        const GUInt64 *chunkArrayStartIdx,
3816
                        const size_t *chunkCount,
3817
                        GUInt64 iCurChunk,
3818
                        GUInt64 nChunkCount,
3819
                        void *pUserData);
3820
    /* clang-format on */
3821
3822
    virtual bool ProcessPerChunk(const GUInt64 *arrayStartIdx,
3823
                                 const GUInt64 *count, const size_t *chunkSize,
3824
                                 FuncProcessPerChunkType pfnFunc,
3825
                                 void *pUserData);
3826
3827
    virtual bool
3828
    Read(const GUInt64 *arrayStartIdx,    // array of size GetDimensionCount()
3829
         const size_t *count,             // array of size GetDimensionCount()
3830
         const GInt64 *arrayStep,         // step in elements
3831
         const GPtrDiff_t *bufferStride,  // stride in elements
3832
         const GDALExtendedDataType &bufferDataType, void *pDstBuffer,
3833
         const void *pDstBufferAllocStart = nullptr,
3834
         size_t nDstBufferAllocSize = 0) const;
3835
3836
    bool
3837
    Write(const GUInt64 *arrayStartIdx,    // array of size GetDimensionCount()
3838
          const size_t *count,             // array of size GetDimensionCount()
3839
          const GInt64 *arrayStep,         // step in elements
3840
          const GPtrDiff_t *bufferStride,  // stride in elements
3841
          const GDALExtendedDataType &bufferDataType, const void *pSrcBuffer,
3842
          const void *pSrcBufferAllocStart = nullptr,
3843
          size_t nSrcBufferAllocSize = 0);
3844
3845
    virtual bool Rename(const std::string &osNewName);
3846
3847
    //! @cond Doxygen_Suppress
3848
    virtual void Deleted();
3849
3850
    virtual void ParentDeleted();
3851
3852
    virtual void ParentRenamed(const std::string &osNewParentFullName);
3853
    //! @endcond
3854
};
3855
3856
/* ******************************************************************** */
3857
/*                              GDALRawResult                           */
3858
/* ******************************************************************** */
3859
3860
/**
3861
 * Store the raw result of an attribute value, which might contain dynamically
3862
 * allocated structures (like pointer to strings).
3863
 *
3864
 * @since GDAL 3.1
3865
 */
3866
class CPL_DLL GDALRawResult
3867
{
3868
  private:
3869
    GDALExtendedDataType m_dt;
3870
    size_t m_nEltCount;
3871
    size_t m_nSize;
3872
    GByte *m_raw;
3873
3874
    void FreeMe();
3875
3876
    GDALRawResult(const GDALRawResult &) = delete;
3877
    GDALRawResult &operator=(const GDALRawResult &) = delete;
3878
3879
  protected:
3880
    friend class GDALAttribute;
3881
    //! @cond Doxygen_Suppress
3882
    GDALRawResult(GByte *raw, const GDALExtendedDataType &dt, size_t nEltCount);
3883
    //! @endcond
3884
3885
  public:
3886
    ~GDALRawResult();
3887
    GDALRawResult(GDALRawResult &&);
3888
    GDALRawResult &operator=(GDALRawResult &&);
3889
3890
    /** Return byte at specified index. */
3891
    const GByte &operator[](size_t idx) const
3892
0
    {
3893
0
        return m_raw[idx];
3894
0
    }
3895
3896
    /** Return pointer to the start of data. */
3897
    const GByte *data() const
3898
0
    {
3899
0
        return m_raw;
3900
0
    }
3901
3902
    /** Return the size in bytes of the raw result. */
3903
    size_t size() const
3904
0
    {
3905
0
        return m_nSize;
3906
0
    }
3907
3908
    //! @cond Doxygen_Suppress
3909
    GByte *StealData();
3910
    //! @endcond
3911
};
3912
3913
/* ******************************************************************** */
3914
/*                              GDALAttribute                           */
3915
/* ******************************************************************** */
3916
3917
/* clang-format off */
3918
/**
3919
 * Class modeling an attribute that has a name, a value and a type, and is
3920
 * typically used to describe a metadata item. The value can be (for the
3921
 * HDF5 format) in the general case a multidimensional array of "any" type
3922
 * (in most cases, this will be a single value of string or numeric type)
3923
 *
3924
 * This is based on the <a href="https://portal.opengeospatial.org/files/81716#_hdf5_attribute">HDF5
3925
 * attribute concept</a>
3926
 *
3927
 * @since GDAL 3.1
3928
 */
3929
/* clang-format on */
3930
3931
class CPL_DLL GDALAttribute : virtual public GDALAbstractMDArray
3932
{
3933
    mutable std::string m_osCachedVal{};
3934
3935
  protected:
3936
    //! @cond Doxygen_Suppress
3937
    GDALAttribute(const std::string &osParentName, const std::string &osName);
3938
    //! @endcond
3939
3940
  public:
3941
    //! @cond Doxygen_Suppress
3942
    ~GDALAttribute();
3943
    //! @endcond
3944
3945
    std::vector<GUInt64> GetDimensionsSize() const;
3946
3947
    GDALRawResult ReadAsRaw() const;
3948
    const char *ReadAsString() const;
3949
    int ReadAsInt() const;
3950
    int64_t ReadAsInt64() const;
3951
    double ReadAsDouble() const;
3952
    CPLStringList ReadAsStringArray() const;
3953
    std::vector<int> ReadAsIntArray() const;
3954
    std::vector<int64_t> ReadAsInt64Array() const;
3955
    std::vector<double> ReadAsDoubleArray() const;
3956
3957
    using GDALAbstractMDArray::Write;
3958
    bool Write(const void *pabyValue, size_t nLen);
3959
    bool Write(const char *);
3960
    bool WriteInt(int);
3961
    bool WriteInt64(int64_t);
3962
    bool Write(double);
3963
    bool Write(CSLConstList);
3964
    bool Write(const int *, size_t);
3965
    bool Write(const int64_t *, size_t);
3966
    bool Write(const double *, size_t);
3967
3968
    //! @cond Doxygen_Suppress
3969
    static constexpr GUInt64 COPY_COST = 100;
3970
    //! @endcond
3971
};
3972
3973
/************************************************************************/
3974
/*                            GDALAttributeString                       */
3975
/************************************************************************/
3976
3977
//! @cond Doxygen_Suppress
3978
class CPL_DLL GDALAttributeString final : public GDALAttribute
3979
{
3980
    std::vector<std::shared_ptr<GDALDimension>> m_dims{};
3981
    GDALExtendedDataType m_dt = GDALExtendedDataType::CreateString();
3982
    std::string m_osValue;
3983
3984
  protected:
3985
    bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
3986
               const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
3987
               void *pDstBuffer) const override;
3988
3989
  public:
3990
    GDALAttributeString(const std::string &osParentName,
3991
                        const std::string &osName, const std::string &osValue,
3992
                        GDALExtendedDataTypeSubType eSubType = GEDTST_NONE);
3993
3994
    const std::vector<std::shared_ptr<GDALDimension>> &
3995
    GetDimensions() const override;
3996
3997
    const GDALExtendedDataType &GetDataType() const override;
3998
};
3999
4000
//! @endcond
4001
4002
/************************************************************************/
4003
/*                           GDALAttributeNumeric                       */
4004
/************************************************************************/
4005
4006
//! @cond Doxygen_Suppress
4007
class CPL_DLL GDALAttributeNumeric final : public GDALAttribute
4008
{
4009
    std::vector<std::shared_ptr<GDALDimension>> m_dims{};
4010
    GDALExtendedDataType m_dt;
4011
    int m_nValue = 0;
4012
    double m_dfValue = 0;
4013
    std::vector<GUInt32> m_anValuesUInt32{};
4014
4015
  protected:
4016
    bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
4017
               const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
4018
               void *pDstBuffer) const override;
4019
4020
  public:
4021
    GDALAttributeNumeric(const std::string &osParentName,
4022
                         const std::string &osName, double dfValue);
4023
    GDALAttributeNumeric(const std::string &osParentName,
4024
                         const std::string &osName, int nValue);
4025
    GDALAttributeNumeric(const std::string &osParentName,
4026
                         const std::string &osName,
4027
                         const std::vector<GUInt32> &anValues);
4028
4029
    const std::vector<std::shared_ptr<GDALDimension>> &
4030
    GetDimensions() const override;
4031
4032
    const GDALExtendedDataType &GetDataType() const override;
4033
};
4034
4035
//! @endcond
4036
4037
/* ******************************************************************** */
4038
/*                              GDALMDArray                             */
4039
/* ******************************************************************** */
4040
4041
/* clang-format off */
4042
/**
4043
 * Class modeling a multi-dimensional array. It has a name, values organized
4044
 * as an array and a list of GDALAttribute.
4045
 *
4046
 * This is based on the <a href="https://portal.opengeospatial.org/files/81716#_hdf5_dataset">HDF5
4047
 * dataset concept</a>
4048
 *
4049
 * @since GDAL 3.1
4050
 */
4051
/* clang-format on */
4052
4053
class CPL_DLL GDALMDArray : virtual public GDALAbstractMDArray,
4054
                            public GDALIHasAttribute
4055
{
4056
    friend class GDALMDArrayResampled;
4057
    std::shared_ptr<GDALMDArray>
4058
    GetView(const std::vector<GUInt64> &indices) const;
4059
4060
    inline std::shared_ptr<GDALMDArray>
4061
    atInternal(const std::vector<GUInt64> &indices) const
4062
0
    {
4063
0
        return GetView(indices);
4064
0
    }
4065
4066
    template <typename... GUInt64VarArg>
4067
    // cppcheck-suppress functionStatic
4068
    inline std::shared_ptr<GDALMDArray>
4069
    atInternal(std::vector<GUInt64> &indices, GUInt64 idx,
4070
               GUInt64VarArg... tail) const
4071
    {
4072
        indices.push_back(idx);
4073
        return atInternal(indices, tail...);
4074
    }
4075
4076
    // Used for example by GDALSubsetGroup to distinguish a derived group
4077
    //from its original, without altering its name
4078
    const std::string m_osContext{};
4079
4080
    mutable bool m_bHasTriedCachedArray = false;
4081
    mutable std::shared_ptr<GDALMDArray> m_poCachedArray{};
4082
4083
  protected:
4084
    //! @cond Doxygen_Suppress
4085
    GDALMDArray(const std::string &osParentName, const std::string &osName,
4086
                const std::string &osContext = std::string());
4087
4088
    virtual bool IAdviseRead(const GUInt64 *arrayStartIdx, const size_t *count,
4089
                             CSLConstList papszOptions) const;
4090
4091
    virtual bool IsCacheable() const
4092
0
    {
4093
0
        return true;
4094
0
    }
4095
4096
    virtual bool SetStatistics(bool bApproxStats, double dfMin, double dfMax,
4097
                               double dfMean, double dfStdDev,
4098
                               GUInt64 nValidCount, CSLConstList papszOptions);
4099
4100
    static std::string MassageName(const std::string &inputName);
4101
4102
    std::shared_ptr<GDALGroup>
4103
    GetCacheRootGroup(bool bCanCreate, std::string &osCacheFilenameOut) const;
4104
4105
    // Returns if bufferStride values express a transposed view of the array
4106
    bool IsTransposedRequest(const size_t *count,
4107
                             const GPtrDiff_t *bufferStride) const;
4108
4109
    // Should only be called if IsTransposedRequest() returns true
4110
    bool ReadForTransposedRequest(const GUInt64 *arrayStartIdx,
4111
                                  const size_t *count, const GInt64 *arrayStep,
4112
                                  const GPtrDiff_t *bufferStride,
4113
                                  const GDALExtendedDataType &bufferDataType,
4114
                                  void *pDstBuffer) const;
4115
4116
    bool IsStepOneContiguousRowMajorOrderedSameDataType(
4117
        const size_t *count, const GInt64 *arrayStep,
4118
        const GPtrDiff_t *bufferStride,
4119
        const GDALExtendedDataType &bufferDataType) const;
4120
4121
    // Should only be called if IsStepOneContiguousRowMajorOrderedSameDataType()
4122
    // returns false
4123
    bool ReadUsingContiguousIRead(const GUInt64 *arrayStartIdx,
4124
                                  const size_t *count, const GInt64 *arrayStep,
4125
                                  const GPtrDiff_t *bufferStride,
4126
                                  const GDALExtendedDataType &bufferDataType,
4127
                                  void *pDstBuffer) const;
4128
4129
    static std::shared_ptr<GDALMDArray> CreateGLTOrthorectified(
4130
        const std::shared_ptr<GDALMDArray> &poParent,
4131
        const std::shared_ptr<GDALGroup> &poRootGroup,
4132
        const std::shared_ptr<GDALMDArray> &poGLTX,
4133
        const std::shared_ptr<GDALMDArray> &poGLTY, int nGLTIndexOffset,
4134
        const std::vector<double> &adfGeoTransform, CSLConstList papszOptions);
4135
4136
    //! @endcond
4137
4138
  public:
4139
    GUInt64 GetTotalCopyCost() const;
4140
4141
    virtual bool CopyFrom(GDALDataset *poSrcDS, const GDALMDArray *poSrcArray,
4142
                          bool bStrict, GUInt64 &nCurCost,
4143
                          const GUInt64 nTotalCost,
4144
                          GDALProgressFunc pfnProgress, void *pProgressData);
4145
4146
    /** Return whether an array is writable. */
4147
    virtual bool IsWritable() const = 0;
4148
4149
    /** Return the filename that contains that array.
4150
     *
4151
     * This is used in particular for caching.
4152
     *
4153
     * Might be empty if the array is not linked to a file.
4154
     *
4155
     * @since GDAL 3.4
4156
     */
4157
    virtual const std::string &GetFilename() const = 0;
4158
4159
    virtual CSLConstList GetStructuralInfo() const;
4160
4161
    virtual const std::string &GetUnit() const;
4162
4163
    virtual bool SetUnit(const std::string &osUnit);
4164
4165
    virtual bool SetSpatialRef(const OGRSpatialReference *poSRS);
4166
4167
    virtual std::shared_ptr<OGRSpatialReference> GetSpatialRef() const;
4168
4169
    virtual const void *GetRawNoDataValue() const;
4170
4171
    double GetNoDataValueAsDouble(bool *pbHasNoData = nullptr) const;
4172
4173
    int64_t GetNoDataValueAsInt64(bool *pbHasNoData = nullptr) const;
4174
4175
    uint64_t GetNoDataValueAsUInt64(bool *pbHasNoData = nullptr) const;
4176
4177
    virtual bool SetRawNoDataValue(const void *pRawNoData);
4178
4179
    //! @cond Doxygen_Suppress
4180
    bool SetNoDataValue(int nNoData)
4181
0
    {
4182
0
        return SetNoDataValue(static_cast<int64_t>(nNoData));
4183
0
    }
4184
4185
    //! @endcond
4186
4187
    bool SetNoDataValue(double dfNoData);
4188
4189
    bool SetNoDataValue(int64_t nNoData);
4190
4191
    bool SetNoDataValue(uint64_t nNoData);
4192
4193
    virtual bool Resize(const std::vector<GUInt64> &anNewDimSizes,
4194
                        CSLConstList papszOptions);
4195
4196
    virtual double GetOffset(bool *pbHasOffset = nullptr,
4197
                             GDALDataType *peStorageType = nullptr) const;
4198
4199
    virtual double GetScale(bool *pbHasScale = nullptr,
4200
                            GDALDataType *peStorageType = nullptr) const;
4201
4202
    virtual bool SetOffset(double dfOffset,
4203
                           GDALDataType eStorageType = GDT_Unknown);
4204
4205
    virtual bool SetScale(double dfScale,
4206
                          GDALDataType eStorageType = GDT_Unknown);
4207
4208
    std::shared_ptr<GDALMDArray> GetView(const std::string &viewExpr) const;
4209
4210
    std::shared_ptr<GDALMDArray> operator[](const std::string &fieldName) const;
4211
4212
    /** Return a view of the array using integer indexing.
4213
     *
4214
     * Equivalent of GetView("[indices_0,indices_1,.....,indices_last]")
4215
     *
4216
     * Example:
4217
     * \code
4218
     * ar->at(0,3,2)
4219
     * \endcode
4220
     */
4221
    // sphinx 4.1.0 / breathe 4.30.0 don't like typename...
4222
    //! @cond Doxygen_Suppress
4223
    template <typename... GUInt64VarArg>
4224
    //! @endcond
4225
    // cppcheck-suppress functionStatic
4226
    std::shared_ptr<GDALMDArray> at(GUInt64 idx, GUInt64VarArg... tail) const
4227
    {
4228
        std::vector<GUInt64> indices;
4229
        indices.push_back(idx);
4230
        return atInternal(indices, tail...);
4231
    }
4232
4233
    virtual std::shared_ptr<GDALMDArray>
4234
    Transpose(const std::vector<int> &anMapNewAxisToOldAxis) const;
4235
4236
    std::shared_ptr<GDALMDArray> GetUnscaled(
4237
        double dfOverriddenScale = std::numeric_limits<double>::quiet_NaN(),
4238
        double dfOverriddenOffset = std::numeric_limits<double>::quiet_NaN(),
4239
        double dfOverriddenDstNodata =
4240
            std::numeric_limits<double>::quiet_NaN()) const;
4241
4242
    virtual std::shared_ptr<GDALMDArray>
4243
    GetMask(CSLConstList papszOptions) const;
4244
4245
    virtual std::shared_ptr<GDALMDArray>
4246
    GetResampled(const std::vector<std::shared_ptr<GDALDimension>> &apoNewDims,
4247
                 GDALRIOResampleAlg resampleAlg,
4248
                 const OGRSpatialReference *poTargetSRS,
4249
                 CSLConstList papszOptions) const;
4250
4251
    std::shared_ptr<GDALMDArray>
4252
    GetGridded(const std::string &osGridOptions,
4253
               const std::shared_ptr<GDALMDArray> &poXArray = nullptr,
4254
               const std::shared_ptr<GDALMDArray> &poYArray = nullptr,
4255
               CSLConstList papszOptions = nullptr) const;
4256
4257
    static std::vector<std::shared_ptr<GDALMDArray>>
4258
    GetMeshGrid(const std::vector<std::shared_ptr<GDALMDArray>> &apoArrays,
4259
                CSLConstList papszOptions = nullptr);
4260
4261
    virtual GDALDataset *
4262
    AsClassicDataset(size_t iXDim, size_t iYDim,
4263
                     const std::shared_ptr<GDALGroup> &poRootGroup = nullptr,
4264
                     CSLConstList papszOptions = nullptr) const;
4265
4266
    virtual CPLErr GetStatistics(bool bApproxOK, bool bForce, double *pdfMin,
4267
                                 double *pdfMax, double *pdfMean,
4268
                                 double *padfStdDev, GUInt64 *pnValidCount,
4269
                                 GDALProgressFunc pfnProgress,
4270
                                 void *pProgressData);
4271
4272
    virtual bool ComputeStatistics(bool bApproxOK, double *pdfMin,
4273
                                   double *pdfMax, double *pdfMean,
4274
                                   double *pdfStdDev, GUInt64 *pnValidCount,
4275
                                   GDALProgressFunc, void *pProgressData,
4276
                                   CSLConstList papszOptions);
4277
4278
    virtual void ClearStatistics();
4279
4280
    virtual std::vector<std::shared_ptr<GDALMDArray>>
4281
    GetCoordinateVariables() const;
4282
4283
    bool AdviseRead(const GUInt64 *arrayStartIdx, const size_t *count,
4284
                    CSLConstList papszOptions = nullptr) const;
4285
4286
    bool IsRegularlySpaced(double &dfStart, double &dfIncrement) const;
4287
4288
    bool GuessGeoTransform(size_t nDimX, size_t nDimY, bool bPixelIsPoint,
4289
                           double adfGeoTransform[6]) const;
4290
4291
    bool Cache(CSLConstList papszOptions = nullptr) const;
4292
4293
    bool
4294
    Read(const GUInt64 *arrayStartIdx,    // array of size GetDimensionCount()
4295
         const size_t *count,             // array of size GetDimensionCount()
4296
         const GInt64 *arrayStep,         // step in elements
4297
         const GPtrDiff_t *bufferStride,  // stride in elements
4298
         const GDALExtendedDataType &bufferDataType, void *pDstBuffer,
4299
         const void *pDstBufferAllocStart = nullptr,
4300
         size_t nDstBufferAllocSize = 0) const override final;
4301
4302
    virtual std::shared_ptr<GDALGroup> GetRootGroup() const;
4303
4304
    //! @cond Doxygen_Suppress
4305
    static constexpr GUInt64 COPY_COST = 1000;
4306
4307
    bool CopyFromAllExceptValues(const GDALMDArray *poSrcArray, bool bStrict,
4308
                                 GUInt64 &nCurCost, const GUInt64 nTotalCost,
4309
                                 GDALProgressFunc pfnProgress,
4310
                                 void *pProgressData);
4311
4312
    struct Range
4313
    {
4314
        GUInt64 m_nStartIdx;
4315
        GInt64 m_nIncr;
4316
4317
        explicit Range(GUInt64 nStartIdx = 0, GInt64 nIncr = 0)
4318
0
            : m_nStartIdx(nStartIdx), m_nIncr(nIncr)
4319
0
        {
4320
0
        }
4321
    };
4322
4323
    struct ViewSpec
4324
    {
4325
        std::string m_osFieldName{};
4326
4327
        // or
4328
4329
        std::vector<size_t>
4330
            m_mapDimIdxToParentDimIdx{};  // of size m_dims.size()
4331
        std::vector<Range>
4332
            m_parentRanges{};  // of size m_poParent->GetDimensionCount()
4333
    };
4334
4335
    virtual std::shared_ptr<GDALMDArray>
4336
    GetView(const std::string &viewExpr, bool bRenameDimensions,
4337
            std::vector<ViewSpec> &viewSpecs) const;
4338
4339
    const std::string &GetContext() const
4340
0
    {
4341
0
        return m_osContext;
4342
0
    }
4343
4344
    //! @endcond
4345
};
4346
4347
//! @cond Doxygen_Suppress
4348
bool GDALMDRasterIOFromBand(GDALRasterBand *poBand, GDALRWFlag eRWFlag,
4349
                            size_t iDimX, size_t iDimY,
4350
                            const GUInt64 *arrayStartIdx, const size_t *count,
4351
                            const GInt64 *arrayStep,
4352
                            const GPtrDiff_t *bufferStride,
4353
                            const GDALExtendedDataType &bufferDataType,
4354
                            void *pBuffer);
4355
4356
//! @endcond
4357
4358
/************************************************************************/
4359
/*                     GDALMDArrayRegularlySpaced                       */
4360
/************************************************************************/
4361
4362
//! @cond Doxygen_Suppress
4363
class CPL_DLL GDALMDArrayRegularlySpaced : public GDALMDArray
4364
{
4365
    double m_dfStart;
4366
    double m_dfIncrement;
4367
    double m_dfOffsetInIncrement;
4368
    GDALExtendedDataType m_dt = GDALExtendedDataType::Create(GDT_Float64);
4369
    std::vector<std::shared_ptr<GDALDimension>> m_dims;
4370
    std::vector<std::shared_ptr<GDALAttribute>> m_attributes{};
4371
    std::string m_osEmptyFilename{};
4372
4373
  protected:
4374
    bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
4375
               const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
4376
               void *pDstBuffer) const override;
4377
4378
  public:
4379
    GDALMDArrayRegularlySpaced(const std::string &osParentName,
4380
                               const std::string &osName,
4381
                               const std::shared_ptr<GDALDimension> &poDim,
4382
                               double dfStart, double dfIncrement,
4383
                               double dfOffsetInIncrement);
4384
4385
    static std::shared_ptr<GDALMDArrayRegularlySpaced>
4386
    Create(const std::string &osParentName, const std::string &osName,
4387
           const std::shared_ptr<GDALDimension> &poDim, double dfStart,
4388
           double dfIncrement, double dfOffsetInIncrement);
4389
4390
    bool IsWritable() const override
4391
0
    {
4392
0
        return false;
4393
0
    }
4394
4395
    const std::string &GetFilename() const override
4396
0
    {
4397
0
        return m_osEmptyFilename;
4398
0
    }
4399
4400
    const std::vector<std::shared_ptr<GDALDimension>> &
4401
    GetDimensions() const override;
4402
4403
    const GDALExtendedDataType &GetDataType() const override;
4404
4405
    std::vector<std::shared_ptr<GDALAttribute>>
4406
        GetAttributes(CSLConstList) const override;
4407
4408
    void AddAttribute(const std::shared_ptr<GDALAttribute> &poAttr);
4409
};
4410
4411
//! @endcond
4412
4413
/* ******************************************************************** */
4414
/*                            GDALDimension                             */
4415
/* ******************************************************************** */
4416
4417
/**
4418
 * Class modeling a a dimension / axis used to index multidimensional arrays.
4419
 * It has a name, a size (that is the number of values that can be indexed along
4420
 * the dimension), a type (see GDALDimension::GetType()), a direction
4421
 * (see GDALDimension::GetDirection()), a unit and can optionally point to a
4422
 * GDALMDArray variable, typically one-dimensional, describing the values taken
4423
 * by the dimension. For a georeferenced GDALMDArray and its X dimension, this
4424
 * will be typically the values of the easting/longitude for each grid point.
4425
 *
4426
 * @since GDAL 3.1
4427
 */
4428
class CPL_DLL GDALDimension
4429
{
4430
  public:
4431
    //! @cond Doxygen_Suppress
4432
    GDALDimension(const std::string &osParentName, const std::string &osName,
4433
                  const std::string &osType, const std::string &osDirection,
4434
                  GUInt64 nSize);
4435
    //! @endcond
4436
4437
    virtual ~GDALDimension();
4438
4439
    /** Return the name.
4440
     *
4441
     * This is the same as the C function GDALDimensionGetName()
4442
     */
4443
    const std::string &GetName() const
4444
0
    {
4445
0
        return m_osName;
4446
0
    }
4447
4448
    /** Return the full name.
4449
     *
4450
     * This is the same as the C function GDALDimensionGetFullName()
4451
     */
4452
    const std::string &GetFullName() const
4453
0
    {
4454
0
        return m_osFullName;
4455
0
    }
4456
4457
    /** Return the axis type.
4458
     *
4459
     * Predefined values are:
4460
     * HORIZONTAL_X, HORIZONTAL_Y, VERTICAL, TEMPORAL, PARAMETRIC
4461
     * Other values might be returned. Empty value means unknown.
4462
     *
4463
     * This is the same as the C function GDALDimensionGetType()
4464
     */
4465
    const std::string &GetType() const
4466
0
    {
4467
0
        return m_osType;
4468
0
    }
4469
4470
    /** Return the axis direction.
4471
     *
4472
     * Predefined values are:
4473
     * EAST, WEST, SOUTH, NORTH, UP, DOWN, FUTURE, PAST
4474
     * Other values might be returned. Empty value means unknown.
4475
     *
4476
     * This is the same as the C function GDALDimensionGetDirection()
4477
     */
4478
    const std::string &GetDirection() const
4479
0
    {
4480
0
        return m_osDirection;
4481
0
    }
4482
4483
    /** Return the size, that is the number of values along the dimension.
4484
     *
4485
     * This is the same as the C function GDALDimensionGetSize()
4486
     */
4487
    GUInt64 GetSize() const
4488
0
    {
4489
0
        return m_nSize;
4490
0
    }
4491
4492
    virtual std::shared_ptr<GDALMDArray> GetIndexingVariable() const;
4493
4494
    virtual bool
4495
    SetIndexingVariable(std::shared_ptr<GDALMDArray> poIndexingVariable);
4496
4497
    virtual bool Rename(const std::string &osNewName);
4498
4499
    //! @cond Doxygen_Suppress
4500
    virtual void ParentRenamed(const std::string &osNewParentFullName);
4501
4502
    virtual void ParentDeleted();
4503
    //! @endcond
4504
4505
  protected:
4506
    //! @cond Doxygen_Suppress
4507
    std::string m_osName;
4508
    std::string m_osFullName;
4509
    std::string m_osType;
4510
    std::string m_osDirection;
4511
    GUInt64 m_nSize;
4512
4513
    void BaseRename(const std::string &osNewName);
4514
4515
    //! @endcond
4516
};
4517
4518
/************************************************************************/
4519
/*                   GDALDimensionWeakIndexingVar()                     */
4520
/************************************************************************/
4521
4522
//! @cond Doxygen_Suppress
4523
class CPL_DLL GDALDimensionWeakIndexingVar : public GDALDimension
4524
{
4525
    std::weak_ptr<GDALMDArray> m_poIndexingVariable{};
4526
4527
  public:
4528
    GDALDimensionWeakIndexingVar(const std::string &osParentName,
4529
                                 const std::string &osName,
4530
                                 const std::string &osType,
4531
                                 const std::string &osDirection, GUInt64 nSize);
4532
4533
    std::shared_ptr<GDALMDArray> GetIndexingVariable() const override;
4534
4535
    bool SetIndexingVariable(
4536
        std::shared_ptr<GDALMDArray> poIndexingVariable) override;
4537
4538
    void SetSize(GUInt64 nNewSize);
4539
};
4540
//! @endcond
4541
4542
/************************************************************************/
4543
/*                       GDALAntiRecursionGuard                         */
4544
/************************************************************************/
4545
4546
//! @cond Doxygen_Suppress
4547
struct GDALAntiRecursionStruct;
4548
4549
class GDALAntiRecursionGuard
4550
{
4551
    GDALAntiRecursionStruct *m_psAntiRecursionStruct;
4552
    std::string m_osIdentifier;
4553
    int m_nDepth;
4554
4555
    GDALAntiRecursionGuard(const GDALAntiRecursionGuard &) = delete;
4556
    GDALAntiRecursionGuard &operator=(const GDALAntiRecursionGuard &) = delete;
4557
4558
  public:
4559
    explicit GDALAntiRecursionGuard(const std::string &osIdentifier);
4560
    GDALAntiRecursionGuard(const GDALAntiRecursionGuard &other,
4561
                           const std::string &osIdentifier);
4562
    ~GDALAntiRecursionGuard();
4563
4564
    int GetCallDepth() const
4565
0
    {
4566
0
        return m_nDepth;
4567
0
    }
4568
};
4569
4570
//! @endcond
4571
4572
/************************************************************************/
4573
/*                           Relationships                              */
4574
/************************************************************************/
4575
4576
/**
4577
 * Definition of a table relationship.
4578
 *
4579
 * GDALRelationship describes the relationship between two tables, including
4580
 * properties such as the cardinality of the relationship and the participating
4581
 * tables.
4582
 *
4583
 * Not all relationship properties are supported by all data formats.
4584
 *
4585
 * @since GDAL 3.6
4586
 */
4587
class CPL_DLL GDALRelationship
4588
{
4589
  protected:
4590
    /*! @cond Doxygen_Suppress */
4591
    std::string m_osName{};
4592
    std::string m_osLeftTableName{};
4593
    std::string m_osRightTableName{};
4594
    GDALRelationshipCardinality m_eCardinality =
4595
        GDALRelationshipCardinality::GRC_ONE_TO_MANY;
4596
    std::string m_osMappingTableName{};
4597
    std::vector<std::string> m_osListLeftTableFields{};
4598
    std::vector<std::string> m_osListRightTableFields{};
4599
    std::vector<std::string> m_osListLeftMappingTableFields{};
4600
    std::vector<std::string> m_osListRightMappingTableFields{};
4601
    GDALRelationshipType m_eType = GDALRelationshipType::GRT_ASSOCIATION;
4602
    std::string m_osForwardPathLabel{};
4603
    std::string m_osBackwardPathLabel{};
4604
    std::string m_osRelatedTableType{};
4605
4606
    /*! @endcond */
4607
4608
  public:
4609
    /**
4610
     * Constructor for a relationship between two tables.
4611
     * @param osName relationship name
4612
     * @param osLeftTableName left table name
4613
     * @param osRightTableName right table name
4614
     * @param eCardinality cardinality of relationship
4615
     */
4616
    GDALRelationship(const std::string &osName,
4617
                     const std::string &osLeftTableName,
4618
                     const std::string &osRightTableName,
4619
                     GDALRelationshipCardinality eCardinality =
4620
                         GDALRelationshipCardinality::GRC_ONE_TO_MANY)
4621
        : m_osName(osName), m_osLeftTableName(osLeftTableName),
4622
          m_osRightTableName(osRightTableName), m_eCardinality(eCardinality)
4623
0
    {
4624
0
    }
4625
4626
    /** Get the name of the relationship */
4627
    const std::string &GetName() const
4628
0
    {
4629
0
        return m_osName;
4630
0
    }
4631
4632
    /** Get the cardinality of the relationship */
4633
    GDALRelationshipCardinality GetCardinality() const
4634
0
    {
4635
0
        return m_eCardinality;
4636
0
    }
4637
4638
    /** Get the name of the left (or base/origin) table in the relationship.
4639
     *
4640
     * @see GetRightTableName()
4641
     */
4642
    const std::string &GetLeftTableName() const
4643
0
    {
4644
0
        return m_osLeftTableName;
4645
0
    }
4646
4647
    /** Get the name of the right (or related/destination) table in the
4648
     * relationship */
4649
    const std::string &GetRightTableName() const
4650
0
    {
4651
0
        return m_osRightTableName;
4652
0
    }
4653
4654
    /** Get the name of the mapping table for many-to-many relationships.
4655
     *
4656
     * @see SetMappingTableName()
4657
     */
4658
    const std::string &GetMappingTableName() const
4659
0
    {
4660
0
        return m_osMappingTableName;
4661
0
    }
4662
4663
    /** Sets the name of the mapping table for many-to-many relationships.
4664
     *
4665
     * @see GetMappingTableName()
4666
     */
4667
    void SetMappingTableName(const std::string &osName)
4668
0
    {
4669
0
        m_osMappingTableName = osName;
4670
0
    }
4671
4672
    /** Get the names of the participating fields from the left table in the
4673
     * relationship.
4674
     *
4675
     * @see GetRightTableFields()
4676
     * @see SetLeftTableFields()
4677
     */
4678
    const std::vector<std::string> &GetLeftTableFields() const
4679
0
    {
4680
0
        return m_osListLeftTableFields;
4681
0
    }
4682
4683
    /** Get the names of the participating fields from the right table in the
4684
     * relationship.
4685
     *
4686
     * @see GetLeftTableFields()
4687
     * @see SetRightTableFields()
4688
     */
4689
    const std::vector<std::string> &GetRightTableFields() const
4690
0
    {
4691
0
        return m_osListRightTableFields;
4692
0
    }
4693
4694
    /** Sets the names of the participating fields from the left table in the
4695
     * relationship.
4696
     *
4697
     * @see GetLeftTableFields()
4698
     * @see SetRightTableFields()
4699
     */
4700
    void SetLeftTableFields(const std::vector<std::string> &osListFields)
4701
0
    {
4702
0
        m_osListLeftTableFields = osListFields;
4703
0
    }
4704
4705
    /** Sets the names of the participating fields from the right table in the
4706
     * relationship.
4707
     *
4708
     * @see GetRightTableFields()
4709
     * @see SetLeftTableFields()
4710
     */
4711
    void SetRightTableFields(const std::vector<std::string> &osListFields)
4712
0
    {
4713
0
        m_osListRightTableFields = osListFields;
4714
0
    }
4715
4716
    /** Get the names of the mapping table fields which correspond to the
4717
     * participating fields from the left table in the relationship.
4718
     *
4719
     * @see GetRightMappingTableFields()
4720
     * @see SetLeftMappingTableFields()
4721
     */
4722
    const std::vector<std::string> &GetLeftMappingTableFields() const
4723
0
    {
4724
0
        return m_osListLeftMappingTableFields;
4725
0
    }
4726
4727
    /** Get the names of the mapping table fields which correspond to the
4728
     * participating fields from the right table in the relationship.
4729
     *
4730
     * @see GetLeftMappingTableFields()
4731
     * @see SetRightMappingTableFields()
4732
     */
4733
    const std::vector<std::string> &GetRightMappingTableFields() const
4734
0
    {
4735
0
        return m_osListRightMappingTableFields;
4736
0
    }
4737
4738
    /** Sets the names of the mapping table fields which correspond to the
4739
     * participating fields from the left table in the relationship.
4740
     *
4741
     * @see GetLeftMappingTableFields()
4742
     * @see SetRightMappingTableFields()
4743
     */
4744
    void SetLeftMappingTableFields(const std::vector<std::string> &osListFields)
4745
0
    {
4746
0
        m_osListLeftMappingTableFields = osListFields;
4747
0
    }
4748
4749
    /** Sets the names of the mapping table fields which correspond to the
4750
     * participating fields from the right table in the relationship.
4751
     *
4752
     * @see GetRightMappingTableFields()
4753
     * @see SetLeftMappingTableFields()
4754
     */
4755
    void
4756
    SetRightMappingTableFields(const std::vector<std::string> &osListFields)
4757
0
    {
4758
0
        m_osListRightMappingTableFields = osListFields;
4759
0
    }
4760
4761
    /** Get the type of the relationship.
4762
     *
4763
     * @see SetType()
4764
     */
4765
    GDALRelationshipType GetType() const
4766
0
    {
4767
0
        return m_eType;
4768
0
    }
4769
4770
    /** Sets the type of the relationship.
4771
     *
4772
     * @see GetType()
4773
     */
4774
    void SetType(GDALRelationshipType eType)
4775
0
    {
4776
0
        m_eType = eType;
4777
0
    }
4778
4779
    /** Get the label of the forward path for the relationship.
4780
     *
4781
     * The forward and backward path labels are free-form, user-friendly strings
4782
     * which can be used to generate descriptions of the relationship between
4783
     * features from the right and left tables.
4784
     *
4785
     * E.g. when the left table contains buildings and the right table contains
4786
     * furniture, the forward path label could be "contains" and the backward
4787
     * path label could be "is located within". A client could then generate a
4788
     * user friendly description string such as "fire hose 1234 is located
4789
     * within building 15a".
4790
     *
4791
     * @see SetForwardPathLabel()
4792
     * @see GetBackwardPathLabel()
4793
     */
4794
    const std::string &GetForwardPathLabel() const
4795
0
    {
4796
0
        return m_osForwardPathLabel;
4797
0
    }
4798
4799
    /** Sets the label of the forward path for the relationship.
4800
     *
4801
     * The forward and backward path labels are free-form, user-friendly strings
4802
     * which can be used to generate descriptions of the relationship between
4803
     * features from the right and left tables.
4804
     *
4805
     * E.g. when the left table contains buildings and the right table contains
4806
     * furniture, the forward path label could be "contains" and the backward
4807
     * path label could be "is located within". A client could then generate a
4808
     * user friendly description string such as "fire hose 1234 is located
4809
     * within building 15a".
4810
     *
4811
     * @see GetForwardPathLabel()
4812
     * @see SetBackwardPathLabel()
4813
     */
4814
    void SetForwardPathLabel(const std::string &osLabel)
4815
0
    {
4816
0
        m_osForwardPathLabel = osLabel;
4817
0
    }
4818
4819
    /** Get the label of the backward path for the relationship.
4820
     *
4821
     * The forward and backward path labels are free-form, user-friendly strings
4822
     * which can be used to generate descriptions of the relationship between
4823
     * features from the right and left tables.
4824
     *
4825
     * E.g. when the left table contains buildings and the right table contains
4826
     * furniture, the forward path label could be "contains" and the backward
4827
     * path label could be "is located within". A client could then generate a
4828
     * user friendly description string such as "fire hose 1234 is located
4829
     * within building 15a".
4830
     *
4831
     * @see SetBackwardPathLabel()
4832
     * @see GetForwardPathLabel()
4833
     */
4834
    const std::string &GetBackwardPathLabel() const
4835
0
    {
4836
0
        return m_osBackwardPathLabel;
4837
0
    }
4838
4839
    /** Sets the label of the backward path for the relationship.
4840
     *
4841
     * The forward and backward path labels are free-form, user-friendly strings
4842
     * which can be used to generate descriptions of the relationship between
4843
     * features from the right and left tables.
4844
     *
4845
     * E.g. when the left table contains buildings and the right table contains
4846
     * furniture, the forward path label could be "contains" and the backward
4847
     * path label could be "is located within". A client could then generate a
4848
     * user friendly description string such as "fire hose 1234 is located
4849
     * within building 15a".
4850
     *
4851
     * @see GetBackwardPathLabel()
4852
     * @see SetForwardPathLabel()
4853
     */
4854
    void SetBackwardPathLabel(const std::string &osLabel)
4855
0
    {
4856
0
        m_osBackwardPathLabel = osLabel;
4857
0
    }
4858
4859
    /** Get the type string of the related table.
4860
     *
4861
     * This a free-form string representing the type of related features, where
4862
     * the exact interpretation is format dependent. For instance, table types
4863
     * from GeoPackage relationships will directly reflect the categories from
4864
     * the GeoPackage related tables extension (i.e. "media", "simple
4865
     * attributes", "features", "attributes" and "tiles").
4866
     *
4867
     * @see SetRelatedTableType()
4868
     */
4869
    const std::string &GetRelatedTableType() const
4870
0
    {
4871
0
        return m_osRelatedTableType;
4872
0
    }
4873
4874
    /** Sets the type string of the related table.
4875
     *
4876
     * This a free-form string representing the type of related features, where
4877
     * the exact interpretation is format dependent. For instance, table types
4878
     * from GeoPackage relationships will directly reflect the categories from
4879
     * the GeoPackage related tables extension (i.e. "media", "simple
4880
     * attributes", "features", "attributes" and "tiles").
4881
     *
4882
     * @see GetRelatedTableType()
4883
     */
4884
    void SetRelatedTableType(const std::string &osType)
4885
0
    {
4886
0
        m_osRelatedTableType = osType;
4887
0
    }
4888
4889
    /** Convert a GDALRelationship* to a GDALRelationshipH.
4890
     */
4891
    static inline GDALRelationshipH ToHandle(GDALRelationship *poRelationship)
4892
0
    {
4893
0
        return static_cast<GDALRelationshipH>(poRelationship);
4894
0
    }
4895
4896
    /** Convert a GDALRelationshipH to a GDALRelationship*.
4897
     */
4898
    static inline GDALRelationship *FromHandle(GDALRelationshipH hRelationship)
4899
0
    {
4900
0
        return static_cast<GDALRelationship *>(hRelationship);
4901
0
    }
4902
};
4903
4904
/* ==================================================================== */
4905
/*      An assortment of overview related stuff.                        */
4906
/* ==================================================================== */
4907
4908
//! @cond Doxygen_Suppress
4909
/* Only exported for drivers as plugin. Signature may change */
4910
CPLErr CPL_DLL GDALRegenerateOverviewsMultiBand(
4911
    int nBands, GDALRasterBand *const *papoSrcBands, int nOverviews,
4912
    GDALRasterBand *const *const *papapoOverviewBands,
4913
    const char *pszResampling, GDALProgressFunc pfnProgress,
4914
    void *pProgressData, CSLConstList papszOptions);
4915
4916
CPLErr CPL_DLL GDALRegenerateOverviewsMultiBand(
4917
    const std::vector<GDALRasterBand *> &apoSrcBands,
4918
    // First level of array is indexed by band (thus aapoOverviewBands.size() must be equal to apoSrcBands.size())
4919
    // Second level is indexed by overview
4920
    const std::vector<std::vector<GDALRasterBand *>> &aapoOverviewBands,
4921
    const char *pszResampling, GDALProgressFunc pfnProgress,
4922
    void *pProgressData, CSLConstList papszOptions);
4923
4924
/************************************************************************/
4925
/*                       GDALOverviewResampleArgs                       */
4926
/************************************************************************/
4927
4928
/** Arguments for overview resampling function. */
4929
// Should not contain any dataset/rasterband object, as this might be
4930
// read in a worker thread.
4931
struct GDALOverviewResampleArgs
4932
{
4933
    //! Datatype of the source band argument
4934
    GDALDataType eSrcDataType = GDT_Unknown;
4935
    //! Datatype of the destination/overview band
4936
    GDALDataType eOvrDataType = GDT_Unknown;
4937
    //! Width in pixel of the destination/overview band
4938
    int nOvrXSize = 0;
4939
    //! Height in pixel of the destination/overview band
4940
    int nOvrYSize = 0;
4941
    //! NBITS value of the destination/overview band (or 0 if not set)
4942
    int nOvrNBITS = 0;
4943
    //! Factor to convert from destination X to source X
4944
    // (source width divided by destination width)
4945
    double dfXRatioDstToSrc = 0;
4946
    //! Factor to convert from destination Y to source Y
4947
    // (source height divided by destination height)
4948
    double dfYRatioDstToSrc = 0;
4949
    //! Sub-pixel delta to add to get source X
4950
    double dfSrcXDelta = 0;
4951
    //! Sub-pixel delta to add to get source Y
4952
    double dfSrcYDelta = 0;
4953
    //! Working data type (data type of the pChunk argument)
4954
    GDALDataType eWrkDataType = GDT_Unknown;
4955
    //! Array of nChunkXSize * nChunkYSize values of mask, or nullptr
4956
    const GByte *pabyChunkNodataMask = nullptr;
4957
    //! X offset of the source chunk in the source band
4958
    int nChunkXOff = 0;
4959
    //! Width in pixel of the source chunk in the source band
4960
    int nChunkXSize = 0;
4961
    //! Y offset of the source chunk in the source band
4962
    int nChunkYOff = 0;
4963
    //! Height in pixel of the source chunk in the source band
4964
    int nChunkYSize = 0;
4965
    //! X Offset of the destination chunk in the destination band
4966
    int nDstXOff = 0;
4967
    //! X Offset of the end (not included) of the destination chunk in the destination band
4968
    int nDstXOff2 = 0;
4969
    //! Y Offset of the destination chunk in the destination band
4970
    int nDstYOff = 0;
4971
    //! Y Offset of the end (not included) of the destination chunk in the destination band
4972
    int nDstYOff2 = 0;
4973
    //! Resampling method
4974
    const char *pszResampling = nullptr;
4975
    //! Whether the source band has a nodata value
4976
    bool bHasNoData = false;
4977
    //! Source band nodata value
4978
    double dfNoDataValue = 0;
4979
    //! Source color table
4980
    const GDALColorTable *poColorTable = nullptr;
4981
    //! Whether a single contributing source pixel at nodata should result
4982
    // in the target pixel to be at nodata too (only taken into account by
4983
    // average resampling)
4984
    bool bPropagateNoData = false;
4985
};
4986
4987
typedef CPLErr (*GDALResampleFunction)(const GDALOverviewResampleArgs &args,
4988
                                       const void *pChunk, void **ppDstBuffer,
4989
                                       GDALDataType *peDstBufferDataType);
4990
4991
GDALResampleFunction GDALGetResampleFunction(const char *pszResampling,
4992
                                             int *pnRadius);
4993
4994
std::string CPL_DLL GDALGetNormalizedOvrResampling(const char *pszResampling);
4995
4996
GDALDataType GDALGetOvrWorkDataType(const char *pszResampling,
4997
                                    GDALDataType eSrcDataType);
4998
4999
CPL_C_START
5000
5001
CPLErr CPL_DLL
5002
HFAAuxBuildOverviews(const char *pszOvrFilename, GDALDataset *poParentDS,
5003
                     GDALDataset **ppoDS, int nBands, const int *panBandList,
5004
                     int nNewOverviews, const int *panNewOverviewList,
5005
                     const char *pszResampling, GDALProgressFunc pfnProgress,
5006
                     void *pProgressData, CSLConstList papszOptions);
5007
5008
CPLErr CPL_DLL GTIFFBuildOverviews(const char *pszFilename, int nBands,
5009
                                   GDALRasterBand *const *papoBandList,
5010
                                   int nOverviews, const int *panOverviewList,
5011
                                   const char *pszResampling,
5012
                                   GDALProgressFunc pfnProgress,
5013
                                   void *pProgressData,
5014
                                   CSLConstList papszOptions);
5015
5016
int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand *poBand, int &nXOff,
5017
                                         int &nYOff, int &nXSize, int &nYSize,
5018
                                         int nBufXSize, int nBufYSize)
5019
    CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead");
5020
int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand *poBand, int &nXOff,
5021
                                          int &nYOff, int &nXSize, int &nYSize,
5022
                                          int nBufXSize, int nBufYSize,
5023
                                          GDALRasterIOExtraArg *psExtraArg);
5024
5025
int CPL_DLL GDALOvLevelAdjust(int nOvLevel, int nXSize)
5026
    CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead");
5027
int CPL_DLL GDALOvLevelAdjust2(int nOvLevel, int nXSize, int nYSize);
5028
int CPL_DLL GDALComputeOvFactor(int nOvrXSize, int nRasterXSize, int nOvrYSize,
5029
                                int nRasterYSize);
5030
5031
GDALDataset CPL_DLL *GDALFindAssociatedAuxFile(const char *pszBasefile,
5032
                                               GDALAccess eAccess,
5033
                                               GDALDataset *poDependentDS);
5034
5035
/* ==================================================================== */
5036
/*  Infrastructure to check that dataset characteristics are valid      */
5037
/* ==================================================================== */
5038
5039
int CPL_DLL GDALCheckDatasetDimensions(int nXSize, int nYSize);
5040
int CPL_DLL GDALCheckBandCount(int nBands, int bIsZeroAllowed);
5041
5042
/* Internal use only */
5043
5044
/* CPL_DLL exported, but only for in-tree drivers that can be built as plugins
5045
 */
5046
int CPL_DLL GDALReadWorldFile2(const char *pszBaseFilename,
5047
                               const char *pszExtension,
5048
                               double *padfGeoTransform,
5049
                               CSLConstList papszSiblingFiles,
5050
                               char **ppszWorldFileNameOut);
5051
int CPL_DLL GDALReadTabFile2(const char *pszBaseFilename,
5052
                             double *padfGeoTransform, char **ppszWKT,
5053
                             int *pnGCPCount, GDAL_GCP **ppasGCPs,
5054
                             CSLConstList papszSiblingFiles,
5055
                             char **ppszTabFileNameOut);
5056
5057
void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg *psDestArg,
5058
                                      GDALRasterIOExtraArg *psSrcArg);
5059
5060
void CPL_DLL GDALExpandPackedBitsToByteAt0Or1(
5061
    const GByte *CPL_RESTRICT pabyInput, GByte *CPL_RESTRICT pabyOutput,
5062
    size_t nInputBits);
5063
5064
void CPL_DLL GDALExpandPackedBitsToByteAt0Or255(
5065
    const GByte *CPL_RESTRICT pabyInput, GByte *CPL_RESTRICT pabyOutput,
5066
    size_t nInputBits);
5067
5068
CPL_C_END
5069
5070
std::unique_ptr<GDALDataset> CPL_DLL
5071
GDALGetThreadSafeDataset(std::unique_ptr<GDALDataset> poDS, int nScopeFlags);
5072
5073
GDALDataset CPL_DLL *GDALGetThreadSafeDataset(GDALDataset *poDS,
5074
                                              int nScopeFlags);
5075
5076
void GDALNullifyOpenDatasetsList();
5077
CPLMutex **GDALGetphDMMutex();
5078
CPLMutex **GDALGetphDLMutex();
5079
void GDALNullifyProxyPoolSingleton();
5080
void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
5081
GIntBig GDALGetResponsiblePIDForCurrentThread();
5082
5083
CPLString GDALFindAssociatedFile(const char *pszBasename, const char *pszExt,
5084
                                 CSLConstList papszSiblingFiles, int nFlags);
5085
5086
CPLErr CPL_DLL EXIFExtractMetadata(char **&papszMetadata, void *fpL,
5087
                                   int nOffset, int bSwabflag, int nTIFFHEADER,
5088
                                   int &nExifOffset, int &nInterOffset,
5089
                                   int &nGPSOffset);
5090
5091
int GDALValidateOpenOptions(GDALDriverH hDriver,
5092
                            const char *const *papszOptionOptions);
5093
int GDALValidateOptions(const char *pszOptionList,
5094
                        const char *const *papszOptionsToValidate,
5095
                        const char *pszErrorMessageOptionType,
5096
                        const char *pszErrorMessageContainerName);
5097
5098
GDALRIOResampleAlg CPL_DLL
5099
GDALRasterIOGetResampleAlg(const char *pszResampling);
5100
const char *GDALRasterIOGetResampleAlg(GDALRIOResampleAlg eResampleAlg);
5101
5102
void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg *psExtraArg,
5103
                                        int nXSize, int nYSize, int nBufXSize,
5104
                                        int nBufYSize);
5105
5106
GDALDataset *GDALCreateOverviewDataset(GDALDataset *poDS, int nOvrLevel,
5107
                                       bool bThisLevelOnly);
5108
5109
// Should cover particular cases of #3573, #4183, #4506, #6578
5110
// Behavior is undefined if fVal1 or fVal2 are NaN (should be tested before
5111
// calling this function)
5112
5113
// TODO: The expression `abs(fVal1 + fVal2)` looks strange; is this a bug?
5114
// Should this be `abs(fVal1) + abs(fVal2)` instead?
5115
5116
inline bool ARE_REAL_EQUAL(float fVal1, float fVal2, int ulp = 2)
5117
0
{
5118
0
    using std::abs;
5119
0
    return fVal1 == fVal2 || /* Should cover infinity */
5120
0
           abs(fVal1 - fVal2) <
5121
0
               std::numeric_limits<float>::epsilon() * abs(fVal1 + fVal2) * ulp;
5122
0
}
5123
5124
// We are using `std::numeric_limits<float>::epsilon()` for backward
5125
// compatibility
5126
inline bool ARE_REAL_EQUAL(double dfVal1, double dfVal2, int ulp = 2)
5127
0
{
5128
0
    using std::abs;
5129
0
    return dfVal1 == dfVal2 || /* Should cover infinity */
5130
0
           abs(dfVal1 - dfVal2) < std::numeric_limits<float>::epsilon() *
5131
0
                                      abs(dfVal1 + dfVal2) * ulp;
5132
0
}
5133
5134
double GDALAdjustNoDataCloseToFloatMax(double dfVal);
5135
5136
0
#define DIV_ROUND_UP(a, b) (((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1))
5137
5138
// Number of data samples that will be used to compute approximate statistics
5139
// (minimum value, maximum value, etc.)
5140
0
#define GDALSTAT_APPROX_NUMSAMPLES 2500
5141
5142
void GDALSerializeGCPListToXML(CPLXMLNode *psParentNode,
5143
                               const std::vector<gdal::GCP> &asGCPs,
5144
                               const OGRSpatialReference *poGCP_SRS);
5145
void GDALDeserializeGCPListFromXML(const CPLXMLNode *psGCPList,
5146
                                   std::vector<gdal::GCP> &asGCPs,
5147
                                   OGRSpatialReference **ppoGCP_SRS);
5148
5149
void GDALSerializeOpenOptionsToXML(CPLXMLNode *psParentNode,
5150
                                   CSLConstList papszOpenOptions);
5151
char CPL_DLL **
5152
GDALDeserializeOpenOptionsFromXML(const CPLXMLNode *psParentNode);
5153
5154
int GDALCanFileAcceptSidecarFile(const char *pszFilename);
5155
5156
bool GDALCanReliablyUseSiblingFileList(const char *pszFilename);
5157
5158
typedef enum
5159
{
5160
    GSF_UNSIGNED_INT,
5161
    GSF_SIGNED_INT,
5162
    GSF_FLOATING_POINT,
5163
} GDALBufferSampleFormat;
5164
5165
bool CPL_DLL GDALBufferHasOnlyNoData(const void *pBuffer, double dfNoDataValue,
5166
                                     size_t nWidth, size_t nHeight,
5167
                                     size_t nLineStride, size_t nComponents,
5168
                                     int nBitsPerSample,
5169
                                     GDALBufferSampleFormat nSampleFormat);
5170
5171
bool CPL_DLL GDALCopyNoDataValue(GDALRasterBand *poDstBand,
5172
                                 GDALRasterBand *poSrcBand,
5173
                                 bool *pbCannotBeExactlyRepresented = nullptr);
5174
5175
double CPL_DLL GDALGetNoDataValueCastToDouble(int64_t nVal);
5176
double CPL_DLL GDALGetNoDataValueCastToDouble(uint64_t nVal);
5177
5178
// Remove me in GDAL 4.0. See GetMetadataItem() implementation
5179
// Internal use in GDAL only !
5180
// Declaration copied in swig/include/gdal.i
5181
void CPL_DLL GDALEnablePixelTypeSignedByteWarning(GDALRasterBandH hBand,
5182
                                                  bool b);
5183
5184
std::string CPL_DLL GDALGetCompressionFormatForJPEG(VSILFILE *fp);
5185
std::string CPL_DLL GDALGetCompressionFormatForJPEG(const void *pBuffer,
5186
                                                    size_t nBufferSize);
5187
5188
GDALRasterAttributeTable CPL_DLL *GDALCreateRasterAttributeTableFromMDArrays(
5189
    GDALRATTableType eTableType,
5190
    const std::vector<std::shared_ptr<GDALMDArray>> &apoArrays,
5191
    const std::vector<GDALRATFieldUsage> &aeUsages);
5192
5193
GDALColorInterp CPL_DLL
5194
GDALGetColorInterpFromSTACCommonName(const char *pszName);
5195
const char CPL_DLL *
5196
GDALGetSTACCommonNameFromColorInterp(GDALColorInterp eInterp);
5197
5198
std::string CPL_DLL GDALGetCacheDirectory();
5199
5200
bool GDALDoesFileOrDatasetExist(const char *pszName,
5201
                                const char **ppszType = nullptr,
5202
                                GDALDriver **ppDriver = nullptr);
5203
5204
std::string CPL_DLL
5205
GDALGetMessageAboutMissingPluginDriver(GDALDriver *poMissingPluginDriver);
5206
5207
std::string GDALPrintDriverList(int nOptions, bool bJSON);
5208
5209
struct GDALColorAssociation
5210
{
5211
    double dfVal;
5212
    int nR;
5213
    int nG;
5214
    int nB;
5215
    int nA;
5216
};
5217
5218
std::vector<GDALColorAssociation> GDALLoadTextColorMap(const char *pszFilename,
5219
                                                       GDALRasterBand *poBand);
5220
5221
void GDALRescaleGeoTransform(double adfGeoTransform[6], double dfXRatio,
5222
                             double dfYRatio);
5223
5224
// Macro used so that Identify and driver metadata methods in drivers built
5225
// as plugin can be duplicated in libgdal core and in the driver under different
5226
// names
5227
#ifdef PLUGIN_FILENAME
5228
#define PLUGIN_SYMBOL_NAME(x) GDAL_core_##x
5229
#else
5230
#define PLUGIN_SYMBOL_NAME(x) GDAL_driver_##x
5231
#endif
5232
5233
//! @endcond
5234
5235
#endif /* ndef GDAL_PRIV_H_INCLUDED */