GDAL
gdal_priv.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id$
3  *
4  * Name: gdal_priv.h
5  * Project: GDAL Core
6  * Purpose: GDAL Core C++/Private declarations.
7  * Author: Frank Warmerdam, warmerdam@pobox.com
8  *
9  ******************************************************************************
10  * Copyright (c) 1998, Frank Warmerdam
11  * Copyright (c) 2007-2014, Even Rouault <even dot rouault at spatialys.com>
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a
14  * copy of this software and associated documentation files (the "Software"),
15  * to deal in the Software without restriction, including without limitation
16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  * and/or sell copies of the Software, and to permit persons to whom the
18  * Software is furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included
21  * in all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29  * DEALINGS IN THE SOFTWARE.
30  ****************************************************************************/
31 
32 #ifndef GDAL_PRIV_H_INCLUDED
33 #define GDAL_PRIV_H_INCLUDED
34 
41 /* -------------------------------------------------------------------- */
42 /* Predeclare various classes before pulling in gdal.h, the */
43 /* public declarations. */
44 /* -------------------------------------------------------------------- */
45 class GDALMajorObject;
46 class GDALDataset;
47 class GDALRasterBand;
48 class GDALDriver;
50 class GDALProxyDataset;
51 class GDALProxyRasterBand;
52 class GDALAsyncReader;
53 class GDALRelationship;
54 
55 /* -------------------------------------------------------------------- */
56 /* Pull in the public declarations. This gets the C apis, and */
57 /* also various constants. However, we will still get to */
58 /* provide the real class definitions for the GDAL classes. */
59 /* -------------------------------------------------------------------- */
60 
61 #include "gdal.h"
62 #include "gdal_frmts.h"
63 #include "gdalsubdatasetinfo.h"
64 #include "cpl_vsi.h"
65 #include "cpl_conv.h"
66 #include "cpl_string.h"
67 #include "cpl_minixml.h"
68 #include "cpl_multiproc.h"
69 #include "cpl_atomic_ops.h"
70 
71 #include <stdarg.h>
72 
73 #include <cmath>
74 #include <cstdint>
75 #include <iterator>
76 #include <limits>
77 #include <map>
78 #include <memory>
79 #include <set>
80 #include <vector>
81 
82 #include "ogr_core.h"
83 #include "ogr_feature.h"
84 
86 #define GMO_VALID 0x0001
87 #define GMO_IGNORE_UNIMPLEMENTED 0x0002
88 #define GMO_SUPPORT_MD 0x0004
89 #define GMO_SUPPORT_MDMD 0x0008
90 #define GMO_MD_DIRTY 0x0010
91 #define GMO_PAM_CLASS 0x0020
92 
94 
95 /************************************************************************/
96 /* GDALMultiDomainMetadata */
97 /************************************************************************/
98 
100 class CPL_DLL GDALMultiDomainMetadata
101 {
102  private:
103  CPLStringList aosDomainList{};
104 
105  struct Comparator
106  {
107  bool operator()(const char *a, const char *b) const
108  {
109  return STRCASECMP(a, b) < 0;
110  }
111  };
112 
113  std::map<const char *, CPLStringList, Comparator> oMetadata{};
114 
115  public:
116  GDALMultiDomainMetadata();
117  ~GDALMultiDomainMetadata();
118 
119  int XMLInit(const CPLXMLNode *psMetadata, int bMerge);
120  CPLXMLNode *Serialize() const;
121 
122  CSLConstList GetDomainList() const
123  {
124  return aosDomainList.List();
125  }
126 
127  char **GetMetadata(const char *pszDomain = "");
128  CPLErr SetMetadata(CSLConstList papszMetadata, const char *pszDomain = "");
129  const char *GetMetadataItem(const char *pszName,
130  const char *pszDomain = "");
131  CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
132  const char *pszDomain = "");
133 
134  void Clear();
135 
136  inline void clear()
137  {
138  Clear();
139  }
140 
141  private:
142  CPL_DISALLOW_COPY_ASSIGN(GDALMultiDomainMetadata)
143 };
144 
146 
147 /* ******************************************************************** */
148 /* GDALMajorObject */
149 /* */
150 /* Base class providing metadata, description and other */
151 /* services shared by major objects. */
152 /* ******************************************************************** */
153 
155 class CPL_DLL GDALMajorObject
156 {
157  protected:
159  int nFlags; // GMO_* flags.
160  CPLString sDescription{};
161  GDALMultiDomainMetadata oMDMD{};
162 
164 
165  char **BuildMetadataDomainList(char **papszList, int bCheckNonEmpty,
166  ...) CPL_NULL_TERMINATED;
167 
168  public:
169  GDALMajorObject();
170  virtual ~GDALMajorObject();
171 
172  int GetMOFlags() const;
173  void SetMOFlags(int nFlagsIn);
174 
175  virtual const char *GetDescription() const;
176  virtual void SetDescription(const char *);
177 
178  virtual char **GetMetadataDomainList();
179 
180  virtual char **GetMetadata(const char *pszDomain = "");
181  virtual CPLErr SetMetadata(char **papszMetadata,
182  const char *pszDomain = "");
183  virtual const char *GetMetadataItem(const char *pszName,
184  const char *pszDomain = "");
185  virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
186  const char *pszDomain = "");
187 
191  static inline GDALMajorObjectH ToHandle(GDALMajorObject *poMajorObject)
192  {
193  return static_cast<GDALMajorObjectH>(poMajorObject);
194  }
195 
199  static inline GDALMajorObject *FromHandle(GDALMajorObjectH hMajorObject)
200  {
201  return static_cast<GDALMajorObject *>(hMajorObject);
202  }
203 };
204 
205 /* ******************************************************************** */
206 /* GDALDefaultOverviews */
207 /* ******************************************************************** */
208 
210 class CPL_DLL GDALDefaultOverviews
211 {
212  friend class GDALDataset;
213 
214  GDALDataset *poDS;
215  GDALDataset *poODS;
216 
217  CPLString osOvrFilename{};
218 
219  bool bOvrIsAux;
220 
221  bool bCheckedForMask;
222  bool bOwnMaskDS;
223  GDALDataset *poMaskDS;
224 
225  // For "overview datasets" we record base level info so we can
226  // find our way back to get overview masks.
227  GDALDataset *poBaseDS;
228 
229  // Stuff for deferred initialize/overviewscans.
230  bool bCheckedForOverviews;
231  void OverviewScan();
232  char *pszInitName;
233  bool bInitNameIsOVR;
234  char **papszInitSiblingFiles;
235 
236  public:
237  GDALDefaultOverviews();
238  ~GDALDefaultOverviews();
239 
240  void Initialize(GDALDataset *poDSIn, const char *pszName = nullptr,
241  char **papszSiblingFiles = nullptr, int bNameIsOVR = FALSE);
242 
243  void TransferSiblingFiles(char **papszSiblingFiles);
244 
245  int IsInitialized();
246 
248 
249  // Overview Related
250 
251  int GetOverviewCount(int nBand);
252  GDALRasterBand *GetOverview(int nBand, int iOverview);
253 
254  CPLErr BuildOverviews(const char *pszBasename, const char *pszResampling,
255  int nOverviews, const int *panOverviewList,
256  int nBands, const int *panBandList,
257  GDALProgressFunc pfnProgress, void *pProgressData,
258  CSLConstList papszOptions);
259 
260  CPLErr BuildOverviewsSubDataset(const char *pszPhysicalFile,
261  const char *pszResampling, int nOverviews,
262  const int *panOverviewList, int nBands,
263  const int *panBandList,
264  GDALProgressFunc pfnProgress,
265  void *pProgressData,
266  CSLConstList papszOptions);
267 
268  CPLErr BuildOverviewsMask(const char *pszResampling, int nOverviews,
269  const int *panOverviewList,
270  GDALProgressFunc pfnProgress, void *pProgressData,
271  CSLConstList papszOptions);
272 
273  CPLErr CleanOverviews();
274 
275  // Mask Related
276 
277  CPLErr CreateMaskBand(int nFlags, int nBand = -1);
278  GDALRasterBand *GetMaskBand(int nBand);
279  int GetMaskFlags(int nBand);
280 
281  int HaveMaskFile(char **papszSiblings = nullptr,
282  const char *pszBasename = nullptr);
283 
284  char **GetSiblingFiles()
285  {
286  return papszInitSiblingFiles;
287  }
288 
289  private:
290  CPL_DISALLOW_COPY_ASSIGN(GDALDefaultOverviews)
291 };
292 
294 
295 /* ******************************************************************** */
296 /* GDALOpenInfo */
297 /* ******************************************************************** */
298 
300 class CPL_DLL GDALOpenInfo
301 {
302  bool bHasGotSiblingFiles;
303  char **papszSiblingFiles;
304  int nHeaderBytesTried;
305 
306  public:
307  GDALOpenInfo(const char *pszFile, int nOpenFlagsIn,
308  const char *const *papszSiblingFiles = nullptr);
309  ~GDALOpenInfo(void);
310 
312  char *pszFilename;
315 
320 
322  int bStatOK;
325 
328 
333 
335  const char *const *papszAllowedDrivers;
336 
337  int TryToIngest(int nBytes);
338  char **GetSiblingFiles();
339  char **StealSiblingFiles();
340  bool AreSiblingFilesLoaded() const;
341 
342  bool IsSingleAllowedDriver(const char *pszDriverName) const;
343 
344  private:
346 };
347 
348 /* ******************************************************************** */
349 /* gdal::GCP */
350 /* ******************************************************************** */
351 
352 namespace gdal
353 {
361 class CPL_DLL GCP
362 {
363  public:
364  explicit GCP(const char *pszId = "", const char *pszInfo = "",
365  double dfPixel = 0, double dfLine = 0, double dfX = 0,
366  double dfY = 0, double dfZ = 0);
367  ~GCP();
368  GCP(const GCP &);
369  explicit GCP(const GDAL_GCP &other);
370  GCP &operator=(const GCP &);
371  GCP(GCP &&);
372  GCP &operator=(GCP &&);
373 
375  inline const char *Id() const
376  {
377  return gcp.pszId;
378  }
379 
380  void SetId(const char *pszId);
381 
383  inline const char *Info() const
384  {
385  return gcp.pszInfo;
386  }
387 
388  void SetInfo(const char *pszInfo);
389 
391  inline double Pixel() const
392  {
393  return gcp.dfGCPPixel;
394  }
395 
397  inline double &Pixel()
398  {
399  return gcp.dfGCPPixel;
400  }
401 
403  inline double Line() const
404  {
405  return gcp.dfGCPLine;
406  }
407 
409  inline double &Line()
410  {
411  return gcp.dfGCPLine;
412  }
413 
415  inline double X() const
416  {
417  return gcp.dfGCPX;
418  }
419 
421  inline double &X()
422  {
423  return gcp.dfGCPX;
424  }
425 
427  inline double Y() const
428  {
429  return gcp.dfGCPY;
430  }
431 
433  inline double &Y()
434  {
435  return gcp.dfGCPY;
436  }
437 
439  inline double Z() const
440  {
441  return gcp.dfGCPZ;
442  }
443 
445  inline double &Z()
446  {
447  return gcp.dfGCPZ;
448  }
449 
451  inline const GDAL_GCP *c_ptr() const
452  {
453  return &gcp;
454  }
455 
456  static const GDAL_GCP *c_ptr(const std::vector<GCP> &asGCPs);
457 
458  static std::vector<GCP> fromC(const GDAL_GCP *pasGCPList, int nGCPCount);
459 
460  private:
461  GDAL_GCP gcp;
462 };
463 
464 } /* namespace gdal */
465 
466 /* ******************************************************************** */
467 /* GDALDataset */
468 /* ******************************************************************** */
469 
470 class OGRLayer;
471 class OGRGeometry;
472 class OGRSpatialReference;
473 class OGRStyleTable;
474 class swq_select;
475 class swq_select_parse_options;
476 class GDALGroup;
477 
479 typedef struct GDALSQLParseInfo GDALSQLParseInfo;
481 
483 #ifdef GDAL_COMPILATION
484 #define OPTIONAL_OUTSIDE_GDAL(val)
485 #else
486 #define OPTIONAL_OUTSIDE_GDAL(val) = val
487 #endif
489 
491 // This macro can be defined to check that GDALDataset::IRasterIO()
492 // implementations do not alter the passed panBandList. It is not defined
493 // by default (and should not!), hence int* is used.
494 #if defined(GDAL_BANDMAP_TYPE_CONST_SAFE)
495 #define BANDMAP_TYPE const int *
496 #else
497 #define BANDMAP_TYPE int *
498 #endif
500 
502 class CPL_DLL GDALDataset : public GDALMajorObject
503 {
504  friend GDALDatasetH CPL_STDCALL
505  GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags,
506  const char *const *papszAllowedDrivers,
507  const char *const *papszOpenOptions,
508  const char *const *papszSiblingFiles);
509  friend CPLErr CPL_STDCALL GDALClose(GDALDatasetH hDS);
510 
511  friend class GDALDriver;
512  friend class GDALDefaultOverviews;
513  friend class GDALProxyDataset;
514  friend class GDALDriverManager;
515 
516  CPL_INTERNAL void AddToDatasetOpenList();
517 
518  CPL_INTERNAL void UnregisterFromSharedDataset();
519 
520  CPL_INTERNAL static void ReportErrorV(const char *pszDSName,
521  CPLErr eErrClass, CPLErrorNum err_no,
522  const char *fmt, va_list args);
523 
524  protected:
526  GDALDriver *poDriver = nullptr;
527  GDALAccess eAccess = GA_ReadOnly;
528 
529  // Stored raster information.
530  int nRasterXSize = 512;
531  int nRasterYSize = 512;
532  int nBands = 0;
533  GDALRasterBand **papoBands = nullptr;
534 
535  static constexpr int OPEN_FLAGS_CLOSED = -1;
536  int nOpenFlags =
537  0; // set to OPEN_FLAGS_CLOSED after Close() has been called
538 
539  int nRefCount = 1;
540  bool bForceCachedIO = false;
541  bool bShared = false;
542  bool bIsInternal = true;
543  bool bSuppressOnClose = false;
544 
545  mutable std::map<std::string, std::unique_ptr<OGRFieldDomain>>
546  m_oMapFieldDomains{};
547 
548  GDALDataset(void);
549  explicit GDALDataset(int bForceCachedIO);
550 
551  void RasterInitialize(int, int);
552  void SetBand(int nNewBand, GDALRasterBand *poBand);
553  void SetBand(int nNewBand, std::unique_ptr<GDALRasterBand> poBand);
554 
555  GDALDefaultOverviews oOvManager{};
556 
557  virtual CPLErr IBuildOverviews(const char *pszResampling, int nOverviews,
558  const int *panOverviewList, int nListBands,
559  const int *panBandList,
560  GDALProgressFunc pfnProgress,
561  void *pProgressData,
562  CSLConstList papszOptions);
563 
564  virtual CPLErr
565  IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize,
566  void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType,
567  int nBandCount, BANDMAP_TYPE panBandMap, GSpacing nPixelSpace,
568  GSpacing nLineSpace, GSpacing nBandSpace,
570 
571  CPLErr
572  BlockBasedRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
573  int nYSize, void *pData, int nBufXSize, int nBufYSize,
574  GDALDataType eBufType, int nBandCount,
575  const int *panBandMap, GSpacing nPixelSpace,
576  GSpacing nLineSpace, GSpacing nBandSpace,
578  CPLErr BlockBasedFlushCache(bool bAtClosing);
579 
580  CPLErr
581  BandBasedRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
582  int nYSize, void *pData, int nBufXSize, int nBufYSize,
583  GDALDataType eBufType, int nBandCount,
584  const int *panBandMap, GSpacing nPixelSpace,
585  GSpacing nLineSpace, GSpacing nBandSpace,
587 
588  CPLErr
589  RasterIOResampled(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
590  int nYSize, void *pData, int nBufXSize, int nBufYSize,
591  GDALDataType eBufType, int nBandCount,
592  const int *panBandMap, GSpacing nPixelSpace,
593  GSpacing nLineSpace, GSpacing nBandSpace,
595 
596  CPLErr ValidateRasterIOOrAdviseReadParameters(
597  const char *pszCallingFunc, int *pbStopProcessingOnCENone, int nXOff,
598  int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize,
599  int nBandCount, const int *panBandMap);
600 
601  CPLErr TryOverviewRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
602  int nXSize, int nYSize, void *pData,
603  int nBufXSize, int nBufYSize,
604  GDALDataType eBufType, int nBandCount,
605  const int *panBandMap, GSpacing nPixelSpace,
606  GSpacing nLineSpace, GSpacing nBandSpace,
607  GDALRasterIOExtraArg *psExtraArg, int *pbTried);
608 
609  void ShareLockWithParentDataset(GDALDataset *poParentDataset);
610 
612 
613  void CleanupPostFileClosing();
614 
615  virtual int CloseDependentDatasets();
617  int ValidateLayerCreationOptions(const char *const *papszLCO);
618 
619  char **papszOpenOptions = nullptr;
620 
621  friend class GDALRasterBand;
622 
623  // The below methods related to read write mutex are fragile logic, and
624  // should not be used by out-of-tree code if possible.
625  int EnterReadWrite(GDALRWFlag eRWFlag);
626  void LeaveReadWrite();
627  void InitRWLock();
628 
629  void TemporarilyDropReadWriteLock();
630  void ReacquireReadWriteLock();
631 
632  void DisableReadWriteMutex();
633 
634  int AcquireMutex();
635  void ReleaseMutex();
636 
637  bool IsAllBands(int nBandCount, const int *panBandList) const;
639 
640  public:
641  ~GDALDataset() override;
642 
643  virtual CPLErr Close();
644 
645  int GetRasterXSize() const;
646  int GetRasterYSize() const;
647  int GetRasterCount() const;
648  GDALRasterBand *GetRasterBand(int);
649  const GDALRasterBand *GetRasterBand(int) const;
650 
657  virtual bool SetQueryLoggerFunc(GDALQueryLoggerFunc pfnQueryLoggerFuncIn,
658  void *poQueryLoggerArgIn);
659 
662  class CPL_DLL Bands
663  {
664  private:
665  friend class GDALDataset;
666  GDALDataset *m_poSelf;
667 
668  CPL_INTERNAL explicit Bands(GDALDataset *poSelf) : m_poSelf(poSelf)
669  {
670  }
671 
672  class CPL_DLL Iterator
673  {
674  struct Private;
675  std::unique_ptr<Private> m_poPrivate;
676 
677  public:
678  Iterator(GDALDataset *poDS, bool bStart);
679  Iterator(const Iterator &oOther); // declared but not defined.
680  // Needed for gcc 5.4 at least
681  Iterator(Iterator &&oOther) noexcept; // declared but not defined.
682  // Needed for gcc 5.4 at least
683  ~Iterator();
684  GDALRasterBand *operator*();
685  Iterator &operator++();
686  bool operator!=(const Iterator &it) const;
687  };
688 
689  public:
690  const Iterator begin() const;
691 
692  const Iterator end() const;
693 
694  size_t size() const;
695 
696  GDALRasterBand *operator[](int iBand);
697  GDALRasterBand *operator[](size_t iBand);
698  };
699 
700  Bands GetBands();
701 
702  virtual CPLErr FlushCache(bool bAtClosing = false);
703  virtual CPLErr DropCache();
704 
705  virtual GIntBig GetEstimatedRAMUsage();
706 
707  virtual const OGRSpatialReference *GetSpatialRef() const;
708  virtual CPLErr SetSpatialRef(const OGRSpatialReference *poSRS);
709 
710  // Compatibility layer
711  const char *GetProjectionRef(void) const;
712  CPLErr SetProjection(const char *pszProjection);
713 
714  virtual CPLErr GetGeoTransform(double *padfTransform);
715  virtual CPLErr SetGeoTransform(double *padfTransform);
716 
717  virtual CPLErr AddBand(GDALDataType eType, char **papszOptions = nullptr);
718 
719  virtual void *GetInternalHandle(const char *pszHandleName);
720  virtual GDALDriver *GetDriver(void);
721  virtual char **GetFileList(void);
722 
723  virtual const char *GetDriverName();
724 
725  virtual const OGRSpatialReference *GetGCPSpatialRef() const;
726  virtual int GetGCPCount();
727  virtual const GDAL_GCP *GetGCPs();
728  virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList,
729  const OGRSpatialReference *poGCP_SRS);
730 
731  // Compatibility layer
732  const char *GetGCPProjection();
733  CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList,
734  const char *pszGCPProjection);
735 
736  virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize,
737  int nBufXSize, int nBufYSize, GDALDataType eDT,
738  int nBandCount, int *panBandList,
739  char **papszOptions);
740 
741  virtual CPLErr CreateMaskBand(int nFlagsIn);
742 
743  virtual GDALAsyncReader *
744  BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize, void *pBuf,
745  int nBufXSize, int nBufYSize, GDALDataType eBufType,
746  int nBandCount, int *panBandMap, int nPixelSpace,
747  int nLineSpace, int nBandSpace, char **papszOptions);
748  virtual void EndAsyncReader(GDALAsyncReader *poARIO);
749 
751  struct RawBinaryLayout
752  {
753  enum class Interleaving
754  {
755  UNKNOWN,
756  BIP,
757  BIL,
758  BSQ
759  };
760  std::string osRawFilename{};
761  Interleaving eInterleaving = Interleaving::UNKNOWN;
762  GDALDataType eDataType = GDT_Unknown;
763  bool bLittleEndianOrder = false;
764 
765  vsi_l_offset nImageOffset = 0;
766  GIntBig nPixelOffset = 0;
767  GIntBig nLineOffset = 0;
768  GIntBig nBandOffset = 0;
769  };
770 
771  virtual bool GetRawBinaryLayout(RawBinaryLayout &);
773 
774 #ifndef DOXYGEN_SKIP
775  CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
776  int nYSize, void *pData, int nBufXSize, int nBufYSize,
777  GDALDataType eBufType, int nBandCount,
778  const int *panBandMap, GSpacing nPixelSpace,
779  GSpacing nLineSpace, GSpacing nBandSpace,
780  GDALRasterIOExtraArg *psExtraArg
781  OPTIONAL_OUTSIDE_GDAL(nullptr)) CPL_WARN_UNUSED_RESULT;
782 #else
783  CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
784  int nYSize, void *pData, int nBufXSize, int nBufYSize,
785  GDALDataType eBufType, int nBandCount,
786  const int *panBandMap, GSpacing nPixelSpace,
787  GSpacing nLineSpace, GSpacing nBandSpace,
789 #endif
790 
791  virtual CPLStringList GetCompressionFormats(int nXOff, int nYOff,
792  int nXSize, int nYSize,
793  int nBandCount,
794  const int *panBandList);
795  virtual CPLErr ReadCompressedData(const char *pszFormat, int nXOff,
796  int nYOff, int nXSize, int nYSize,
797  int nBands, const int *panBandList,
798  void **ppBuffer, size_t *pnBufferSize,
799  char **ppszDetailedFormat);
800 
801  int Reference();
802  int Dereference();
803  int ReleaseRef();
804 
809  {
810  return eAccess;
811  }
812 
813  int GetShared() const;
814  void MarkAsShared();
815 
816  void MarkSuppressOnClose();
817  void UnMarkSuppressOnClose();
818 
823  {
824  return bSuppressOnClose;
825  }
826 
830  char **GetOpenOptions()
831  {
832  return papszOpenOptions;
833  }
834 
835  static GDALDataset **GetOpenDatasets(int *pnDatasetCount);
836 
837 #ifndef DOXYGEN_SKIP
838  CPLErr
839  BuildOverviews(const char *pszResampling, int nOverviews,
840  const int *panOverviewList, int nListBands,
841  const int *panBandList, GDALProgressFunc pfnProgress,
842  void *pProgressData,
843  CSLConstList papszOptions OPTIONAL_OUTSIDE_GDAL(nullptr));
844 #else
845  CPLErr BuildOverviews(const char *pszResampling, int nOverviews,
846  const int *panOverviewList, int nListBands,
847  const int *panBandList, GDALProgressFunc pfnProgress,
848  void *pProgressData, CSLConstList papszOptions);
849 #endif
850 
851 #ifndef DOXYGEN_XML
852  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,
853  ...) const CPL_PRINT_FUNC_FORMAT(4, 5);
854 
855  static void ReportError(const char *pszDSName, CPLErr eErrClass,
856  CPLErrorNum err_no, const char *fmt, ...)
857  CPL_PRINT_FUNC_FORMAT(4, 5);
858 #endif
859 
860  char **GetMetadata(const char *pszDomain = "") override;
861 
862 // Only defined when Doxygen enabled
863 #ifdef DOXYGEN_SKIP
864  CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override;
865  CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
866  const char *pszDomain) override;
867 #endif
868 
869  char **GetMetadataDomainList() override;
870 
871  virtual void ClearStatistics();
872 
876  static inline GDALDatasetH ToHandle(GDALDataset *poDS)
877  {
878  return static_cast<GDALDatasetH>(poDS);
879  }
880 
884  static inline GDALDataset *FromHandle(GDALDatasetH hDS)
885  {
886  return static_cast<GDALDataset *>(hDS);
887  }
888 
892  static GDALDataset *Open(const char *pszFilename,
893  unsigned int nOpenFlags = 0,
894  const char *const *papszAllowedDrivers = nullptr,
895  const char *const *papszOpenOptions = nullptr,
896  const char *const *papszSiblingFiles = nullptr)
897  {
898  return FromHandle(GDALOpenEx(pszFilename, nOpenFlags,
899  papszAllowedDrivers, papszOpenOptions,
900  papszSiblingFiles));
901  }
902 
905  {
908 
910  OGRLayer *layer = nullptr;
911  };
912 
914  // SetEnableOverviews() only to be used by GDALOverviewDataset
915  void SetEnableOverviews(bool bEnable);
916 
917  // Only to be used by driver's GetOverviewCount() method.
918  bool AreOverviewsEnabled() const;
920 
921  private:
922  class Private;
923  Private *m_poPrivate;
924 
925  CPL_INTERNAL OGRLayer *BuildLayerFromSelectInfo(
926  swq_select *psSelectInfo, OGRGeometry *poSpatialFilter,
927  const char *pszDialect, swq_select_parse_options *poSelectParseOptions);
928  CPLStringList oDerivedMetadataList{};
929 
930  public:
931  virtual int GetLayerCount();
932  virtual OGRLayer *GetLayer(int iLayer);
933 
934  virtual bool IsLayerPrivate(int iLayer) const;
935 
939  class CPL_DLL Layers
940  {
941  private:
942  friend class GDALDataset;
943  GDALDataset *m_poSelf;
944 
945  CPL_INTERNAL explicit Layers(GDALDataset *poSelf) : m_poSelf(poSelf)
946  {
947  }
948 
949  public:
953  class CPL_DLL Iterator
954  {
955  struct Private;
956  std::unique_ptr<Private> m_poPrivate;
957 
958  public:
959  using value_type = OGRLayer *;
960  using reference = OGRLayer *;
961  using difference_type = void;
962  using pointer = void;
964  std::input_iterator_tag;
966  Iterator();
967  Iterator(GDALDataset *poDS, bool bStart);
968  Iterator(const Iterator &oOther);
969  Iterator(Iterator &&oOther) noexcept;
972  Iterator &
973  operator=(const Iterator &oOther);
974  Iterator &operator=(
975  Iterator &&oOther) noexcept;
977  OGRLayer *operator*() const;
978  Iterator &operator++();
979  Iterator operator++(int);
980  bool operator!=(const Iterator &it)
981  const;
982  };
983 
984  Iterator begin() const;
985  Iterator end() const;
986 
987  size_t size() const;
988 
989  OGRLayer *operator[](int iLayer);
990  OGRLayer *operator[](size_t iLayer);
991  OGRLayer *operator[](const char *pszLayername);
992  };
993 
994  Layers GetLayers();
995 
996  virtual OGRLayer *GetLayerByName(const char *);
997  virtual OGRErr DeleteLayer(int iLayer);
998 
999  virtual void ResetReading();
1000  virtual OGRFeature *GetNextFeature(OGRLayer **ppoBelongingLayer,
1001  double *pdfProgressPct,
1002  GDALProgressFunc pfnProgress,
1003  void *pProgressData);
1004 
1007  class CPL_DLL Features
1008  {
1009  private:
1010  friend class GDALDataset;
1011  GDALDataset *m_poSelf;
1012 
1013  CPL_INTERNAL explicit Features(GDALDataset *poSelf) : m_poSelf(poSelf)
1014  {
1015  }
1016 
1017  class CPL_DLL Iterator
1018  {
1019  struct Private;
1020  std::unique_ptr<Private> m_poPrivate;
1021 
1022  public:
1023  Iterator(GDALDataset *poDS, bool bStart);
1024  Iterator(const Iterator &oOther); // declared but not defined.
1025  // Needed for gcc 5.4 at least
1026  Iterator(Iterator &&oOther) noexcept; // declared but not defined.
1027  // Needed for gcc 5.4 at least
1028  ~Iterator();
1029  const FeatureLayerPair &operator*() const;
1030  Iterator &operator++();
1031  bool operator!=(const Iterator &it) const;
1032  };
1033 
1034  public:
1035  const Iterator begin() const;
1036 
1037  const Iterator end() const;
1038  };
1039 
1040  Features GetFeatures();
1041 
1042  virtual int TestCapability(const char *);
1043 
1044  virtual std::vector<std::string>
1045  GetFieldDomainNames(CSLConstList papszOptions = nullptr) const;
1046 
1047  virtual const OGRFieldDomain *GetFieldDomain(const std::string &name) const;
1048 
1049  virtual bool AddFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
1050  std::string &failureReason);
1051 
1052  virtual bool DeleteFieldDomain(const std::string &name,
1053  std::string &failureReason);
1054 
1055  virtual bool UpdateFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
1056  std::string &failureReason);
1057 
1058  virtual std::vector<std::string>
1059  GetRelationshipNames(CSLConstList papszOptions = nullptr) const;
1060 
1061  virtual const GDALRelationship *
1062  GetRelationship(const std::string &name) const;
1063 
1064  virtual bool
1065  AddRelationship(std::unique_ptr<GDALRelationship> &&relationship,
1066  std::string &failureReason);
1067 
1068  virtual bool DeleteRelationship(const std::string &name,
1069  std::string &failureReason);
1070 
1071  virtual bool
1072  UpdateRelationship(std::unique_ptr<GDALRelationship> &&relationship,
1073  std::string &failureReason);
1074 
1076  OGRLayer *CreateLayer(const char *pszName);
1077 
1078  OGRLayer *CreateLayer(const char *pszName, std::nullptr_t);
1080 
1081  OGRLayer *CreateLayer(const char *pszName,
1082  const OGRSpatialReference *poSpatialRef,
1083  OGRwkbGeometryType eGType = wkbUnknown,
1084  CSLConstList papszOptions = nullptr);
1085 
1086  OGRLayer *CreateLayer(const char *pszName,
1087  const OGRGeomFieldDefn *poGeomFieldDefn,
1088  CSLConstList papszOptions = nullptr);
1089 
1090  virtual OGRLayer *CopyLayer(OGRLayer *poSrcLayer, const char *pszNewName,
1091  char **papszOptions = nullptr);
1092 
1093  virtual OGRStyleTable *GetStyleTable();
1094  virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable);
1095 
1096  virtual void SetStyleTable(OGRStyleTable *poStyleTable);
1097 
1098  virtual OGRLayer *ExecuteSQL(const char *pszStatement,
1099  OGRGeometry *poSpatialFilter,
1100  const char *pszDialect);
1101  virtual void ReleaseResultSet(OGRLayer *poResultsSet);
1102  virtual OGRErr AbortSQL();
1103 
1104  int GetRefCount() const;
1105  int GetSummaryRefCount() const;
1106  OGRErr Release();
1107 
1108  virtual OGRErr StartTransaction(int bForce = FALSE);
1109  virtual OGRErr CommitTransaction();
1110  virtual OGRErr RollbackTransaction();
1111 
1112  virtual std::shared_ptr<GDALGroup> GetRootGroup() const;
1113 
1115  static int IsGenericSQLDialect(const char *pszDialect);
1116 
1117  // Semi-public methods. Only to be used by in-tree drivers.
1118  GDALSQLParseInfo *
1119  BuildParseInfo(swq_select *psSelectInfo,
1120  swq_select_parse_options *poSelectParseOptions);
1121  static void DestroyParseInfo(GDALSQLParseInfo *psParseInfo);
1122  OGRLayer *ExecuteSQL(const char *pszStatement, OGRGeometry *poSpatialFilter,
1123  const char *pszDialect,
1124  swq_select_parse_options *poSelectParseOptions);
1126 
1127  protected:
1128  virtual OGRLayer *ICreateLayer(const char *pszName,
1129  const OGRGeomFieldDefn *poGeomFieldDefn,
1130  CSLConstList papszOptions);
1131 
1133  OGRErr ProcessSQLCreateIndex(const char *);
1134  OGRErr ProcessSQLDropIndex(const char *);
1135  OGRErr ProcessSQLDropTable(const char *);
1136  OGRErr ProcessSQLAlterTableAddColumn(const char *);
1137  OGRErr ProcessSQLAlterTableDropColumn(const char *);
1138  OGRErr ProcessSQLAlterTableAlterColumn(const char *);
1139  OGRErr ProcessSQLAlterTableRenameColumn(const char *);
1140 
1141  OGRStyleTable *m_poStyleTable = nullptr;
1142 
1143  friend class GDALProxyPoolDataset;
1145 
1146  private:
1148 };
1149 
1151 struct CPL_DLL GDALDatasetUniquePtrDeleter
1152 {
1153  void operator()(GDALDataset *poDataset) const
1154  {
1155  GDALClose(poDataset);
1156  }
1157 };
1158 
1160 
1162 struct CPL_DLL GDALDatasetUniquePtrReleaser
1163 {
1164  void operator()(GDALDataset *poDataset) const
1165  {
1166  if (poDataset)
1167  poDataset->Release();
1168  }
1169 };
1170 
1172 
1179  std::unique_ptr<GDALDataset, GDALDatasetUniquePtrDeleter>;
1180 
1181 /* ******************************************************************** */
1182 /* GDALRasterBlock */
1183 /* ******************************************************************** */
1184 
1189 class CPL_DLL GDALRasterBlock
1190 {
1191  friend class GDALAbstractBandBlockCache;
1192 
1193  GDALDataType eType;
1194 
1195  bool bDirty;
1196  volatile int nLockCount;
1197 
1198  int nXOff;
1199  int nYOff;
1200 
1201  int nXSize;
1202  int nYSize;
1203 
1204  void *pData;
1205 
1206  GDALRasterBand *poBand;
1207 
1208  GDALRasterBlock *poNext;
1209  GDALRasterBlock *poPrevious;
1210 
1211  bool bMustDetach;
1212 
1213  CPL_INTERNAL void Detach_unlocked(void);
1214  CPL_INTERNAL void Touch_unlocked(void);
1215 
1216  CPL_INTERNAL void RecycleFor(int nXOffIn, int nYOffIn);
1217 
1218  public:
1219  GDALRasterBlock(GDALRasterBand *, int, int);
1220  GDALRasterBlock(int nXOffIn, int nYOffIn); /* only for lookup purpose */
1221  virtual ~GDALRasterBlock();
1222 
1223  CPLErr Internalize(void);
1224  void Touch(void);
1225  void MarkDirty(void);
1226  void MarkClean(void);
1227 
1229  int AddLock(void)
1230  {
1231  return CPLAtomicInc(&nLockCount);
1232  }
1233 
1235  int DropLock(void)
1236  {
1237  return CPLAtomicDec(&nLockCount);
1238  }
1239 
1240  void Detach();
1241 
1242  CPLErr Write();
1243 
1248  {
1249  return eType;
1250  }
1251 
1255  int GetXOff() const
1256  {
1257  return nXOff;
1258  }
1259 
1263  int GetYOff() const
1264  {
1265  return nYOff;
1266  }
1267 
1271  int GetXSize() const
1272  {
1273  return nXSize;
1274  }
1275 
1279  int GetYSize() const
1280  {
1281  return nYSize;
1282  }
1283 
1287  int GetDirty() const
1288  {
1289  return bDirty;
1290  }
1291 
1295  void *GetDataRef(void)
1296  {
1297  return pData;
1298  }
1299 
1304  {
1305  return static_cast<GPtrDiff_t>(nXSize) * nYSize *
1306  GDALGetDataTypeSizeBytes(eType);
1307  }
1308 
1309  int TakeLock();
1310  int DropLockForRemovalFromStorage();
1311 
1315  {
1316  return poBand;
1317  }
1318 
1319  static void FlushDirtyBlocks();
1320  static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE);
1321  static void Verify();
1322 
1323  static void EnterDisableDirtyBlockFlush();
1324  static void LeaveDisableDirtyBlockFlush();
1325 
1326 #ifdef notdef
1327  static void CheckNonOrphanedBlocks(GDALRasterBand *poBand);
1328  void DumpBlock();
1329  static void DumpAll();
1330 #endif
1331 
1332  /* Should only be called by GDALDestroyDriverManager() */
1334  CPL_INTERNAL static void DestroyRBMutex();
1336 
1337  private:
1339 };
1340 
1341 /* ******************************************************************** */
1342 /* GDALColorTable */
1343 /* ******************************************************************** */
1344 
1347 class CPL_DLL GDALColorTable
1348 {
1349  GDALPaletteInterp eInterp;
1350 
1351  std::vector<GDALColorEntry> aoEntries{};
1352 
1353  public:
1356 
1357  GDALColorTable *Clone() const;
1358  int IsSame(const GDALColorTable *poOtherCT) const;
1359 
1360  GDALPaletteInterp GetPaletteInterpretation() const;
1361 
1362  int GetColorEntryCount() const;
1363  const GDALColorEntry *GetColorEntry(int i) const;
1364  int GetColorEntryAsRGB(int i, GDALColorEntry *poEntry) const;
1365  void SetColorEntry(int i, const GDALColorEntry *poEntry);
1366  int CreateColorRamp(int nStartIndex, const GDALColorEntry *psStartColor,
1367  int nEndIndex, const GDALColorEntry *psEndColor);
1368  bool IsIdentity() const;
1369 
1374  {
1375  return static_cast<GDALColorTableH>(poCT);
1376  }
1377 
1382  {
1383  return static_cast<GDALColorTable *>(hCT);
1384  }
1385 };
1386 
1387 /* ******************************************************************** */
1388 /* GDALAbstractBandBlockCache */
1389 /* ******************************************************************** */
1390 
1392 
1394 // only used by GDALRasterBand implementation.
1395 
1396 class GDALAbstractBandBlockCache
1397 {
1398  // List of blocks that can be freed or recycled, and its lock
1399  CPLLock *hSpinLock = nullptr;
1400  GDALRasterBlock *psListBlocksToFree = nullptr;
1401 
1402  // Band keep alive counter, and its lock & condition
1403  CPLCond *hCond = nullptr;
1404  CPLMutex *hCondMutex = nullptr;
1405  volatile int nKeepAliveCounter = 0;
1406 
1407  volatile int m_nDirtyBlocks = 0;
1408 
1409  CPL_DISALLOW_COPY_ASSIGN(GDALAbstractBandBlockCache)
1410 
1411  protected:
1412  GDALRasterBand *poBand;
1413 
1414  int m_nInitialDirtyBlocksInFlushCache = 0;
1415  int m_nLastTick = -1;
1416  size_t m_nWriteDirtyBlocksDisabled = 0;
1417 
1418  void FreeDanglingBlocks();
1419  void UnreferenceBlockBase();
1420 
1421  void StartDirtyBlockFlushingLog();
1422  void UpdateDirtyBlockFlushingLog();
1423  void EndDirtyBlockFlushingLog();
1424 
1425  public:
1426  explicit GDALAbstractBandBlockCache(GDALRasterBand *poBand);
1427  virtual ~GDALAbstractBandBlockCache();
1428 
1429  GDALRasterBlock *CreateBlock(int nXBlockOff, int nYBlockOff);
1430  void AddBlockToFreeList(GDALRasterBlock *poBlock);
1431  void IncDirtyBlocks(int nInc);
1432  void WaitCompletionPendingTasks();
1433 
1434  void EnableDirtyBlockWriting()
1435  {
1436  --m_nWriteDirtyBlocksDisabled;
1437  }
1438 
1439  void DisableDirtyBlockWriting()
1440  {
1441  ++m_nWriteDirtyBlocksDisabled;
1442  }
1443 
1444  bool HasDirtyBlocks() const
1445  {
1446  return m_nDirtyBlocks > 0;
1447  }
1448 
1449  virtual bool Init() = 0;
1450  virtual bool IsInitOK() = 0;
1451  virtual CPLErr FlushCache() = 0;
1452  virtual CPLErr AdoptBlock(GDALRasterBlock *poBlock) = 0;
1453  virtual GDALRasterBlock *TryGetLockedBlockRef(int nXBlockOff,
1454  int nYBlockYOff) = 0;
1455  virtual CPLErr UnreferenceBlock(GDALRasterBlock *poBlock) = 0;
1456  virtual CPLErr FlushBlock(int nXBlockOff, int nYBlockOff,
1457  int bWriteDirtyBlock) = 0;
1458 };
1459 
1460 GDALAbstractBandBlockCache *
1461 GDALArrayBandBlockCacheCreate(GDALRasterBand *poBand);
1462 GDALAbstractBandBlockCache *
1463 GDALHashSetBandBlockCacheCreate(GDALRasterBand *poBand);
1464 
1466 
1467 /* ******************************************************************** */
1468 /* GDALRasterBand */
1469 /* ******************************************************************** */
1470 
1471 class GDALMDArray;
1472 
1474 typedef enum
1475 {
1476  GMVR_UNKNOWN,
1481 
1484 
1487 
1490 
1493 
1496 
1500 
1503 class CPL_DLL GDALRasterBand : public GDALMajorObject
1504 {
1505  private:
1506  friend class GDALArrayBandBlockCache;
1507  friend class GDALHashSetBandBlockCache;
1508  friend class GDALRasterBlock;
1509  friend class GDALDataset;
1510 
1511  CPLErr eFlushBlockErr = CE_None;
1512  GDALAbstractBandBlockCache *poBandBlockCache = nullptr;
1513 
1514  CPL_INTERNAL void SetFlushBlockErr(CPLErr eErr);
1515  CPL_INTERNAL CPLErr UnreferenceBlock(GDALRasterBlock *poBlock);
1516  CPL_INTERNAL void IncDirtyBlocks(int nInc);
1517 
1518  protected:
1520  GDALDataset *poDS = nullptr;
1521  int nBand = 0; /* 1 based */
1522 
1523  int nRasterXSize = 0;
1524  int nRasterYSize = 0;
1525 
1526  GDALDataType eDataType = GDT_Byte;
1527  GDALAccess eAccess = GA_ReadOnly;
1528 
1529  /* stuff related to blocking, and raster cache */
1530  int nBlockXSize = -1;
1531  int nBlockYSize = -1;
1532  int nBlocksPerRow = 0;
1533  int nBlocksPerColumn = 0;
1534 
1535  int nBlockReads = 0;
1536  int bForceCachedIO = 0;
1537 
1538  class GDALRasterBandOwnedOrNot
1539  {
1540  public:
1541  GDALRasterBandOwnedOrNot()
1542  {
1543  }
1544 
1545  GDALRasterBandOwnedOrNot(GDALRasterBand *poBand, bool bOwned)
1546  : m_poBandOwned(bOwned ? poBand : nullptr),
1547  m_poBandRef(bOwned ? nullptr : poBand)
1548  {
1549  }
1550 
1551  void reset()
1552  {
1553  m_poBandOwned.reset();
1554  m_poBandRef = nullptr;
1555  }
1556 
1557  void reset(GDALRasterBand *poBand, bool bOwned)
1558  {
1559  m_poBandOwned.reset(bOwned ? poBand : nullptr);
1560  m_poBandRef = bOwned ? nullptr : poBand;
1561  }
1562 
1563  GDALRasterBand *get()
1564  {
1565  return static_cast<GDALRasterBand *>(*this);
1566  }
1567 
1568  bool IsOwned() const
1569  {
1570  return m_poBandOwned != nullptr;
1571  }
1572 
1573  operator GDALRasterBand *()
1574  {
1575  return m_poBandOwned ? m_poBandOwned.get() : m_poBandRef;
1576  }
1577 
1578  private:
1579  CPL_DISALLOW_COPY_ASSIGN(GDALRasterBandOwnedOrNot)
1580  std::unique_ptr<GDALRasterBand> m_poBandOwned{};
1581  GDALRasterBand *m_poBandRef = nullptr;
1582  };
1583 
1584  GDALRasterBandOwnedOrNot poMask{};
1585  bool m_bEnablePixelTypeSignedByteWarning =
1586  true; // Remove me in GDAL 4.0. See GetMetadataItem() implementation
1587  int nMaskFlags = 0;
1588 
1589  void InvalidateMaskBand();
1590 
1591  friend class GDALProxyRasterBand;
1592  friend class GDALDefaultOverviews;
1593 
1594  CPLErr
1595  RasterIOResampled(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1596  int nYSize, void *pData, int nBufXSize, int nBufYSize,
1597  GDALDataType eBufType, GSpacing nPixelSpace,
1598  GSpacing nLineSpace,
1600 
1601  int EnterReadWrite(GDALRWFlag eRWFlag);
1602  void LeaveReadWrite();
1603  void InitRWLock();
1604  void SetValidPercent(GUIntBig nSampleCount, GUIntBig nValidCount);
1605 
1607 
1608  protected:
1609  virtual CPLErr IReadBlock(int nBlockXOff, int nBlockYOff, void *pData) = 0;
1610  virtual CPLErr IWriteBlock(int nBlockXOff, int nBlockYOff, void *pData);
1611 
1612  virtual CPLErr
1613  IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize,
1614  void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType,
1615  GSpacing nPixelSpace, GSpacing nLineSpace,
1617 
1618  virtual int IGetDataCoverageStatus(int nXOff, int nYOff, int nXSize,
1619  int nYSize, int nMaskFlagStop,
1620  double *pdfDataPct);
1622  CPLErr
1623  OverviewRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1624  int nYSize, void *pData, int nBufXSize, int nBufYSize,
1625  GDALDataType eBufType, GSpacing nPixelSpace,
1626  GSpacing nLineSpace,
1628 
1629  CPLErr TryOverviewRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
1630  int nXSize, int nYSize, void *pData,
1631  int nBufXSize, int nBufYSize,
1632  GDALDataType eBufType, GSpacing nPixelSpace,
1633  GSpacing nLineSpace,
1634  GDALRasterIOExtraArg *psExtraArg, int *pbTried);
1635 
1636  int InitBlockInfo();
1637 
1638  void AddBlockToFreeList(GDALRasterBlock *);
1639 
1640  bool HasBlockCache() const
1641  {
1642  return poBandBlockCache != nullptr;
1643  }
1644 
1645  bool HasDirtyBlocks() const
1646  {
1647  return poBandBlockCache && poBandBlockCache->HasDirtyBlocks();
1648  }
1649 
1651 
1652  public:
1653  GDALRasterBand();
1654  explicit GDALRasterBand(int bForceCachedIO);
1655 
1656  ~GDALRasterBand() override;
1657 
1658  int GetXSize();
1659  int GetYSize();
1660  int GetBand();
1661  GDALDataset *GetDataset();
1662 
1663  GDALDataType GetRasterDataType(void);
1664  void GetBlockSize(int *pnXSize, int *pnYSize);
1665  CPLErr GetActualBlockSize(int nXBlockOff, int nYBlockOff, int *pnXValid,
1666  int *pnYValid);
1667 
1669  GetSuggestedBlockAccessPattern() const;
1670 
1671  GDALAccess GetAccess();
1672 
1673 #ifndef DOXYGEN_SKIP
1674  CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1675  int nYSize, void *pData, int nBufXSize, int nBufYSize,
1676  GDALDataType eBufType, GSpacing nPixelSpace,
1677  GSpacing nLineSpace,
1678  GDALRasterIOExtraArg *psExtraArg
1679  OPTIONAL_OUTSIDE_GDAL(nullptr)) CPL_WARN_UNUSED_RESULT;
1680 #else
1681  CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1682  int nYSize, void *pData, int nBufXSize, int nBufYSize,
1683  GDALDataType eBufType, GSpacing nPixelSpace,
1684  GSpacing nLineSpace,
1686 #endif
1687  CPLErr ReadBlock(int nXBlockOff, int nYBlockOff,
1688  void *pImage) CPL_WARN_UNUSED_RESULT;
1689 
1690  CPLErr WriteBlock(int nXBlockOff, int nYBlockOff,
1691  void *pImage) CPL_WARN_UNUSED_RESULT;
1692 
1693  GDALRasterBlock *
1694  GetLockedBlockRef(int nXBlockOff, int nYBlockOff,
1695  int bJustInitialize = FALSE) CPL_WARN_UNUSED_RESULT;
1696  GDALRasterBlock *TryGetLockedBlockRef(int nXBlockOff, int nYBlockYOff)
1698  CPLErr FlushBlock(int nXBlockOff, int nYBlockOff,
1699  int bWriteDirtyBlock = TRUE);
1700 
1701  unsigned char *
1702  GetIndexColorTranslationTo(/* const */ GDALRasterBand *poReferenceBand,
1703  unsigned char *pTranslationTable = nullptr,
1704  int *pApproximateMatching = nullptr);
1705 
1706  // New OpengIS CV_SampleDimension stuff.
1707 
1708  virtual CPLErr FlushCache(bool bAtClosing = false);
1709  virtual CPLErr DropCache();
1710  virtual char **GetCategoryNames();
1711  virtual double GetNoDataValue(int *pbSuccess = nullptr);
1712  virtual int64_t GetNoDataValueAsInt64(int *pbSuccess = nullptr);
1713  virtual uint64_t GetNoDataValueAsUInt64(int *pbSuccess = nullptr);
1714  virtual double GetMinimum(int *pbSuccess = nullptr);
1715  virtual double GetMaximum(int *pbSuccess = nullptr);
1716  virtual double GetOffset(int *pbSuccess = nullptr);
1717  virtual double GetScale(int *pbSuccess = nullptr);
1718  virtual const char *GetUnitType();
1719  virtual GDALColorInterp GetColorInterpretation();
1720  virtual GDALColorTable *GetColorTable();
1721  virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
1722 
1723  virtual CPLErr SetCategoryNames(char **papszNames);
1724  virtual CPLErr SetNoDataValue(double dfNoData);
1725  virtual CPLErr SetNoDataValueAsInt64(int64_t nNoData);
1726  virtual CPLErr SetNoDataValueAsUInt64(uint64_t nNoData);
1727  virtual CPLErr DeleteNoDataValue();
1728  virtual CPLErr SetColorTable(GDALColorTable *poCT);
1729  virtual CPLErr SetColorInterpretation(GDALColorInterp eColorInterp);
1730  virtual CPLErr SetOffset(double dfNewOffset);
1731  virtual CPLErr SetScale(double dfNewScale);
1732  virtual CPLErr SetUnitType(const char *pszNewValue);
1733 
1734  virtual CPLErr GetStatistics(int bApproxOK, int bForce, double *pdfMin,
1735  double *pdfMax, double *pdfMean,
1736  double *padfStdDev);
1737  virtual CPLErr ComputeStatistics(int bApproxOK, double *pdfMin,
1738  double *pdfMax, double *pdfMean,
1739  double *pdfStdDev, GDALProgressFunc,
1740  void *pProgressData);
1741  virtual CPLErr SetStatistics(double dfMin, double dfMax, double dfMean,
1742  double dfStdDev);
1743  virtual CPLErr ComputeRasterMinMax(int bApproxOK, double *adfMinMax);
1744 
1745 // Only defined when Doxygen enabled
1746 #ifdef DOXYGEN_SKIP
1747  CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override;
1748  CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
1749  const char *pszDomain) override;
1750 #endif
1751  virtual const char *GetMetadataItem(const char *pszName,
1752  const char *pszDomain = "") override;
1753 
1754  virtual int HasArbitraryOverviews();
1755  virtual int GetOverviewCount();
1756  virtual GDALRasterBand *GetOverview(int i);
1757  virtual GDALRasterBand *GetRasterSampleOverview(GUIntBig);
1758  virtual CPLErr BuildOverviews(const char *pszResampling, int nOverviews,
1759  const int *panOverviewList,
1760  GDALProgressFunc pfnProgress,
1761  void *pProgressData,
1762  CSLConstList papszOptions);
1763 
1764  virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize,
1765  int nBufXSize, int nBufYSize,
1766  GDALDataType eBufType, char **papszOptions);
1767 
1768  virtual CPLErr GetHistogram(double dfMin, double dfMax, int nBuckets,
1769  GUIntBig *panHistogram, int bIncludeOutOfRange,
1770  int bApproxOK, GDALProgressFunc,
1771  void *pProgressData);
1772 
1773  virtual CPLErr GetDefaultHistogram(double *pdfMin, double *pdfMax,
1774  int *pnBuckets, GUIntBig **ppanHistogram,
1775  int bForce, GDALProgressFunc,
1776  void *pProgressData);
1777  virtual CPLErr SetDefaultHistogram(double dfMin, double dfMax, int nBuckets,
1778  GUIntBig *panHistogram);
1779 
1780  virtual GDALRasterAttributeTable *GetDefaultRAT();
1781  virtual CPLErr SetDefaultRAT(const GDALRasterAttributeTable *poRAT);
1782 
1783  virtual GDALRasterBand *GetMaskBand();
1784  virtual int GetMaskFlags();
1785  virtual CPLErr CreateMaskBand(int nFlagsIn);
1786  virtual bool IsMaskBand() const;
1787  virtual GDALMaskValueRange GetMaskValueRange() const;
1788 
1789  virtual CPLVirtualMem *
1790  GetVirtualMemAuto(GDALRWFlag eRWFlag, int *pnPixelSpace,
1791  GIntBig *pnLineSpace,
1792  char **papszOptions) CPL_WARN_UNUSED_RESULT;
1793 
1794  int GetDataCoverageStatus(int nXOff, int nYOff, int nXSize, int nYSize,
1795  int nMaskFlagStop = 0,
1796  double *pdfDataPct = nullptr);
1797 
1798  std::shared_ptr<GDALMDArray> AsMDArray() const;
1799 
1800 #ifndef DOXYGEN_XML
1801  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...)
1802  CPL_PRINT_FUNC_FORMAT(4, 5);
1803 #endif
1804 
1808  static inline GDALRasterBandH ToHandle(GDALRasterBand *poBand)
1809  {
1810  return static_cast<GDALRasterBandH>(poBand);
1811  }
1812 
1817  {
1818  return static_cast<GDALRasterBand *>(hBand);
1819  }
1820 
1822  // Remove me in GDAL 4.0. See GetMetadataItem() implementation
1823  // Internal use in GDAL only !
1824  void EnablePixelTypeSignedByteWarning(bool b)
1825 #ifndef GDAL_COMPILATION
1826  CPL_WARN_DEPRECATED("Do not use that method outside of GDAL!")
1827 #endif
1828  ;
1829 
1831 
1832  private:
1834 };
1835 
1837 /* ******************************************************************** */
1838 /* GDALAllValidMaskBand */
1839 /* ******************************************************************** */
1840 
1841 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
1842 {
1843  protected:
1844  CPLErr IReadBlock(int, int, void *) override;
1845 
1846  CPL_DISALLOW_COPY_ASSIGN(GDALAllValidMaskBand)
1847 
1848  public:
1849  explicit GDALAllValidMaskBand(GDALRasterBand *);
1850  ~GDALAllValidMaskBand() override;
1851 
1852  GDALRasterBand *GetMaskBand() override;
1853  int GetMaskFlags() override;
1854 
1855  bool IsMaskBand() const override
1856  {
1857  return true;
1858  }
1859 
1860  GDALMaskValueRange GetMaskValueRange() const override
1861  {
1862  return GMVR_0_AND_255_ONLY;
1863  }
1864 
1865  CPLErr ComputeStatistics(int bApproxOK, double *pdfMin, double *pdfMax,
1866  double *pdfMean, double *pdfStdDev,
1867  GDALProgressFunc, void *pProgressData) override;
1868 };
1869 
1870 /* ******************************************************************** */
1871 /* GDALNoDataMaskBand */
1872 /* ******************************************************************** */
1873 
1874 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
1875 {
1876  friend class GDALRasterBand;
1877  double m_dfNoDataValue = 0;
1878  int64_t m_nNoDataValueInt64 = 0;
1879  uint64_t m_nNoDataValueUInt64 = 0;
1880  GDALRasterBand *m_poParent = nullptr;
1881 
1882  CPL_DISALLOW_COPY_ASSIGN(GDALNoDataMaskBand)
1883 
1884  protected:
1885  CPLErr IReadBlock(int, int, void *) override;
1886  CPLErr IRasterIO(GDALRWFlag, int, int, int, int, void *, int, int,
1888  GDALRasterIOExtraArg *psExtraArg) override;
1889 
1890  public:
1891  explicit GDALNoDataMaskBand(GDALRasterBand *);
1892  explicit GDALNoDataMaskBand(GDALRasterBand *, double dfNoDataValue);
1893  ~GDALNoDataMaskBand() override;
1894 
1895  bool IsMaskBand() const override
1896  {
1897  return true;
1898  }
1899 
1900  GDALMaskValueRange GetMaskValueRange() const override
1901  {
1902  return GMVR_0_AND_255_ONLY;
1903  }
1904 
1905  static bool IsNoDataInRange(double dfNoDataValue, GDALDataType eDataType);
1906 };
1907 
1908 /* ******************************************************************** */
1909 /* GDALNoDataValuesMaskBand */
1910 /* ******************************************************************** */
1911 
1912 class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
1913 {
1914  double *padfNodataValues;
1915 
1916  CPL_DISALLOW_COPY_ASSIGN(GDALNoDataValuesMaskBand)
1917 
1918  protected:
1919  CPLErr IReadBlock(int, int, void *) override;
1920 
1921  public:
1922  explicit GDALNoDataValuesMaskBand(GDALDataset *);
1923  ~GDALNoDataValuesMaskBand() override;
1924 
1925  bool IsMaskBand() const override
1926  {
1927  return true;
1928  }
1929 
1930  GDALMaskValueRange GetMaskValueRange() const override
1931  {
1932  return GMVR_0_AND_255_ONLY;
1933  }
1934 };
1935 
1936 /* ******************************************************************** */
1937 /* GDALRescaledAlphaBand */
1938 /* ******************************************************************** */
1939 
1940 class GDALRescaledAlphaBand : public GDALRasterBand
1941 {
1942  GDALRasterBand *poParent;
1943  void *pTemp;
1944 
1945  CPL_DISALLOW_COPY_ASSIGN(GDALRescaledAlphaBand)
1946 
1947  protected:
1948  CPLErr IReadBlock(int, int, void *) override;
1949  CPLErr IRasterIO(GDALRWFlag, int, int, int, int, void *, int, int,
1951  GDALRasterIOExtraArg *psExtraArg) override;
1952 
1953  public:
1954  explicit GDALRescaledAlphaBand(GDALRasterBand *);
1955  ~GDALRescaledAlphaBand() override;
1956 
1957  bool IsMaskBand() const override
1958  {
1959  return true;
1960  }
1961 };
1962 
1964 
1965 /* ******************************************************************** */
1966 /* GDALIdentifyEnum */
1967 /* ******************************************************************** */
1968 
1974 typedef enum
1975 {
1982  GDAL_IDENTIFY_TRUE = 1
1984 
1985 /* ******************************************************************** */
1986 /* GDALDriver */
1987 /* ******************************************************************** */
1988 
2000 class CPL_DLL GDALDriver : public GDALMajorObject
2001 {
2002  public:
2003  GDALDriver();
2004  ~GDALDriver() override;
2005 
2006  CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
2007  const char *pszDomain = "") override;
2008 
2009  /* -------------------------------------------------------------------- */
2010  /* Public C++ methods. */
2011  /* -------------------------------------------------------------------- */
2012  GDALDataset *Create(const char *pszName, int nXSize, int nYSize, int nBands,
2013  GDALDataType eType,
2014  CSLConstList papszOptions) CPL_WARN_UNUSED_RESULT;
2015 
2016  GDALDataset *
2017  CreateMultiDimensional(const char *pszName,
2018  CSLConstList papszRootGroupOptions,
2019  CSLConstList papszOptions) CPL_WARN_UNUSED_RESULT;
2020 
2021  CPLErr Delete(const char *pszName);
2022  CPLErr Rename(const char *pszNewName, const char *pszOldName);
2023  CPLErr CopyFiles(const char *pszNewName, const char *pszOldName);
2024 
2025  GDALDataset *CreateCopy(const char *, GDALDataset *, int,
2026  CSLConstList papszOptions,
2027  GDALProgressFunc pfnProgress,
2028  void *pProgressData) CPL_WARN_UNUSED_RESULT;
2029 
2030  bool CanVectorTranslateFrom(const char *pszDestName,
2031  GDALDataset *poSourceDS,
2032  CSLConstList papszVectorTranslateArguments,
2033  char ***ppapszFailureReasons);
2034 
2035  GDALDataset *
2036  VectorTranslateFrom(const char *pszDestName, GDALDataset *poSourceDS,
2037  CSLConstList papszVectorTranslateArguments,
2038  GDALProgressFunc pfnProgress,
2039  void *pProgressData) CPL_WARN_UNUSED_RESULT;
2040 
2041  /* -------------------------------------------------------------------- */
2042  /* The following are semiprivate, not intended to be accessed */
2043  /* by anyone but the formats instantiating and populating the */
2044  /* drivers. */
2045  /* -------------------------------------------------------------------- */
2047 
2048  // Not aimed at being used outside of GDAL. Use GDALDataset::Open() instead
2049  GDALDataset *Open(GDALOpenInfo *poOpenInfo, bool bSetOpenOptions);
2050 
2051  typedef GDALDataset *(*OpenCallback)(GDALOpenInfo *);
2052 
2053  OpenCallback pfnOpen = nullptr;
2054 
2055  virtual OpenCallback GetOpenCallback()
2056  {
2057  return pfnOpen;
2058  }
2059 
2060  typedef GDALDataset *(*CreateCallback)(const char *pszName, int nXSize,
2061  int nYSize, int nBands,
2062  GDALDataType eType,
2063  char **papszOptions);
2064 
2065  CreateCallback pfnCreate = nullptr;
2066 
2067  virtual CreateCallback GetCreateCallback()
2068  {
2069  return pfnCreate;
2070  }
2071 
2072  GDALDataset *(*pfnCreateEx)(GDALDriver *, const char *pszName, int nXSize,
2073  int nYSize, int nBands, GDALDataType eType,
2074  char **papszOptions) = nullptr;
2075 
2076  typedef GDALDataset *(*CreateMultiDimensionalCallback)(
2077  const char *pszName, CSLConstList papszRootGroupOptions,
2078  CSLConstList papszOptions);
2079 
2080  CreateMultiDimensionalCallback pfnCreateMultiDimensional = nullptr;
2081 
2082  virtual CreateMultiDimensionalCallback GetCreateMultiDimensionalCallback()
2083  {
2084  return pfnCreateMultiDimensional;
2085  }
2086 
2087  typedef CPLErr (*DeleteCallback)(const char *pszName);
2088  DeleteCallback pfnDelete = nullptr;
2089 
2090  virtual DeleteCallback GetDeleteCallback()
2091  {
2092  return pfnDelete;
2093  }
2094 
2095  typedef GDALDataset *(*CreateCopyCallback)(const char *, GDALDataset *, int,
2096  char **,
2097  GDALProgressFunc pfnProgress,
2098  void *pProgressData);
2099 
2100  CreateCopyCallback pfnCreateCopy = nullptr;
2101 
2102  virtual CreateCopyCallback GetCreateCopyCallback()
2103  {
2104  return pfnCreateCopy;
2105  }
2106 
2107  void *pDriverData = nullptr;
2108 
2109  void (*pfnUnloadDriver)(GDALDriver *) = nullptr;
2110 
2119  int (*pfnIdentify)(GDALOpenInfo *) = nullptr;
2120  int (*pfnIdentifyEx)(GDALDriver *, GDALOpenInfo *) = nullptr;
2121 
2122  typedef CPLErr (*RenameCallback)(const char *pszNewName,
2123  const char *pszOldName);
2124  RenameCallback pfnRename = nullptr;
2125 
2126  virtual RenameCallback GetRenameCallback()
2127  {
2128  return pfnRename;
2129  }
2130 
2131  typedef CPLErr (*CopyFilesCallback)(const char *pszNewName,
2132  const char *pszOldName);
2133  CopyFilesCallback pfnCopyFiles = nullptr;
2134 
2135  virtual CopyFilesCallback GetCopyFilesCallback()
2136  {
2137  return pfnCopyFiles;
2138  }
2139 
2140  // Used for legacy OGR drivers, and Python drivers
2141  GDALDataset *(*pfnOpenWithDriverArg)(GDALDriver *,
2142  GDALOpenInfo *) = nullptr;
2143 
2144  /* For legacy OGR drivers */
2145  GDALDataset *(*pfnCreateVectorOnly)(GDALDriver *, const char *pszName,
2146  char **papszOptions) = nullptr;
2147  CPLErr (*pfnDeleteDataSource)(GDALDriver *, const char *pszName) = nullptr;
2148 
2153  bool (*pfnCanVectorTranslateFrom)(
2154  const char *pszDestName, GDALDataset *poSourceDS,
2155  CSLConstList papszVectorTranslateArguments,
2156  char ***ppapszFailureReasons) = nullptr;
2157 
2162  GDALDataset *(*pfnVectorTranslateFrom)(
2163  const char *pszDestName, GDALDataset *poSourceDS,
2164  CSLConstList papszVectorTranslateArguments,
2165  GDALProgressFunc pfnProgress, void *pProgressData) = nullptr;
2166 
2171  GDALSubdatasetInfo *(*pfnGetSubdatasetInfoFunc)(const char *pszFileName) =
2172  nullptr;
2173 
2175 
2176  /* -------------------------------------------------------------------- */
2177  /* Helper methods. */
2178  /* -------------------------------------------------------------------- */
2180  GDALDataset *DefaultCreateCopy(const char *, GDALDataset *, int,
2181  CSLConstList papszOptions,
2182  GDALProgressFunc pfnProgress,
2183  void *pProgressData) CPL_WARN_UNUSED_RESULT;
2184 
2185  static CPLErr DefaultCreateCopyMultiDimensional(
2186  GDALDataset *poSrcDS, GDALDataset *poDstDS, bool bStrict,
2187  CSLConstList /*papszOptions*/, GDALProgressFunc pfnProgress,
2188  void *pProgressData);
2189 
2190  static CPLErr DefaultCopyMasks(GDALDataset *poSrcDS, GDALDataset *poDstDS,
2191  int bStrict);
2192  static CPLErr DefaultCopyMasks(GDALDataset *poSrcDS, GDALDataset *poDstDS,
2193  int bStrict, CSLConstList papszOptions,
2194  GDALProgressFunc pfnProgress,
2195  void *pProgressData);
2196 
2197  CPLErr QuietDeleteForCreateCopy(const char *pszFilename,
2198  GDALDataset *poSrcDS);
2199 
2201  static CPLErr QuietDelete(const char *pszName,
2202  CSLConstList papszAllowedDrivers = nullptr);
2203 
2205  static CPLErr DefaultRename(const char *pszNewName, const char *pszOldName);
2206  static CPLErr DefaultCopyFiles(const char *pszNewName,
2207  const char *pszOldName);
2208  static void DefaultCopyMetadata(GDALDataset *poSrcDS, GDALDataset *poDstDS,
2209  CSLConstList papszOptions,
2210  CSLConstList papszExcludedDomains);
2211 
2213 
2217  static inline GDALDriverH ToHandle(GDALDriver *poDriver)
2218  {
2219  return static_cast<GDALDriverH>(poDriver);
2220  }
2221 
2225  static inline GDALDriver *FromHandle(GDALDriverH hDriver)
2226  {
2227  return static_cast<GDALDriver *>(hDriver);
2228  }
2229 
2230  private:
2232 };
2233 
2234 /************************************************************************/
2235 /* GDALPluginDriverProxy */
2236 /************************************************************************/
2237 
2238 // clang-format off
2276 // clang-format on
2277 
2279 {
2280  const std::string m_osPluginFileName;
2281  std::string m_osPluginFullPath{};
2282  std::unique_ptr<GDALDriver> m_poRealDriver{};
2283  std::set<std::string> m_oSetMetadataItems{};
2284 
2285  GDALDriver *GetRealDriver();
2286 
2288 
2289  protected:
2290  friend class GDALDriverManager;
2291 
2293  void SetPluginFullPath(const std::string &osFullPath)
2294  {
2295  m_osPluginFullPath = osFullPath;
2296  }
2297 
2299 
2300  public:
2301  explicit GDALPluginDriverProxy(const std::string &osPluginFileName);
2302 
2304  const std::string &GetPluginFileName() const
2305  {
2306  return m_osPluginFileName;
2307  }
2308 
2310  OpenCallback GetOpenCallback() override;
2311 
2312  CreateCallback GetCreateCallback() override;
2313 
2314  CreateMultiDimensionalCallback GetCreateMultiDimensionalCallback() override;
2315 
2316  CreateCopyCallback GetCreateCopyCallback() override;
2317 
2318  DeleteCallback GetDeleteCallback() override;
2319 
2320  RenameCallback GetRenameCallback() override;
2321 
2322  CopyFilesCallback GetCopyFilesCallback() override;
2324 
2325  CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
2326  const char *pszDomain = "") override;
2327 
2328  char **GetMetadata(const char *pszDomain) override;
2329 
2330  const char *GetMetadataItem(const char *pszName,
2331  const char *pszDomain = "") override;
2332 };
2333 
2334 /* ******************************************************************** */
2335 /* GDALDriverManager */
2336 /* ******************************************************************** */
2337 
2345 class CPL_DLL GDALDriverManager : public GDALMajorObject
2346 {
2347  int nDrivers = 0;
2348  GDALDriver **papoDrivers = nullptr;
2349  std::map<CPLString, GDALDriver *> oMapNameToDrivers{};
2350  std::string m_osPluginPath{};
2351  std::string m_osDriversIniPath{};
2352  mutable std::string m_osLastTriedDirectory{};
2353  std::set<std::string> m_oSetPluginFileNames{};
2354  bool m_bInDeferredDriverLoading = false;
2355  std::map<std::string, std::unique_ptr<GDALDriver>> m_oMapRealDrivers{};
2356  std::vector<std::unique_ptr<GDALDriver>> m_aoHiddenDrivers{};
2357 
2358  GDALDriver *GetDriver_unlocked(int iDriver)
2359  {
2360  return (iDriver >= 0 && iDriver < nDrivers) ? papoDrivers[iDriver]
2361  : nullptr;
2362  }
2363 
2364  GDALDriver *GetDriverByName_unlocked(const char *pszName) const
2365  {
2366  auto oIter = oMapNameToDrivers.find(CPLString(pszName).toupper());
2367  return oIter == oMapNameToDrivers.end() ? nullptr : oIter->second;
2368  }
2369 
2370  static void CleanupPythonDrivers();
2371 
2372  std::string GetPluginFullPath(const char *pszFilename) const;
2373 
2374  int RegisterDriver(GDALDriver *, bool bHidden);
2375 
2377 
2378  protected:
2379  friend class GDALPluginDriverProxy;
2380  friend GDALDatasetH CPL_STDCALL
2381  GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags,
2382  const char *const *papszAllowedDrivers,
2383  const char *const *papszOpenOptions,
2384  const char *const *papszSiblingFiles);
2385 
2387  static char **GetSearchPaths(const char *pszGDAL_DRIVER_PATH);
2389 
2390  public:
2392  ~GDALDriverManager();
2393 
2394  int GetDriverCount(void) const;
2395  GDALDriver *GetDriver(int);
2396  GDALDriver *GetDriverByName(const char *);
2397 
2398  int RegisterDriver(GDALDriver *);
2399  void DeregisterDriver(GDALDriver *);
2400 
2401  // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
2402  void AutoLoadDrivers();
2403  void AutoSkipDrivers();
2404  void ReorderDrivers();
2405  static CPLErr LoadPlugin(const char *name);
2406 
2407  static void AutoLoadPythonDrivers();
2408 
2409  void DeclareDeferredPluginDriver(GDALPluginDriverProxy *poProxyDriver);
2410 
2412  int GetDriverCount(bool bIncludeHidden) const;
2413  GDALDriver *GetDriver(int iDriver, bool bIncludeHidden);
2415 };
2416 
2419 CPL_C_END
2420 
2421 /* ******************************************************************** */
2422 /* GDALAsyncReader */
2423 /* ******************************************************************** */
2424 
2430 class CPL_DLL GDALAsyncReader
2431 {
2432 
2434 
2435  protected:
2437  GDALDataset *poDS;
2438  int nXOff;
2439  int nYOff;
2440  int nXSize;
2441  int nYSize;
2442  void *pBuf;
2443  int nBufXSize;
2444  int nBufYSize;
2445  GDALDataType eBufType;
2446  int nBandCount;
2447  int *panBandMap;
2448  int nPixelSpace;
2449  int nLineSpace;
2450  int nBandSpace;
2452 
2453  public:
2454  GDALAsyncReader();
2455  virtual ~GDALAsyncReader();
2456 
2461  {
2462  return poDS;
2463  }
2464 
2468  int GetXOffset() const
2469  {
2470  return nXOff;
2471  }
2472 
2476  int GetYOffset() const
2477  {
2478  return nYOff;
2479  }
2480 
2484  int GetXSize() const
2485  {
2486  return nXSize;
2487  }
2488 
2492  int GetYSize() const
2493  {
2494  return nYSize;
2495  }
2496 
2500  void *GetBuffer()
2501  {
2502  return pBuf;
2503  }
2504 
2508  int GetBufferXSize() const
2509  {
2510  return nBufXSize;
2511  }
2512 
2516  int GetBufferYSize() const
2517  {
2518  return nBufYSize;
2519  }
2520 
2525  {
2526  return eBufType;
2527  }
2528 
2532  int GetBandCount() const
2533  {
2534  return nBandCount;
2535  }
2536 
2540  int *GetBandMap()
2541  {
2542  return panBandMap;
2543  }
2544 
2548  int GetPixelSpace() const
2549  {
2550  return nPixelSpace;
2551  }
2552 
2556  int GetLineSpace() const
2557  {
2558  return nLineSpace;
2559  }
2560 
2564  int GetBandSpace() const
2565  {
2566  return nBandSpace;
2567  }
2568 
2569  virtual GDALAsyncStatusType
2570  GetNextUpdatedRegion(double dfTimeout, int *pnBufXOff, int *pnBufYOff,
2571  int *pnBufXSize, int *pnBufYSize) = 0;
2572  virtual int LockBuffer(double dfTimeout = -1.0);
2573  virtual void UnlockBuffer();
2574 };
2575 
2576 /* ******************************************************************** */
2577 /* Multidimensional array API */
2578 /* ******************************************************************** */
2579 
2580 class GDALMDArray;
2581 class GDALAttribute;
2582 class GDALDimension;
2583 class GDALEDTComponent;
2584 
2585 /* ******************************************************************** */
2586 /* GDALExtendedDataType */
2587 /* ******************************************************************** */
2588 
2597 {
2598  public:
2600 
2602 
2603  GDALExtendedDataType &operator=(const GDALExtendedDataType &);
2605 
2606  static GDALExtendedDataType Create(GDALDataType eType);
2607  static GDALExtendedDataType
2608  Create(const std::string &osName, size_t nTotalSize,
2609  std::vector<std::unique_ptr<GDALEDTComponent>> &&components);
2610  static GDALExtendedDataType
2611  CreateString(size_t nMaxStringLength = 0,
2613 
2614  bool operator==(const GDALExtendedDataType &) const;
2615 
2617  bool operator!=(const GDALExtendedDataType &other) const
2618  {
2619  return !(operator==(other));
2620  }
2621 
2626  const std::string &GetName() const
2627  {
2628  return m_osName;
2629  }
2630 
2636  {
2637  return m_eClass;
2638  }
2639 
2646  {
2647  return m_eNumericDT;
2648  }
2649 
2657  {
2658  return m_eSubType;
2659  }
2660 
2666  const std::vector<std::unique_ptr<GDALEDTComponent>> &GetComponents() const
2667  {
2668  return m_aoComponents;
2669  }
2670 
2677  size_t GetSize() const
2678  {
2679  return m_nSize;
2680  }
2681 
2686  size_t GetMaxStringLength() const
2687  {
2688  return m_nMaxStringLength;
2689  }
2690 
2691  bool CanConvertTo(const GDALExtendedDataType &other) const;
2692 
2693  bool NeedsFreeDynamicMemory() const;
2694 
2695  void FreeDynamicMemory(void *pBuffer) const;
2696 
2697  static bool CopyValue(const void *pSrc, const GDALExtendedDataType &srcType,
2698  void *pDst, const GDALExtendedDataType &dstType);
2699 
2700  static bool CopyValues(const void *pSrc,
2701  const GDALExtendedDataType &srcType,
2702  GPtrDiff_t nSrcStrideInElts, void *pDst,
2703  const GDALExtendedDataType &dstType,
2704  GPtrDiff_t nDstStrideInElts, size_t nValues);
2705 
2706  private:
2707  GDALExtendedDataType(size_t nMaxStringLength,
2708  GDALExtendedDataTypeSubType eSubType);
2709  explicit GDALExtendedDataType(GDALDataType eType);
2711  const std::string &osName, size_t nTotalSize,
2712  std::vector<std::unique_ptr<GDALEDTComponent>> &&components);
2713 
2714  std::string m_osName{};
2717  GDALDataType m_eNumericDT = GDT_Unknown;
2718  std::vector<std::unique_ptr<GDALEDTComponent>> m_aoComponents{};
2719  size_t m_nSize = 0;
2720  size_t m_nMaxStringLength = 0;
2721 };
2722 
2723 /* ******************************************************************** */
2724 /* GDALEDTComponent */
2725 /* ******************************************************************** */
2726 
2732 class CPL_DLL GDALEDTComponent
2733 {
2734  public:
2735  ~GDALEDTComponent();
2736  GDALEDTComponent(const std::string &name, size_t offset,
2737  const GDALExtendedDataType &type);
2739 
2740  bool operator==(const GDALEDTComponent &) const;
2741 
2746  const std::string &GetName() const
2747  {
2748  return m_osName;
2749  }
2750 
2755  size_t GetOffset() const
2756  {
2757  return m_nOffset;
2758  }
2759 
2765  {
2766  return m_oType;
2767  }
2768 
2769  private:
2770  std::string m_osName;
2771  size_t m_nOffset;
2772  GDALExtendedDataType m_oType;
2773 };
2774 
2775 /* ******************************************************************** */
2776 /* GDALIHasAttribute */
2777 /* ******************************************************************** */
2778 
2784 class CPL_DLL GDALIHasAttribute
2785 {
2786  protected:
2787  std::shared_ptr<GDALAttribute>
2788  GetAttributeFromAttributes(const std::string &osName) const;
2789 
2790  public:
2791  virtual ~GDALIHasAttribute();
2792 
2793  virtual std::shared_ptr<GDALAttribute>
2794  GetAttribute(const std::string &osName) const;
2795 
2796  virtual std::vector<std::shared_ptr<GDALAttribute>>
2797  GetAttributes(CSLConstList papszOptions = nullptr) const;
2798 
2799  virtual std::shared_ptr<GDALAttribute>
2800  CreateAttribute(const std::string &osName,
2801  const std::vector<GUInt64> &anDimensions,
2802  const GDALExtendedDataType &oDataType,
2803  CSLConstList papszOptions = nullptr);
2804 
2805  virtual bool DeleteAttribute(const std::string &osName,
2806  CSLConstList papszOptions = nullptr);
2807 };
2808 
2809 /* ******************************************************************** */
2810 /* GDALGroup */
2811 /* ******************************************************************** */
2812 
2813 /* clang-format off */
2823 /* clang-format on */
2824 
2825 class CPL_DLL GDALGroup : public GDALIHasAttribute
2826 {
2827  protected:
2829  std::string m_osName{};
2830 
2831  // This is actually a path of the form "/parent_path/{m_osName}"
2832  std::string m_osFullName{};
2833 
2834  // Used for example by GDALSubsetGroup to distinguish a derived group
2835  //from its original, without altering its name
2836  const std::string m_osContext{};
2837 
2838  std::weak_ptr<GDALGroup> m_pSelf{};
2839 
2841  bool m_bValid = true;
2842 
2843  GDALGroup(const std::string &osParentName, const std::string &osName,
2844  const std::string &osContext = std::string());
2845 
2846  const GDALGroup *
2847  GetInnerMostGroup(const std::string &osPathOrArrayOrDim,
2848  std::shared_ptr<GDALGroup> &curGroupHolder,
2849  std::string &osLastPart) const;
2850 
2851  void BaseRename(const std::string &osNewName);
2852 
2853  bool CheckValidAndErrorOutIfNot() const;
2854 
2855  void SetSelf(const std::shared_ptr<GDALGroup> &self)
2856  {
2857  m_pSelf = self;
2858  }
2859 
2860  virtual void NotifyChildrenOfRenaming()
2861  {
2862  }
2863 
2864  virtual void NotifyChildrenOfDeletion()
2865  {
2866  }
2867 
2869 
2870  public:
2871  virtual ~GDALGroup();
2872 
2877  const std::string &GetName() const
2878  {
2879  return m_osName;
2880  }
2881 
2886  const std::string &GetFullName() const
2887  {
2888  return m_osFullName;
2889  }
2890 
2891  virtual std::vector<std::string>
2892  GetMDArrayNames(CSLConstList papszOptions = nullptr) const;
2893  virtual std::shared_ptr<GDALMDArray>
2894  OpenMDArray(const std::string &osName,
2895  CSLConstList papszOptions = nullptr) const;
2896 
2897  virtual std::vector<std::string>
2898  GetGroupNames(CSLConstList papszOptions = nullptr) const;
2899  virtual std::shared_ptr<GDALGroup>
2900  OpenGroup(const std::string &osName,
2901  CSLConstList papszOptions = nullptr) const;
2902 
2903  virtual std::vector<std::string>
2904  GetVectorLayerNames(CSLConstList papszOptions = nullptr) const;
2905  virtual OGRLayer *
2906  OpenVectorLayer(const std::string &osName,
2907  CSLConstList papszOptions = nullptr) const;
2908 
2909  virtual std::vector<std::shared_ptr<GDALDimension>>
2910  GetDimensions(CSLConstList papszOptions = nullptr) const;
2911 
2912  virtual std::shared_ptr<GDALGroup>
2913  CreateGroup(const std::string &osName, CSLConstList papszOptions = nullptr);
2914 
2915  virtual bool DeleteGroup(const std::string &osName,
2916  CSLConstList papszOptions = nullptr);
2917 
2918  virtual std::shared_ptr<GDALDimension>
2919  CreateDimension(const std::string &osName, const std::string &osType,
2920  const std::string &osDirection, GUInt64 nSize,
2921  CSLConstList papszOptions = nullptr);
2922 
2923  virtual std::shared_ptr<GDALMDArray> CreateMDArray(
2924  const std::string &osName,
2925  const std::vector<std::shared_ptr<GDALDimension>> &aoDimensions,
2926  const GDALExtendedDataType &oDataType,
2927  CSLConstList papszOptions = nullptr);
2928 
2929  virtual bool DeleteMDArray(const std::string &osName,
2930  CSLConstList papszOptions = nullptr);
2931 
2932  GUInt64 GetTotalCopyCost() const;
2933 
2934  virtual bool CopyFrom(const std::shared_ptr<GDALGroup> &poDstRootGroup,
2935  GDALDataset *poSrcDS,
2936  const std::shared_ptr<GDALGroup> &poSrcGroup,
2937  bool bStrict, GUInt64 &nCurCost,
2938  const GUInt64 nTotalCost,
2939  GDALProgressFunc pfnProgress, void *pProgressData,
2940  CSLConstList papszOptions = nullptr);
2941 
2942  virtual CSLConstList GetStructuralInfo() const;
2943 
2944  std::shared_ptr<GDALMDArray>
2945  OpenMDArrayFromFullname(const std::string &osFullName,
2946  CSLConstList papszOptions = nullptr) const;
2947 
2948  std::shared_ptr<GDALMDArray>
2949  ResolveMDArray(const std::string &osName, const std::string &osStartingPath,
2950  CSLConstList papszOptions = nullptr) const;
2951 
2952  std::shared_ptr<GDALGroup>
2953  OpenGroupFromFullname(const std::string &osFullName,
2954  CSLConstList papszOptions = nullptr) const;
2955 
2956  std::shared_ptr<GDALDimension>
2957  OpenDimensionFromFullname(const std::string &osFullName) const;
2958 
2959  virtual void ClearStatistics();
2960 
2961  virtual bool Rename(const std::string &osNewName);
2962 
2963  std::shared_ptr<GDALGroup>
2964  SubsetDimensionFromSelection(const std::string &osSelection) const;
2965 
2967  virtual void ParentRenamed(const std::string &osNewParentFullName);
2968 
2969  virtual void Deleted();
2970 
2971  virtual void ParentDeleted();
2972 
2973  const std::string &GetContext() const
2974  {
2975  return m_osContext;
2976  }
2977 
2979 
2981  static constexpr GUInt64 COPY_COST = 1000;
2983 };
2984 
2985 /* ******************************************************************** */
2986 /* GDALAbstractMDArray */
2987 /* ******************************************************************** */
2988 
2994 class CPL_DLL GDALAbstractMDArray
2995 {
2996  protected:
2998  std::string m_osName{};
2999 
3000  // This is actually a path of the form "/parent_path/{m_osName}"
3001  std::string m_osFullName{};
3002  std::weak_ptr<GDALAbstractMDArray> m_pSelf{};
3003 
3005  bool m_bValid = true;
3006 
3007  GDALAbstractMDArray(const std::string &osParentName,
3008  const std::string &osName);
3009 
3010  void SetSelf(const std::shared_ptr<GDALAbstractMDArray> &self)
3011  {
3012  m_pSelf = self;
3013  }
3014 
3015  bool CheckValidAndErrorOutIfNot() const;
3016 
3017  bool CheckReadWriteParams(const GUInt64 *arrayStartIdx, const size_t *count,
3018  const GInt64 *&arrayStep,
3019  const GPtrDiff_t *&bufferStride,
3020  const GDALExtendedDataType &bufferDataType,
3021  const void *buffer,
3022  const void *buffer_alloc_start,
3023  size_t buffer_alloc_size,
3024  std::vector<GInt64> &tmp_arrayStep,
3025  std::vector<GPtrDiff_t> &tmp_bufferStride) const;
3026 
3027  virtual bool
3028  IRead(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3029  const size_t *count, // array of size GetDimensionCount()
3030  const GInt64 *arrayStep, // step in elements
3031  const GPtrDiff_t *bufferStride, // stride in elements
3032  const GDALExtendedDataType &bufferDataType,
3033  void *pDstBuffer) const = 0;
3034 
3035  virtual bool
3036  IWrite(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3037  const size_t *count, // array of size GetDimensionCount()
3038  const GInt64 *arrayStep, // step in elements
3039  const GPtrDiff_t *bufferStride, // stride in elements
3040  const GDALExtendedDataType &bufferDataType, const void *pSrcBuffer);
3041 
3042  void BaseRename(const std::string &osNewName);
3043 
3044  virtual void NotifyChildrenOfRenaming()
3045  {
3046  }
3047 
3048  virtual void NotifyChildrenOfDeletion()
3049  {
3050  }
3051 
3053 
3054  public:
3055  virtual ~GDALAbstractMDArray();
3056 
3062  const std::string &GetName() const
3063  {
3064  return m_osName;
3065  }
3066 
3072  const std::string &GetFullName() const
3073  {
3074  return m_osFullName;
3075  }
3076 
3077  GUInt64 GetTotalElementsCount() const;
3078 
3079  virtual size_t GetDimensionCount() const;
3080 
3081  virtual const std::vector<std::shared_ptr<GDALDimension>> &
3082  GetDimensions() const = 0;
3083 
3084  virtual const GDALExtendedDataType &GetDataType() const = 0;
3085 
3086  virtual std::vector<GUInt64> GetBlockSize() const;
3087 
3088  virtual std::vector<size_t>
3089  GetProcessingChunkSize(size_t nMaxChunkMemory) const;
3090 
3091  /* clang-format off */
3107  typedef bool (*FuncProcessPerChunkType)(
3108  GDALAbstractMDArray *array,
3109  const GUInt64 *chunkArrayStartIdx,
3110  const size_t *chunkCount,
3111  GUInt64 iCurChunk,
3112  GUInt64 nChunkCount,
3113  void *pUserData);
3114  /* clang-format on */
3115 
3116  virtual bool ProcessPerChunk(const GUInt64 *arrayStartIdx,
3117  const GUInt64 *count, const size_t *chunkSize,
3118  FuncProcessPerChunkType pfnFunc,
3119  void *pUserData);
3120 
3121  virtual bool
3122  Read(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3123  const size_t *count, // array of size GetDimensionCount()
3124  const GInt64 *arrayStep, // step in elements
3125  const GPtrDiff_t *bufferStride, // stride in elements
3126  const GDALExtendedDataType &bufferDataType, void *pDstBuffer,
3127  const void *pDstBufferAllocStart = nullptr,
3128  size_t nDstBufferAllocSize = 0) const;
3129 
3130  bool
3131  Write(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3132  const size_t *count, // array of size GetDimensionCount()
3133  const GInt64 *arrayStep, // step in elements
3134  const GPtrDiff_t *bufferStride, // stride in elements
3135  const GDALExtendedDataType &bufferDataType, const void *pSrcBuffer,
3136  const void *pSrcBufferAllocStart = nullptr,
3137  size_t nSrcBufferAllocSize = 0);
3138 
3139  virtual bool Rename(const std::string &osNewName);
3140 
3142  virtual void Deleted();
3143 
3144  virtual void ParentDeleted();
3145 
3146  virtual void ParentRenamed(const std::string &osNewParentFullName);
3148 };
3149 
3150 /* ******************************************************************** */
3151 /* GDALRawResult */
3152 /* ******************************************************************** */
3153 
3160 class CPL_DLL GDALRawResult
3161 {
3162  private:
3163  GDALExtendedDataType m_dt;
3164  size_t m_nEltCount;
3165  size_t m_nSize;
3166  GByte *m_raw;
3167 
3168  void FreeMe();
3169 
3170  GDALRawResult(const GDALRawResult &) = delete;
3171  GDALRawResult &operator=(const GDALRawResult &) = delete;
3172 
3173  protected:
3174  friend class GDALAttribute;
3176  GDALRawResult(GByte *raw, const GDALExtendedDataType &dt, size_t nEltCount);
3178 
3179  public:
3180  ~GDALRawResult();
3182  GDALRawResult &operator=(GDALRawResult &&);
3183 
3185  const GByte &operator[](size_t idx) const
3186  {
3187  return m_raw[idx];
3188  }
3189 
3191  const GByte *data() const
3192  {
3193  return m_raw;
3194  }
3195 
3197  size_t size() const
3198  {
3199  return m_nSize;
3200  }
3201 
3203  GByte *StealData();
3205 };
3206 
3207 /* ******************************************************************** */
3208 /* GDALAttribute */
3209 /* ******************************************************************** */
3210 
3211 /* clang-format off */
3223 /* clang-format on */
3224 
3225 class CPL_DLL GDALAttribute : virtual public GDALAbstractMDArray
3226 {
3227  mutable std::string m_osCachedVal{};
3228 
3229  protected:
3231  GDALAttribute(const std::string &osParentName, const std::string &osName);
3233 
3234  public:
3235  std::vector<GUInt64> GetDimensionsSize() const;
3236 
3237  GDALRawResult ReadAsRaw() const;
3238  const char *ReadAsString() const;
3239  int ReadAsInt() const;
3240  int64_t ReadAsInt64() const;
3241  double ReadAsDouble() const;
3242  CPLStringList ReadAsStringArray() const;
3243  std::vector<int> ReadAsIntArray() const;
3244  std::vector<int64_t> ReadAsInt64Array() const;
3245  std::vector<double> ReadAsDoubleArray() const;
3246 
3248  bool Write(const void *pabyValue, size_t nLen);
3249  bool Write(const char *);
3250  bool WriteInt(int);
3251  bool WriteInt64(int64_t);
3252  bool Write(double);
3253  bool Write(CSLConstList);
3254  bool Write(const int *, size_t);
3255  bool Write(const int64_t *, size_t);
3256  bool Write(const double *, size_t);
3257 
3259  static constexpr GUInt64 COPY_COST = 100;
3261 };
3262 
3263 /************************************************************************/
3264 /* GDALAttributeString */
3265 /************************************************************************/
3266 
3268 class CPL_DLL GDALAttributeString final : public GDALAttribute
3269 {
3270  std::vector<std::shared_ptr<GDALDimension>> m_dims{};
3272  std::string m_osValue;
3273 
3274  protected:
3275  bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
3276  const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
3277  void *pDstBuffer) const override;
3278 
3279  public:
3280  GDALAttributeString(const std::string &osParentName,
3281  const std::string &osName, const std::string &osValue,
3283 
3284  const std::vector<std::shared_ptr<GDALDimension>> &
3285  GetDimensions() const override;
3286 
3287  const GDALExtendedDataType &GetDataType() const override;
3288 };
3289 
3291 
3292 /************************************************************************/
3293 /* GDALAttributeNumeric */
3294 /************************************************************************/
3295 
3297 class CPL_DLL GDALAttributeNumeric final : public GDALAttribute
3298 {
3299  std::vector<std::shared_ptr<GDALDimension>> m_dims{};
3300  GDALExtendedDataType m_dt;
3301  int m_nValue = 0;
3302  double m_dfValue = 0;
3303  std::vector<GUInt32> m_anValuesUInt32{};
3304 
3305  protected:
3306  bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
3307  const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
3308  void *pDstBuffer) const override;
3309 
3310  public:
3311  GDALAttributeNumeric(const std::string &osParentName,
3312  const std::string &osName, double dfValue);
3313  GDALAttributeNumeric(const std::string &osParentName,
3314  const std::string &osName, int nValue);
3315  GDALAttributeNumeric(const std::string &osParentName,
3316  const std::string &osName,
3317  const std::vector<GUInt32> &anValues);
3318 
3319  const std::vector<std::shared_ptr<GDALDimension>> &
3320  GetDimensions() const override;
3321 
3322  const GDALExtendedDataType &GetDataType() const override;
3323 };
3324 
3326 
3327 /* ******************************************************************** */
3328 /* GDALMDArray */
3329 /* ******************************************************************** */
3330 
3331 /* clang-format off */
3341 /* clang-format on */
3342 
3343 class CPL_DLL GDALMDArray : virtual public GDALAbstractMDArray,
3344  public GDALIHasAttribute
3345 {
3346  friend class GDALMDArrayResampled;
3347  std::shared_ptr<GDALMDArray>
3348  GetView(const std::vector<GUInt64> &indices) const;
3349 
3350  inline std::shared_ptr<GDALMDArray>
3351  atInternal(const std::vector<GUInt64> &indices) const
3352  {
3353  return GetView(indices);
3354  }
3355 
3356  template <typename... GUInt64VarArg>
3357  // cppcheck-suppress functionStatic
3358  inline std::shared_ptr<GDALMDArray>
3359  atInternal(std::vector<GUInt64> &indices, GUInt64 idx,
3360  GUInt64VarArg... tail) const
3361  {
3362  indices.push_back(idx);
3363  return atInternal(indices, tail...);
3364  }
3365 
3366  // Used for example by GDALSubsetGroup to distinguish a derived group
3367  //from its original, without altering its name
3368  const std::string m_osContext{};
3369 
3370  mutable bool m_bHasTriedCachedArray = false;
3371  mutable std::shared_ptr<GDALMDArray> m_poCachedArray{};
3372 
3373  protected:
3375  GDALMDArray(const std::string &osParentName, const std::string &osName,
3376  const std::string &osContext = std::string());
3377 
3378  virtual bool IAdviseRead(const GUInt64 *arrayStartIdx, const size_t *count,
3379  CSLConstList papszOptions) const;
3380 
3381  virtual bool IsCacheable() const
3382  {
3383  return true;
3384  }
3385 
3386  virtual bool SetStatistics(bool bApproxStats, double dfMin, double dfMax,
3387  double dfMean, double dfStdDev,
3388  GUInt64 nValidCount, CSLConstList papszOptions);
3389 
3390  static std::string MassageName(const std::string &inputName);
3391 
3392  std::shared_ptr<GDALGroup>
3393  GetCacheRootGroup(bool bCanCreate, std::string &osCacheFilenameOut) const;
3394 
3395  // Returns if bufferStride values express a transposed view of the array
3396  bool IsTransposedRequest(const size_t *count,
3397  const GPtrDiff_t *bufferStride) const;
3398 
3399  // Should only be called if IsTransposedRequest() returns true
3400  bool ReadForTransposedRequest(const GUInt64 *arrayStartIdx,
3401  const size_t *count, const GInt64 *arrayStep,
3402  const GPtrDiff_t *bufferStride,
3403  const GDALExtendedDataType &bufferDataType,
3404  void *pDstBuffer) const;
3405 
3406  bool IsStepOneContiguousRowMajorOrderedSameDataType(
3407  const size_t *count, const GInt64 *arrayStep,
3408  const GPtrDiff_t *bufferStride,
3409  const GDALExtendedDataType &bufferDataType) const;
3410 
3411  // Should only be called if IsStepOneContiguousRowMajorOrderedSameDataType()
3412  // returns false
3413  bool ReadUsingContiguousIRead(const GUInt64 *arrayStartIdx,
3414  const size_t *count, const GInt64 *arrayStep,
3415  const GPtrDiff_t *bufferStride,
3416  const GDALExtendedDataType &bufferDataType,
3417  void *pDstBuffer) const;
3418 
3419  static std::shared_ptr<GDALMDArray> CreateGLTOrthorectified(
3420  const std::shared_ptr<GDALMDArray> &poParent,
3421  const std::shared_ptr<GDALGroup> &poRootGroup,
3422  const std::shared_ptr<GDALMDArray> &poGLTX,
3423  const std::shared_ptr<GDALMDArray> &poGLTY, int nGLTIndexOffset,
3424  const std::vector<double> &adfGeoTransform, CSLConstList papszOptions);
3425 
3427 
3428  public:
3429  GUInt64 GetTotalCopyCost() const;
3430 
3431  virtual bool CopyFrom(GDALDataset *poSrcDS, const GDALMDArray *poSrcArray,
3432  bool bStrict, GUInt64 &nCurCost,
3433  const GUInt64 nTotalCost,
3434  GDALProgressFunc pfnProgress, void *pProgressData);
3435 
3437  virtual bool IsWritable() const = 0;
3438 
3447  virtual const std::string &GetFilename() const = 0;
3448 
3449  virtual CSLConstList GetStructuralInfo() const;
3450 
3451  virtual const std::string &GetUnit() const;
3452 
3453  virtual bool SetUnit(const std::string &osUnit);
3454 
3455  virtual bool SetSpatialRef(const OGRSpatialReference *poSRS);
3456 
3457  virtual std::shared_ptr<OGRSpatialReference> GetSpatialRef() const;
3458 
3459  virtual const void *GetRawNoDataValue() const;
3460 
3461  double GetNoDataValueAsDouble(bool *pbHasNoData = nullptr) const;
3462 
3463  int64_t GetNoDataValueAsInt64(bool *pbHasNoData = nullptr) const;
3464 
3465  uint64_t GetNoDataValueAsUInt64(bool *pbHasNoData = nullptr) const;
3466 
3467  virtual bool SetRawNoDataValue(const void *pRawNoData);
3468 
3470  bool SetNoDataValue(int nNoData)
3471  {
3472  return SetNoDataValue(static_cast<int64_t>(nNoData));
3473  }
3474 
3476 
3477  bool SetNoDataValue(double dfNoData);
3478 
3479  bool SetNoDataValue(int64_t nNoData);
3480 
3481  bool SetNoDataValue(uint64_t nNoData);
3482 
3483  virtual bool Resize(const std::vector<GUInt64> &anNewDimSizes,
3484  CSLConstList papszOptions);
3485 
3486  virtual double GetOffset(bool *pbHasOffset = nullptr,
3487  GDALDataType *peStorageType = nullptr) const;
3488 
3489  virtual double GetScale(bool *pbHasScale = nullptr,
3490  GDALDataType *peStorageType = nullptr) const;
3491 
3492  virtual bool SetOffset(double dfOffset,
3493  GDALDataType eStorageType = GDT_Unknown);
3494 
3495  virtual bool SetScale(double dfScale,
3496  GDALDataType eStorageType = GDT_Unknown);
3497 
3498  std::shared_ptr<GDALMDArray> GetView(const std::string &viewExpr) const;
3499 
3500  std::shared_ptr<GDALMDArray> operator[](const std::string &fieldName) const;
3501 
3511  // sphinx 4.1.0 / breathe 4.30.0 don't like typename...
3513  template <typename... GUInt64VarArg>
3515  // cppcheck-suppress functionStatic
3516  std::shared_ptr<GDALMDArray> at(GUInt64 idx, GUInt64VarArg... tail) const
3517  {
3518  std::vector<GUInt64> indices;
3519  indices.push_back(idx);
3520  return atInternal(indices, tail...);
3521  }
3522 
3523  virtual std::shared_ptr<GDALMDArray>
3524  Transpose(const std::vector<int> &anMapNewAxisToOldAxis) const;
3525 
3526  std::shared_ptr<GDALMDArray> GetUnscaled(
3527  double dfOverriddenScale = std::numeric_limits<double>::quiet_NaN(),
3528  double dfOverriddenOffset = std::numeric_limits<double>::quiet_NaN(),
3529  double dfOverriddenDstNodata =
3530  std::numeric_limits<double>::quiet_NaN()) const;
3531 
3532  virtual std::shared_ptr<GDALMDArray>
3533  GetMask(CSLConstList papszOptions) const;
3534 
3535  virtual std::shared_ptr<GDALMDArray>
3536  GetResampled(const std::vector<std::shared_ptr<GDALDimension>> &apoNewDims,
3537  GDALRIOResampleAlg resampleAlg,
3538  const OGRSpatialReference *poTargetSRS,
3539  CSLConstList papszOptions) const;
3540 
3541  std::shared_ptr<GDALMDArray>
3542  GetGridded(const std::string &osGridOptions,
3543  const std::shared_ptr<GDALMDArray> &poXArray = nullptr,
3544  const std::shared_ptr<GDALMDArray> &poYArray = nullptr,
3545  CSLConstList papszOptions = nullptr) const;
3546 
3547  virtual GDALDataset *
3548  AsClassicDataset(size_t iXDim, size_t iYDim,
3549  const std::shared_ptr<GDALGroup> &poRootGroup = nullptr,
3550  CSLConstList papszOptions = nullptr) const;
3551 
3552  virtual CPLErr GetStatistics(bool bApproxOK, bool bForce, double *pdfMin,
3553  double *pdfMax, double *pdfMean,
3554  double *padfStdDev, GUInt64 *pnValidCount,
3555  GDALProgressFunc pfnProgress,
3556  void *pProgressData);
3557 
3558  virtual bool ComputeStatistics(bool bApproxOK, double *pdfMin,
3559  double *pdfMax, double *pdfMean,
3560  double *pdfStdDev, GUInt64 *pnValidCount,
3561  GDALProgressFunc, void *pProgressData,
3562  CSLConstList papszOptions);
3563 
3564  virtual void ClearStatistics();
3565 
3566  virtual std::vector<std::shared_ptr<GDALMDArray>>
3567  GetCoordinateVariables() const;
3568 
3569  bool AdviseRead(const GUInt64 *arrayStartIdx, const size_t *count,
3570  CSLConstList papszOptions = nullptr) const;
3571 
3572  bool IsRegularlySpaced(double &dfStart, double &dfIncrement) const;
3573 
3574  bool GuessGeoTransform(size_t nDimX, size_t nDimY, bool bPixelIsPoint,
3575  double adfGeoTransform[6]) const;
3576 
3577  bool Cache(CSLConstList papszOptions = nullptr) const;
3578 
3579  bool
3580  Read(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3581  const size_t *count, // array of size GetDimensionCount()
3582  const GInt64 *arrayStep, // step in elements
3583  const GPtrDiff_t *bufferStride, // stride in elements
3584  const GDALExtendedDataType &bufferDataType, void *pDstBuffer,
3585  const void *pDstBufferAllocStart = nullptr,
3586  size_t nDstBufferAllocSize = 0) const override final;
3587 
3588  virtual std::shared_ptr<GDALGroup> GetRootGroup() const;
3589 
3591  static constexpr GUInt64 COPY_COST = 1000;
3592 
3593  bool CopyFromAllExceptValues(const GDALMDArray *poSrcArray, bool bStrict,
3594  GUInt64 &nCurCost, const GUInt64 nTotalCost,
3595  GDALProgressFunc pfnProgress,
3596  void *pProgressData);
3597 
3598  struct Range
3599  {
3600  GUInt64 m_nStartIdx;
3601  GInt64 m_nIncr;
3602 
3603  explicit Range(GUInt64 nStartIdx = 0, GInt64 nIncr = 0)
3604  : m_nStartIdx(nStartIdx), m_nIncr(nIncr)
3605  {
3606  }
3607  };
3608 
3609  struct ViewSpec
3610  {
3611  std::string m_osFieldName{};
3612 
3613  // or
3614 
3615  std::vector<size_t>
3616  m_mapDimIdxToParentDimIdx{}; // of size m_dims.size()
3617  std::vector<Range>
3618  m_parentRanges{}; // of size m_poParent->GetDimensionCount()
3619  };
3620 
3621  virtual std::shared_ptr<GDALMDArray>
3622  GetView(const std::string &viewExpr, bool bRenameDimensions,
3623  std::vector<ViewSpec> &viewSpecs) const;
3624 
3625  const std::string &GetContext() const
3626  {
3627  return m_osContext;
3628  }
3629 
3631 };
3632 
3634 bool GDALMDRasterIOFromBand(GDALRasterBand *poBand, GDALRWFlag eRWFlag,
3635  size_t iDimX, size_t iDimY,
3636  const GUInt64 *arrayStartIdx, const size_t *count,
3637  const GInt64 *arrayStep,
3638  const GPtrDiff_t *bufferStride,
3639  const GDALExtendedDataType &bufferDataType,
3640  void *pBuffer);
3641 
3643 
3644 /************************************************************************/
3645 /* GDALMDArrayRegularlySpaced */
3646 /************************************************************************/
3647 
3649 class CPL_DLL GDALMDArrayRegularlySpaced : public GDALMDArray
3650 {
3651  double m_dfStart;
3652  double m_dfIncrement;
3653  double m_dfOffsetInIncrement;
3655  std::vector<std::shared_ptr<GDALDimension>> m_dims;
3656  std::vector<std::shared_ptr<GDALAttribute>> m_attributes{};
3657  std::string m_osEmptyFilename{};
3658 
3659  protected:
3660  bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
3661  const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
3662  void *pDstBuffer) const override;
3663 
3664  public:
3665  GDALMDArrayRegularlySpaced(const std::string &osParentName,
3666  const std::string &osName,
3667  const std::shared_ptr<GDALDimension> &poDim,
3668  double dfStart, double dfIncrement,
3669  double dfOffsetInIncrement);
3670 
3671  static std::shared_ptr<GDALMDArrayRegularlySpaced>
3672  Create(const std::string &osParentName, const std::string &osName,
3673  const std::shared_ptr<GDALDimension> &poDim, double dfStart,
3674  double dfIncrement, double dfOffsetInIncrement);
3675 
3676  bool IsWritable() const override
3677  {
3678  return false;
3679  }
3680 
3681  const std::string &GetFilename() const override
3682  {
3683  return m_osEmptyFilename;
3684  }
3685 
3686  const std::vector<std::shared_ptr<GDALDimension>> &
3687  GetDimensions() const override;
3688 
3689  const GDALExtendedDataType &GetDataType() const override;
3690 
3691  std::vector<std::shared_ptr<GDALAttribute>>
3692  GetAttributes(CSLConstList) const override;
3693 
3694  void AddAttribute(const std::shared_ptr<GDALAttribute> &poAttr);
3695 };
3696 
3698 
3699 /* ******************************************************************** */
3700 /* GDALDimension */
3701 /* ******************************************************************** */
3702 
3714 class CPL_DLL GDALDimension
3715 {
3716  public:
3718  GDALDimension(const std::string &osParentName, const std::string &osName,
3719  const std::string &osType, const std::string &osDirection,
3720  GUInt64 nSize);
3722 
3723  virtual ~GDALDimension();
3724 
3729  const std::string &GetName() const
3730  {
3731  return m_osName;
3732  }
3733 
3738  const std::string &GetFullName() const
3739  {
3740  return m_osFullName;
3741  }
3742 
3751  const std::string &GetType() const
3752  {
3753  return m_osType;
3754  }
3755 
3764  const std::string &GetDirection() const
3765  {
3766  return m_osDirection;
3767  }
3768 
3774  {
3775  return m_nSize;
3776  }
3777 
3778  virtual std::shared_ptr<GDALMDArray> GetIndexingVariable() const;
3779 
3780  virtual bool
3781  SetIndexingVariable(std::shared_ptr<GDALMDArray> poIndexingVariable);
3782 
3783  virtual bool Rename(const std::string &osNewName);
3784 
3786  virtual void ParentRenamed(const std::string &osNewParentFullName);
3787 
3788  virtual void ParentDeleted();
3790 
3791  protected:
3793  std::string m_osName;
3794  std::string m_osFullName;
3795  std::string m_osType;
3796  std::string m_osDirection;
3797  GUInt64 m_nSize;
3798 
3799  void BaseRename(const std::string &osNewName);
3800 
3802 };
3803 
3804 /************************************************************************/
3805 /* GDALDimensionWeakIndexingVar() */
3806 /************************************************************************/
3807 
3809 class CPL_DLL GDALDimensionWeakIndexingVar : public GDALDimension
3810 {
3811  std::weak_ptr<GDALMDArray> m_poIndexingVariable{};
3812 
3813  public:
3814  GDALDimensionWeakIndexingVar(const std::string &osParentName,
3815  const std::string &osName,
3816  const std::string &osType,
3817  const std::string &osDirection, GUInt64 nSize);
3818 
3819  std::shared_ptr<GDALMDArray> GetIndexingVariable() const override;
3820 
3821  bool SetIndexingVariable(
3822  std::shared_ptr<GDALMDArray> poIndexingVariable) override;
3823 
3824  void SetSize(GUInt64 nNewSize);
3825 };
3827 
3828 /************************************************************************/
3829 /* GDALAntiRecursionGuard */
3830 /************************************************************************/
3831 
3833 struct GDALAntiRecursionStruct;
3834 
3835 class GDALAntiRecursionGuard
3836 {
3837  GDALAntiRecursionStruct *m_psAntiRecursionStruct;
3838  std::string m_osIdentifier;
3839  int m_nDepth;
3840 
3841  GDALAntiRecursionGuard(const GDALAntiRecursionGuard &) = delete;
3842  GDALAntiRecursionGuard &operator=(const GDALAntiRecursionGuard &) = delete;
3843 
3844  public:
3845  explicit GDALAntiRecursionGuard(const std::string &osIdentifier);
3846  GDALAntiRecursionGuard(const GDALAntiRecursionGuard &other,
3847  const std::string &osIdentifier);
3848  ~GDALAntiRecursionGuard();
3849 
3850  int GetCallDepth() const
3851  {
3852  return m_nDepth;
3853  }
3854 };
3855 
3857 
3858 /************************************************************************/
3859 /* Relationships */
3860 /************************************************************************/
3861 
3873 class CPL_DLL GDALRelationship
3874 {
3875  protected:
3877  std::string m_osName{};
3878  std::string m_osLeftTableName{};
3879  std::string m_osRightTableName{};
3880  GDALRelationshipCardinality m_eCardinality =
3882  std::string m_osMappingTableName{};
3883  std::vector<std::string> m_osListLeftTableFields{};
3884  std::vector<std::string> m_osListRightTableFields{};
3885  std::vector<std::string> m_osListLeftMappingTableFields{};
3886  std::vector<std::string> m_osListRightMappingTableFields{};
3888  std::string m_osForwardPathLabel{};
3889  std::string m_osBackwardPathLabel{};
3890  std::string m_osRelatedTableType{};
3891 
3894  public:
3902  GDALRelationship(const std::string &osName,
3903  const std::string &osLeftTableName,
3904  const std::string &osRightTableName,
3905  GDALRelationshipCardinality eCardinality =
3907  : m_osName(osName), m_osLeftTableName(osLeftTableName),
3908  m_osRightTableName(osRightTableName), m_eCardinality(eCardinality)
3909  {
3910  }
3911 
3913  const std::string &GetName() const
3914  {
3915  return m_osName;
3916  }
3917 
3920  {
3921  return m_eCardinality;
3922  }
3923 
3928  const std::string &GetLeftTableName() const
3929  {
3930  return m_osLeftTableName;
3931  }
3932 
3935  const std::string &GetRightTableName() const
3936  {
3937  return m_osRightTableName;
3938  }
3939 
3944  const std::string &GetMappingTableName() const
3945  {
3946  return m_osMappingTableName;
3947  }
3948 
3953  void SetMappingTableName(const std::string &osName)
3954  {
3955  m_osMappingTableName = osName;
3956  }
3957 
3964  const std::vector<std::string> &GetLeftTableFields() const
3965  {
3966  return m_osListLeftTableFields;
3967  }
3968 
3975  const std::vector<std::string> &GetRightTableFields() const
3976  {
3977  return m_osListRightTableFields;
3978  }
3979 
3986  void SetLeftTableFields(const std::vector<std::string> &osListFields)
3987  {
3988  m_osListLeftTableFields = osListFields;
3989  }
3990 
3997  void SetRightTableFields(const std::vector<std::string> &osListFields)
3998  {
3999  m_osListRightTableFields = osListFields;
4000  }
4001 
4008  const std::vector<std::string> &GetLeftMappingTableFields() const
4009  {
4010  return m_osListLeftMappingTableFields;
4011  }
4012 
4019  const std::vector<std::string> &GetRightMappingTableFields() const
4020  {
4021  return m_osListRightMappingTableFields;
4022  }
4023 
4030  void SetLeftMappingTableFields(const std::vector<std::string> &osListFields)
4031  {
4032  m_osListLeftMappingTableFields = osListFields;
4033  }
4034 
4041  void
4042  SetRightMappingTableFields(const std::vector<std::string> &osListFields)
4043  {
4044  m_osListRightMappingTableFields = osListFields;
4045  }
4046 
4052  {
4053  return m_eType;
4054  }
4055 
4061  {
4062  m_eType = eType;
4063  }
4064 
4080  const std::string &GetForwardPathLabel() const
4081  {
4082  return m_osForwardPathLabel;
4083  }
4084 
4100  void SetForwardPathLabel(const std::string &osLabel)
4101  {
4102  m_osForwardPathLabel = osLabel;
4103  }
4104 
4120  const std::string &GetBackwardPathLabel() const
4121  {
4122  return m_osBackwardPathLabel;
4123  }
4124 
4140  void SetBackwardPathLabel(const std::string &osLabel)
4141  {
4142  m_osBackwardPathLabel = osLabel;
4143  }
4144 
4155  const std::string &GetRelatedTableType() const
4156  {
4157  return m_osRelatedTableType;
4158  }
4159 
4170  void SetRelatedTableType(const std::string &osType)
4171  {
4172  m_osRelatedTableType = osType;
4173  }
4174 
4177  static inline GDALRelationshipH ToHandle(GDALRelationship *poRelationship)
4178  {
4179  return static_cast<GDALRelationshipH>(poRelationship);
4180  }
4181 
4184  static inline GDALRelationship *FromHandle(GDALRelationshipH hRelationship)
4185  {
4186  return static_cast<GDALRelationship *>(hRelationship);
4187  }
4188 };
4189 
4190 /* ==================================================================== */
4191 /* An assortment of overview related stuff. */
4192 /* ==================================================================== */
4193 
4195 /* Only exported for drivers as plugin. Signature may change */
4196 CPLErr CPL_DLL GDALRegenerateOverviewsMultiBand(
4197  int nBands, GDALRasterBand *const *papoSrcBands, int nOverviews,
4198  GDALRasterBand *const *const *papapoOverviewBands,
4199  const char *pszResampling, GDALProgressFunc pfnProgress,
4200  void *pProgressData, CSLConstList papszOptions);
4201 
4202 CPLErr CPL_DLL GDALRegenerateOverviewsMultiBand(
4203  const std::vector<GDALRasterBand *> &apoSrcBands,
4204  // First level of array is indexed by band (thus aapoOverviewBands.size() must be equal to apoSrcBands.size())
4205  // Second level is indexed by overview
4206  const std::vector<std::vector<GDALRasterBand *>> &aapoOverviewBands,
4207  const char *pszResampling, GDALProgressFunc pfnProgress,
4208  void *pProgressData, CSLConstList papszOptions);
4209 
4210 /************************************************************************/
4211 /* GDALOverviewResampleArgs */
4212 /************************************************************************/
4213 
4215 // Should not contain any dataset/rasterband object, as this might be
4216 // read in a worker thread.
4217 struct GDALOverviewResampleArgs
4218 {
4220  GDALDataType eSrcDataType = GDT_Unknown;
4222  GDALDataType eOvrDataType = GDT_Unknown;
4224  int nOvrXSize = 0;
4226  int nOvrYSize = 0;
4228  int nOvrNBITS = 0;
4230  // (source width divided by destination width)
4231  double dfXRatioDstToSrc = 0;
4233  // (source height divided by destination height)
4234  double dfYRatioDstToSrc = 0;
4236  double dfSrcXDelta = 0;
4238  double dfSrcYDelta = 0;
4240  GDALDataType eWrkDataType = GDT_Unknown;
4242  const GByte *pabyChunkNodataMask = nullptr;
4244  int nChunkXOff = 0;
4246  int nChunkXSize = 0;
4248  int nChunkYOff = 0;
4250  int nChunkYSize = 0;
4252  int nDstXOff = 0;
4254  int nDstXOff2 = 0;
4256  int nDstYOff = 0;
4258  int nDstYOff2 = 0;
4260  const char *pszResampling = nullptr;
4262  bool bHasNoData = false;
4264  double dfNoDataValue = 0;
4266  const GDALColorTable *poColorTable = nullptr;
4268  // in the target pixel to be at nodata too (only taken into account by
4269  // average resampling)
4270  bool bPropagateNoData = false;
4271 };
4272 
4273 typedef CPLErr (*GDALResampleFunction)(const GDALOverviewResampleArgs &args,
4274  const void *pChunk, void **ppDstBuffer,
4275  GDALDataType *peDstBufferDataType);
4276 
4277 GDALResampleFunction GDALGetResampleFunction(const char *pszResampling,
4278  int *pnRadius);
4279 
4280 std::string CPL_DLL GDALGetNormalizedOvrResampling(const char *pszResampling);
4281 
4282 GDALDataType GDALGetOvrWorkDataType(const char *pszResampling,
4283  GDALDataType eSrcDataType);
4284 
4286 
4287 CPLErr CPL_DLL
4288 HFAAuxBuildOverviews(const char *pszOvrFilename, GDALDataset *poParentDS,
4289  GDALDataset **ppoDS, int nBands, const int *panBandList,
4290  int nNewOverviews, const int *panNewOverviewList,
4291  const char *pszResampling, GDALProgressFunc pfnProgress,
4292  void *pProgressData, CSLConstList papszOptions);
4293 
4294 CPLErr CPL_DLL GTIFFBuildOverviews(const char *pszFilename, int nBands,
4295  GDALRasterBand *const *papoBandList,
4296  int nOverviews, const int *panOverviewList,
4297  const char *pszResampling,
4298  GDALProgressFunc pfnProgress,
4299  void *pProgressData,
4300  CSLConstList papszOptions);
4301 
4302 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand *poBand, int &nXOff,
4303  int &nYOff, int &nXSize, int &nYSize,
4304  int nBufXSize, int nBufYSize)
4305  CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead");
4306 int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand *poBand, int &nXOff,
4307  int &nYOff, int &nXSize, int &nYSize,
4308  int nBufXSize, int nBufYSize,
4309  GDALRasterIOExtraArg *psExtraArg);
4310 
4311 int CPL_DLL GDALOvLevelAdjust(int nOvLevel, int nXSize)
4312  CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead");
4313 int CPL_DLL GDALOvLevelAdjust2(int nOvLevel, int nXSize, int nYSize);
4314 int CPL_DLL GDALComputeOvFactor(int nOvrXSize, int nRasterXSize, int nOvrYSize,
4315  int nRasterYSize);
4316 
4317 GDALDataset CPL_DLL *GDALFindAssociatedAuxFile(const char *pszBasefile,
4318  GDALAccess eAccess,
4319  GDALDataset *poDependentDS);
4320 
4321 /* ==================================================================== */
4322 /* Infrastructure to check that dataset characteristics are valid */
4323 /* ==================================================================== */
4324 
4325 int CPL_DLL GDALCheckDatasetDimensions(int nXSize, int nYSize);
4326 int CPL_DLL GDALCheckBandCount(int nBands, int bIsZeroAllowed);
4327 
4328 /* Internal use only */
4329 
4330 /* CPL_DLL exported, but only for in-tree drivers that can be built as plugins
4331  */
4332 int CPL_DLL GDALReadWorldFile2(const char *pszBaseFilename,
4333  const char *pszExtension,
4334  double *padfGeoTransform,
4335  char **papszSiblingFiles,
4336  char **ppszWorldFileNameOut);
4337 int CPL_DLL GDALReadTabFile2(const char *pszBaseFilename,
4338  double *padfGeoTransform, char **ppszWKT,
4339  int *pnGCPCount, GDAL_GCP **ppasGCPs,
4340  char **papszSiblingFiles,
4341  char **ppszTabFileNameOut);
4342 
4343 void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg *psDestArg,
4344  GDALRasterIOExtraArg *psSrcArg);
4345 
4346 CPL_C_END
4347 
4348 void GDALNullifyOpenDatasetsList();
4349 CPLMutex **GDALGetphDMMutex();
4350 CPLMutex **GDALGetphDLMutex();
4351 void GDALNullifyProxyPoolSingleton();
4352 void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
4353 GIntBig GDALGetResponsiblePIDForCurrentThread();
4354 
4355 CPLString GDALFindAssociatedFile(const char *pszBasename, const char *pszExt,
4356  CSLConstList papszSiblingFiles, int nFlags);
4357 
4358 CPLErr CPL_DLL EXIFExtractMetadata(char **&papszMetadata, void *fpL,
4359  int nOffset, int bSwabflag, int nTIFFHEADER,
4360  int &nExifOffset, int &nInterOffset,
4361  int &nGPSOffset);
4362 
4363 int GDALValidateOpenOptions(GDALDriverH hDriver,
4364  const char *const *papszOptionOptions);
4365 int GDALValidateOptions(const char *pszOptionList,
4366  const char *const *papszOptionsToValidate,
4367  const char *pszErrorMessageOptionType,
4368  const char *pszErrorMessageContainerName);
4369 
4370 GDALRIOResampleAlg GDALRasterIOGetResampleAlg(const char *pszResampling);
4371 const char *GDALRasterIOGetResampleAlg(GDALRIOResampleAlg eResampleAlg);
4372 
4373 void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg *psExtraArg,
4374  int nXSize, int nYSize, int nBufXSize,
4375  int nBufYSize);
4376 
4377 GDALDataset *GDALCreateOverviewDataset(GDALDataset *poDS, int nOvrLevel,
4378  bool bThisLevelOnly);
4379 
4380 // Should cover particular cases of #3573, #4183, #4506, #6578
4381 // Behavior is undefined if fVal1 or fVal2 are NaN (should be tested before
4382 // calling this function)
4383 template <class T> inline bool ARE_REAL_EQUAL(T fVal1, T fVal2, int ulp = 2)
4384 {
4385  return fVal1 == fVal2 || /* Should cover infinity */
4386  std::abs(fVal1 - fVal2) < std::numeric_limits<float>::epsilon() *
4387  std::abs(fVal1 + fVal2) * ulp;
4388 }
4389 
4390 double GDALAdjustNoDataCloseToFloatMax(double dfVal);
4391 
4392 #define DIV_ROUND_UP(a, b) (((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1))
4393 
4394 // Number of data samples that will be used to compute approximate statistics
4395 // (minimum value, maximum value, etc.)
4396 #define GDALSTAT_APPROX_NUMSAMPLES 2500
4397 
4398 void GDALSerializeGCPListToXML(CPLXMLNode *psParentNode,
4399  const std::vector<gdal::GCP> &asGCPs,
4400  const OGRSpatialReference *poGCP_SRS);
4401 void GDALDeserializeGCPListFromXML(const CPLXMLNode *psGCPList,
4402  std::vector<gdal::GCP> &asGCPs,
4403  OGRSpatialReference **ppoGCP_SRS);
4404 
4405 void GDALSerializeOpenOptionsToXML(CPLXMLNode *psParentNode,
4406  char **papszOpenOptions);
4407 char **GDALDeserializeOpenOptionsFromXML(const CPLXMLNode *psParentNode);
4408 
4409 int GDALCanFileAcceptSidecarFile(const char *pszFilename);
4410 
4411 bool GDALCanReliablyUseSiblingFileList(const char *pszFilename);
4412 
4413 typedef enum
4414 {
4415  GSF_UNSIGNED_INT,
4416  GSF_SIGNED_INT,
4417  GSF_FLOATING_POINT,
4418 } GDALBufferSampleFormat;
4419 
4420 bool CPL_DLL GDALBufferHasOnlyNoData(const void *pBuffer, double dfNoDataValue,
4421  size_t nWidth, size_t nHeight,
4422  size_t nLineStride, size_t nComponents,
4423  int nBitsPerSample,
4424  GDALBufferSampleFormat nSampleFormat);
4425 
4426 void CPL_DLL GDALCopyNoDataValue(GDALRasterBand *poDstBand,
4427  GDALRasterBand *poSrcBand);
4428 
4429 double CPL_DLL GDALGetNoDataValueCastToDouble(int64_t nVal);
4430 double CPL_DLL GDALGetNoDataValueCastToDouble(uint64_t nVal);
4431 
4432 // Remove me in GDAL 4.0. See GetMetadataItem() implementation
4433 // Internal use in GDAL only !
4434 // Declaration copied in swig/include/gdal.i
4435 void CPL_DLL GDALEnablePixelTypeSignedByteWarning(GDALRasterBandH hBand,
4436  bool b);
4437 
4438 std::string CPL_DLL GDALGetCompressionFormatForJPEG(VSILFILE *fp);
4439 std::string CPL_DLL GDALGetCompressionFormatForJPEG(const void *pBuffer,
4440  size_t nBufferSize);
4441 
4443  GDALRATTableType eTableType,
4444  const std::vector<std::shared_ptr<GDALMDArray>> &apoArrays,
4445  const std::vector<GDALRATFieldUsage> &aeUsages);
4446 
4447 // Macro used so that Identify and driver metadata methods in drivers built
4448 // as plugin can be duplicated in libgdal core and in the driver under different
4449 // names
4450 #ifdef PLUGIN_FILENAME
4451 #define PLUGIN_SYMBOL_NAME(x) GDAL_core_##x
4452 #else
4453 #define PLUGIN_SYMBOL_NAME(x) GDAL_driver_##x
4454 #endif
4455 
4457 
4458 #endif /* ndef GDAL_PRIV_H_INCLUDED */
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:449
Convenient string class based on std::string.
Definition: cpl_string.h:320
Abstract class, implemented by GDALAttribute and GDALMDArray.
Definition: gdal_priv.h:2995
virtual const std::vector< std::shared_ptr< GDALDimension > > & GetDimensions() const =0
Return the dimensions of an attribute/array.
virtual const GDALExtendedDataType & GetDataType() const =0
Return the data type of an attribute/array.
const std::string & GetFullName() const
Return the name of an array or attribute.
Definition: gdal_priv.h:3072
const std::string & GetName() const
Return the name of an array or attribute.
Definition: gdal_priv.h:3062
bool Write(const GUInt64 *arrayStartIdx, const size_t *count, const GInt64 *arrayStep, const GPtrDiff_t *bufferStride, const GDALExtendedDataType &bufferDataType, const void *pSrcBuffer, const void *pSrcBufferAllocStart=nullptr, size_t nSrcBufferAllocSize=0)
Write part or totality of a multidimensional array or attribute.
Definition: gdalmultidim.cpp:2245
Class used as a session object for asynchronous requests.
Definition: gdal_priv.h:2431
void * GetBuffer()
Return buffer.
Definition: gdal_priv.h:2500
int GetXOffset() const
Return x offset.
Definition: gdal_priv.h:2468
int GetYOffset() const
Return y offset.
Definition: gdal_priv.h:2476
int GetYSize() const
Return height.
Definition: gdal_priv.h:2492
int GetBandCount() const
Return band count.
Definition: gdal_priv.h:2532
GDALDataType GetBufferType() const
Return buffer data type.
Definition: gdal_priv.h:2524
int GetBandSpace() const
Return band spacing.
Definition: gdal_priv.h:2564
int GetBufferYSize() const
Return buffer height.
Definition: gdal_priv.h:2516
int GetXSize() const
Return width.
Definition: gdal_priv.h:2484
GDALDataset * GetGDALDataset()
Return dataset.
Definition: gdal_priv.h:2460
virtual GDALAsyncStatusType GetNextUpdatedRegion(double dfTimeout, int *pnBufXOff, int *pnBufYOff, int *pnBufXSize, int *pnBufYSize)=0
= 0;
int GetPixelSpace() const
Return pixel spacing.
Definition: gdal_priv.h:2548
int * GetBandMap()
Return band map.
Definition: gdal_priv.h:2540
int GetLineSpace() const
Return line spacing.
Definition: gdal_priv.h:2556
int GetBufferXSize() const
Return buffer width.
Definition: gdal_priv.h:2508
Class modeling an attribute that has a name, a value and a type, and is typically used to describe a ...
Definition: gdal_priv.h:3226
A color table / palette.
Definition: gdal_priv.h:1348
static GDALColorTableH ToHandle(GDALColorTable *poCT)
Convert a GDALColorTable* to a GDALRasterBandH.
Definition: gdal_priv.h:1373
static GDALColorTable * FromHandle(GDALColorTableH hCT)
Convert a GDALColorTableH to a GDALColorTable*.
Definition: gdal_priv.h:1381
~GDALColorTable()
Destructor.
Class returned by GetBands() that act as a container for raster bands.
Definition: gdal_priv.h:663
Class returned by GetFeatures() that act as a container for vector features.
Definition: gdal_priv.h:1008
Layer iterator.
Definition: gdal_priv.h:954
void pointer
pointer
Definition: gdal_priv.h:962
void difference_type
difference_type
Definition: gdal_priv.h:961
std::input_iterator_tag iterator_category
iterator_category
Definition: gdal_priv.h:964
Class returned by GetLayers() that acts as a range of layers.
Definition: gdal_priv.h:940
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:503
virtual int CloseDependentDatasets()
Drop references to any other datasets referenced by this dataset.
Definition: gdaldataset.cpp:4509
virtual bool SetQueryLoggerFunc(GDALQueryLoggerFunc pfnQueryLoggerFuncIn, void *poQueryLoggerArgIn)
SetQueryLoggerFunc.
static GDALDataset * FromHandle(GDALDatasetH hDS)
Convert a GDALDatasetH to a GDALDataset*.
Definition: gdal_priv.h:884
CPLErr BuildOverviews(const char *pszResampling, int nOverviews, const int *panOverviewList, int nListBands, const int *panBandList, GDALProgressFunc pfnProgress, void *pProgressData, CSLConstList papszOptions)
Build raster overview(s)
Definition: gdaldataset.cpp:2125
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the dataset.
Definition: gdaldataset.cpp:3343
static GDALDataset * Open(const char *pszFilename, unsigned int nOpenFlags=0, const char *const *papszAllowedDrivers=nullptr, const char *const *papszOpenOptions=nullptr, const char *const *papszSiblingFiles=nullptr)
Definition: gdal_priv.h:892
bool IsMarkedSuppressOnClose()
Return MarkSuppressOnClose flag.
Definition: gdal_priv.h:822
OGRErr Release()
Drop a reference to this dataset, and if the reference count drops to one close (destroy) the dataset...
Definition: gdaldataset.cpp:5515
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
char ** GetOpenOptions()
Return open options.
Definition: gdal_priv.h:830
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
static GDALDatasetH ToHandle(GDALDataset *poDS)
Convert a GDALDataset* to a GDALDatasetH.
Definition: gdal_priv.h:876
GDALAccess GetAccess() const
Return access mode.
Definition: gdal_priv.h:808
Class modeling a a dimension / axis used to index multidimensional arrays.
Definition: gdal_priv.h:3715
const std::string & GetName() const
Return the name.
Definition: gdal_priv.h:3729
const std::string & GetType() const
Return the axis type.
Definition: gdal_priv.h:3751
const std::string & GetDirection() const
Return the axis direction.
Definition: gdal_priv.h:3764
GUInt64 GetSize() const
Return the size, that is the number of values along the dimension.
Definition: gdal_priv.h:3773
const std::string & GetFullName() const
Return the full name.
Definition: gdal_priv.h:3738
Class for managing the registration of file format drivers.
Definition: gdal_priv.h:2346
Format specific driver.
Definition: gdal_priv.h:2001
static GDALDriver * FromHandle(GDALDriverH hDriver)
Convert a GDALDriverH to a GDALDriver*.
Definition: gdal_priv.h:2225
static GDALDriverH ToHandle(GDALDriver *poDriver)
Convert a GDALDriver* to a GDALDriverH.
Definition: gdal_priv.h:2217
Class for a component of a compound extended data type.
Definition: gdal_priv.h:2733
const std::string & GetName() const
Return the name.
Definition: gdal_priv.h:2746
size_t GetOffset() const
Return the offset (in bytes) of the component in the compound data type.
Definition: gdal_priv.h:2755
const GDALExtendedDataType & GetType() const
Return the data type of the component.
Definition: gdal_priv.h:2764
GDALEDTComponent(const GDALEDTComponent &)
Copy constructor.
Class used to represent potentially complex data types.
Definition: gdal_priv.h:2597
bool operator!=(const GDALExtendedDataType &other) const
Non-equality operator.
Definition: gdal_priv.h:2617
GDALExtendedDataTypeSubType GetSubType() const
Return subtype.
Definition: gdal_priv.h:2656
size_t GetSize() const
Return data type size in bytes.
Definition: gdal_priv.h:2677
size_t GetMaxStringLength() const
Return the maximum length of a string in bytes.
Definition: gdal_priv.h:2686
static GDALExtendedDataType Create(GDALDataType eType)
Return a new GDALExtendedDataType of class GEDTC_NUMERIC.
Definition: gdalmultidim.cpp:10047
const std::vector< std::unique_ptr< GDALEDTComponent > > & GetComponents() const
Return the components of the data type (only valid when GetClass() == GEDTC_COMPOUND)
Definition: gdal_priv.h:2666
static GDALExtendedDataType CreateString(size_t nMaxStringLength=0, GDALExtendedDataTypeSubType eSubType=GEDTST_NONE)
Return a new GDALExtendedDataType of class GEDTC_STRING.
Definition: gdalmultidim.cpp:10112
GDALDataType GetNumericDataType() const
Return numeric data type (only valid when GetClass() == GEDTC_NUMERIC)
Definition: gdal_priv.h:2645
GDALExtendedDataTypeClass GetClass() const
Return type class.
Definition: gdal_priv.h:2635
const std::string & GetName() const
Return type name.
Definition: gdal_priv.h:2626
Class modeling a named container of GDALAttribute, GDALMDArray, OGRLayer or other GDALGroup.
Definition: gdal_priv.h:2826
const std::string & GetName() const
Return the name of the group.
Definition: gdal_priv.h:2877
const std::string & GetFullName() const
Return the full name of the group.
Definition: gdal_priv.h:2886
Interface used to get a single GDALAttribute or a set of GDALAttribute.
Definition: gdal_priv.h:2785
Class modeling a multi-dimensional array.
Definition: gdal_priv.h:3345
virtual bool IsWritable() const =0
Return whether an array is writable.
virtual const std::string & GetFilename() const =0
Return the filename that contains that array.
std::shared_ptr< GDALMDArray > at(GUInt64 idx, GUInt64VarArg... tail) const
Return a view of the array using integer indexing.
Definition: gdal_priv.h:3516
Object with metadata.
Definition: gdal_priv.h:156
static GDALMajorObjectH ToHandle(GDALMajorObject *poMajorObject)
Convert a GDALMajorObject* to a GDALMajorObjectH.
Definition: gdal_priv.h:191
static GDALMajorObject * FromHandle(GDALMajorObjectH hMajorObject)
Convert a GDALMajorObjectH to a GDALMajorObject*.
Definition: gdal_priv.h:199
Class for dataset open functions.
Definition: gdal_priv.h:301
int bStatOK
Whether stat()'ing the file was successful.
Definition: gdal_priv.h:322
GByte * pabyHeader
Buffer with first bytes of the file.
Definition: gdal_priv.h:332
int bIsDirectory
Whether the file is a directory.
Definition: gdal_priv.h:324
char ** papszOpenOptions
Open options.
Definition: gdal_priv.h:314
GDALAccess eAccess
Access flag.
Definition: gdal_priv.h:317
int nOpenFlags
Open flags.
Definition: gdal_priv.h:319
VSILFILE * fpL
Pointer to the file.
Definition: gdal_priv.h:327
char * pszFilename
Filename.
Definition: gdal_priv.h:312
int nHeaderBytes
Number of bytes in pabyHeader.
Definition: gdal_priv.h:330
const char *const * papszAllowedDrivers
Allowed drivers (NULL for all)
Definition: gdal_priv.h:335
Proxy for a plugin driver.
Definition: gdal_priv.h:2279
const char * GetMetadataItem(const char *pszName, const char *pszDomain="") override
Fetch single metadata item.
Definition: gdaldrivermanager.cpp:1303
char ** GetMetadata(const char *pszDomain) override
Fetch metadata.
Definition: gdaldrivermanager.cpp:1260
GDALPluginDriverProxy(const std::string &osPluginFileName)
Constructor for a plugin driver proxy.
Definition: gdaldrivermanager.cpp:1233
const std::string & GetPluginFileName() const
Return the plugin file name (not a full path)
Definition: gdal_priv.h:2304
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain="") override
Set single metadata item.
Definition: gdaldrivermanager.cpp:1268
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition: gdal_rat.h:48
A single raster band (or channel).
Definition: gdal_priv.h:1504
void static GDALRasterBandH ToHandle(GDALRasterBand *poBand)
Convert a GDALRasterBand* to a GDALRasterBandH.
Definition: gdal_priv.h:1808
virtual bool IsMaskBand() const
Returns whether a band is a mask band.
Definition: gdalrasterband.cpp:7636
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
virtual CPLErr IReadBlock(int nBlockXOff, int nBlockYOff, void *pData)=0
Default internal implementation ...
virtual CPLErr IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType, GSpacing nPixelSpace, GSpacing nLineSpace, GDALRasterIOExtraArg *psExtraArg)
Read/write a region of image data for this band.
Definition: rasterio.cpp:207
virtual GDALMaskValueRange GetMaskValueRange() const
Returns the range of values that a mask band can take.
Definition: gdalrasterband.cpp:7687
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
static GDALRasterBand * FromHandle(GDALRasterBandH hBand)
Convert a GDALRasterBandH to a GDALRasterBand*.
Definition: gdal_priv.h:1816
A single raster block in the block cache.
Definition: gdal_priv.h:1190
int GetDirty() const
Return the dirty flag.
Definition: gdal_priv.h:1287
int GetXSize() const
Return the width of the block.
Definition: gdal_priv.h:1271
GPtrDiff_t GetBlockSize() const
Return the block size in bytes.
Definition: gdal_priv.h:1303
int GetYSize() const
Return the height of the block.
Definition: gdal_priv.h:1279
GDALDataType GetDataType() const
Return the data type.
Definition: gdal_priv.h:1247
int GetXOff() const
Return the x offset of the top-left corner of the block.
Definition: gdal_priv.h:1255
int AddLock(void)
Increment the lock count.
Definition: gdal_priv.h:1229
GDALRasterBand * GetBand()
Accessor to source GDALRasterBand object.
Definition: gdal_priv.h:1314
int GetYOff() const
Return the y offset of the top-left corner of the block.
Definition: gdal_priv.h:1263
int DropLock(void)
Decrement the lock count.
Definition: gdal_priv.h:1235
void * GetDataRef(void)
Return the data buffer.
Definition: gdal_priv.h:1295
Store the raw result of an attribute value, which might contain dynamically allocated structures (lik...
Definition: gdal_priv.h:3161
size_t size() const
Return the size in bytes of the raw result.
Definition: gdal_priv.h:3197
const GByte * data() const
Return pointer to the start of data.
Definition: gdal_priv.h:3191
const GByte & operator[](size_t idx) const
Return byte at specified index.
Definition: gdal_priv.h:3185
Definition of a table relationship.
Definition: gdal_priv.h:3874
void SetType(GDALRelationshipType eType)
Sets the type of the relationship.
Definition: gdal_priv.h:4060
void SetLeftMappingTableFields(const std::vector< std::string > &osListFields)
Sets the names of the mapping table fields which correspond to the participating fields from the left...
Definition: gdal_priv.h:4030
void SetMappingTableName(const std::string &osName)
Sets the name of the mapping table for many-to-many relationships.
Definition: gdal_priv.h:3953
const std::vector< std::string > & GetRightTableFields() const
Get the names of the participating fields from the right table in the relationship.
Definition: gdal_priv.h:3975
const std::vector< std::string > & GetRightMappingTableFields() const
Get the names of the mapping table fields which correspond to the participating fields from the right...
Definition: gdal_priv.h:4019
static GDALRelationshipH ToHandle(GDALRelationship *poRelationship)
Convert a GDALRelationship* to a GDALRelationshipH.
Definition: gdal_priv.h:4177
const std::vector< std::string > & GetLeftMappingTableFields() const
Get the names of the mapping table fields which correspond to the participating fields from the left ...
Definition: gdal_priv.h:4008
const std::string & GetMappingTableName() const
Get the name of the mapping table for many-to-many relationships.
Definition: gdal_priv.h:3944
const std::string & GetForwardPathLabel() const
Get the label of the forward path for the relationship.
Definition: gdal_priv.h:4080
const std::string & GetLeftTableName() const
Get the name of the left (or base/origin) table in the relationship.
Definition: gdal_priv.h:3928
const std::vector< std::string > & GetLeftTableFields() const
Get the names of the participating fields from the left table in the relationship.
Definition: gdal_priv.h:3964
void SetLeftTableFields(const std::vector< std::string > &osListFields)
Sets the names of the participating fields from the left table in the relationship.
Definition: gdal_priv.h:3986
GDALRelationshipCardinality GetCardinality() const
Get the cardinality of the relationship.
Definition: gdal_priv.h:3919
const std::string & GetBackwardPathLabel() const
Get the label of the backward path for the relationship.
Definition: gdal_priv.h:4120
void SetRightTableFields(const std::vector< std::string > &osListFields)
Sets the names of the participating fields from the right table in the relationship.
Definition: gdal_priv.h:3997
void SetForwardPathLabel(const std::string &osLabel)
Sets the label of the forward path for the relationship.
Definition: gdal_priv.h:4100
void SetBackwardPathLabel(const std::string &osLabel)
Sets the label of the backward path for the relationship.
Definition: gdal_priv.h:4140
const std::string & GetName() const
Get the name of the relationship.
Definition: gdal_priv.h:3913
void SetRightMappingTableFields(const std::vector< std::string > &osListFields)
Sets the names of the mapping table fields which correspond to the participating fields from the righ...
Definition: gdal_priv.h:4042
const std::string & GetRelatedTableType() const
Get the type string of the related table.
Definition: gdal_priv.h:4155
static GDALRelationship * FromHandle(GDALRelationshipH hRelationship)
Convert a GDALRelationshipH to a GDALRelationship*.
Definition: gdal_priv.h:4184
GDALRelationship(const std::string &osName, const std::string &osLeftTableName, const std::string &osRightTableName, GDALRelationshipCardinality eCardinality=GDALRelationshipCardinality::GRC_ONE_TO_MANY)
Constructor for a relationship between two tables.
Definition: gdal_priv.h:3902
const std::string & GetRightTableName() const
Get the name of the right (or related/destination) table in the relationship.
Definition: gdal_priv.h:3935
GDALRelationshipType GetType() const
Get the type of the relationship.
Definition: gdal_priv.h:4051
void SetRelatedTableType(const std::string &osType)
Sets the type string of the related table.
Definition: gdal_priv.h:4170
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:893
Definition of a field domain.
Definition: ogr_feature.h:1627
Definition of a geometry field of an OGRFeatureDefn.
Definition: ogr_feature.h:346
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:377
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:74
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:169
This class represents a style table.
Definition: ogr_featurestyle.h:86
C++ wrapper over the C GDAL_GCP structure.
Definition: gdal_priv.h:362
double & X()
Returns a reference to the "X" member.
Definition: gdal_priv.h:421
double Line() const
Returns the "line" member.
Definition: gdal_priv.h:403
double X() const
Returns the "X" member.
Definition: gdal_priv.h:415
double & Line()
Returns a reference to the "line" member.
Definition: gdal_priv.h:409
double & Z()
Returns a reference to the "Z" member.
Definition: gdal_priv.h:445
double Pixel() const
Returns the "pixel" member.
Definition: gdal_priv.h:391
const char * Id() const
Returns the "id" member.
Definition: gdal_priv.h:375
double Y() const
Returns the "Y" member.
Definition: gdal_priv.h:427
double & Y()
Returns a reference to the "Y" member.
Definition: gdal_priv.h:433
double & Pixel()
Returns a reference to the "pixel" member.
Definition: gdal_priv.h:397
const char * Info() const
Returns the "info" member.
Definition: gdal_priv.h:383
const GDAL_GCP * c_ptr() const
Casts as a C GDAL_GCP pointer.
Definition: gdal_priv.h:451
double Z() const
Returns the "Z" member.
Definition: gdal_priv.h:439
Various convenience functions for CPL.
CPLErr
Error category.
Definition: cpl_error.h:53
int CPLErrorNum
Error number.
Definition: cpl_error.h:95
Definitions for CPL mini XML Parser/Serializer.
int GPtrDiff_t
Integer type large enough to hold the difference between 2 addresses.
Definition: cpl_port.h:256
#define STRCASECMP(a, b)
Alias for strcasecmp()
Definition: cpl_port.h:544
#define CPL_NULL_TERMINATED
Null terminated variadic.
Definition: cpl_port.h:938
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:218
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:299
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:295
GIntBig GInt64
Signed 64 bit integer type.
Definition: cpl_port.h:236
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition: cpl_port.h:950
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:1042
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1183
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition: cpl_port.h:238
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:976
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:185
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:215
Various convenience functions for working with strings and string lists.
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition: cpl_virtualmem.h:62
Standard C Covers.
GUIntBig vsi_l_offset
Type for a file offset.
Definition: cpl_vsi.h:146
Public (C callable) GDAL entry points.
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:315
void(* GDALQueryLoggerFunc)(const char *pszSQL, const char *pszError, int64_t lNumRecords, int64_t lExecutionTimeMilliseconds, void *pQueryLoggerArg)
Type of functions to pass to GDALDatasetSetQueryLoggerFunc.
Definition: gdal.h:1309
GDALRATTableType
RAT table type (thematic or athematic)
Definition: gdal.h:2028
GDALAccess
Definition: gdal.h:125
@ GA_ReadOnly
Definition: gdal.h:126
GDALPaletteInterp
Definition: gdal.h:253
@ GPI_RGB
Definition: gdal.h:255
GDALDataType
Definition: gdal.h:64
@ GDT_Byte
Definition: gdal.h:66
@ GDT_Float64
Definition: gdal.h:75
@ GDT_Unknown
Definition: gdal.h:65
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition: gdal.h:291
GDALRasterAttributeTableH GDALCreateRasterAttributeTableFromMDArrays(GDALRATTableType eTableType, int nArrays, const GDALMDArrayH *ahArrays, const GDALRATFieldUsage *paeUsages)
Return a virtual Raster Attribute Table from several GDALMDArray's.
Definition: gdalmultidim_rat.cpp:429
GDALExtendedDataTypeClass
Enumeration giving the class of a GDALExtendedDataType.
Definition: gdal.h:321
@ GEDTC_NUMERIC
Numeric value.
Definition: gdal.h:323
GDALRelationshipCardinality
Cardinality of relationship.
Definition: gdal.h:2114
@ GRC_ONE_TO_MANY
One-to-many.
Definition: gdal.h:2118
GDALRIOResampleAlg
RasterIO() resampling method.
Definition: gdal.h:143
CPLErr GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition: gdaldataset.cpp:4119
void * GDALRelationshipH
Opaque type used for the C bindings of the C++ GDALRelationship class.
Definition: gdal.h:312
int GDALGetDataTypeSizeBytes(GDALDataType)
Get data type size in bytes.
Definition: gdal_misc.cpp:337
GDALDatasetH GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags, const char *const *papszAllowedDrivers, const char *const *papszOpenOptions, const char *const *papszSiblingFiles)
Open a raster or vector file as a GDALDataset.
Definition: gdaldataset.cpp:3569
GDALExtendedDataTypeSubType
Enumeration giving the subtype of a GDALExtendedDataType.
Definition: gdal.h:334
@ GEDTST_NONE
None.
Definition: gdal.h:336
void * GDALMajorObjectH
Opaque type used for the C bindings of the C++ GDALMajorObject class.
Definition: gdal.h:288
GDALColorInterp
Definition: gdal.h:227
GDALRelationshipType
Type of relationship.
Definition: gdal.h:2130
@ GRT_ASSOCIATION
Association relationship.
Definition: gdal.h:2134
GDALAsyncStatusType
status of the asynchronous stream
Definition: gdal.h:111
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition: gdal.h:297
GDALRWFlag
Definition: gdal.h:132
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:294
void * GDALColorTableH
Opaque type used for the C bindings of the C++ GDALColorTable class.
Definition: gdal.h:300
std::unique_ptr< GDALDataset, GDALDatasetUniquePtrDeleter > GDALDatasetUniquePtr
Unique pointer type for GDALDataset.
Definition: gdal_priv.h:1179
constexpr GDALSuggestedBlockAccessPattern GSBAP_UNKNOWN
Unknown, or no particular read order is suggested.
Definition: gdal_priv.h:1486
int GDALSuggestedBlockAccessPattern
Suggested/most efficient access pattern to blocks.
Definition: gdal_priv.h:1483
constexpr GDALSuggestedBlockAccessPattern GSBAP_RANDOM
Random access to blocks is efficient.
Definition: gdal_priv.h:1489
GDALDriverManager * GetGDALDriverManager(void)
Fetch the global GDAL driver manager.
Definition: gdaldrivermanager.cpp:102
GDALMaskValueRange
Range of values found in a mask band.
Definition: gdal_priv.h:1475
@ GMVR_0_AND_1_ONLY
Definition: gdal_priv.h:1478
@ GMVR_0_AND_255_ONLY
Definition: gdal_priv.h:1479
constexpr GDALSuggestedBlockAccessPattern GSBAP_TOP_TO_BOTTOM
Reading by strips from top to bottom is the most efficient.
Definition: gdal_priv.h:1492
GDALIdentifyEnum
Enumeration used by GDALDriver::pfnIdentify().
Definition: gdal_priv.h:1975
@ GDAL_IDENTIFY_TRUE
Identify determined the file is recognized by the probed driver.
Definition: gdal_priv.h:1982
@ GDAL_IDENTIFY_FALSE
Identify determined the file is not recognized by the probed driver.
Definition: gdal_priv.h:1980
@ GDAL_IDENTIFY_UNKNOWN
Identify could not determine if the file is recognized or not by the probed driver.
Definition: gdal_priv.h:1978
constexpr GDALSuggestedBlockAccessPattern GSBAP_LARGEST_CHUNK_POSSIBLE
Reading the largest chunk from the raster is the most efficient (can be combined with above values).
Definition: gdal_priv.h:1499
constexpr GDALSuggestedBlockAccessPattern GSBAP_BOTTOM_TO_TOP
Reading by strips from bottom to top is the most efficient.
Definition: gdal_priv.h:1495
Core portability services for cross-platform OGR code.
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:416
@ wkbUnknown
unknown type, non-standard
Definition: ogr_core.h:417
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:387
Simple feature classes.
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:1570
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:434
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:442
Document node structure.
Definition: cpl_minixml.h:71
Color tuple.
Definition: gdal.h:1955
Object returned by GetFeatures() iterators.
Definition: gdal_priv.h:905
Structure to pass extra arguments to RasterIO() method, must be initialized with INIT_RASTERIO_EXTRA_...
Definition: gdal.h:176
The GDALSubdatasetInfo abstract class provides methods to extract and manipulate subdataset informati...
Definition: gdalsubdatasetinfo.h:43
Ground Control Point.
Definition: gdal.h:1075
Virtual file handle.
Definition: cpl_vsi_virtual.h:63