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 * SPDX-License-Identifier: MIT
14 ****************************************************************************/
15
16#ifndef GDAL_PRIV_H_INCLUDED
17#define GDAL_PRIV_H_INCLUDED
18
25/* -------------------------------------------------------------------- */
26/* Predeclare various classes before pulling in gdal.h, the */
27/* public declarations. */
28/* -------------------------------------------------------------------- */
29 class GDALMajorObject;
30 class GDALDataset;
31 class GDALRasterBand;
32 class GDALDriver;
33 class GDALRasterAttributeTable;
34 class GDALProxyDataset;
35 class GDALProxyRasterBand;
36 class GDALAsyncReader;
37 class GDALRelationship;
38
39/* -------------------------------------------------------------------- */
40/* Pull in the public declarations. This gets the C apis, and */
41/* also various constants. However, we will still get to */
42/* provide the real class definitions for the GDAL classes. */
43/* -------------------------------------------------------------------- */
44
45#include "gdal.h"
46#include "gdal_frmts.h"
47#include "gdalsubdatasetinfo.h"
48#include "cpl_vsi.h"
49#include "cpl_conv.h"
50#include "cpl_string.h"
51#include "cpl_minixml.h"
52#include "cpl_multiproc.h"
53#include "cpl_atomic_ops.h"
54
55#include <stdarg.h>
56
57#include <cmath>
58#include <complex>
59#include <cstdint>
60#include <iterator>
61#include <limits>
62#include <map>
63#include <memory>
64#include <set>
65#if __cplusplus >= 202002L
66#include <span>
67#endif
68#include <vector>
69
70#include "ogr_core.h"
71#include "ogr_feature.h"
72
74#define GMO_VALID 0x0001
75#define GMO_IGNORE_UNIMPLEMENTED 0x0002
76#define GMO_SUPPORT_MD 0x0004
77#define GMO_SUPPORT_MDMD 0x0008
78#define GMO_MD_DIRTY 0x0010
79#define GMO_PAM_CLASS 0x0020
80
82
83/************************************************************************/
84/* GDALMultiDomainMetadata */
85/************************************************************************/
86
88 class CPL_DLL GDALMultiDomainMetadata
89{
90 private:
91 CPLStringList aosDomainList{};
92
93 struct Comparator
94 {
95 bool operator()(const char *a, const char *b) const
96 {
97 return STRCASECMP(a, b) < 0;
98 }
99 };
100
101 std::map<const char *, CPLStringList, Comparator> oMetadata{};
102
103 public:
104 GDALMultiDomainMetadata();
105 ~GDALMultiDomainMetadata();
106
107 int XMLInit(const CPLXMLNode *psMetadata, int bMerge);
108 CPLXMLNode *Serialize() const;
109
110 CSLConstList GetDomainList() const
111 {
112 return aosDomainList.List();
113 }
114
115 char **GetMetadata(const char *pszDomain = "");
116 CPLErr SetMetadata(CSLConstList papszMetadata, const char *pszDomain = "");
117 const char *GetMetadataItem(const char *pszName,
118 const char *pszDomain = "");
119 CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
120 const char *pszDomain = "");
121
122 void Clear();
123
124 inline void clear()
125 {
126 Clear();
127 }
128};
129
131
132/* ******************************************************************** */
133/* GDALMajorObject */
134/* */
135/* Base class providing metadata, description and other */
136/* services shared by major objects. */
137/* ******************************************************************** */
138
140 class CPL_DLL GDALMajorObject
141{
142 protected:
144 int nFlags; // GMO_* flags.
145 CPLString sDescription{};
146 GDALMultiDomainMetadata oMDMD{};
147
149
150 char **BuildMetadataDomainList(char **papszList, int bCheckNonEmpty,
151 ...) CPL_NULL_TERMINATED;
152
153 public:
154 GDALMajorObject();
155 virtual ~GDALMajorObject();
156
157 int GetMOFlags() const;
158 void SetMOFlags(int nFlagsIn);
159
160 virtual const char *GetDescription() const;
161 virtual void SetDescription(const char *);
162
163 virtual char **GetMetadataDomainList();
164
165 virtual char **GetMetadata(const char *pszDomain = "");
166 virtual CPLErr SetMetadata(char **papszMetadata,
167 const char *pszDomain = "");
168 virtual const char *GetMetadataItem(const char *pszName,
169 const char *pszDomain = "");
170 virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
171 const char *pszDomain = "");
172
176 static inline GDALMajorObjectH ToHandle(GDALMajorObject *poMajorObject)
177 {
178 return static_cast<GDALMajorObjectH>(poMajorObject);
179 }
180
184 static inline GDALMajorObject *FromHandle(GDALMajorObjectH hMajorObject)
185 {
186 return static_cast<GDALMajorObject *>(hMajorObject);
187 }
188};
189
190/* ******************************************************************** */
191/* GDALDefaultOverviews */
192/* ******************************************************************** */
193
195 class GDALOpenInfo;
196
197 class CPL_DLL GDALDefaultOverviews
198{
199 friend class GDALDataset;
200
201 GDALDataset *poDS;
202 GDALDataset *poODS;
203
204 CPLString osOvrFilename{};
205
206 bool bOvrIsAux;
207
208 bool bCheckedForMask;
209 bool bOwnMaskDS;
210 GDALDataset *poMaskDS;
211
212 // For "overview datasets" we record base level info so we can
213 // find our way back to get overview masks.
214 GDALDataset *poBaseDS;
215
216 // Stuff for deferred initialize/overviewscans.
217 bool bCheckedForOverviews;
218 void OverviewScan();
219 char *pszInitName;
220 bool bInitNameIsOVR;
221 char **papszInitSiblingFiles;
222
223 public:
224 GDALDefaultOverviews();
225 ~GDALDefaultOverviews();
226
227 void Initialize(GDALDataset *poDSIn, const char *pszName = nullptr,
228 CSLConstList papszSiblingFiles = nullptr,
229 bool bNameIsOVR = false);
230
231 void Initialize(GDALDataset *poDSIn, GDALOpenInfo *poOpenInfo,
232 const char *pszName = nullptr,
233 bool bTransferSiblingFilesIfLoaded = true);
234
235 void TransferSiblingFiles(char **papszSiblingFiles);
236
237 int IsInitialized();
238
239 int CloseDependentDatasets();
240
241 // Overview Related
242
243 int GetOverviewCount(int nBand);
244 GDALRasterBand *GetOverview(int nBand, int iOverview);
245
246 CPLErr BuildOverviews(const char *pszBasename, const char *pszResampling,
247 int nOverviews, const int *panOverviewList,
248 int nBands, const int *panBandList,
249 GDALProgressFunc pfnProgress, void *pProgressData,
250 CSLConstList papszOptions);
251
252 CPLErr BuildOverviewsSubDataset(const char *pszPhysicalFile,
253 const char *pszResampling, int nOverviews,
254 const int *panOverviewList, int nBands,
255 const int *panBandList,
256 GDALProgressFunc pfnProgress,
257 void *pProgressData,
258 CSLConstList papszOptions);
259
260 CPLErr BuildOverviewsMask(const char *pszResampling, int nOverviews,
261 const int *panOverviewList,
262 GDALProgressFunc pfnProgress, void *pProgressData,
263 CSLConstList papszOptions);
264
265 CPLErr CleanOverviews();
266
267 // Mask Related
268
269 CPLErr CreateMaskBand(int nFlags, int nBand = -1);
270 GDALRasterBand *GetMaskBand(int nBand);
271 int GetMaskFlags(int nBand);
272
273 int HaveMaskFile(char **papszSiblings = nullptr,
274 const char *pszBasename = nullptr);
275
276 char **GetSiblingFiles()
277 {
278 return papszInitSiblingFiles;
279 }
280
281 private:
282 CPL_DISALLOW_COPY_ASSIGN(GDALDefaultOverviews)
283};
284
286
287/* ******************************************************************** */
288/* GDALOpenInfo */
289/* ******************************************************************** */
290
292 class CPL_DLL GDALOpenInfo
293{
294 bool bHasGotSiblingFiles;
295 char **papszSiblingFiles;
296 int nHeaderBytesTried;
297
298 public:
299 GDALOpenInfo(const char *pszFile, int nOpenFlagsIn,
300 const char *const *papszSiblingFiles = nullptr);
301 ~GDALOpenInfo(void);
302
304 char *pszFilename;
306 char **papszOpenOptions;
307
309 GDALAccess eAccess;
311 int nOpenFlags;
312
314 int bStatOK;
316 int bIsDirectory;
317
319 VSILFILE *fpL;
320
322 int nHeaderBytes;
324 GByte *pabyHeader;
325
327 const char *const *papszAllowedDrivers;
328
329 int TryToIngest(int nBytes);
330 char **GetSiblingFiles();
331 char **StealSiblingFiles();
332 bool AreSiblingFilesLoaded() const;
333
334 bool IsSingleAllowedDriver(const char *pszDriverName) const;
335
336 private:
337 CPL_DISALLOW_COPY_ASSIGN(GDALOpenInfo)
338};
339
340/* ******************************************************************** */
341/* gdal::GCP */
342/* ******************************************************************** */
343
344 namespace gdal
345{
353 class CPL_DLL GCP
354{
355 public:
356 explicit GCP(const char *pszId = "", const char *pszInfo = "",
357 double dfPixel = 0, double dfLine = 0, double dfX = 0,
358 double dfY = 0, double dfZ = 0);
359 ~GCP();
360 GCP(const GCP &);
361 explicit GCP(const GDAL_GCP &other);
362 GCP &operator=(const GCP &);
363 GCP(GCP &&);
364 GCP &operator=(GCP &&);
365
367 inline const char *Id() const
368 {
369 return gcp.pszId;
370 }
371
372 void SetId(const char *pszId);
373
375 inline const char *Info() const
376 {
377 return gcp.pszInfo;
378 }
379
380 void SetInfo(const char *pszInfo);
381
383 inline double Pixel() const
384 {
385 return gcp.dfGCPPixel;
386 }
387
389 inline double &Pixel()
390 {
391 return gcp.dfGCPPixel;
392 }
393
395 inline double Line() const
396 {
397 return gcp.dfGCPLine;
398 }
399
401 inline double &Line()
402 {
403 return gcp.dfGCPLine;
404 }
405
407 inline double X() const
408 {
409 return gcp.dfGCPX;
410 }
411
413 inline double &X()
414 {
415 return gcp.dfGCPX;
416 }
417
419 inline double Y() const
420 {
421 return gcp.dfGCPY;
422 }
423
425 inline double &Y()
426 {
427 return gcp.dfGCPY;
428 }
429
431 inline double Z() const
432 {
433 return gcp.dfGCPZ;
434 }
435
437 inline double &Z()
438 {
439 return gcp.dfGCPZ;
440 }
441
443 inline const GDAL_GCP *c_ptr() const
444 {
445 return &gcp;
446 }
447
448 static const GDAL_GCP *c_ptr(const std::vector<GCP> &asGCPs);
449
450 static std::vector<GCP> fromC(const GDAL_GCP *pasGCPList, int nGCPCount);
451
452 private:
453 GDAL_GCP gcp;
454};
455
456} /* namespace gdal */
457
458/* ******************************************************************** */
459/* GDALDataset */
460/* ******************************************************************** */
461
462 class OGRLayer;
463 class OGRGeometry;
464 class OGRSpatialReference;
465 class OGRStyleTable;
466 class swq_select;
467 class swq_select_parse_options;
468 class GDALGroup;
469
471 typedef struct GDALSQLParseInfo GDALSQLParseInfo;
473
475#ifdef GDAL_COMPILATION
476#define OPTIONAL_OUTSIDE_GDAL(val)
477#else
478#define OPTIONAL_OUTSIDE_GDAL(val) = val
479#endif
481
483// This macro can be defined to check that GDALDataset::IRasterIO()
484// implementations do not alter the passed panBandList. It is not defined
485// by default (and should not!), hence int* is used.
486#if defined(GDAL_BANDMAP_TYPE_CONST_SAFE)
487#define BANDMAP_TYPE const int *
488#else
489#define BANDMAP_TYPE int *
490#endif
492
494 class CPL_DLL GDALDataset : public GDALMajorObject
495{
496 friend GDALDatasetH CPL_STDCALL
497 GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags,
498 const char *const *papszAllowedDrivers,
499 const char *const *papszOpenOptions,
500 const char *const *papszSiblingFiles);
501 friend CPLErr CPL_STDCALL GDALClose(GDALDatasetH hDS);
502
503 friend class GDALDriver;
504 friend class GDALDefaultOverviews;
505 friend class GDALProxyDataset;
506 friend class GDALDriverManager;
507
508 CPL_INTERNAL void AddToDatasetOpenList();
509
510 CPL_INTERNAL void UnregisterFromSharedDataset();
511
512 CPL_INTERNAL static void ReportErrorV(const char *pszDSName,
513 CPLErr eErrClass, CPLErrorNum err_no,
514 const char *fmt, va_list args);
515
516 protected:
518 GDALDriver *poDriver = nullptr;
519 GDALAccess eAccess = GA_ReadOnly;
520
521 // Stored raster information.
522 int nRasterXSize = 512;
523 int nRasterYSize = 512;
524 int nBands = 0;
525 GDALRasterBand **papoBands = nullptr;
526
527 static constexpr int OPEN_FLAGS_CLOSED = -1;
528 int nOpenFlags =
529 0; // set to OPEN_FLAGS_CLOSED after Close() has been called
530
531 int nRefCount = 1;
532 bool bForceCachedIO = false;
533 bool bShared = false;
534 bool bIsInternal = true;
535 bool bSuppressOnClose = false;
536
537 mutable std::map<std::string, std::unique_ptr<OGRFieldDomain>>
538 m_oMapFieldDomains{};
539
540 GDALDataset(void);
541 explicit GDALDataset(int bForceCachedIO);
542
543 void RasterInitialize(int, int);
544 void SetBand(int nNewBand, GDALRasterBand *poBand);
545 void SetBand(int nNewBand, std::unique_ptr<GDALRasterBand> poBand);
546
547 GDALDefaultOverviews oOvManager{};
548
549 virtual CPLErr IBuildOverviews(const char *pszResampling, int nOverviews,
550 const int *panOverviewList, int nListBands,
551 const int *panBandList,
552 GDALProgressFunc pfnProgress,
553 void *pProgressData,
554 CSLConstList papszOptions);
555
556 virtual CPLErr
557 IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize,
558 void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType,
559 int nBandCount, BANDMAP_TYPE panBandMap, GSpacing nPixelSpace,
560 GSpacing nLineSpace, GSpacing nBandSpace,
561 GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
562
563 /* This method should only be be overloaded by GDALProxyDataset */
564 virtual CPLErr
565 BlockBasedRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
566 int nYSize, void *pData, int nBufXSize, int nBufYSize,
567 GDALDataType eBufType, int nBandCount,
568 const int *panBandMap, GSpacing nPixelSpace,
569 GSpacing nLineSpace, GSpacing nBandSpace,
570 GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
571 CPLErr BlockBasedFlushCache(bool bAtClosing);
572
573 CPLErr
574 BandBasedRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
575 int nYSize, void *pData, int nBufXSize, int nBufYSize,
576 GDALDataType eBufType, int nBandCount,
577 const int *panBandMap, GSpacing nPixelSpace,
578 GSpacing nLineSpace, GSpacing nBandSpace,
579 GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
580
581 CPLErr
582 RasterIOResampled(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
583 int nYSize, void *pData, int nBufXSize, int nBufYSize,
584 GDALDataType eBufType, int nBandCount,
585 const int *panBandMap, GSpacing nPixelSpace,
586 GSpacing nLineSpace, GSpacing nBandSpace,
587 GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
588
589 CPLErr ValidateRasterIOOrAdviseReadParameters(
590 const char *pszCallingFunc, int *pbStopProcessingOnCENone, int nXOff,
591 int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize,
592 int nBandCount, const int *panBandMap);
593
594 CPLErr TryOverviewRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
595 int nXSize, int nYSize, void *pData,
596 int nBufXSize, int nBufYSize,
597 GDALDataType eBufType, int nBandCount,
598 const int *panBandMap, GSpacing nPixelSpace,
599 GSpacing nLineSpace, GSpacing nBandSpace,
600 GDALRasterIOExtraArg *psExtraArg, int *pbTried);
601
602 void ShareLockWithParentDataset(GDALDataset *poParentDataset);
603
604 bool m_bCanBeReopened = false;
605
606 virtual bool CanBeCloned(int nScopeFlags, bool bCanShareState) const;
607
608 friend class GDALThreadSafeDataset;
609 friend class MEMDataset;
610 virtual std::unique_ptr<GDALDataset> Clone(int nScopeFlags,
611 bool bCanShareState) const;
612
614
615 void CleanupPostFileClosing();
616
617 virtual int CloseDependentDatasets();
619 int ValidateLayerCreationOptions(const char *const *papszLCO);
620
621 char **papszOpenOptions = nullptr;
622
623 friend class GDALRasterBand;
624
625 // The below methods related to read write mutex are fragile logic, and
626 // should not be used by out-of-tree code if possible.
627 int EnterReadWrite(GDALRWFlag eRWFlag);
628 void LeaveReadWrite();
629 void InitRWLock();
630
631 void TemporarilyDropReadWriteLock();
632 void ReacquireReadWriteLock();
633
634 void DisableReadWriteMutex();
635
636 int AcquireMutex();
637 void ReleaseMutex();
638
639 bool IsAllBands(int nBandCount, const int *panBandList) const;
641
642 public:
643 ~GDALDataset() override;
644
645 virtual CPLErr Close();
646
647 int GetRasterXSize() const;
648 int GetRasterYSize() const;
649 int GetRasterCount() const;
650 GDALRasterBand *GetRasterBand(int);
651 const GDALRasterBand *GetRasterBand(int) const;
652
659 virtual bool SetQueryLoggerFunc(GDALQueryLoggerFunc pfnQueryLoggerFuncIn,
660 void *poQueryLoggerArgIn);
661
664 class CPL_DLL Bands
665 {
666 private:
667 friend class GDALDataset;
668 GDALDataset *m_poSelf;
669
670 CPL_INTERNAL explicit Bands(GDALDataset *poSelf) : m_poSelf(poSelf)
671 {
672 }
673
674 class CPL_DLL Iterator
675 {
676 struct Private;
677 std::unique_ptr<Private> m_poPrivate;
678
679 public:
680 Iterator(GDALDataset *poDS, bool bStart);
681 Iterator(const Iterator &oOther); // declared but not defined.
682 // Needed for gcc 5.4 at least
683 Iterator(Iterator &&oOther) noexcept; // declared but not defined.
684 // Needed for gcc 5.4 at least
685 ~Iterator();
686 GDALRasterBand *operator*();
687 Iterator &operator++();
688 bool operator!=(const Iterator &it) const;
689 };
690
691 public:
692 const Iterator begin() const;
693
694 const Iterator end() const;
695
696 size_t size() const;
697
698 GDALRasterBand *operator[](int iBand);
699 GDALRasterBand *operator[](size_t iBand);
700 };
701
702 Bands GetBands();
703
704 virtual CPLErr FlushCache(bool bAtClosing = false);
705 virtual CPLErr DropCache();
706
707 virtual GIntBig GetEstimatedRAMUsage();
708
709 virtual const OGRSpatialReference *GetSpatialRef() const;
710 virtual CPLErr SetSpatialRef(const OGRSpatialReference *poSRS);
711
712 // Compatibility layer
713 const char *GetProjectionRef(void) const;
714 CPLErr SetProjection(const char *pszProjection);
715
716 virtual CPLErr GetGeoTransform(double *padfTransform);
717 virtual CPLErr SetGeoTransform(double *padfTransform);
718
719 virtual CPLErr AddBand(GDALDataType eType, char **papszOptions = nullptr);
720
721 virtual void *GetInternalHandle(const char *pszHandleName);
722 virtual GDALDriver *GetDriver(void);
723 virtual char **GetFileList(void);
724
725 virtual const char *GetDriverName();
726
727 virtual const OGRSpatialReference *GetGCPSpatialRef() const;
728 virtual int GetGCPCount();
729 virtual const GDAL_GCP *GetGCPs();
730 virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList,
731 const OGRSpatialReference *poGCP_SRS);
732
733 // Compatibility layer
734 const char *GetGCPProjection();
735 CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList,
736 const char *pszGCPProjection);
737
738 virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize,
739 int nBufXSize, int nBufYSize, GDALDataType eDT,
740 int nBandCount, int *panBandList,
741 char **papszOptions);
742
743 virtual CPLErr CreateMaskBand(int nFlagsIn);
744
745 virtual GDALAsyncReader *
746 BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize, void *pBuf,
747 int nBufXSize, int nBufYSize, GDALDataType eBufType,
748 int nBandCount, int *panBandMap, int nPixelSpace,
749 int nLineSpace, int nBandSpace, char **papszOptions);
750 virtual void EndAsyncReader(GDALAsyncReader *poARIO);
751
753 struct RawBinaryLayout
754 {
755 enum class Interleaving
756 {
757 UNKNOWN,
758 BIP,
759 BIL,
760 BSQ
761 };
762 std::string osRawFilename{};
763 Interleaving eInterleaving = Interleaving::UNKNOWN;
764 GDALDataType eDataType = GDT_Unknown;
765 bool bLittleEndianOrder = false;
766
767 vsi_l_offset nImageOffset = 0;
768 GIntBig nPixelOffset = 0;
769 GIntBig nLineOffset = 0;
770 GIntBig nBandOffset = 0;
771 };
772
773 virtual bool GetRawBinaryLayout(RawBinaryLayout &);
775
776#ifndef DOXYGEN_SKIP
777 CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
778 int nYSize, void *pData, int nBufXSize, int nBufYSize,
779 GDALDataType eBufType, int nBandCount,
780 const int *panBandMap, GSpacing nPixelSpace,
781 GSpacing nLineSpace, GSpacing nBandSpace,
782 GDALRasterIOExtraArg *psExtraArg
783 OPTIONAL_OUTSIDE_GDAL(nullptr)) CPL_WARN_UNUSED_RESULT;
784#else
785 CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
786 int nYSize, void *pData, int nBufXSize, int nBufYSize,
787 GDALDataType eBufType, int nBandCount,
788 const int *panBandMap, GSpacing nPixelSpace,
789 GSpacing nLineSpace, GSpacing nBandSpace,
790 GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
791#endif
792
793 virtual CPLStringList GetCompressionFormats(int nXOff, int nYOff,
794 int nXSize, int nYSize,
795 int nBandCount,
796 const int *panBandList);
797 virtual CPLErr ReadCompressedData(const char *pszFormat, int nXOff,
798 int nYOff, int nXSize, int nYSize,
799 int nBands, const int *panBandList,
800 void **ppBuffer, size_t *pnBufferSize,
801 char **ppszDetailedFormat);
802
803 int Reference();
804 int Dereference();
805 int ReleaseRef();
806
810 GDALAccess GetAccess() const
811 {
812 return eAccess;
813 }
814
815 int GetShared() const;
816 void MarkAsShared();
817
818 void MarkSuppressOnClose();
819 void UnMarkSuppressOnClose();
820
824 bool IsMarkedSuppressOnClose() const
825 {
826 return bSuppressOnClose;
827 }
828
832 char **GetOpenOptions()
833 {
834 return papszOpenOptions;
835 }
836
837 bool IsThreadSafe(int nScopeFlags) const;
838
839#ifndef DOXYGEN_SKIP
843 CSLConstList GetOpenOptions() const
844 {
845 return papszOpenOptions;
846 }
847#endif
848
849 static GDALDataset **GetOpenDatasets(int *pnDatasetCount);
850
851#ifndef DOXYGEN_SKIP
852 CPLErr
853 BuildOverviews(const char *pszResampling, int nOverviews,
854 const int *panOverviewList, int nListBands,
855 const int *panBandList, GDALProgressFunc pfnProgress,
856 void *pProgressData,
857 CSLConstList papszOptions OPTIONAL_OUTSIDE_GDAL(nullptr));
858#else
859 CPLErr BuildOverviews(const char *pszResampling, int nOverviews,
860 const int *panOverviewList, int nListBands,
861 const int *panBandList, GDALProgressFunc pfnProgress,
862 void *pProgressData, CSLConstList papszOptions);
863#endif
864
865#ifndef DOXYGEN_XML
866 void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,
867 ...) const CPL_PRINT_FUNC_FORMAT(4, 5);
868
869 static void ReportError(const char *pszDSName, CPLErr eErrClass,
870 CPLErrorNum err_no, const char *fmt, ...)
871 CPL_PRINT_FUNC_FORMAT(4, 5);
872#endif
873
874 char **GetMetadata(const char *pszDomain = "") override;
875
876// Only defined when Doxygen enabled
877#ifdef DOXYGEN_SKIP
878 CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override;
879 CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
880 const char *pszDomain) override;
881#endif
882
883 char **GetMetadataDomainList() override;
884
885 virtual void ClearStatistics();
886
890 static inline GDALDatasetH ToHandle(GDALDataset *poDS)
891 {
892 return static_cast<GDALDatasetH>(poDS);
893 }
894
898 static inline GDALDataset *FromHandle(GDALDatasetH hDS)
899 {
900 return static_cast<GDALDataset *>(hDS);
901 }
902
906 static GDALDataset *Open(const char *pszFilename,
907 unsigned int nOpenFlags = 0,
908 const char *const *papszAllowedDrivers = nullptr,
909 const char *const *papszOpenOptions = nullptr,
910 const char *const *papszSiblingFiles = nullptr)
911 {
912 return FromHandle(GDALOpenEx(pszFilename, nOpenFlags,
913 papszAllowedDrivers, papszOpenOptions,
914 papszSiblingFiles));
915 }
916
918 struct FeatureLayerPair
919 {
921 OGRFeatureUniquePtr feature{};
922
924 OGRLayer *layer = nullptr;
925 };
926
928 // SetEnableOverviews() only to be used by GDALOverviewDataset
929 void SetEnableOverviews(bool bEnable);
930
931 // Only to be used by driver's GetOverviewCount() method.
932 bool AreOverviewsEnabled() const;
934
935 private:
936 class Private;
937 Private *m_poPrivate;
938
939 CPL_INTERNAL OGRLayer *BuildLayerFromSelectInfo(
940 swq_select *psSelectInfo, OGRGeometry *poSpatialFilter,
941 const char *pszDialect, swq_select_parse_options *poSelectParseOptions);
942 CPLStringList oDerivedMetadataList{};
943
944 public:
945 virtual int GetLayerCount();
946 virtual OGRLayer *GetLayer(int iLayer);
947
948 virtual bool IsLayerPrivate(int iLayer) const;
949
953 class CPL_DLL Layers
954 {
955 private:
956 friend class GDALDataset;
957 GDALDataset *m_poSelf;
958
959 CPL_INTERNAL explicit Layers(GDALDataset *poSelf) : m_poSelf(poSelf)
960 {
961 }
962
963 public:
967 class CPL_DLL Iterator
968 {
969 struct Private;
970 std::unique_ptr<Private> m_poPrivate;
971
972 public:
973 using value_type = OGRLayer *;
974 using reference = OGRLayer *;
975 using difference_type = void;
976 using pointer = void;
977 using iterator_category =
978 std::input_iterator_tag;
980 Iterator();
981 Iterator(GDALDataset *poDS, bool bStart);
982 Iterator(const Iterator &oOther);
983 Iterator(Iterator &&oOther) noexcept;
984 ~Iterator();
986 Iterator &
987 operator=(const Iterator &oOther);
988 Iterator &operator=(
989 Iterator &&oOther) noexcept;
991 OGRLayer *operator*() const;
992 Iterator &operator++();
993 Iterator operator++(int);
994 bool operator!=(const Iterator &it)
995 const;
996 };
997
998 Iterator begin() const;
999 Iterator end() const;
1000
1001 size_t size() const;
1002
1003 OGRLayer *operator[](int iLayer);
1004 OGRLayer *operator[](size_t iLayer);
1005 OGRLayer *operator[](const char *pszLayername);
1006 };
1007
1008 Layers GetLayers();
1009
1010 virtual OGRLayer *GetLayerByName(const char *);
1011 virtual OGRErr DeleteLayer(int iLayer);
1012
1013 virtual void ResetReading();
1014 virtual OGRFeature *GetNextFeature(OGRLayer **ppoBelongingLayer,
1015 double *pdfProgressPct,
1016 GDALProgressFunc pfnProgress,
1017 void *pProgressData);
1018
1021 class CPL_DLL Features
1022 {
1023 private:
1024 friend class GDALDataset;
1025 GDALDataset *m_poSelf;
1026
1027 CPL_INTERNAL explicit Features(GDALDataset *poSelf) : m_poSelf(poSelf)
1028 {
1029 }
1030
1031 class CPL_DLL Iterator
1032 {
1033 struct Private;
1034 std::unique_ptr<Private> m_poPrivate;
1035
1036 public:
1037 Iterator(GDALDataset *poDS, bool bStart);
1038 Iterator(const Iterator &oOther); // declared but not defined.
1039 // Needed for gcc 5.4 at least
1040 Iterator(Iterator &&oOther) noexcept; // declared but not defined.
1041 // Needed for gcc 5.4 at least
1042 ~Iterator();
1043 const FeatureLayerPair &operator*() const;
1044 Iterator &operator++();
1045 bool operator!=(const Iterator &it) const;
1046 };
1047
1048 public:
1049 const Iterator begin() const;
1050
1051 const Iterator end() const;
1052 };
1053
1054 Features GetFeatures();
1055
1056 virtual int TestCapability(const char *);
1057
1058 virtual std::vector<std::string>
1059 GetFieldDomainNames(CSLConstList papszOptions = nullptr) const;
1060
1061 virtual const OGRFieldDomain *GetFieldDomain(const std::string &name) const;
1062
1063 virtual bool AddFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
1064 std::string &failureReason);
1065
1066 virtual bool DeleteFieldDomain(const std::string &name,
1067 std::string &failureReason);
1068
1069 virtual bool UpdateFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
1070 std::string &failureReason);
1071
1072 virtual std::vector<std::string>
1073 GetRelationshipNames(CSLConstList papszOptions = nullptr) const;
1074
1075 virtual const GDALRelationship *
1076 GetRelationship(const std::string &name) const;
1077
1078 virtual bool
1079 AddRelationship(std::unique_ptr<GDALRelationship> &&relationship,
1080 std::string &failureReason);
1081
1082 virtual bool DeleteRelationship(const std::string &name,
1083 std::string &failureReason);
1084
1085 virtual bool
1086 UpdateRelationship(std::unique_ptr<GDALRelationship> &&relationship,
1087 std::string &failureReason);
1088
1090 OGRLayer *CreateLayer(const char *pszName);
1091
1092 OGRLayer *CreateLayer(const char *pszName, std::nullptr_t);
1094
1095 OGRLayer *CreateLayer(const char *pszName,
1096 const OGRSpatialReference *poSpatialRef,
1097 OGRwkbGeometryType eGType = wkbUnknown,
1098 CSLConstList papszOptions = nullptr);
1099
1100 OGRLayer *CreateLayer(const char *pszName,
1101 const OGRGeomFieldDefn *poGeomFieldDefn,
1102 CSLConstList papszOptions = nullptr);
1103
1104 virtual OGRLayer *CopyLayer(OGRLayer *poSrcLayer, const char *pszNewName,
1105 char **papszOptions = nullptr);
1106
1107 virtual OGRStyleTable *GetStyleTable();
1108 virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable);
1109
1110 virtual void SetStyleTable(OGRStyleTable *poStyleTable);
1111
1112 virtual OGRLayer *ExecuteSQL(const char *pszStatement,
1113 OGRGeometry *poSpatialFilter,
1114 const char *pszDialect);
1115 virtual void ReleaseResultSet(OGRLayer *poResultsSet);
1116 virtual OGRErr AbortSQL();
1117
1118 int GetRefCount() const;
1119 int GetSummaryRefCount() const;
1120 OGRErr Release();
1121
1122 virtual OGRErr StartTransaction(int bForce = FALSE);
1123 virtual OGRErr CommitTransaction();
1124 virtual OGRErr RollbackTransaction();
1125
1126 virtual std::shared_ptr<GDALGroup> GetRootGroup() const;
1127
1129 static int IsGenericSQLDialect(const char *pszDialect);
1130
1131 // Semi-public methods. Only to be used by in-tree drivers.
1132 GDALSQLParseInfo *
1133 BuildParseInfo(swq_select *psSelectInfo,
1134 swq_select_parse_options *poSelectParseOptions);
1135 static void DestroyParseInfo(GDALSQLParseInfo *psParseInfo);
1136 OGRLayer *ExecuteSQL(const char *pszStatement, OGRGeometry *poSpatialFilter,
1137 const char *pszDialect,
1138 swq_select_parse_options *poSelectParseOptions);
1140
1141 protected:
1142 virtual OGRLayer *ICreateLayer(const char *pszName,
1143 const OGRGeomFieldDefn *poGeomFieldDefn,
1144 CSLConstList papszOptions);
1145
1147 OGRErr ProcessSQLCreateIndex(const char *);
1148 OGRErr ProcessSQLDropIndex(const char *);
1149 OGRErr ProcessSQLDropTable(const char *);
1150 OGRErr ProcessSQLAlterTableAddColumn(const char *);
1151 OGRErr ProcessSQLAlterTableDropColumn(const char *);
1152 OGRErr ProcessSQLAlterTableAlterColumn(const char *);
1153 OGRErr ProcessSQLAlterTableRenameColumn(const char *);
1154
1155 OGRStyleTable *m_poStyleTable = nullptr;
1156
1157 friend class GDALProxyPoolDataset;
1159
1160 private:
1161 CPL_DISALLOW_COPY_ASSIGN(GDALDataset)
1162};
1163
1165 struct CPL_DLL GDALDatasetUniquePtrDeleter
1166{
1167 void operator()(GDALDataset *poDataset) const
1168 {
1169 GDALClose(poDataset);
1170 }
1171};
1172
1174
1176 struct CPL_DLL GDALDatasetUniquePtrReleaser
1177{
1178 void operator()(GDALDataset *poDataset) const
1179 {
1180 if (poDataset)
1181 poDataset->Release();
1182 }
1183};
1184
1186
1192 using GDALDatasetUniquePtr =
1193 std::unique_ptr<GDALDataset, GDALDatasetUniquePtrDeleter>;
1194
1195/* ******************************************************************** */
1196/* GDALRasterBlock */
1197/* ******************************************************************** */
1198
1203 class CPL_DLL GDALRasterBlock
1204{
1205 friend class GDALAbstractBandBlockCache;
1206
1207 GDALDataType eType;
1208
1209 bool bDirty;
1210 volatile int nLockCount;
1211
1212 int nXOff;
1213 int nYOff;
1214
1215 int nXSize;
1216 int nYSize;
1217
1218 void *pData;
1219
1220 GDALRasterBand *poBand;
1221
1222 GDALRasterBlock *poNext;
1223 GDALRasterBlock *poPrevious;
1224
1225 bool bMustDetach;
1226
1227 CPL_INTERNAL void Detach_unlocked(void);
1228 CPL_INTERNAL void Touch_unlocked(void);
1229
1230 CPL_INTERNAL void RecycleFor(int nXOffIn, int nYOffIn);
1231
1232 public:
1233 GDALRasterBlock(GDALRasterBand *, int, int);
1234 GDALRasterBlock(int nXOffIn, int nYOffIn); /* only for lookup purpose */
1235 virtual ~GDALRasterBlock();
1236
1237 CPLErr Internalize(void);
1238 void Touch(void);
1239 void MarkDirty(void);
1240 void MarkClean(void);
1241
1243 int AddLock(void)
1244 {
1245 return CPLAtomicInc(&nLockCount);
1246 }
1247
1249 int DropLock(void)
1250 {
1251 return CPLAtomicDec(&nLockCount);
1252 }
1253
1254 void Detach();
1255
1256 CPLErr Write();
1257
1261 GDALDataType GetDataType() const
1262 {
1263 return eType;
1264 }
1265
1269 int GetXOff() const
1270 {
1271 return nXOff;
1272 }
1273
1277 int GetYOff() const
1278 {
1279 return nYOff;
1280 }
1281
1285 int GetXSize() const
1286 {
1287 return nXSize;
1288 }
1289
1293 int GetYSize() const
1294 {
1295 return nYSize;
1296 }
1297
1301 int GetDirty() const
1302 {
1303 return bDirty;
1304 }
1305
1309 void *GetDataRef(void)
1310 {
1311 return pData;
1312 }
1313
1317 GPtrDiff_t GetBlockSize() const
1318 {
1319 return static_cast<GPtrDiff_t>(nXSize) * nYSize *
1320 GDALGetDataTypeSizeBytes(eType);
1321 }
1322
1323 int TakeLock();
1324 int DropLockForRemovalFromStorage();
1325
1328 GDALRasterBand *GetBand()
1329 {
1330 return poBand;
1331 }
1332
1333 static void FlushDirtyBlocks();
1334 static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE);
1335 static void Verify();
1336
1337 static void EnterDisableDirtyBlockFlush();
1338 static void LeaveDisableDirtyBlockFlush();
1339
1340#ifdef notdef
1341 static void CheckNonOrphanedBlocks(GDALRasterBand *poBand);
1342 void DumpBlock();
1343 static void DumpAll();
1344#endif
1345
1346 /* Should only be called by GDALDestroyDriverManager() */
1348 CPL_INTERNAL static void DestroyRBMutex();
1350
1351 private:
1352 CPL_DISALLOW_COPY_ASSIGN(GDALRasterBlock)
1353};
1354
1355/* ******************************************************************** */
1356/* GDALColorTable */
1357/* ******************************************************************** */
1358
1361 class CPL_DLL GDALColorTable
1362{
1363 GDALPaletteInterp eInterp;
1364
1365 std::vector<GDALColorEntry> aoEntries{};
1366
1367 public:
1368 explicit GDALColorTable(GDALPaletteInterp = GPI_RGB);
1369 ~GDALColorTable();
1370
1371 GDALColorTable *Clone() const;
1372 int IsSame(const GDALColorTable *poOtherCT) const;
1373
1374 GDALPaletteInterp GetPaletteInterpretation() const;
1375
1376 int GetColorEntryCount() const;
1377 const GDALColorEntry *GetColorEntry(int i) const;
1378 int GetColorEntryAsRGB(int i, GDALColorEntry *poEntry) const;
1379 void SetColorEntry(int i, const GDALColorEntry *poEntry);
1380 int CreateColorRamp(int nStartIndex, const GDALColorEntry *psStartColor,
1381 int nEndIndex, const GDALColorEntry *psEndColor);
1382 bool IsIdentity() const;
1383
1387 static inline GDALColorTableH ToHandle(GDALColorTable *poCT)
1388 {
1389 return static_cast<GDALColorTableH>(poCT);
1390 }
1391
1395 static inline GDALColorTable *FromHandle(GDALColorTableH hCT)
1396 {
1397 return static_cast<GDALColorTable *>(hCT);
1398 }
1399};
1400
1401/* ******************************************************************** */
1402/* GDALAbstractBandBlockCache */
1403/* ******************************************************************** */
1404
1406
1408// only used by GDALRasterBand implementation.
1409
1410 class GDALAbstractBandBlockCache
1411{
1412 // List of blocks that can be freed or recycled, and its lock
1413 CPLLock *hSpinLock = nullptr;
1414 GDALRasterBlock *psListBlocksToFree = nullptr;
1415
1416 // Band keep alive counter, and its lock & condition
1417 CPLCond *hCond = nullptr;
1418 CPLMutex *hCondMutex = nullptr;
1419 volatile int nKeepAliveCounter = 0;
1420
1421 volatile int m_nDirtyBlocks = 0;
1422
1423 CPL_DISALLOW_COPY_ASSIGN(GDALAbstractBandBlockCache)
1424
1425 protected:
1426 GDALRasterBand *poBand;
1427
1428 int m_nInitialDirtyBlocksInFlushCache = 0;
1429 int m_nLastTick = -1;
1430 size_t m_nWriteDirtyBlocksDisabled = 0;
1431
1432 void FreeDanglingBlocks();
1433 void UnreferenceBlockBase();
1434
1435 void StartDirtyBlockFlushingLog();
1436 void UpdateDirtyBlockFlushingLog();
1437 void EndDirtyBlockFlushingLog();
1438
1439 public:
1440 explicit GDALAbstractBandBlockCache(GDALRasterBand *poBand);
1441 virtual ~GDALAbstractBandBlockCache();
1442
1443 GDALRasterBlock *CreateBlock(int nXBlockOff, int nYBlockOff);
1444 void AddBlockToFreeList(GDALRasterBlock *poBlock);
1445 void IncDirtyBlocks(int nInc);
1446 void WaitCompletionPendingTasks();
1447
1448 void EnableDirtyBlockWriting()
1449 {
1450 --m_nWriteDirtyBlocksDisabled;
1451 }
1452
1453 void DisableDirtyBlockWriting()
1454 {
1455 ++m_nWriteDirtyBlocksDisabled;
1456 }
1457
1458 bool HasDirtyBlocks() const
1459 {
1460 return m_nDirtyBlocks > 0;
1461 }
1462
1463 virtual bool Init() = 0;
1464 virtual bool IsInitOK() = 0;
1465 virtual CPLErr FlushCache() = 0;
1466 virtual CPLErr AdoptBlock(GDALRasterBlock *poBlock) = 0;
1467 virtual GDALRasterBlock *TryGetLockedBlockRef(int nXBlockOff,
1468 int nYBlockYOff) = 0;
1469 virtual CPLErr UnreferenceBlock(GDALRasterBlock *poBlock) = 0;
1470 virtual CPLErr FlushBlock(int nXBlockOff, int nYBlockOff,
1471 int bWriteDirtyBlock) = 0;
1472};
1473
1474GDALAbstractBandBlockCache *
1475GDALArrayBandBlockCacheCreate(GDALRasterBand *poBand);
1476GDALAbstractBandBlockCache *
1477GDALHashSetBandBlockCacheCreate(GDALRasterBand *poBand);
1478
1480
1481/* ******************************************************************** */
1482/* GDALRasterBand */
1483/* ******************************************************************** */
1484
1485 class GDALMDArray;
1486 class GDALDoublePointsCache;
1487
1489 typedef enum
1490{
1491 GMVR_UNKNOWN,
1493 GMVR_0_AND_1_ONLY,
1494 GMVR_0_AND_255_ONLY,
1495} GDALMaskValueRange;
1496
1498 typedef int GDALSuggestedBlockAccessPattern;
1499
1501 constexpr GDALSuggestedBlockAccessPattern GSBAP_UNKNOWN = 0;
1502
1504 constexpr GDALSuggestedBlockAccessPattern GSBAP_RANDOM = 1;
1505
1507 constexpr GDALSuggestedBlockAccessPattern GSBAP_TOP_TO_BOTTOM = 2;
1508
1510 constexpr GDALSuggestedBlockAccessPattern GSBAP_BOTTOM_TO_TOP = 3;
1511
1514 constexpr GDALSuggestedBlockAccessPattern GSBAP_LARGEST_CHUNK_POSSIBLE = 0x100;
1515
1518 class CPL_DLL GDALRasterBand : public GDALMajorObject
1519{
1520 private:
1521 friend class GDALArrayBandBlockCache;
1522 friend class GDALHashSetBandBlockCache;
1523 friend class GDALRasterBlock;
1524 friend class GDALDataset;
1525
1526 CPLErr eFlushBlockErr = CE_None;
1527 GDALAbstractBandBlockCache *poBandBlockCache = nullptr;
1528
1529 CPL_INTERNAL void SetFlushBlockErr(CPLErr eErr);
1530 CPL_INTERNAL CPLErr UnreferenceBlock(GDALRasterBlock *poBlock);
1531 CPL_INTERNAL void IncDirtyBlocks(int nInc);
1532
1533 protected:
1535 GDALDataset *poDS = nullptr;
1536 int nBand = 0; /* 1 based */
1537
1538 int nRasterXSize = 0;
1539 int nRasterYSize = 0;
1540
1541 GDALDataType eDataType = GDT_Byte;
1542 GDALAccess eAccess = GA_ReadOnly;
1543
1544 /* stuff related to blocking, and raster cache */
1545 int nBlockXSize = -1;
1546 int nBlockYSize = -1;
1547 int nBlocksPerRow = 0;
1548 int nBlocksPerColumn = 0;
1549
1550 int nBlockReads = 0;
1551 int bForceCachedIO = 0;
1552
1553 class GDALRasterBandOwnedOrNot
1554 {
1555 public:
1556 GDALRasterBandOwnedOrNot()
1557 {
1558 }
1559
1560 GDALRasterBandOwnedOrNot(GDALRasterBand *poBand, bool bOwned)
1561 : m_poBandOwned(bOwned ? poBand : nullptr),
1562 m_poBandRef(bOwned ? nullptr : poBand)
1563 {
1564 }
1565
1566 void reset()
1567 {
1568 m_poBandOwned.reset();
1569 m_poBandRef = nullptr;
1570 }
1571
1572 void reset(GDALRasterBand *poBand, bool bOwned)
1573 {
1574 m_poBandOwned.reset(bOwned ? poBand : nullptr);
1575 m_poBandRef = bOwned ? nullptr : poBand;
1576 }
1577
1578 const GDALRasterBand *get() const
1579 {
1580 return static_cast<const GDALRasterBand *>(*this);
1581 }
1582
1583 GDALRasterBand *get()
1584 {
1585 return static_cast<GDALRasterBand *>(*this);
1586 }
1587
1588 bool IsOwned() const
1589 {
1590 return m_poBandOwned != nullptr;
1591 }
1592
1593 operator const GDALRasterBand *() const
1594 {
1595 return m_poBandOwned ? m_poBandOwned.get() : m_poBandRef;
1596 }
1597
1598 operator GDALRasterBand *()
1599 {
1600 return m_poBandOwned ? m_poBandOwned.get() : m_poBandRef;
1601 }
1602
1603 private:
1604 CPL_DISALLOW_COPY_ASSIGN(GDALRasterBandOwnedOrNot)
1605 std::unique_ptr<GDALRasterBand> m_poBandOwned{};
1606 GDALRasterBand *m_poBandRef = nullptr;
1607 };
1608
1609 GDALRasterBandOwnedOrNot poMask{};
1610 bool m_bEnablePixelTypeSignedByteWarning =
1611 true; // Remove me in GDAL 4.0. See GetMetadataItem() implementation
1612 int nMaskFlags = 0;
1613
1614 void InvalidateMaskBand();
1615
1616 friend class GDALProxyRasterBand;
1617 friend class GDALDefaultOverviews;
1618
1619 CPLErr
1620 RasterIOResampled(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1621 int nYSize, void *pData, int nBufXSize, int nBufYSize,
1622 GDALDataType eBufType, GSpacing nPixelSpace,
1623 GSpacing nLineSpace,
1624 GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
1625
1626 int EnterReadWrite(GDALRWFlag eRWFlag);
1627 void LeaveReadWrite();
1628 void InitRWLock();
1629 void SetValidPercent(GUIntBig nSampleCount, GUIntBig nValidCount);
1630
1631 mutable GDALDoublePointsCache *m_poPointsCache = nullptr;
1632
1634
1635 protected:
1636 virtual CPLErr IReadBlock(int nBlockXOff, int nBlockYOff, void *pData) = 0;
1637 virtual CPLErr IWriteBlock(int nBlockXOff, int nBlockYOff, void *pData);
1638
1639 virtual CPLErr
1640 IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize,
1641 void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType,
1642 GSpacing nPixelSpace, GSpacing nLineSpace,
1643 GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
1644
1645 virtual int IGetDataCoverageStatus(int nXOff, int nYOff, int nXSize,
1646 int nYSize, int nMaskFlagStop,
1647 double *pdfDataPct);
1649 CPLErr
1650 OverviewRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1651 int nYSize, void *pData, int nBufXSize, int nBufYSize,
1652 GDALDataType eBufType, GSpacing nPixelSpace,
1653 GSpacing nLineSpace,
1654 GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
1655
1656 CPLErr TryOverviewRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
1657 int nXSize, int nYSize, void *pData,
1658 int nBufXSize, int nBufYSize,
1659 GDALDataType eBufType, GSpacing nPixelSpace,
1660 GSpacing nLineSpace,
1661 GDALRasterIOExtraArg *psExtraArg, int *pbTried);
1662
1663 int InitBlockInfo();
1664
1665 void AddBlockToFreeList(GDALRasterBlock *);
1666
1667 bool HasBlockCache() const
1668 {
1669 return poBandBlockCache != nullptr;
1670 }
1671
1672 bool HasDirtyBlocks() const
1673 {
1674 return poBandBlockCache && poBandBlockCache->HasDirtyBlocks();
1675 }
1676
1678
1679 public:
1680 GDALRasterBand();
1681 explicit GDALRasterBand(int bForceCachedIO);
1682
1683 ~GDALRasterBand() override;
1684
1685 int GetXSize() const;
1686 int GetYSize() const;
1687 int GetBand() const;
1688 GDALDataset *GetDataset() const;
1689
1690 GDALDataType GetRasterDataType(void) const;
1691 void GetBlockSize(int *pnXSize, int *pnYSize) const;
1692 CPLErr GetActualBlockSize(int nXBlockOff, int nYBlockOff, int *pnXValid,
1693 int *pnYValid) const;
1694
1695 virtual GDALSuggestedBlockAccessPattern
1696 GetSuggestedBlockAccessPattern() const;
1697
1698 GDALAccess GetAccess();
1699
1700#ifndef DOXYGEN_SKIP
1701 CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1702 int nYSize, void *pData, int nBufXSize, int nBufYSize,
1703 GDALDataType eBufType, GSpacing nPixelSpace,
1704 GSpacing nLineSpace,
1705 GDALRasterIOExtraArg *psExtraArg
1706 OPTIONAL_OUTSIDE_GDAL(nullptr)) CPL_WARN_UNUSED_RESULT;
1707#else
1708 CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1709 int nYSize, void *pData, int nBufXSize, int nBufYSize,
1710 GDALDataType eBufType, GSpacing nPixelSpace,
1711 GSpacing nLineSpace,
1712 GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
1713#endif
1714
1715 template <class T>
1716 CPLErr ReadRaster(T *pData, size_t nArrayEltCount = 0, double dfXOff = 0,
1717 double dfYOff = 0, double dfXSize = 0, double dfYSize = 0,
1718 size_t nBufXSize = 0, size_t nBufYSize = 0,
1719 GDALRIOResampleAlg eResampleAlg = GRIORA_NearestNeighbour,
1720 GDALProgressFunc pfnProgress = nullptr,
1721 void *pProgressData = nullptr) const;
1722
1723 template <class T>
1724 CPLErr ReadRaster(std::vector<T> &vData, double dfXOff = 0,
1725 double dfYOff = 0, double dfXSize = 0, double dfYSize = 0,
1726 size_t nBufXSize = 0, size_t nBufYSize = 0,
1727 GDALRIOResampleAlg eResampleAlg = GRIORA_NearestNeighbour,
1728 GDALProgressFunc pfnProgress = nullptr,
1729 void *pProgressData = nullptr) const;
1730
1731#if __cplusplus >= 202002L
1733 template <class T>
1734 inline CPLErr
1735 ReadRaster(std::span<T> pData, double dfXOff = 0, double dfYOff = 0,
1736 double dfXSize = 0, double dfYSize = 0, size_t nBufXSize = 0,
1737 size_t nBufYSize = 0,
1738 GDALRIOResampleAlg eResampleAlg = GRIORA_NearestNeighbour,
1739 GDALProgressFunc pfnProgress = nullptr,
1740 void *pProgressData = nullptr) const
1741 {
1742 return ReadRaster(pData.data(), pData.size(), dfXOff, dfYOff, dfXSize,
1743 dfYSize, nBufXSize, nBufYSize, eResampleAlg,
1744 pfnProgress, pProgressData);
1745 }
1746
1748#endif
1749
1750 CPLErr ReadBlock(int nXBlockOff, int nYBlockOff,
1751 void *pImage) CPL_WARN_UNUSED_RESULT;
1752
1753 CPLErr WriteBlock(int nXBlockOff, int nYBlockOff,
1754 void *pImage) CPL_WARN_UNUSED_RESULT;
1755
1756 // This method should only be overloaded by GDALProxyRasterBand
1757 virtual GDALRasterBlock *
1758 GetLockedBlockRef(int nXBlockOff, int nYBlockOff,
1759 int bJustInitialize = FALSE) CPL_WARN_UNUSED_RESULT;
1760
1761 // This method should only be overloaded by GDALProxyRasterBand
1762 virtual GDALRasterBlock *
1763 TryGetLockedBlockRef(int nXBlockOff,
1764 int nYBlockYOff) CPL_WARN_UNUSED_RESULT;
1765
1766 // This method should only be overloaded by GDALProxyRasterBand
1767 virtual CPLErr FlushBlock(int nXBlockOff, int nYBlockOff,
1768 int bWriteDirtyBlock = TRUE);
1769
1770 unsigned char *
1771 GetIndexColorTranslationTo(/* const */ GDALRasterBand *poReferenceBand,
1772 unsigned char *pTranslationTable = nullptr,
1773 int *pApproximateMatching = nullptr);
1774
1775 // New OpengIS CV_SampleDimension stuff.
1776
1777 virtual CPLErr FlushCache(bool bAtClosing = false);
1778 virtual CPLErr DropCache();
1779 virtual char **GetCategoryNames();
1780 virtual double GetNoDataValue(int *pbSuccess = nullptr);
1781 virtual int64_t GetNoDataValueAsInt64(int *pbSuccess = nullptr);
1782 virtual uint64_t GetNoDataValueAsUInt64(int *pbSuccess = nullptr);
1783 virtual double GetMinimum(int *pbSuccess = nullptr);
1784 virtual double GetMaximum(int *pbSuccess = nullptr);
1785 virtual double GetOffset(int *pbSuccess = nullptr);
1786 virtual double GetScale(int *pbSuccess = nullptr);
1787 virtual const char *GetUnitType();
1788 virtual GDALColorInterp GetColorInterpretation();
1789 virtual GDALColorTable *GetColorTable();
1790 virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
1791
1792 virtual CPLErr SetCategoryNames(char **papszNames);
1793 virtual CPLErr SetNoDataValue(double dfNoData);
1794 virtual CPLErr SetNoDataValueAsInt64(int64_t nNoData);
1795 virtual CPLErr SetNoDataValueAsUInt64(uint64_t nNoData);
1796 virtual CPLErr DeleteNoDataValue();
1797 virtual CPLErr SetColorTable(GDALColorTable *poCT);
1798 virtual CPLErr SetColorInterpretation(GDALColorInterp eColorInterp);
1799 virtual CPLErr SetOffset(double dfNewOffset);
1800 virtual CPLErr SetScale(double dfNewScale);
1801 virtual CPLErr SetUnitType(const char *pszNewValue);
1802
1803 virtual CPLErr GetStatistics(int bApproxOK, int bForce, double *pdfMin,
1804 double *pdfMax, double *pdfMean,
1805 double *padfStdDev);
1806 virtual CPLErr ComputeStatistics(int bApproxOK, double *pdfMin,
1807 double *pdfMax, double *pdfMean,
1808 double *pdfStdDev, GDALProgressFunc,
1809 void *pProgressData);
1810 virtual CPLErr SetStatistics(double dfMin, double dfMax, double dfMean,
1811 double dfStdDev);
1812 virtual CPLErr ComputeRasterMinMax(int bApproxOK, double *adfMinMax);
1813
1814// Only defined when Doxygen enabled
1815#ifdef DOXYGEN_SKIP
1816 CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override;
1817 CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
1818 const char *pszDomain) override;
1819#endif
1820 virtual const char *GetMetadataItem(const char *pszName,
1821 const char *pszDomain = "") override;
1822
1823 virtual int HasArbitraryOverviews();
1824 virtual int GetOverviewCount();
1825 virtual GDALRasterBand *GetOverview(int i);
1826 virtual GDALRasterBand *GetRasterSampleOverview(GUIntBig);
1827 virtual CPLErr BuildOverviews(const char *pszResampling, int nOverviews,
1828 const int *panOverviewList,
1829 GDALProgressFunc pfnProgress,
1830 void *pProgressData,
1831 CSLConstList papszOptions);
1832
1833 virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize,
1834 int nBufXSize, int nBufYSize,
1835 GDALDataType eBufType, char **papszOptions);
1836
1837 virtual CPLErr GetHistogram(double dfMin, double dfMax, int nBuckets,
1838 GUIntBig *panHistogram, int bIncludeOutOfRange,
1839 int bApproxOK, GDALProgressFunc,
1840 void *pProgressData);
1841
1842 virtual CPLErr GetDefaultHistogram(double *pdfMin, double *pdfMax,
1843 int *pnBuckets, GUIntBig **ppanHistogram,
1844 int bForce, GDALProgressFunc,
1845 void *pProgressData);
1846 virtual CPLErr SetDefaultHistogram(double dfMin, double dfMax, int nBuckets,
1847 GUIntBig *panHistogram);
1848
1849 virtual GDALRasterAttributeTable *GetDefaultRAT();
1850 virtual CPLErr SetDefaultRAT(const GDALRasterAttributeTable *poRAT);
1851
1852 virtual GDALRasterBand *GetMaskBand();
1853 virtual int GetMaskFlags();
1854 virtual CPLErr CreateMaskBand(int nFlagsIn);
1855 virtual bool IsMaskBand() const;
1856 virtual GDALMaskValueRange GetMaskValueRange() const;
1857
1858 virtual CPLVirtualMem *
1859 GetVirtualMemAuto(GDALRWFlag eRWFlag, int *pnPixelSpace,
1860 GIntBig *pnLineSpace,
1861 char **papszOptions) CPL_WARN_UNUSED_RESULT;
1862
1863 int GetDataCoverageStatus(int nXOff, int nYOff, int nXSize, int nYSize,
1864 int nMaskFlagStop = 0,
1865 double *pdfDataPct = nullptr);
1866
1867 std::shared_ptr<GDALMDArray> AsMDArray() const;
1868
1869 virtual CPLErr InterpolateAtPoint(double dfPixel, double dfLine,
1870 GDALRIOResampleAlg eInterpolation,
1871 double *pdfRealValue,
1872 double *pdfImagValue = nullptr) const;
1873
1874#ifndef DOXYGEN_XML
1875 void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,
1876 ...) const CPL_PRINT_FUNC_FORMAT(4, 5);
1877#endif
1878
1882 static inline GDALRasterBandH ToHandle(GDALRasterBand *poBand)
1883 {
1884 return static_cast<GDALRasterBandH>(poBand);
1885 }
1886
1890 static inline GDALRasterBand *FromHandle(GDALRasterBandH hBand)
1891 {
1892 return static_cast<GDALRasterBand *>(hBand);
1893 }
1894
1896 // Remove me in GDAL 4.0. See GetMetadataItem() implementation
1897 // Internal use in GDAL only !
1898 virtual void EnablePixelTypeSignedByteWarning(bool b)
1899#ifndef GDAL_COMPILATION
1900 CPL_WARN_DEPRECATED("Do not use that method outside of GDAL!")
1901#endif
1902 ;
1903
1905
1906 private:
1907 CPL_DISALLOW_COPY_ASSIGN(GDALRasterBand)
1908};
1909
1911#define GDAL_EXTERN_TEMPLATE_READ_RASTER(T) \
1912 extern template CPLErr GDALRasterBand::ReadRaster<T>( \
1913 T * pData, size_t nArrayEltCount, double dfXOff, double dfYOff, \
1914 double dfXSize, double dfYSize, size_t nBufXSize, size_t nBufYSize, \
1915 GDALRIOResampleAlg eResampleAlg, GDALProgressFunc pfnProgress, \
1916 void *pProgressData) const;
1917
1918GDAL_EXTERN_TEMPLATE_READ_RASTER(uint8_t)
1919GDAL_EXTERN_TEMPLATE_READ_RASTER(int8_t)
1920GDAL_EXTERN_TEMPLATE_READ_RASTER(uint16_t)
1921GDAL_EXTERN_TEMPLATE_READ_RASTER(int16_t)
1922GDAL_EXTERN_TEMPLATE_READ_RASTER(uint32_t)
1923GDAL_EXTERN_TEMPLATE_READ_RASTER(int32_t)
1924GDAL_EXTERN_TEMPLATE_READ_RASTER(uint64_t)
1925GDAL_EXTERN_TEMPLATE_READ_RASTER(int64_t)
1926GDAL_EXTERN_TEMPLATE_READ_RASTER(float)
1927GDAL_EXTERN_TEMPLATE_READ_RASTER(double)
1928// Not allowed by C++ standard
1929// GDAL_EXTERN_TEMPLATE_READ_RASTER(std::complex<int16_t>)
1930// GDAL_EXTERN_TEMPLATE_READ_RASTER(std::complex<int32_t>)
1931GDAL_EXTERN_TEMPLATE_READ_RASTER(std::complex<float>)
1932GDAL_EXTERN_TEMPLATE_READ_RASTER(std::complex<double>)
1933
1934#define GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(T) \
1935 extern template CPLErr GDALRasterBand::ReadRaster<T>( \
1936 std::vector<T> & vData, double dfXOff, double dfYOff, double dfXSize, \
1937 double dfYSize, size_t nBufXSize, size_t nBufYSize, \
1938 GDALRIOResampleAlg eResampleAlg, GDALProgressFunc pfnProgress, \
1939 void *pProgressData) const;
1940
1941GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(uint8_t)
1942GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(int8_t)
1943GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(uint16_t)
1944GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(int16_t)
1945GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(uint32_t)
1946GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(int32_t)
1947GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(uint64_t)
1948GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(int64_t)
1949GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(float)
1950GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(double)
1951// Not allowed by C++ standard
1952// GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(std::complex<int16_t>)
1953// GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(std::complex<int32_t>)
1954GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(std::complex<float>)
1955GDAL_EXTERN_TEMPLATE_READ_RASTER_VECTOR(std::complex<double>)
1956
1957
1958
1959
1960/* ******************************************************************** */
1961/* GDALAllValidMaskBand */
1962/* ******************************************************************** */
1963
1964 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
1965{
1966 protected:
1967 CPLErr IReadBlock(int, int, void *) override;
1968
1969 CPL_DISALLOW_COPY_ASSIGN(GDALAllValidMaskBand)
1970
1971 public:
1972 explicit GDALAllValidMaskBand(GDALRasterBand *);
1973 ~GDALAllValidMaskBand() override;
1974
1975 GDALRasterBand *GetMaskBand() override;
1976 int GetMaskFlags() override;
1977
1978 bool IsMaskBand() const override
1979 {
1980 return true;
1981 }
1982
1983 GDALMaskValueRange GetMaskValueRange() const override
1984 {
1985 return GMVR_0_AND_255_ONLY;
1986 }
1987
1988 CPLErr ComputeStatistics(int bApproxOK, double *pdfMin, double *pdfMax,
1989 double *pdfMean, double *pdfStdDev,
1990 GDALProgressFunc, void *pProgressData) override;
1991};
1992
1993/* ******************************************************************** */
1994/* GDALNoDataMaskBand */
1995/* ******************************************************************** */
1996
1997 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
1998{
1999 friend class GDALRasterBand;
2000 double m_dfNoDataValue = 0;
2001 int64_t m_nNoDataValueInt64 = 0;
2002 uint64_t m_nNoDataValueUInt64 = 0;
2003 GDALRasterBand *m_poParent = nullptr;
2004
2005 CPL_DISALLOW_COPY_ASSIGN(GDALNoDataMaskBand)
2006
2007 protected:
2008 CPLErr IReadBlock(int, int, void *) override;
2009 CPLErr IRasterIO(GDALRWFlag, int, int, int, int, void *, int, int,
2010 GDALDataType, GSpacing, GSpacing,
2011 GDALRasterIOExtraArg *psExtraArg) override;
2012
2013 public:
2014 explicit GDALNoDataMaskBand(GDALRasterBand *);
2015 explicit GDALNoDataMaskBand(GDALRasterBand *, double dfNoDataValue);
2016 ~GDALNoDataMaskBand() override;
2017
2018 bool IsMaskBand() const override
2019 {
2020 return true;
2021 }
2022
2023 GDALMaskValueRange GetMaskValueRange() const override
2024 {
2025 return GMVR_0_AND_255_ONLY;
2026 }
2027
2028 static bool IsNoDataInRange(double dfNoDataValue, GDALDataType eDataType);
2029};
2030
2031/* ******************************************************************** */
2032/* GDALNoDataValuesMaskBand */
2033/* ******************************************************************** */
2034
2035 class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
2036{
2037 double *padfNodataValues;
2038
2039 CPL_DISALLOW_COPY_ASSIGN(GDALNoDataValuesMaskBand)
2040
2041 protected:
2042 CPLErr IReadBlock(int, int, void *) override;
2043
2044 public:
2045 explicit GDALNoDataValuesMaskBand(GDALDataset *);
2046 ~GDALNoDataValuesMaskBand() override;
2047
2048 bool IsMaskBand() const override
2049 {
2050 return true;
2051 }
2052
2053 GDALMaskValueRange GetMaskValueRange() const override
2054 {
2055 return GMVR_0_AND_255_ONLY;
2056 }
2057};
2058
2059/* ******************************************************************** */
2060/* GDALRescaledAlphaBand */
2061/* ******************************************************************** */
2062
2063 class GDALRescaledAlphaBand : public GDALRasterBand
2064{
2065 GDALRasterBand *poParent;
2066 void *pTemp;
2067
2068 CPL_DISALLOW_COPY_ASSIGN(GDALRescaledAlphaBand)
2069
2070 protected:
2071 CPLErr IReadBlock(int, int, void *) override;
2072 CPLErr IRasterIO(GDALRWFlag, int, int, int, int, void *, int, int,
2073 GDALDataType, GSpacing, GSpacing,
2074 GDALRasterIOExtraArg *psExtraArg) override;
2075
2076 public:
2077 explicit GDALRescaledAlphaBand(GDALRasterBand *);
2078 ~GDALRescaledAlphaBand() override;
2079
2080 bool IsMaskBand() const override
2081 {
2082 return true;
2083 }
2084};
2085
2087
2088/* ******************************************************************** */
2089/* GDALIdentifyEnum */
2090/* ******************************************************************** */
2091
2097 typedef enum
2098{
2101 GDAL_IDENTIFY_UNKNOWN = -1,
2103 GDAL_IDENTIFY_FALSE = 0,
2105 GDAL_IDENTIFY_TRUE = 1
2106} GDALIdentifyEnum;
2107
2108/* ******************************************************************** */
2109/* GDALDriver */
2110/* ******************************************************************** */
2111
2123 class CPL_DLL GDALDriver : public GDALMajorObject
2124{
2125 public:
2126 GDALDriver();
2127 ~GDALDriver() override;
2128
2129 CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
2130 const char *pszDomain = "") override;
2131
2132 /* -------------------------------------------------------------------- */
2133 /* Public C++ methods. */
2134 /* -------------------------------------------------------------------- */
2135 GDALDataset *Create(const char *pszName, int nXSize, int nYSize, int nBands,
2136 GDALDataType eType,
2137 CSLConstList papszOptions) CPL_WARN_UNUSED_RESULT;
2138
2139 GDALDataset *
2140 CreateMultiDimensional(const char *pszName,
2141 CSLConstList papszRootGroupOptions,
2142 CSLConstList papszOptions) CPL_WARN_UNUSED_RESULT;
2143
2144 CPLErr Delete(const char *pszName);
2145 CPLErr Rename(const char *pszNewName, const char *pszOldName);
2146 CPLErr CopyFiles(const char *pszNewName, const char *pszOldName);
2147
2148 GDALDataset *CreateCopy(const char *, GDALDataset *, int,
2149 CSLConstList papszOptions,
2150 GDALProgressFunc pfnProgress,
2151 void *pProgressData) CPL_WARN_UNUSED_RESULT;
2152
2153 bool CanVectorTranslateFrom(const char *pszDestName,
2154 GDALDataset *poSourceDS,
2155 CSLConstList papszVectorTranslateArguments,
2156 char ***ppapszFailureReasons);
2157
2158 GDALDataset *
2159 VectorTranslateFrom(const char *pszDestName, GDALDataset *poSourceDS,
2160 CSLConstList papszVectorTranslateArguments,
2161 GDALProgressFunc pfnProgress,
2162 void *pProgressData) CPL_WARN_UNUSED_RESULT;
2163
2164 /* -------------------------------------------------------------------- */
2165 /* The following are semiprivate, not intended to be accessed */
2166 /* by anyone but the formats instantiating and populating the */
2167 /* drivers. */
2168 /* -------------------------------------------------------------------- */
2170
2171 // Not aimed at being used outside of GDAL. Use GDALDataset::Open() instead
2172 GDALDataset *Open(GDALOpenInfo *poOpenInfo, bool bSetOpenOptions);
2173
2174 typedef GDALDataset *(*OpenCallback)(GDALOpenInfo *);
2175
2176 OpenCallback pfnOpen = nullptr;
2177
2178 virtual OpenCallback GetOpenCallback()
2179 {
2180 return pfnOpen;
2181 }
2182
2183 typedef GDALDataset *(*CreateCallback)(const char *pszName, int nXSize,
2184 int nYSize, int nBands,
2185 GDALDataType eType,
2186 char **papszOptions);
2187
2188 CreateCallback pfnCreate = nullptr;
2189
2190 virtual CreateCallback GetCreateCallback()
2191 {
2192 return pfnCreate;
2193 }
2194
2195 GDALDataset *(*pfnCreateEx)(GDALDriver *, const char *pszName, int nXSize,
2196 int nYSize, int nBands, GDALDataType eType,
2197 char **papszOptions) = nullptr;
2198
2199 typedef GDALDataset *(*CreateMultiDimensionalCallback)(
2200 const char *pszName, CSLConstList papszRootGroupOptions,
2201 CSLConstList papszOptions);
2202
2203 CreateMultiDimensionalCallback pfnCreateMultiDimensional = nullptr;
2204
2205 virtual CreateMultiDimensionalCallback GetCreateMultiDimensionalCallback()
2206 {
2207 return pfnCreateMultiDimensional;
2208 }
2209
2210 typedef CPLErr (*DeleteCallback)(const char *pszName);
2211 DeleteCallback pfnDelete = nullptr;
2212
2213 virtual DeleteCallback GetDeleteCallback()
2214 {
2215 return pfnDelete;
2216 }
2217
2218 typedef GDALDataset *(*CreateCopyCallback)(const char *, GDALDataset *, int,
2219 char **,
2220 GDALProgressFunc pfnProgress,
2221 void *pProgressData);
2222
2223 CreateCopyCallback pfnCreateCopy = nullptr;
2224
2225 virtual CreateCopyCallback GetCreateCopyCallback()
2226 {
2227 return pfnCreateCopy;
2228 }
2229
2230 void *pDriverData = nullptr;
2231
2232 void (*pfnUnloadDriver)(GDALDriver *) = nullptr;
2233
2242 int (*pfnIdentify)(GDALOpenInfo *) = nullptr;
2243 int (*pfnIdentifyEx)(GDALDriver *, GDALOpenInfo *) = nullptr;
2244
2245 typedef CPLErr (*RenameCallback)(const char *pszNewName,
2246 const char *pszOldName);
2247 RenameCallback pfnRename = nullptr;
2248
2249 virtual RenameCallback GetRenameCallback()
2250 {
2251 return pfnRename;
2252 }
2253
2254 typedef CPLErr (*CopyFilesCallback)(const char *pszNewName,
2255 const char *pszOldName);
2256 CopyFilesCallback pfnCopyFiles = nullptr;
2257
2258 virtual CopyFilesCallback GetCopyFilesCallback()
2259 {
2260 return pfnCopyFiles;
2261 }
2262
2263 // Used for legacy OGR drivers, and Python drivers
2264 GDALDataset *(*pfnOpenWithDriverArg)(GDALDriver *,
2265 GDALOpenInfo *) = nullptr;
2266
2267 /* For legacy OGR drivers */
2268 GDALDataset *(*pfnCreateVectorOnly)(GDALDriver *, const char *pszName,
2269 char **papszOptions) = nullptr;
2270 CPLErr (*pfnDeleteDataSource)(GDALDriver *, const char *pszName) = nullptr;
2271
2276 bool (*pfnCanVectorTranslateFrom)(
2277 const char *pszDestName, GDALDataset *poSourceDS,
2278 CSLConstList papszVectorTranslateArguments,
2279 char ***ppapszFailureReasons) = nullptr;
2280
2285 GDALDataset *(*pfnVectorTranslateFrom)(
2286 const char *pszDestName, GDALDataset *poSourceDS,
2287 CSLConstList papszVectorTranslateArguments,
2288 GDALProgressFunc pfnProgress, void *pProgressData) = nullptr;
2289
2294 GDALSubdatasetInfo *(*pfnGetSubdatasetInfoFunc)(const char *pszFileName) =
2295 nullptr;
2296
2298
2299 /* -------------------------------------------------------------------- */
2300 /* Helper methods. */
2301 /* -------------------------------------------------------------------- */
2303 GDALDataset *DefaultCreateCopy(const char *, GDALDataset *, int,
2304 CSLConstList papszOptions,
2305 GDALProgressFunc pfnProgress,
2306 void *pProgressData) CPL_WARN_UNUSED_RESULT;
2307
2308 static CPLErr DefaultCreateCopyMultiDimensional(
2309 GDALDataset *poSrcDS, GDALDataset *poDstDS, bool bStrict,
2310 CSLConstList /*papszOptions*/, GDALProgressFunc pfnProgress,
2311 void *pProgressData);
2312
2313 static CPLErr DefaultCopyMasks(GDALDataset *poSrcDS, GDALDataset *poDstDS,
2314 int bStrict);
2315 static CPLErr DefaultCopyMasks(GDALDataset *poSrcDS, GDALDataset *poDstDS,
2316 int bStrict, CSLConstList papszOptions,
2317 GDALProgressFunc pfnProgress,
2318 void *pProgressData);
2319
2320 CPLErr QuietDeleteForCreateCopy(const char *pszFilename,
2321 GDALDataset *poSrcDS);
2322
2324 static CPLErr QuietDelete(const char *pszName,
2325 CSLConstList papszAllowedDrivers = nullptr);
2326
2328 static CPLErr DefaultRename(const char *pszNewName, const char *pszOldName);
2329 static CPLErr DefaultCopyFiles(const char *pszNewName,
2330 const char *pszOldName);
2331 static void DefaultCopyMetadata(GDALDataset *poSrcDS, GDALDataset *poDstDS,
2332 CSLConstList papszOptions,
2333 CSLConstList papszExcludedDomains);
2334
2336
2340 static inline GDALDriverH ToHandle(GDALDriver *poDriver)
2341 {
2342 return static_cast<GDALDriverH>(poDriver);
2343 }
2344
2348 static inline GDALDriver *FromHandle(GDALDriverH hDriver)
2349 {
2350 return static_cast<GDALDriver *>(hDriver);
2351 }
2352
2353 private:
2354 CPL_DISALLOW_COPY_ASSIGN(GDALDriver)
2355};
2356
2357/************************************************************************/
2358/* GDALPluginDriverProxy */
2359/************************************************************************/
2360
2361// clang-format off
2399// clang-format on
2400
2401 class GDALPluginDriverProxy : public GDALDriver
2402{
2403 const std::string m_osPluginFileName;
2404 std::string m_osPluginFullPath{};
2405 std::unique_ptr<GDALDriver> m_poRealDriver{};
2406 std::set<std::string> m_oSetMetadataItems{};
2407
2408 GDALDriver *GetRealDriver();
2409
2410 CPL_DISALLOW_COPY_ASSIGN(GDALPluginDriverProxy)
2411
2412 protected:
2413 friend class GDALDriverManager;
2414
2416 void SetPluginFullPath(const std::string &osFullPath)
2417 {
2418 m_osPluginFullPath = osFullPath;
2419 }
2420
2422
2423 public:
2424 explicit GDALPluginDriverProxy(const std::string &osPluginFileName);
2425
2427 const std::string &GetPluginFileName() const
2428 {
2429 return m_osPluginFileName;
2430 }
2431
2433 OpenCallback GetOpenCallback() override;
2434
2435 CreateCallback GetCreateCallback() override;
2436
2437 CreateMultiDimensionalCallback GetCreateMultiDimensionalCallback() override;
2438
2439 CreateCopyCallback GetCreateCopyCallback() override;
2440
2441 DeleteCallback GetDeleteCallback() override;
2442
2443 RenameCallback GetRenameCallback() override;
2444
2445 CopyFilesCallback GetCopyFilesCallback() override;
2447
2448 CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
2449 const char *pszDomain = "") override;
2450
2451 char **GetMetadata(const char *pszDomain) override;
2452
2453 const char *GetMetadataItem(const char *pszName,
2454 const char *pszDomain = "") override;
2455};
2456
2457/* ******************************************************************** */
2458/* GDALDriverManager */
2459/* ******************************************************************** */
2460
2468 class CPL_DLL GDALDriverManager : public GDALMajorObject
2469{
2470 int nDrivers = 0;
2471 GDALDriver **papoDrivers = nullptr;
2472 std::map<CPLString, GDALDriver *> oMapNameToDrivers{};
2473 std::string m_osPluginPath{};
2474 std::string m_osDriversIniPath{};
2475 mutable std::string m_osLastTriedDirectory{};
2476 std::set<std::string> m_oSetPluginFileNames{};
2477 bool m_bInDeferredDriverLoading = false;
2478 std::map<std::string, std::unique_ptr<GDALDriver>> m_oMapRealDrivers{};
2479 std::vector<std::unique_ptr<GDALDriver>> m_aoHiddenDrivers{};
2480
2481 GDALDriver *GetDriver_unlocked(int iDriver)
2482 {
2483 return (iDriver >= 0 && iDriver < nDrivers) ? papoDrivers[iDriver]
2484 : nullptr;
2485 }
2486
2487 GDALDriver *GetDriverByName_unlocked(const char *pszName) const
2488 {
2489 auto oIter = oMapNameToDrivers.find(CPLString(pszName).toupper());
2490 return oIter == oMapNameToDrivers.end() ? nullptr : oIter->second;
2491 }
2492
2493 static void CleanupPythonDrivers();
2494
2495 std::string GetPluginFullPath(const char *pszFilename) const;
2496
2497 int RegisterDriver(GDALDriver *, bool bHidden);
2498
2499 CPL_DISALLOW_COPY_ASSIGN(GDALDriverManager)
2500
2501 protected:
2502 friend class GDALPluginDriverProxy;
2503 friend GDALDatasetH CPL_STDCALL
2504 GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags,
2505 const char *const *papszAllowedDrivers,
2506 const char *const *papszOpenOptions,
2507 const char *const *papszSiblingFiles);
2508
2510 static char **GetSearchPaths(const char *pszGDAL_DRIVER_PATH);
2512
2513 public:
2514 GDALDriverManager();
2515 ~GDALDriverManager();
2516
2517 int GetDriverCount(void) const;
2518 GDALDriver *GetDriver(int);
2519 GDALDriver *GetDriverByName(const char *);
2520
2521 int RegisterDriver(GDALDriver *);
2522 void DeregisterDriver(GDALDriver *);
2523
2524 // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
2525 void AutoLoadDrivers();
2526 void AutoSkipDrivers();
2527 void ReorderDrivers();
2528 static CPLErr LoadPlugin(const char *name);
2529
2530 static void AutoLoadPythonDrivers();
2531
2532 void DeclareDeferredPluginDriver(GDALPluginDriverProxy *poProxyDriver);
2533
2535 int GetDriverCount(bool bIncludeHidden) const;
2536 GDALDriver *GetDriver(int iDriver, bool bIncludeHidden);
2537 bool IsKnownDriver(const char *pszDriverName) const;
2539};
2540
2541 CPL_C_START
2542 GDALDriverManager CPL_DLL *GetGDALDriverManager(void);
2543 CPL_C_END
2544
2545/* ******************************************************************** */
2546/* GDALAsyncReader */
2547/* ******************************************************************** */
2548
2554 class CPL_DLL GDALAsyncReader
2555{
2556
2557 CPL_DISALLOW_COPY_ASSIGN(GDALAsyncReader)
2558
2559 protected:
2561 GDALDataset *poDS;
2562 int nXOff;
2563 int nYOff;
2564 int nXSize;
2565 int nYSize;
2566 void *pBuf;
2567 int nBufXSize;
2568 int nBufYSize;
2569 GDALDataType eBufType;
2570 int nBandCount;
2571 int *panBandMap;
2572 int nPixelSpace;
2573 int nLineSpace;
2574 int nBandSpace;
2576
2577 public:
2578 GDALAsyncReader();
2579 virtual ~GDALAsyncReader();
2580
2584 GDALDataset *GetGDALDataset()
2585 {
2586 return poDS;
2587 }
2588
2592 int GetXOffset() const
2593 {
2594 return nXOff;
2595 }
2596
2600 int GetYOffset() const
2601 {
2602 return nYOff;
2603 }
2604
2608 int GetXSize() const
2609 {
2610 return nXSize;
2611 }
2612
2616 int GetYSize() const
2617 {
2618 return nYSize;
2619 }
2620
2624 void *GetBuffer()
2625 {
2626 return pBuf;
2627 }
2628
2632 int GetBufferXSize() const
2633 {
2634 return nBufXSize;
2635 }
2636
2640 int GetBufferYSize() const
2641 {
2642 return nBufYSize;
2643 }
2644
2648 GDALDataType GetBufferType() const
2649 {
2650 return eBufType;
2651 }
2652
2656 int GetBandCount() const
2657 {
2658 return nBandCount;
2659 }
2660
2664 int *GetBandMap()
2665 {
2666 return panBandMap;
2667 }
2668
2672 int GetPixelSpace() const
2673 {
2674 return nPixelSpace;
2675 }
2676
2680 int GetLineSpace() const
2681 {
2682 return nLineSpace;
2683 }
2684
2688 int GetBandSpace() const
2689 {
2690 return nBandSpace;
2691 }
2692
2693 virtual GDALAsyncStatusType
2694 GetNextUpdatedRegion(double dfTimeout, int *pnBufXOff, int *pnBufYOff,
2695 int *pnBufXSize, int *pnBufYSize) = 0;
2696 virtual int LockBuffer(double dfTimeout = -1.0);
2697 virtual void UnlockBuffer();
2698};
2699
2700/* ******************************************************************** */
2701/* Multidimensional array API */
2702/* ******************************************************************** */
2703
2704 class GDALMDArray;
2705 class GDALAttribute;
2706 class GDALDimension;
2707 class GDALEDTComponent;
2708
2709/* ******************************************************************** */
2710/* GDALExtendedDataType */
2711/* ******************************************************************** */
2712
2720 class CPL_DLL GDALExtendedDataType
2721{
2722 public:
2723 ~GDALExtendedDataType();
2724
2725 GDALExtendedDataType(const GDALExtendedDataType &);
2726
2727 GDALExtendedDataType &operator=(const GDALExtendedDataType &);
2728 GDALExtendedDataType &operator=(GDALExtendedDataType &&);
2729
2730 static GDALExtendedDataType Create(GDALDataType eType);
2731 static GDALExtendedDataType
2732 Create(const std::string &osName, size_t nTotalSize,
2733 std::vector<std::unique_ptr<GDALEDTComponent>> &&components);
2734 static GDALExtendedDataType
2735 CreateString(size_t nMaxStringLength = 0,
2736 GDALExtendedDataTypeSubType eSubType = GEDTST_NONE);
2737
2738 bool operator==(const GDALExtendedDataType &) const;
2739
2741 bool operator!=(const GDALExtendedDataType &other) const
2742 {
2743 return !(operator==(other));
2744 }
2745
2750 const std::string &GetName() const
2751 {
2752 return m_osName;
2753 }
2754
2759 GDALExtendedDataTypeClass GetClass() const
2760 {
2761 return m_eClass;
2762 }
2763
2769 GDALDataType GetNumericDataType() const
2770 {
2771 return m_eNumericDT;
2772 }
2773
2780 GDALExtendedDataTypeSubType GetSubType() const
2781 {
2782 return m_eSubType;
2783 }
2784
2790 const std::vector<std::unique_ptr<GDALEDTComponent>> &GetComponents() const
2791 {
2792 return m_aoComponents;
2793 }
2794
2801 size_t GetSize() const
2802 {
2803 return m_nSize;
2804 }
2805
2810 size_t GetMaxStringLength() const
2811 {
2812 return m_nMaxStringLength;
2813 }
2814
2815 bool CanConvertTo(const GDALExtendedDataType &other) const;
2816
2817 bool NeedsFreeDynamicMemory() const;
2818
2819 void FreeDynamicMemory(void *pBuffer) const;
2820
2821 static bool CopyValue(const void *pSrc, const GDALExtendedDataType &srcType,
2822 void *pDst, const GDALExtendedDataType &dstType);
2823
2824 static bool CopyValues(const void *pSrc,
2825 const GDALExtendedDataType &srcType,
2826 GPtrDiff_t nSrcStrideInElts, void *pDst,
2827 const GDALExtendedDataType &dstType,
2828 GPtrDiff_t nDstStrideInElts, size_t nValues);
2829
2830 private:
2831 GDALExtendedDataType(size_t nMaxStringLength,
2832 GDALExtendedDataTypeSubType eSubType);
2833 explicit GDALExtendedDataType(GDALDataType eType);
2834 GDALExtendedDataType(
2835 const std::string &osName, size_t nTotalSize,
2836 std::vector<std::unique_ptr<GDALEDTComponent>> &&components);
2837
2838 std::string m_osName{};
2839 GDALExtendedDataTypeClass m_eClass = GEDTC_NUMERIC;
2840 GDALExtendedDataTypeSubType m_eSubType = GEDTST_NONE;
2841 GDALDataType m_eNumericDT = GDT_Unknown;
2842 std::vector<std::unique_ptr<GDALEDTComponent>> m_aoComponents{};
2843 size_t m_nSize = 0;
2844 size_t m_nMaxStringLength = 0;
2845};
2846
2847/* ******************************************************************** */
2848/* GDALEDTComponent */
2849/* ******************************************************************** */
2850
2856 class CPL_DLL GDALEDTComponent
2857{
2858 public:
2859 ~GDALEDTComponent();
2860 GDALEDTComponent(const std::string &name, size_t offset,
2861 const GDALExtendedDataType &type);
2862 GDALEDTComponent(const GDALEDTComponent &);
2863
2864 bool operator==(const GDALEDTComponent &) const;
2865
2870 const std::string &GetName() const
2871 {
2872 return m_osName;
2873 }
2874
2879 size_t GetOffset() const
2880 {
2881 return m_nOffset;
2882 }
2883
2888 const GDALExtendedDataType &GetType() const
2889 {
2890 return m_oType;
2891 }
2892
2893 private:
2894 std::string m_osName;
2895 size_t m_nOffset;
2896 GDALExtendedDataType m_oType;
2897};
2898
2899/* ******************************************************************** */
2900/* GDALIHasAttribute */
2901/* ******************************************************************** */
2902
2908 class CPL_DLL GDALIHasAttribute
2909{
2910 protected:
2911 std::shared_ptr<GDALAttribute>
2912 GetAttributeFromAttributes(const std::string &osName) const;
2913
2914 public:
2915 virtual ~GDALIHasAttribute();
2916
2917 virtual std::shared_ptr<GDALAttribute>
2918 GetAttribute(const std::string &osName) const;
2919
2920 virtual std::vector<std::shared_ptr<GDALAttribute>>
2921 GetAttributes(CSLConstList papszOptions = nullptr) const;
2922
2923 virtual std::shared_ptr<GDALAttribute>
2924 CreateAttribute(const std::string &osName,
2925 const std::vector<GUInt64> &anDimensions,
2926 const GDALExtendedDataType &oDataType,
2927 CSLConstList papszOptions = nullptr);
2928
2929 virtual bool DeleteAttribute(const std::string &osName,
2930 CSLConstList papszOptions = nullptr);
2931};
2932
2933/* ******************************************************************** */
2934/* GDALGroup */
2935/* ******************************************************************** */
2936
2937/* clang-format off */
2947/* clang-format on */
2948
2949 class CPL_DLL GDALGroup : public GDALIHasAttribute
2950{
2951 protected:
2953 std::string m_osName{};
2954
2955 // This is actually a path of the form "/parent_path/{m_osName}"
2956 std::string m_osFullName{};
2957
2958 // Used for example by GDALSubsetGroup to distinguish a derived group
2959 //from its original, without altering its name
2960 const std::string m_osContext{};
2961
2962 std::weak_ptr<GDALGroup> m_pSelf{};
2963
2965 bool m_bValid = true;
2966
2967 GDALGroup(const std::string &osParentName, const std::string &osName,
2968 const std::string &osContext = std::string());
2969
2970 const GDALGroup *
2971 GetInnerMostGroup(const std::string &osPathOrArrayOrDim,
2972 std::shared_ptr<GDALGroup> &curGroupHolder,
2973 std::string &osLastPart) const;
2974
2975 void BaseRename(const std::string &osNewName);
2976
2977 bool CheckValidAndErrorOutIfNot() const;
2978
2979 void SetSelf(const std::shared_ptr<GDALGroup> &self)
2980 {
2981 m_pSelf = self;
2982 }
2983
2984 virtual void NotifyChildrenOfRenaming()
2985 {
2986 }
2987
2988 virtual void NotifyChildrenOfDeletion()
2989 {
2990 }
2991
2993
2994 public:
2995 virtual ~GDALGroup();
2996
3001 const std::string &GetName() const
3002 {
3003 return m_osName;
3004 }
3005
3010 const std::string &GetFullName() const
3011 {
3012 return m_osFullName;
3013 }
3014
3015 virtual std::vector<std::string>
3016 GetMDArrayNames(CSLConstList papszOptions = nullptr) const;
3017 virtual std::shared_ptr<GDALMDArray>
3018 OpenMDArray(const std::string &osName,
3019 CSLConstList papszOptions = nullptr) const;
3020
3021 virtual std::vector<std::string>
3022 GetGroupNames(CSLConstList papszOptions = nullptr) const;
3023 virtual std::shared_ptr<GDALGroup>
3024 OpenGroup(const std::string &osName,
3025 CSLConstList papszOptions = nullptr) const;
3026
3027 virtual std::vector<std::string>
3028 GetVectorLayerNames(CSLConstList papszOptions = nullptr) const;
3029 virtual OGRLayer *
3030 OpenVectorLayer(const std::string &osName,
3031 CSLConstList papszOptions = nullptr) const;
3032
3033 virtual std::vector<std::shared_ptr<GDALDimension>>
3034 GetDimensions(CSLConstList papszOptions = nullptr) const;
3035
3036 virtual std::shared_ptr<GDALGroup>
3037 CreateGroup(const std::string &osName, CSLConstList papszOptions = nullptr);
3038
3039 virtual bool DeleteGroup(const std::string &osName,
3040 CSLConstList papszOptions = nullptr);
3041
3042 virtual std::shared_ptr<GDALDimension>
3043 CreateDimension(const std::string &osName, const std::string &osType,
3044 const std::string &osDirection, GUInt64 nSize,
3045 CSLConstList papszOptions = nullptr);
3046
3047 virtual std::shared_ptr<GDALMDArray> CreateMDArray(
3048 const std::string &osName,
3049 const std::vector<std::shared_ptr<GDALDimension>> &aoDimensions,
3050 const GDALExtendedDataType &oDataType,
3051 CSLConstList papszOptions = nullptr);
3052
3053 virtual bool DeleteMDArray(const std::string &osName,
3054 CSLConstList papszOptions = nullptr);
3055
3056 GUInt64 GetTotalCopyCost() const;
3057
3058 virtual bool CopyFrom(const std::shared_ptr<GDALGroup> &poDstRootGroup,
3059 GDALDataset *poSrcDS,
3060 const std::shared_ptr<GDALGroup> &poSrcGroup,
3061 bool bStrict, GUInt64 &nCurCost,
3062 const GUInt64 nTotalCost,
3063 GDALProgressFunc pfnProgress, void *pProgressData,
3064 CSLConstList papszOptions = nullptr);
3065
3066 virtual CSLConstList GetStructuralInfo() const;
3067
3068 std::shared_ptr<GDALMDArray>
3069 OpenMDArrayFromFullname(const std::string &osFullName,
3070 CSLConstList papszOptions = nullptr) const;
3071
3072 std::shared_ptr<GDALMDArray>
3073 ResolveMDArray(const std::string &osName, const std::string &osStartingPath,
3074 CSLConstList papszOptions = nullptr) const;
3075
3076 std::shared_ptr<GDALGroup>
3077 OpenGroupFromFullname(const std::string &osFullName,
3078 CSLConstList papszOptions = nullptr) const;
3079
3080 std::shared_ptr<GDALDimension>
3081 OpenDimensionFromFullname(const std::string &osFullName) const;
3082
3083 virtual void ClearStatistics();
3084
3085 virtual bool Rename(const std::string &osNewName);
3086
3087 std::shared_ptr<GDALGroup>
3088 SubsetDimensionFromSelection(const std::string &osSelection) const;
3089
3091 virtual void ParentRenamed(const std::string &osNewParentFullName);
3092
3093 virtual void Deleted();
3094
3095 virtual void ParentDeleted();
3096
3097 const std::string &GetContext() const
3098 {
3099 return m_osContext;
3100 }
3101
3103
3105 static constexpr GUInt64 COPY_COST = 1000;
3107};
3108
3109/* ******************************************************************** */
3110/* GDALAbstractMDArray */
3111/* ******************************************************************** */
3112
3118 class CPL_DLL GDALAbstractMDArray
3119{
3120 protected:
3122 std::string m_osName{};
3123
3124 // This is actually a path of the form "/parent_path/{m_osName}"
3125 std::string m_osFullName{};
3126 std::weak_ptr<GDALAbstractMDArray> m_pSelf{};
3127
3129 bool m_bValid = true;
3130
3131 GDALAbstractMDArray(const std::string &osParentName,
3132 const std::string &osName);
3133
3134 void SetSelf(const std::shared_ptr<GDALAbstractMDArray> &self)
3135 {
3136 m_pSelf = self;
3137 }
3138
3139 bool CheckValidAndErrorOutIfNot() const;
3140
3141 bool CheckReadWriteParams(const GUInt64 *arrayStartIdx, const size_t *count,
3142 const GInt64 *&arrayStep,
3143 const GPtrDiff_t *&bufferStride,
3144 const GDALExtendedDataType &bufferDataType,
3145 const void *buffer,
3146 const void *buffer_alloc_start,
3147 size_t buffer_alloc_size,
3148 std::vector<GInt64> &tmp_arrayStep,
3149 std::vector<GPtrDiff_t> &tmp_bufferStride) const;
3150
3151 virtual bool
3152 IRead(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3153 const size_t *count, // array of size GetDimensionCount()
3154 const GInt64 *arrayStep, // step in elements
3155 const GPtrDiff_t *bufferStride, // stride in elements
3156 const GDALExtendedDataType &bufferDataType,
3157 void *pDstBuffer) const = 0;
3158
3159 virtual bool
3160 IWrite(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3161 const size_t *count, // array of size GetDimensionCount()
3162 const GInt64 *arrayStep, // step in elements
3163 const GPtrDiff_t *bufferStride, // stride in elements
3164 const GDALExtendedDataType &bufferDataType, const void *pSrcBuffer);
3165
3166 void BaseRename(const std::string &osNewName);
3167
3168 virtual void NotifyChildrenOfRenaming()
3169 {
3170 }
3171
3172 virtual void NotifyChildrenOfDeletion()
3173 {
3174 }
3175
3177
3178 public:
3179 virtual ~GDALAbstractMDArray();
3180
3186 const std::string &GetName() const
3187 {
3188 return m_osName;
3189 }
3190
3196 const std::string &GetFullName() const
3197 {
3198 return m_osFullName;
3199 }
3200
3201 GUInt64 GetTotalElementsCount() const;
3202
3203 virtual size_t GetDimensionCount() const;
3204
3205 virtual const std::vector<std::shared_ptr<GDALDimension>> &
3206 GetDimensions() const = 0;
3207
3208 virtual const GDALExtendedDataType &GetDataType() const = 0;
3209
3210 virtual std::vector<GUInt64> GetBlockSize() const;
3211
3212 virtual std::vector<size_t>
3213 GetProcessingChunkSize(size_t nMaxChunkMemory) const;
3214
3215 /* clang-format off */
3231 typedef bool (*FuncProcessPerChunkType)(
3232 GDALAbstractMDArray *array,
3233 const GUInt64 *chunkArrayStartIdx,
3234 const size_t *chunkCount,
3235 GUInt64 iCurChunk,
3236 GUInt64 nChunkCount,
3237 void *pUserData);
3238 /* clang-format on */
3239
3240 virtual bool ProcessPerChunk(const GUInt64 *arrayStartIdx,
3241 const GUInt64 *count, const size_t *chunkSize,
3242 FuncProcessPerChunkType pfnFunc,
3243 void *pUserData);
3244
3245 virtual bool
3246 Read(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3247 const size_t *count, // array of size GetDimensionCount()
3248 const GInt64 *arrayStep, // step in elements
3249 const GPtrDiff_t *bufferStride, // stride in elements
3250 const GDALExtendedDataType &bufferDataType, void *pDstBuffer,
3251 const void *pDstBufferAllocStart = nullptr,
3252 size_t nDstBufferAllocSize = 0) const;
3253
3254 bool
3255 Write(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3256 const size_t *count, // array of size GetDimensionCount()
3257 const GInt64 *arrayStep, // step in elements
3258 const GPtrDiff_t *bufferStride, // stride in elements
3259 const GDALExtendedDataType &bufferDataType, const void *pSrcBuffer,
3260 const void *pSrcBufferAllocStart = nullptr,
3261 size_t nSrcBufferAllocSize = 0);
3262
3263 virtual bool Rename(const std::string &osNewName);
3264
3266 virtual void Deleted();
3267
3268 virtual void ParentDeleted();
3269
3270 virtual void ParentRenamed(const std::string &osNewParentFullName);
3272};
3273
3274/* ******************************************************************** */
3275/* GDALRawResult */
3276/* ******************************************************************** */
3277
3284 class CPL_DLL GDALRawResult
3285{
3286 private:
3287 GDALExtendedDataType m_dt;
3288 size_t m_nEltCount;
3289 size_t m_nSize;
3290 GByte *m_raw;
3291
3292 void FreeMe();
3293
3294 GDALRawResult(const GDALRawResult &) = delete;
3295 GDALRawResult &operator=(const GDALRawResult &) = delete;
3296
3297 protected:
3298 friend class GDALAttribute;
3300 GDALRawResult(GByte *raw, const GDALExtendedDataType &dt, size_t nEltCount);
3302
3303 public:
3304 ~GDALRawResult();
3305 GDALRawResult(GDALRawResult &&);
3306 GDALRawResult &operator=(GDALRawResult &&);
3307
3309 const GByte &operator[](size_t idx) const
3310 {
3311 return m_raw[idx];
3312 }
3313
3315 const GByte *data() const
3316 {
3317 return m_raw;
3318 }
3319
3321 size_t size() const
3322 {
3323 return m_nSize;
3324 }
3325
3327 GByte *StealData();
3329};
3330
3331/* ******************************************************************** */
3332/* GDALAttribute */
3333/* ******************************************************************** */
3334
3335/* clang-format off */
3347/* clang-format on */
3348
3349 class CPL_DLL GDALAttribute : virtual public GDALAbstractMDArray
3350{
3351 mutable std::string m_osCachedVal{};
3352
3353 protected:
3355 GDALAttribute(const std::string &osParentName, const std::string &osName);
3357
3358 public:
3359 std::vector<GUInt64> GetDimensionsSize() const;
3360
3361 GDALRawResult ReadAsRaw() const;
3362 const char *ReadAsString() const;
3363 int ReadAsInt() const;
3364 int64_t ReadAsInt64() const;
3365 double ReadAsDouble() const;
3366 CPLStringList ReadAsStringArray() const;
3367 std::vector<int> ReadAsIntArray() const;
3368 std::vector<int64_t> ReadAsInt64Array() const;
3369 std::vector<double> ReadAsDoubleArray() const;
3370
3371 using GDALAbstractMDArray::Write;
3372 bool Write(const void *pabyValue, size_t nLen);
3373 bool Write(const char *);
3374 bool WriteInt(int);
3375 bool WriteInt64(int64_t);
3376 bool Write(double);
3377 bool Write(CSLConstList);
3378 bool Write(const int *, size_t);
3379 bool Write(const int64_t *, size_t);
3380 bool Write(const double *, size_t);
3381
3383 static constexpr GUInt64 COPY_COST = 100;
3385};
3386
3387/************************************************************************/
3388/* GDALAttributeString */
3389/************************************************************************/
3390
3392 class CPL_DLL GDALAttributeString final : public GDALAttribute
3393{
3394 std::vector<std::shared_ptr<GDALDimension>> m_dims{};
3395 GDALExtendedDataType m_dt = GDALExtendedDataType::CreateString();
3396 std::string m_osValue;
3397
3398 protected:
3399 bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
3400 const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
3401 void *pDstBuffer) const override;
3402
3403 public:
3404 GDALAttributeString(const std::string &osParentName,
3405 const std::string &osName, const std::string &osValue,
3406 GDALExtendedDataTypeSubType eSubType = GEDTST_NONE);
3407
3408 const std::vector<std::shared_ptr<GDALDimension>> &
3409 GetDimensions() const override;
3410
3411 const GDALExtendedDataType &GetDataType() const override;
3412};
3413
3415
3416/************************************************************************/
3417/* GDALAttributeNumeric */
3418/************************************************************************/
3419
3421 class CPL_DLL GDALAttributeNumeric final : public GDALAttribute
3422{
3423 std::vector<std::shared_ptr<GDALDimension>> m_dims{};
3424 GDALExtendedDataType m_dt;
3425 int m_nValue = 0;
3426 double m_dfValue = 0;
3427 std::vector<GUInt32> m_anValuesUInt32{};
3428
3429 protected:
3430 bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
3431 const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
3432 void *pDstBuffer) const override;
3433
3434 public:
3435 GDALAttributeNumeric(const std::string &osParentName,
3436 const std::string &osName, double dfValue);
3437 GDALAttributeNumeric(const std::string &osParentName,
3438 const std::string &osName, int nValue);
3439 GDALAttributeNumeric(const std::string &osParentName,
3440 const std::string &osName,
3441 const std::vector<GUInt32> &anValues);
3442
3443 const std::vector<std::shared_ptr<GDALDimension>> &
3444 GetDimensions() const override;
3445
3446 const GDALExtendedDataType &GetDataType() const override;
3447};
3448
3450
3451/* ******************************************************************** */
3452/* GDALMDArray */
3453/* ******************************************************************** */
3454
3455/* clang-format off */
3465/* clang-format on */
3466
3467 class CPL_DLL GDALMDArray : virtual public GDALAbstractMDArray,
3468 public GDALIHasAttribute
3469{
3470 friend class GDALMDArrayResampled;
3471 std::shared_ptr<GDALMDArray>
3472 GetView(const std::vector<GUInt64> &indices) const;
3473
3474 inline std::shared_ptr<GDALMDArray>
3475 atInternal(const std::vector<GUInt64> &indices) const
3476 {
3477 return GetView(indices);
3478 }
3479
3480 template <typename... GUInt64VarArg>
3481 // cppcheck-suppress functionStatic
3482 inline std::shared_ptr<GDALMDArray>
3483 atInternal(std::vector<GUInt64> &indices, GUInt64 idx,
3484 GUInt64VarArg... tail) const
3485 {
3486 indices.push_back(idx);
3487 return atInternal(indices, tail...);
3488 }
3489
3490 // Used for example by GDALSubsetGroup to distinguish a derived group
3491 //from its original, without altering its name
3492 const std::string m_osContext{};
3493
3494 mutable bool m_bHasTriedCachedArray = false;
3495 mutable std::shared_ptr<GDALMDArray> m_poCachedArray{};
3496
3497 protected:
3499 GDALMDArray(const std::string &osParentName, const std::string &osName,
3500 const std::string &osContext = std::string());
3501
3502 virtual bool IAdviseRead(const GUInt64 *arrayStartIdx, const size_t *count,
3503 CSLConstList papszOptions) const;
3504
3505 virtual bool IsCacheable() const
3506 {
3507 return true;
3508 }
3509
3510 virtual bool SetStatistics(bool bApproxStats, double dfMin, double dfMax,
3511 double dfMean, double dfStdDev,
3512 GUInt64 nValidCount, CSLConstList papszOptions);
3513
3514 static std::string MassageName(const std::string &inputName);
3515
3516 std::shared_ptr<GDALGroup>
3517 GetCacheRootGroup(bool bCanCreate, std::string &osCacheFilenameOut) const;
3518
3519 // Returns if bufferStride values express a transposed view of the array
3520 bool IsTransposedRequest(const size_t *count,
3521 const GPtrDiff_t *bufferStride) const;
3522
3523 // Should only be called if IsTransposedRequest() returns true
3524 bool ReadForTransposedRequest(const GUInt64 *arrayStartIdx,
3525 const size_t *count, const GInt64 *arrayStep,
3526 const GPtrDiff_t *bufferStride,
3527 const GDALExtendedDataType &bufferDataType,
3528 void *pDstBuffer) const;
3529
3530 bool IsStepOneContiguousRowMajorOrderedSameDataType(
3531 const size_t *count, const GInt64 *arrayStep,
3532 const GPtrDiff_t *bufferStride,
3533 const GDALExtendedDataType &bufferDataType) const;
3534
3535 // Should only be called if IsStepOneContiguousRowMajorOrderedSameDataType()
3536 // returns false
3537 bool ReadUsingContiguousIRead(const GUInt64 *arrayStartIdx,
3538 const size_t *count, const GInt64 *arrayStep,
3539 const GPtrDiff_t *bufferStride,
3540 const GDALExtendedDataType &bufferDataType,
3541 void *pDstBuffer) const;
3542
3543 static std::shared_ptr<GDALMDArray> CreateGLTOrthorectified(
3544 const std::shared_ptr<GDALMDArray> &poParent,
3545 const std::shared_ptr<GDALGroup> &poRootGroup,
3546 const std::shared_ptr<GDALMDArray> &poGLTX,
3547 const std::shared_ptr<GDALMDArray> &poGLTY, int nGLTIndexOffset,
3548 const std::vector<double> &adfGeoTransform, CSLConstList papszOptions);
3549
3551
3552 public:
3553 GUInt64 GetTotalCopyCost() const;
3554
3555 virtual bool CopyFrom(GDALDataset *poSrcDS, const GDALMDArray *poSrcArray,
3556 bool bStrict, GUInt64 &nCurCost,
3557 const GUInt64 nTotalCost,
3558 GDALProgressFunc pfnProgress, void *pProgressData);
3559
3561 virtual bool IsWritable() const = 0;
3562
3571 virtual const std::string &GetFilename() const = 0;
3572
3573 virtual CSLConstList GetStructuralInfo() const;
3574
3575 virtual const std::string &GetUnit() const;
3576
3577 virtual bool SetUnit(const std::string &osUnit);
3578
3579 virtual bool SetSpatialRef(const OGRSpatialReference *poSRS);
3580
3581 virtual std::shared_ptr<OGRSpatialReference> GetSpatialRef() const;
3582
3583 virtual const void *GetRawNoDataValue() const;
3584
3585 double GetNoDataValueAsDouble(bool *pbHasNoData = nullptr) const;
3586
3587 int64_t GetNoDataValueAsInt64(bool *pbHasNoData = nullptr) const;
3588
3589 uint64_t GetNoDataValueAsUInt64(bool *pbHasNoData = nullptr) const;
3590
3591 virtual bool SetRawNoDataValue(const void *pRawNoData);
3592
3594 bool SetNoDataValue(int nNoData)
3595 {
3596 return SetNoDataValue(static_cast<int64_t>(nNoData));
3597 }
3598
3600
3601 bool SetNoDataValue(double dfNoData);
3602
3603 bool SetNoDataValue(int64_t nNoData);
3604
3605 bool SetNoDataValue(uint64_t nNoData);
3606
3607 virtual bool Resize(const std::vector<GUInt64> &anNewDimSizes,
3608 CSLConstList papszOptions);
3609
3610 virtual double GetOffset(bool *pbHasOffset = nullptr,
3611 GDALDataType *peStorageType = nullptr) const;
3612
3613 virtual double GetScale(bool *pbHasScale = nullptr,
3614 GDALDataType *peStorageType = nullptr) const;
3615
3616 virtual bool SetOffset(double dfOffset,
3617 GDALDataType eStorageType = GDT_Unknown);
3618
3619 virtual bool SetScale(double dfScale,
3620 GDALDataType eStorageType = GDT_Unknown);
3621
3622 std::shared_ptr<GDALMDArray> GetView(const std::string &viewExpr) const;
3623
3624 std::shared_ptr<GDALMDArray> operator[](const std::string &fieldName) const;
3625
3635 // sphinx 4.1.0 / breathe 4.30.0 don't like typename...
3637 template <typename... GUInt64VarArg>
3639 // cppcheck-suppress functionStatic
3640 std::shared_ptr<GDALMDArray> at(GUInt64 idx, GUInt64VarArg... tail) const
3641 {
3642 std::vector<GUInt64> indices;
3643 indices.push_back(idx);
3644 return atInternal(indices, tail...);
3645 }
3646
3647 virtual std::shared_ptr<GDALMDArray>
3648 Transpose(const std::vector<int> &anMapNewAxisToOldAxis) const;
3649
3650 std::shared_ptr<GDALMDArray> GetUnscaled(
3651 double dfOverriddenScale = std::numeric_limits<double>::quiet_NaN(),
3652 double dfOverriddenOffset = std::numeric_limits<double>::quiet_NaN(),
3653 double dfOverriddenDstNodata =
3654 std::numeric_limits<double>::quiet_NaN()) const;
3655
3656 virtual std::shared_ptr<GDALMDArray>
3657 GetMask(CSLConstList papszOptions) const;
3658
3659 virtual std::shared_ptr<GDALMDArray>
3660 GetResampled(const std::vector<std::shared_ptr<GDALDimension>> &apoNewDims,
3661 GDALRIOResampleAlg resampleAlg,
3662 const OGRSpatialReference *poTargetSRS,
3663 CSLConstList papszOptions) const;
3664
3665 std::shared_ptr<GDALMDArray>
3666 GetGridded(const std::string &osGridOptions,
3667 const std::shared_ptr<GDALMDArray> &poXArray = nullptr,
3668 const std::shared_ptr<GDALMDArray> &poYArray = nullptr,
3669 CSLConstList papszOptions = nullptr) const;
3670
3671 static std::vector<std::shared_ptr<GDALMDArray>>
3672 GetMeshGrid(const std::vector<std::shared_ptr<GDALMDArray>> &apoArrays,
3673 CSLConstList papszOptions = nullptr);
3674
3675 virtual GDALDataset *
3676 AsClassicDataset(size_t iXDim, size_t iYDim,
3677 const std::shared_ptr<GDALGroup> &poRootGroup = nullptr,
3678 CSLConstList papszOptions = nullptr) const;
3679
3680 virtual CPLErr GetStatistics(bool bApproxOK, bool bForce, double *pdfMin,
3681 double *pdfMax, double *pdfMean,
3682 double *padfStdDev, GUInt64 *pnValidCount,
3683 GDALProgressFunc pfnProgress,
3684 void *pProgressData);
3685
3686 virtual bool ComputeStatistics(bool bApproxOK, double *pdfMin,
3687 double *pdfMax, double *pdfMean,
3688 double *pdfStdDev, GUInt64 *pnValidCount,
3689 GDALProgressFunc, void *pProgressData,
3690 CSLConstList papszOptions);
3691
3692 virtual void ClearStatistics();
3693
3694 virtual std::vector<std::shared_ptr<GDALMDArray>>
3695 GetCoordinateVariables() const;
3696
3697 bool AdviseRead(const GUInt64 *arrayStartIdx, const size_t *count,
3698 CSLConstList papszOptions = nullptr) const;
3699
3700 bool IsRegularlySpaced(double &dfStart, double &dfIncrement) const;
3701
3702 bool GuessGeoTransform(size_t nDimX, size_t nDimY, bool bPixelIsPoint,
3703 double adfGeoTransform[6]) const;
3704
3705 bool Cache(CSLConstList papszOptions = nullptr) const;
3706
3707 bool
3708 Read(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3709 const size_t *count, // array of size GetDimensionCount()
3710 const GInt64 *arrayStep, // step in elements
3711 const GPtrDiff_t *bufferStride, // stride in elements
3712 const GDALExtendedDataType &bufferDataType, void *pDstBuffer,
3713 const void *pDstBufferAllocStart = nullptr,
3714 size_t nDstBufferAllocSize = 0) const override final;
3715
3716 virtual std::shared_ptr<GDALGroup> GetRootGroup() const;
3717
3719 static constexpr GUInt64 COPY_COST = 1000;
3720
3721 bool CopyFromAllExceptValues(const GDALMDArray *poSrcArray, bool bStrict,
3722 GUInt64 &nCurCost, const GUInt64 nTotalCost,
3723 GDALProgressFunc pfnProgress,
3724 void *pProgressData);
3725
3726 struct Range
3727 {
3728 GUInt64 m_nStartIdx;
3729 GInt64 m_nIncr;
3730
3731 explicit Range(GUInt64 nStartIdx = 0, GInt64 nIncr = 0)
3732 : m_nStartIdx(nStartIdx), m_nIncr(nIncr)
3733 {
3734 }
3735 };
3736
3737 struct ViewSpec
3738 {
3739 std::string m_osFieldName{};
3740
3741 // or
3742
3743 std::vector<size_t>
3744 m_mapDimIdxToParentDimIdx{}; // of size m_dims.size()
3745 std::vector<Range>
3746 m_parentRanges{}; // of size m_poParent->GetDimensionCount()
3747 };
3748
3749 virtual std::shared_ptr<GDALMDArray>
3750 GetView(const std::string &viewExpr, bool bRenameDimensions,
3751 std::vector<ViewSpec> &viewSpecs) const;
3752
3753 const std::string &GetContext() const
3754 {
3755 return m_osContext;
3756 }
3757
3759};
3760
3762 bool GDALMDRasterIOFromBand(GDALRasterBand *poBand, GDALRWFlag eRWFlag,
3763 size_t iDimX, size_t iDimY,
3764 const GUInt64 *arrayStartIdx, const size_t *count,
3765 const GInt64 *arrayStep,
3766 const GPtrDiff_t *bufferStride,
3767 const GDALExtendedDataType &bufferDataType,
3768 void *pBuffer);
3769
3771
3772/************************************************************************/
3773/* GDALMDArrayRegularlySpaced */
3774/************************************************************************/
3775
3777 class CPL_DLL GDALMDArrayRegularlySpaced : public GDALMDArray
3778{
3779 double m_dfStart;
3780 double m_dfIncrement;
3781 double m_dfOffsetInIncrement;
3782 GDALExtendedDataType m_dt = GDALExtendedDataType::Create(GDT_Float64);
3783 std::vector<std::shared_ptr<GDALDimension>> m_dims;
3784 std::vector<std::shared_ptr<GDALAttribute>> m_attributes{};
3785 std::string m_osEmptyFilename{};
3786
3787 protected:
3788 bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
3789 const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
3790 void *pDstBuffer) const override;
3791
3792 public:
3793 GDALMDArrayRegularlySpaced(const std::string &osParentName,
3794 const std::string &osName,
3795 const std::shared_ptr<GDALDimension> &poDim,
3796 double dfStart, double dfIncrement,
3797 double dfOffsetInIncrement);
3798
3799 static std::shared_ptr<GDALMDArrayRegularlySpaced>
3800 Create(const std::string &osParentName, const std::string &osName,
3801 const std::shared_ptr<GDALDimension> &poDim, double dfStart,
3802 double dfIncrement, double dfOffsetInIncrement);
3803
3804 bool IsWritable() const override
3805 {
3806 return false;
3807 }
3808
3809 const std::string &GetFilename() const override
3810 {
3811 return m_osEmptyFilename;
3812 }
3813
3814 const std::vector<std::shared_ptr<GDALDimension>> &
3815 GetDimensions() const override;
3816
3817 const GDALExtendedDataType &GetDataType() const override;
3818
3819 std::vector<std::shared_ptr<GDALAttribute>>
3820 GetAttributes(CSLConstList) const override;
3821
3822 void AddAttribute(const std::shared_ptr<GDALAttribute> &poAttr);
3823};
3824
3826
3827/* ******************************************************************** */
3828/* GDALDimension */
3829/* ******************************************************************** */
3830
3842 class CPL_DLL GDALDimension
3843{
3844 public:
3846 GDALDimension(const std::string &osParentName, const std::string &osName,
3847 const std::string &osType, const std::string &osDirection,
3848 GUInt64 nSize);
3850
3851 virtual ~GDALDimension();
3852
3857 const std::string &GetName() const
3858 {
3859 return m_osName;
3860 }
3861
3866 const std::string &GetFullName() const
3867 {
3868 return m_osFullName;
3869 }
3870
3879 const std::string &GetType() const
3880 {
3881 return m_osType;
3882 }
3883
3892 const std::string &GetDirection() const
3893 {
3894 return m_osDirection;
3895 }
3896
3901 GUInt64 GetSize() const
3902 {
3903 return m_nSize;
3904 }
3905
3906 virtual std::shared_ptr<GDALMDArray> GetIndexingVariable() const;
3907
3908 virtual bool
3909 SetIndexingVariable(std::shared_ptr<GDALMDArray> poIndexingVariable);
3910
3911 virtual bool Rename(const std::string &osNewName);
3912
3914 virtual void ParentRenamed(const std::string &osNewParentFullName);
3915
3916 virtual void ParentDeleted();
3918
3919 protected:
3921 std::string m_osName;
3922 std::string m_osFullName;
3923 std::string m_osType;
3924 std::string m_osDirection;
3925 GUInt64 m_nSize;
3926
3927 void BaseRename(const std::string &osNewName);
3928
3930};
3931
3932/************************************************************************/
3933/* GDALDimensionWeakIndexingVar() */
3934/************************************************************************/
3935
3937 class CPL_DLL GDALDimensionWeakIndexingVar : public GDALDimension
3938{
3939 std::weak_ptr<GDALMDArray> m_poIndexingVariable{};
3940
3941 public:
3942 GDALDimensionWeakIndexingVar(const std::string &osParentName,
3943 const std::string &osName,
3944 const std::string &osType,
3945 const std::string &osDirection, GUInt64 nSize);
3946
3947 std::shared_ptr<GDALMDArray> GetIndexingVariable() const override;
3948
3949 bool SetIndexingVariable(
3950 std::shared_ptr<GDALMDArray> poIndexingVariable) override;
3951
3952 void SetSize(GUInt64 nNewSize);
3953};
3955
3956/************************************************************************/
3957/* GDALAntiRecursionGuard */
3958/************************************************************************/
3959
3961 struct GDALAntiRecursionStruct;
3962
3963 class GDALAntiRecursionGuard
3964{
3965 GDALAntiRecursionStruct *m_psAntiRecursionStruct;
3966 std::string m_osIdentifier;
3967 int m_nDepth;
3968
3969 GDALAntiRecursionGuard(const GDALAntiRecursionGuard &) = delete;
3970 GDALAntiRecursionGuard &operator=(const GDALAntiRecursionGuard &) = delete;
3971
3972 public:
3973 explicit GDALAntiRecursionGuard(const std::string &osIdentifier);
3974 GDALAntiRecursionGuard(const GDALAntiRecursionGuard &other,
3975 const std::string &osIdentifier);
3976 ~GDALAntiRecursionGuard();
3977
3978 int GetCallDepth() const
3979 {
3980 return m_nDepth;
3981 }
3982};
3983
3985
3986/************************************************************************/
3987/* Relationships */
3988/************************************************************************/
3989
4001 class CPL_DLL GDALRelationship
4002{
4003 protected:
4005 std::string m_osName{};
4006 std::string m_osLeftTableName{};
4007 std::string m_osRightTableName{};
4008 GDALRelationshipCardinality m_eCardinality =
4009 GDALRelationshipCardinality::GRC_ONE_TO_MANY;
4010 std::string m_osMappingTableName{};
4011 std::vector<std::string> m_osListLeftTableFields{};
4012 std::vector<std::string> m_osListRightTableFields{};
4013 std::vector<std::string> m_osListLeftMappingTableFields{};
4014 std::vector<std::string> m_osListRightMappingTableFields{};
4015 GDALRelationshipType m_eType = GDALRelationshipType::GRT_ASSOCIATION;
4016 std::string m_osForwardPathLabel{};
4017 std::string m_osBackwardPathLabel{};
4018 std::string m_osRelatedTableType{};
4019
4022 public:
4030 GDALRelationship(const std::string &osName,
4031 const std::string &osLeftTableName,
4032 const std::string &osRightTableName,
4033 GDALRelationshipCardinality eCardinality =
4034 GDALRelationshipCardinality::GRC_ONE_TO_MANY)
4035 : m_osName(osName), m_osLeftTableName(osLeftTableName),
4036 m_osRightTableName(osRightTableName), m_eCardinality(eCardinality)
4037 {
4038 }
4039
4041 const std::string &GetName() const
4042 {
4043 return m_osName;
4044 }
4045
4047 GDALRelationshipCardinality GetCardinality() const
4048 {
4049 return m_eCardinality;
4050 }
4051
4056 const std::string &GetLeftTableName() const
4057 {
4058 return m_osLeftTableName;
4059 }
4060
4063 const std::string &GetRightTableName() const
4064 {
4065 return m_osRightTableName;
4066 }
4067
4072 const std::string &GetMappingTableName() const
4073 {
4074 return m_osMappingTableName;
4075 }
4076
4081 void SetMappingTableName(const std::string &osName)
4082 {
4083 m_osMappingTableName = osName;
4084 }
4085
4092 const std::vector<std::string> &GetLeftTableFields() const
4093 {
4094 return m_osListLeftTableFields;
4095 }
4096
4103 const std::vector<std::string> &GetRightTableFields() const
4104 {
4105 return m_osListRightTableFields;
4106 }
4107
4114 void SetLeftTableFields(const std::vector<std::string> &osListFields)
4115 {
4116 m_osListLeftTableFields = osListFields;
4117 }
4118
4125 void SetRightTableFields(const std::vector<std::string> &osListFields)
4126 {
4127 m_osListRightTableFields = osListFields;
4128 }
4129
4136 const std::vector<std::string> &GetLeftMappingTableFields() const
4137 {
4138 return m_osListLeftMappingTableFields;
4139 }
4140
4147 const std::vector<std::string> &GetRightMappingTableFields() const
4148 {
4149 return m_osListRightMappingTableFields;
4150 }
4151
4158 void SetLeftMappingTableFields(const std::vector<std::string> &osListFields)
4159 {
4160 m_osListLeftMappingTableFields = osListFields;
4161 }
4162
4169 void
4170 SetRightMappingTableFields(const std::vector<std::string> &osListFields)
4171 {
4172 m_osListRightMappingTableFields = osListFields;
4173 }
4174
4179 GDALRelationshipType GetType() const
4180 {
4181 return m_eType;
4182 }
4183
4188 void SetType(GDALRelationshipType eType)
4189 {
4190 m_eType = eType;
4191 }
4192
4208 const std::string &GetForwardPathLabel() const
4209 {
4210 return m_osForwardPathLabel;
4211 }
4212
4228 void SetForwardPathLabel(const std::string &osLabel)
4229 {
4230 m_osForwardPathLabel = osLabel;
4231 }
4232
4248 const std::string &GetBackwardPathLabel() const
4249 {
4250 return m_osBackwardPathLabel;
4251 }
4252
4268 void SetBackwardPathLabel(const std::string &osLabel)
4269 {
4270 m_osBackwardPathLabel = osLabel;
4271 }
4272
4283 const std::string &GetRelatedTableType() const
4284 {
4285 return m_osRelatedTableType;
4286 }
4287
4298 void SetRelatedTableType(const std::string &osType)
4299 {
4300 m_osRelatedTableType = osType;
4301 }
4302
4305 static inline GDALRelationshipH ToHandle(GDALRelationship *poRelationship)
4306 {
4307 return static_cast<GDALRelationshipH>(poRelationship);
4308 }
4309
4312 static inline GDALRelationship *FromHandle(GDALRelationshipH hRelationship)
4313 {
4314 return static_cast<GDALRelationship *>(hRelationship);
4315 }
4316};
4317
4318/* ==================================================================== */
4319/* An assortment of overview related stuff. */
4320/* ==================================================================== */
4321
4323/* Only exported for drivers as plugin. Signature may change */
4324 CPLErr CPL_DLL GDALRegenerateOverviewsMultiBand(
4325 int nBands, GDALRasterBand *const *papoSrcBands, int nOverviews,
4326 GDALRasterBand *const *const *papapoOverviewBands,
4327 const char *pszResampling, GDALProgressFunc pfnProgress,
4328 void *pProgressData, CSLConstList papszOptions);
4329
4330 CPLErr CPL_DLL GDALRegenerateOverviewsMultiBand(
4331 const std::vector<GDALRasterBand *> &apoSrcBands,
4332 // First level of array is indexed by band (thus aapoOverviewBands.size() must be equal to apoSrcBands.size())
4333 // Second level is indexed by overview
4334 const std::vector<std::vector<GDALRasterBand *>> &aapoOverviewBands,
4335 const char *pszResampling, GDALProgressFunc pfnProgress,
4336 void *pProgressData, CSLConstList papszOptions);
4337
4338/************************************************************************/
4339/* GDALOverviewResampleArgs */
4340/************************************************************************/
4341
4343// Should not contain any dataset/rasterband object, as this might be
4344// read in a worker thread.
4345 struct GDALOverviewResampleArgs
4346{
4348 GDALDataType eSrcDataType = GDT_Unknown;
4350 GDALDataType eOvrDataType = GDT_Unknown;
4352 int nOvrXSize = 0;
4354 int nOvrYSize = 0;
4356 int nOvrNBITS = 0;
4358 // (source width divided by destination width)
4359 double dfXRatioDstToSrc = 0;
4361 // (source height divided by destination height)
4362 double dfYRatioDstToSrc = 0;
4364 double dfSrcXDelta = 0;
4366 double dfSrcYDelta = 0;
4368 GDALDataType eWrkDataType = GDT_Unknown;
4370 const GByte *pabyChunkNodataMask = nullptr;
4372 int nChunkXOff = 0;
4374 int nChunkXSize = 0;
4376 int nChunkYOff = 0;
4378 int nChunkYSize = 0;
4380 int nDstXOff = 0;
4382 int nDstXOff2 = 0;
4384 int nDstYOff = 0;
4386 int nDstYOff2 = 0;
4388 const char *pszResampling = nullptr;
4390 bool bHasNoData = false;
4392 double dfNoDataValue = 0;
4394 const GDALColorTable *poColorTable = nullptr;
4396 // in the target pixel to be at nodata too (only taken into account by
4397 // average resampling)
4398 bool bPropagateNoData = false;
4399};
4400
4401 typedef CPLErr (*GDALResampleFunction)(const GDALOverviewResampleArgs &args,
4402 const void *pChunk, void **ppDstBuffer,
4403 GDALDataType *peDstBufferDataType);
4404
4405GDALResampleFunction GDALGetResampleFunction(const char *pszResampling,
4406 int *pnRadius);
4407
4408std::string CPL_DLL GDALGetNormalizedOvrResampling(const char *pszResampling);
4409
4410 GDALDataType GDALGetOvrWorkDataType(const char *pszResampling,
4411 GDALDataType eSrcDataType);
4412
4413 CPL_C_START
4414
4415 CPLErr CPL_DLL
4416HFAAuxBuildOverviews(const char *pszOvrFilename, GDALDataset *poParentDS,
4417 GDALDataset **ppoDS, int nBands, const int *panBandList,
4418 int nNewOverviews, const int *panNewOverviewList,
4419 const char *pszResampling, GDALProgressFunc pfnProgress,
4420 void *pProgressData, CSLConstList papszOptions);
4421
4422 CPLErr CPL_DLL GTIFFBuildOverviews(const char *pszFilename, int nBands,
4423 GDALRasterBand *const *papoBandList,
4424 int nOverviews, const int *panOverviewList,
4425 const char *pszResampling,
4426 GDALProgressFunc pfnProgress,
4427 void *pProgressData,
4428 CSLConstList papszOptions);
4429
4430 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand *poBand, int &nXOff,
4431 int &nYOff, int &nXSize, int &nYSize,
4432 int nBufXSize, int nBufYSize)
4433 CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead");
4434 int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand *poBand, int &nXOff,
4435 int &nYOff, int &nXSize, int &nYSize,
4436 int nBufXSize, int nBufYSize,
4437 GDALRasterIOExtraArg *psExtraArg);
4438
4439 int CPL_DLL GDALOvLevelAdjust(int nOvLevel, int nXSize)
4440 CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead");
4441 int CPL_DLL GDALOvLevelAdjust2(int nOvLevel, int nXSize, int nYSize);
4442 int CPL_DLL GDALComputeOvFactor(int nOvrXSize, int nRasterXSize, int nOvrYSize,
4443 int nRasterYSize);
4444
4445 GDALDataset CPL_DLL *GDALFindAssociatedAuxFile(const char *pszBasefile,
4446 GDALAccess eAccess,
4447 GDALDataset *poDependentDS);
4448
4449/* ==================================================================== */
4450/* Infrastructure to check that dataset characteristics are valid */
4451/* ==================================================================== */
4452
4453 int CPL_DLL GDALCheckDatasetDimensions(int nXSize, int nYSize);
4454 int CPL_DLL GDALCheckBandCount(int nBands, int bIsZeroAllowed);
4455
4456/* Internal use only */
4457
4458/* CPL_DLL exported, but only for in-tree drivers that can be built as plugins
4459 */
4460 int CPL_DLL GDALReadWorldFile2(const char *pszBaseFilename,
4461 const char *pszExtension,
4462 double *padfGeoTransform,
4463 CSLConstList papszSiblingFiles,
4464 char **ppszWorldFileNameOut);
4465 int CPL_DLL GDALReadTabFile2(const char *pszBaseFilename,
4466 double *padfGeoTransform, char **ppszWKT,
4467 int *pnGCPCount, GDAL_GCP **ppasGCPs,
4468 CSLConstList papszSiblingFiles,
4469 char **ppszTabFileNameOut);
4470
4471 void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg *psDestArg,
4472 GDALRasterIOExtraArg *psSrcArg);
4473
4474 CPL_C_END
4475
4476std::unique_ptr<GDALDataset> CPL_DLL
4477 GDALGetThreadSafeDataset(std::unique_ptr<GDALDataset> poDS, int nScopeFlags);
4478
4479 GDALDataset CPL_DLL *GDALGetThreadSafeDataset(GDALDataset *poDS,
4480 int nScopeFlags);
4481
4482 void GDALNullifyOpenDatasetsList();
4483CPLMutex **GDALGetphDMMutex();
4484CPLMutex **GDALGetphDLMutex();
4485 void GDALNullifyProxyPoolSingleton();
4486 void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
4487 GIntBig GDALGetResponsiblePIDForCurrentThread();
4488
4489 CPLString GDALFindAssociatedFile(const char *pszBasename, const char *pszExt,
4490 CSLConstList papszSiblingFiles, int nFlags);
4491
4492 CPLErr CPL_DLL EXIFExtractMetadata(char **&papszMetadata, void *fpL,
4493 int nOffset, int bSwabflag, int nTIFFHEADER,
4494 int &nExifOffset, int &nInterOffset,
4495 int &nGPSOffset);
4496
4497 int GDALValidateOpenOptions(GDALDriverH hDriver,
4498 const char *const *papszOptionOptions);
4499 int GDALValidateOptions(const char *pszOptionList,
4500 const char *const *papszOptionsToValidate,
4501 const char *pszErrorMessageOptionType,
4502 const char *pszErrorMessageContainerName);
4503
4504 GDALRIOResampleAlg CPL_DLL
4505GDALRasterIOGetResampleAlg(const char *pszResampling);
4506 const char *GDALRasterIOGetResampleAlg(GDALRIOResampleAlg eResampleAlg);
4507
4508 void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg *psExtraArg,
4509 int nXSize, int nYSize, int nBufXSize,
4510 int nBufYSize);
4511
4512 GDALDataset *GDALCreateOverviewDataset(GDALDataset *poDS, int nOvrLevel,
4513 bool bThisLevelOnly);
4514
4515// Should cover particular cases of #3573, #4183, #4506, #6578
4516// Behavior is undefined if fVal1 or fVal2 are NaN (should be tested before
4517// calling this function)
4518 template <class T> inline bool ARE_REAL_EQUAL(T fVal1, T fVal2, int ulp = 2)
4519{
4520 return fVal1 == fVal2 || /* Should cover infinity */
4521 std::abs(fVal1 - fVal2) < std::numeric_limits<float>::epsilon() *
4522 std::abs(fVal1 + fVal2) * ulp;
4523}
4524
4525 double GDALAdjustNoDataCloseToFloatMax(double dfVal);
4526
4527#define DIV_ROUND_UP(a, b) (((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1))
4528
4529// Number of data samples that will be used to compute approximate statistics
4530// (minimum value, maximum value, etc.)
4531#define GDALSTAT_APPROX_NUMSAMPLES 2500
4532
4533 void GDALSerializeGCPListToXML(CPLXMLNode *psParentNode,
4534 const std::vector<gdal::GCP> &asGCPs,
4535 const OGRSpatialReference *poGCP_SRS);
4536 void GDALDeserializeGCPListFromXML(const CPLXMLNode *psGCPList,
4537 std::vector<gdal::GCP> &asGCPs,
4538 OGRSpatialReference **ppoGCP_SRS);
4539
4540 void GDALSerializeOpenOptionsToXML(CPLXMLNode *psParentNode,
4541 CSLConstList papszOpenOptions);
4542 char CPL_DLL **
4543GDALDeserializeOpenOptionsFromXML(const CPLXMLNode *psParentNode);
4544
4545 int GDALCanFileAcceptSidecarFile(const char *pszFilename);
4546
4547 bool GDALCanReliablyUseSiblingFileList(const char *pszFilename);
4548
4549 typedef enum
4550{
4551 GSF_UNSIGNED_INT,
4552 GSF_SIGNED_INT,
4553 GSF_FLOATING_POINT,
4554} GDALBufferSampleFormat;
4555
4556 bool CPL_DLL GDALBufferHasOnlyNoData(const void *pBuffer, double dfNoDataValue,
4557 size_t nWidth, size_t nHeight,
4558 size_t nLineStride, size_t nComponents,
4559 int nBitsPerSample,
4560 GDALBufferSampleFormat nSampleFormat);
4561
4562 void CPL_DLL GDALCopyNoDataValue(GDALRasterBand *poDstBand,
4563 GDALRasterBand *poSrcBand);
4564
4565 double CPL_DLL GDALGetNoDataValueCastToDouble(int64_t nVal);
4566 double CPL_DLL GDALGetNoDataValueCastToDouble(uint64_t nVal);
4567
4568// Remove me in GDAL 4.0. See GetMetadataItem() implementation
4569// Internal use in GDAL only !
4570// Declaration copied in swig/include/gdal.i
4571 void CPL_DLL GDALEnablePixelTypeSignedByteWarning(GDALRasterBandH hBand,
4572 bool b);
4573
4574std::string CPL_DLL GDALGetCompressionFormatForJPEG(VSILFILE *fp);
4575std::string CPL_DLL GDALGetCompressionFormatForJPEG(const void *pBuffer,
4576 size_t nBufferSize);
4577
4578 GDALRasterAttributeTable CPL_DLL *GDALCreateRasterAttributeTableFromMDArrays(
4579 GDALRATTableType eTableType,
4580 const std::vector<std::shared_ptr<GDALMDArray>> &apoArrays,
4581 const std::vector<GDALRATFieldUsage> &aeUsages);
4582
4583 GDALColorInterp CPL_DLL
4584GDALGetColorInterpFromSTACCommonName(const char *pszName);
4585 const char CPL_DLL *
4586GDALGetSTACCommonNameFromColorInterp(GDALColorInterp eInterp);
4587
4588// Macro used so that Identify and driver metadata methods in drivers built
4589// as plugin can be duplicated in libgdal core and in the driver under different
4590// names
4591#ifdef PLUGIN_FILENAME
4592#define PLUGIN_SYMBOL_NAME(x) GDAL_core_##x
4593#else
4594#define PLUGIN_SYMBOL_NAME(x) GDAL_driver_##x
4595#endif
4596
4598
4599#endif /* ndef GDAL_PRIV_H_INCLUDED */
CPLStringList
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:436
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:307
GDALAbstractMDArray
Abstract class, implemented by GDALAttribute and GDALMDArray.
Definition: gdal_priv.h:3119
GDALAbstractMDArray::GetFullName
const std::string & GetFullName() const
Return the name of an array or attribute.
Definition: gdal_priv.h:3196
GDALAbstractMDArray::GetDimensions
virtual const std::vector< std::shared_ptr< GDALDimension > > & GetDimensions() const =0
Return the dimensions of an attribute/array.
GDALAbstractMDArray::GetDataType
virtual const GDALExtendedDataType & GetDataType() const =0
Return the data type of an attribute/array.
GDALAbstractMDArray::GetName
const std::string & GetName() const
Return the name of an array or attribute.
Definition: gdal_priv.h:3186
GDALAbstractMDArray::Write
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:2227
GDALAsyncReader
Class used as a session object for asynchronous requests.
Definition: gdal_priv.h:2555
GDALAsyncReader::GetXOffset
int GetXOffset() const
Return x offset.
Definition: gdal_priv.h:2592
GDALAsyncReader::GetYOffset
int GetYOffset() const
Return y offset.
Definition: gdal_priv.h:2600
GDALAsyncReader::GetYSize
int GetYSize() const
Return height.
Definition: gdal_priv.h:2616
GDALAsyncReader::GetBandCount
int GetBandCount() const
Return band count.
Definition: gdal_priv.h:2656
GDALAsyncReader::GetBufferType
GDALDataType GetBufferType() const
Return buffer data type.
Definition: gdal_priv.h:2648
GDALAsyncReader::GetBandSpace
int GetBandSpace() const
Return band spacing.
Definition: gdal_priv.h:2688
GDALAsyncReader::GetBufferYSize
int GetBufferYSize() const
Return buffer height.
Definition: gdal_priv.h:2640
GDALAsyncReader::GetXSize
int GetXSize() const
Return width.
Definition: gdal_priv.h:2608
GDALAsyncReader::GetNextUpdatedRegion
virtual GDALAsyncStatusType GetNextUpdatedRegion(double dfTimeout, int *pnBufXOff, int *pnBufYOff, int *pnBufXSize, int *pnBufYSize)=0
= 0;
GDALAsyncReader::GetBuffer
void * GetBuffer()
Return buffer.
Definition: gdal_priv.h:2624
GDALAsyncReader::GetPixelSpace
int GetPixelSpace() const
Return pixel spacing.
Definition: gdal_priv.h:2672
GDALAsyncReader::GetBandMap
int * GetBandMap()
Return band map.
Definition: gdal_priv.h:2664
GDALAsyncReader::GetGDALDataset
GDALDataset * GetGDALDataset()
Return dataset.
Definition: gdal_priv.h:2584
GDALAsyncReader::GetLineSpace
int GetLineSpace() const
Return line spacing.
Definition: gdal_priv.h:2680
GDALAsyncReader::GetBufferXSize
int GetBufferXSize() const
Return buffer width.
Definition: gdal_priv.h:2632
GDALAttribute
Class modeling an attribute that has a name, a value and a type, and is typically used to describe a ...
Definition: gdal_priv.h:3350
GDALColorTable
A color table / palette.
Definition: gdal_priv.h:1362
GDALColorTable::ToHandle
static GDALColorTableH ToHandle(GDALColorTable *poCT)
Convert a GDALColorTable* to a GDALRasterBandH.
Definition: gdal_priv.h:1387
GDALColorTable::~GDALColorTable
~GDALColorTable()
Destructor.
GDALColorTable::FromHandle
static GDALColorTable * FromHandle(GDALColorTableH hCT)
Convert a GDALColorTableH to a GDALColorTable*.
Definition: gdal_priv.h:1395
GDALDataset::Bands
Class returned by GetBands() that act as a container for raster bands.
Definition: gdal_priv.h:665
GDALDataset::Features
Class returned by GetFeatures() that act as a container for vector features.
Definition: gdal_priv.h:1022
GDALDataset::Layers::Iterator
Layer iterator.
Definition: gdal_priv.h:968
GDALDataset::Layers::Iterator::~Iterator
~Iterator()
Destructor.
GDALDataset::Layers::Iterator::pointer
void pointer
pointer
Definition: gdal_priv.h:976
GDALDataset::Layers::Iterator::difference_type
void difference_type
difference_type
Definition: gdal_priv.h:975
GDALDataset::Layers::Iterator::iterator_category
std::input_iterator_tag iterator_category
iterator_category
Definition: gdal_priv.h:978
GDALDataset::Layers
Class returned by GetLayers() that acts as a range of layers.
Definition: gdal_priv.h:954
GDALDataset
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:495
GDALDataset::CloseDependentDatasets
virtual int CloseDependentDatasets()
Drop references to any other datasets referenced by this dataset.
Definition: gdaldataset.cpp:4584
GDALDataset::SetQueryLoggerFunc
virtual bool SetQueryLoggerFunc(GDALQueryLoggerFunc pfnQueryLoggerFuncIn, void *poQueryLoggerArgIn)
SetQueryLoggerFunc.
GDALDataset::BuildOverviews
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:2131
GDALDataset::CreateMaskBand
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the dataset.
Definition: gdaldataset.cpp:3349
GDALDataset::Open
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:906
GDALDataset::Release
OGRErr Release()
Drop a reference to this dataset, and if the reference count drops to one close (destroy) the dataset...
Definition: gdaldataset.cpp:5592
GDALDataset::SetMetadata
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
GDALDataset::SetMetadataItem
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
GDALDataset::GetOpenOptions
char ** GetOpenOptions()
Return open options.
Definition: gdal_priv.h:832
GDALDataset::IsMarkedSuppressOnClose
bool IsMarkedSuppressOnClose() const
Return MarkSuppressOnClose flag.
Definition: gdal_priv.h:824
GDALDataset::FromHandle
static GDALDataset * FromHandle(GDALDatasetH hDS)
Convert a GDALDatasetH to a GDALDataset*.
Definition: gdal_priv.h:898
GDALDataset::ToHandle
static GDALDatasetH ToHandle(GDALDataset *poDS)
Convert a GDALDataset* to a GDALDatasetH.
Definition: gdal_priv.h:890
GDALDataset::GetAccess
GDALAccess GetAccess() const
Return access mode.
Definition: gdal_priv.h:810
GDALDimension
Class modeling a a dimension / axis used to index multidimensional arrays.
Definition: gdal_priv.h:3843
GDALDimension::GetName
const std::string & GetName() const
Return the name.
Definition: gdal_priv.h:3857
GDALDimension::GetDirection
const std::string & GetDirection() const
Return the axis direction.
Definition: gdal_priv.h:3892
GDALDimension::GetFullName
const std::string & GetFullName() const
Return the full name.
Definition: gdal_priv.h:3866
GDALDimension::GetSize
GUInt64 GetSize() const
Return the size, that is the number of values along the dimension.
Definition: gdal_priv.h:3901
GDALDimension::GetType
const std::string & GetType() const
Return the axis type.
Definition: gdal_priv.h:3879
GDALDriverManager
Class for managing the registration of file format drivers.
Definition: gdal_priv.h:2469
GDALDriver
Format specific driver.
Definition: gdal_priv.h:2124
GDALDriver::FromHandle
static GDALDriver * FromHandle(GDALDriverH hDriver)
Convert a GDALDriverH to a GDALDriver*.
Definition: gdal_priv.h:2348
GDALDriver::ToHandle
static GDALDriverH ToHandle(GDALDriver *poDriver)
Convert a GDALDriver* to a GDALDriverH.
Definition: gdal_priv.h:2340
GDALEDTComponent
Class for a component of a compound extended data type.
Definition: gdal_priv.h:2857
GDALEDTComponent::GetType
const GDALExtendedDataType & GetType() const
Return the data type of the component.
Definition: gdal_priv.h:2888
GDALEDTComponent::GetOffset
size_t GetOffset() const
Return the offset (in bytes) of the component in the compound data type.
Definition: gdal_priv.h:2879
GDALEDTComponent::GetName
const std::string & GetName() const
Return the name.
Definition: gdal_priv.h:2870
GDALEDTComponent::GDALEDTComponent
GDALEDTComponent(const GDALEDTComponent &)
Copy constructor.
GDALExtendedDataType
Class used to represent potentially complex data types.
Definition: gdal_priv.h:2721
GDALExtendedDataType::operator!=
bool operator!=(const GDALExtendedDataType &other) const
Non-equality operator.
Definition: gdal_priv.h:2741
GDALExtendedDataType::GetSubType
GDALExtendedDataTypeSubType GetSubType() const
Return subtype.
Definition: gdal_priv.h:2780
GDALExtendedDataType::GetSize
size_t GetSize() const
Return data type size in bytes.
Definition: gdal_priv.h:2801
GDALExtendedDataType::GetMaxStringLength
size_t GetMaxStringLength() const
Return the maximum length of a string in bytes.
Definition: gdal_priv.h:2810
GDALExtendedDataType::Create
static GDALExtendedDataType Create(GDALDataType eType)
Return a new GDALExtendedDataType of class GEDTC_NUMERIC.
Definition: gdalmultidim.cpp:10048
GDALExtendedDataType::CreateString
static GDALExtendedDataType CreateString(size_t nMaxStringLength=0, GDALExtendedDataTypeSubType eSubType=GEDTST_NONE)
Return a new GDALExtendedDataType of class GEDTC_STRING.
Definition: gdalmultidim.cpp:10113
GDALExtendedDataType::GetNumericDataType
GDALDataType GetNumericDataType() const
Return numeric data type (only valid when GetClass() == GEDTC_NUMERIC)
Definition: gdal_priv.h:2769
GDALExtendedDataType::GetClass
GDALExtendedDataTypeClass GetClass() const
Return type class.
Definition: gdal_priv.h:2759
GDALExtendedDataType::GetComponents
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:2790
GDALExtendedDataType::GetName
const std::string & GetName() const
Return type name.
Definition: gdal_priv.h:2750
GDALGroup
Class modeling a named container of GDALAttribute, GDALMDArray, OGRLayer or other GDALGroup.
Definition: gdal_priv.h:2950
GDALGroup::GetName
const std::string & GetName() const
Return the name of the group.
Definition: gdal_priv.h:3001
GDALGroup::GetFullName
const std::string & GetFullName() const
Return the full name of the group.
Definition: gdal_priv.h:3010
GDALIHasAttribute
Interface used to get a single GDALAttribute or a set of GDALAttribute.
Definition: gdal_priv.h:2909
GDALMDArray
Class modeling a multi-dimensional array.
Definition: gdal_priv.h:3469
GDALMDArray::IsWritable
virtual bool IsWritable() const =0
Return whether an array is writable.
GDALMDArray::GetFilename
virtual const std::string & GetFilename() const =0
Return the filename that contains that array.
GDALMDArray::at
std::shared_ptr< GDALMDArray > at(GUInt64 idx, GUInt64VarArg... tail) const
Return a view of the array using integer indexing.
Definition: gdal_priv.h:3640
GDALMajorObject
Object with metadata.
Definition: gdal_priv.h:141
GDALMajorObject::FromHandle
static GDALMajorObject * FromHandle(GDALMajorObjectH hMajorObject)
Convert a GDALMajorObjectH to a GDALMajorObject*.
Definition: gdal_priv.h:184
GDALMajorObject::ToHandle
static GDALMajorObjectH ToHandle(GDALMajorObject *poMajorObject)
Convert a GDALMajorObject* to a GDALMajorObjectH.
Definition: gdal_priv.h:176
GDALOpenInfo
Class for dataset open functions.
Definition: gdal_priv.h:293
GDALOpenInfo::bStatOK
int bStatOK
Whether stat()'ing the file was successful.
Definition: gdal_priv.h:314
GDALOpenInfo::pabyHeader
GByte * pabyHeader
Buffer with first bytes of the file.
Definition: gdal_priv.h:324
GDALOpenInfo::bIsDirectory
int bIsDirectory
Whether the file is a directory.
Definition: gdal_priv.h:316
GDALOpenInfo::papszOpenOptions
char ** papszOpenOptions
Open options.
Definition: gdal_priv.h:306
GDALOpenInfo::eAccess
GDALAccess eAccess
Access flag.
Definition: gdal_priv.h:309
GDALOpenInfo::nOpenFlags
int nOpenFlags
Open flags.
Definition: gdal_priv.h:311
GDALOpenInfo::fpL
VSILFILE * fpL
Pointer to the file.
Definition: gdal_priv.h:319
GDALOpenInfo::pszFilename
char * pszFilename
Filename.
Definition: gdal_priv.h:304
GDALOpenInfo::nHeaderBytes
int nHeaderBytes
Number of bytes in pabyHeader.
Definition: gdal_priv.h:322
GDALOpenInfo::papszAllowedDrivers
const char *const * papszAllowedDrivers
Allowed drivers (NULL for all)
Definition: gdal_priv.h:327
GDALPluginDriverProxy
Proxy for a plugin driver.
Definition: gdal_priv.h:2402
GDALPluginDriverProxy::GetMetadataItem
const char * GetMetadataItem(const char *pszName, const char *pszDomain="") override
Fetch single metadata item.
Definition: gdaldrivermanager.cpp:1304
GDALPluginDriverProxy::GetMetadata
char ** GetMetadata(const char *pszDomain) override
Fetch metadata.
Definition: gdaldrivermanager.cpp:1261
GDALPluginDriverProxy::GDALPluginDriverProxy
GDALPluginDriverProxy(const std::string &osPluginFileName)
Constructor for a plugin driver proxy.
Definition: gdaldrivermanager.cpp:1234
GDALPluginDriverProxy::GetPluginFileName
const std::string & GetPluginFileName() const
Return the plugin file name (not a full path)
Definition: gdal_priv.h:2427
GDALPluginDriverProxy::SetMetadataItem
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain="") override
Set single metadata item.
Definition: gdaldrivermanager.cpp:1269
GDALRasterAttributeTable
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition: gdal_rat.h:32
GDALRasterBand
A single raster band (or channel).
Definition: gdal_priv.h:1519
GDALRasterBand::ToHandle
void static GDALRasterBandH ToHandle(GDALRasterBand *poBand)
Convert a GDALRasterBand* to a GDALRasterBandH.
Definition: gdal_priv.h:1882
GDALRasterBand::IsMaskBand
virtual bool IsMaskBand() const
Returns whether a band is a mask band.
Definition: gdalrasterband.cpp:8138
GDALRasterBand::SetMetadata
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
GDALRasterBand::IReadBlock
virtual CPLErr IReadBlock(int nBlockXOff, int nBlockYOff, void *pData)=0
Default internal implementation ... to be overridden by subclasses that support reading.
GDALRasterBand::IRasterIO
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:191
GDALRasterBand::GetMaskValueRange
virtual GDALMaskValueRange GetMaskValueRange() const
Returns the range of values that a mask band can take.
Definition: gdalrasterband.cpp:8189
GDALRasterBand::SetMetadataItem
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
GDALRasterBand::FromHandle
static GDALRasterBand * FromHandle(GDALRasterBandH hBand)
Convert a GDALRasterBandH to a GDALRasterBand*.
Definition: gdal_priv.h:1890
GDALRasterBlock
A single raster block in the block cache.
Definition: gdal_priv.h:1204
GDALRasterBlock::GetDirty
int GetDirty() const
Return the dirty flag.
Definition: gdal_priv.h:1301
GDALRasterBlock::GetBand
GDALRasterBand * GetBand()
Accessor to source GDALRasterBand object.
Definition: gdal_priv.h:1328
GDALRasterBlock::GetXSize
int GetXSize() const
Return the width of the block.
Definition: gdal_priv.h:1285
GDALRasterBlock::GetBlockSize
GPtrDiff_t GetBlockSize() const
Return the block size in bytes.
Definition: gdal_priv.h:1317
GDALRasterBlock::GetYSize
int GetYSize() const
Return the height of the block.
Definition: gdal_priv.h:1293
GDALRasterBlock::GetDataType
GDALDataType GetDataType() const
Return the data type.
Definition: gdal_priv.h:1261
GDALRasterBlock::GetXOff
int GetXOff() const
Return the x offset of the top-left corner of the block.
Definition: gdal_priv.h:1269
GDALRasterBlock::AddLock
int AddLock(void)
Increment the lock count.
Definition: gdal_priv.h:1243
GDALRasterBlock::GetDataRef
void * GetDataRef(void)
Return the data buffer.
Definition: gdal_priv.h:1309
GDALRasterBlock::GetYOff
int GetYOff() const
Return the y offset of the top-left corner of the block.
Definition: gdal_priv.h:1277
GDALRasterBlock::DropLock
int DropLock(void)
Decrement the lock count.
Definition: gdal_priv.h:1249
GDALRawResult
Store the raw result of an attribute value, which might contain dynamically allocated structures (lik...
Definition: gdal_priv.h:3285
GDALRawResult::size
size_t size() const
Return the size in bytes of the raw result.
Definition: gdal_priv.h:3321
GDALRawResult::data
const GByte * data() const
Return pointer to the start of data.
Definition: gdal_priv.h:3315
GDALRawResult::operator[]
const GByte & operator[](size_t idx) const
Return byte at specified index.
Definition: gdal_priv.h:3309
GDALRelationship
Definition of a table relationship.
Definition: gdal_priv.h:4002
GDALRelationship::GetName
const std::string & GetName() const
Get the name of the relationship.
Definition: gdal_priv.h:4041
GDALRelationship::GetLeftMappingTableFields
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:4136
GDALRelationship::SetType
void SetType(GDALRelationshipType eType)
Sets the type of the relationship.
Definition: gdal_priv.h:4188
GDALRelationship::SetLeftMappingTableFields
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:4158
GDALRelationship::SetMappingTableName
void SetMappingTableName(const std::string &osName)
Sets the name of the mapping table for many-to-many relationships.
Definition: gdal_priv.h:4081
GDALRelationship::ToHandle
static GDALRelationshipH ToHandle(GDALRelationship *poRelationship)
Convert a GDALRelationship* to a GDALRelationshipH.
Definition: gdal_priv.h:4305
GDALRelationship::GetForwardPathLabel
const std::string & GetForwardPathLabel() const
Get the label of the forward path for the relationship.
Definition: gdal_priv.h:4208
GDALRelationship::GetLeftTableName
const std::string & GetLeftTableName() const
Get the name of the left (or base/origin) table in the relationship.
Definition: gdal_priv.h:4056
GDALRelationship::GetBackwardPathLabel
const std::string & GetBackwardPathLabel() const
Get the label of the backward path for the relationship.
Definition: gdal_priv.h:4248
GDALRelationship::GetRelatedTableType
const std::string & GetRelatedTableType() const
Get the type string of the related table.
Definition: gdal_priv.h:4283
GDALRelationship::GetMappingTableName
const std::string & GetMappingTableName() const
Get the name of the mapping table for many-to-many relationships.
Definition: gdal_priv.h:4072
GDALRelationship::SetLeftTableFields
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:4114
GDALRelationship::GetCardinality
GDALRelationshipCardinality GetCardinality() const
Get the cardinality of the relationship.
Definition: gdal_priv.h:4047
GDALRelationship::SetRightTableFields
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:4125
GDALRelationship::SetForwardPathLabel
void SetForwardPathLabel(const std::string &osLabel)
Sets the label of the forward path for the relationship.
Definition: gdal_priv.h:4228
GDALRelationship::SetBackwardPathLabel
void SetBackwardPathLabel(const std::string &osLabel)
Sets the label of the backward path for the relationship.
Definition: gdal_priv.h:4268
GDALRelationship::GetRightTableFields
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:4103
GDALRelationship::SetRightMappingTableFields
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:4170
GDALRelationship::FromHandle
static GDALRelationship * FromHandle(GDALRelationshipH hRelationship)
Convert a GDALRelationshipH to a GDALRelationship*.
Definition: gdal_priv.h:4312
GDALRelationship::GetRightMappingTableFields
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:4147
GDALRelationship::GDALRelationship
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:4030
GDALRelationship::GetType
GDALRelationshipType GetType() const
Get the type of the relationship.
Definition: gdal_priv.h:4179
GDALRelationship::GetLeftTableFields
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:4092
GDALRelationship::GetRightTableName
const std::string & GetRightTableName() const
Get the name of the right (or related/destination) table in the relationship.
Definition: gdal_priv.h:4063
GDALRelationship::SetRelatedTableType
void SetRelatedTableType(const std::string &osType)
Sets the type string of the related table.
Definition: gdal_priv.h:4298
OGRFeature
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:877
OGRFieldDomain
Definition of a field domain.
Definition: ogr_feature.h:1611
OGRGeomFieldDefn
Definition of a geometry field of an OGRFeatureDefn.
Definition: ogr_feature.h:330
OGRGeometry
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:361
OGRLayer
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:58
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:153
OGRStyleTable
This class represents a style table.
Definition: ogr_featurestyle.h:70
gdal::GCP
C++ wrapper over the C GDAL_GCP structure.
Definition: gdal_priv.h:354
gdal::GCP::Line
double Line() const
Returns the "line" member.
Definition: gdal_priv.h:395
gdal::GCP::Pixel
double & Pixel()
Returns a reference to the "pixel" member.
Definition: gdal_priv.h:389
gdal::GCP::X
double X() const
Returns the "X" member.
Definition: gdal_priv.h:407
gdal::GCP::X
double & X()
Returns a reference to the "X" member.
Definition: gdal_priv.h:413
gdal::GCP::Pixel
double Pixel() const
Returns the "pixel" member.
Definition: gdal_priv.h:383
gdal::GCP::Z
double & Z()
Returns a reference to the "Z" member.
Definition: gdal_priv.h:437
gdal::GCP::Y
double Y() const
Returns the "Y" member.
Definition: gdal_priv.h:419
gdal::GCP::c_ptr
const GDAL_GCP * c_ptr() const
Casts as a C GDAL_GCP pointer.
Definition: gdal_priv.h:443
gdal::GCP::Y
double & Y()
Returns a reference to the "Y" member.
Definition: gdal_priv.h:425
gdal::GCP::Id
const char * Id() const
Returns the "id" member.
Definition: gdal_priv.h:367
gdal::GCP::Info
const char * Info() const
Returns the "info" member.
Definition: gdal_priv.h:375
gdal::GCP::Z
double Z() const
Returns the "Z" member.
Definition: gdal_priv.h:431
gdal::GCP::Line
double & Line()
Returns a reference to the "line" member.
Definition: gdal_priv.h:401
cpl_conv.h
Various convenience functions for CPL.
CPLErr
CPLErr
Error category.
Definition: cpl_error.h:37
CPLErrorNum
int CPLErrorNum
Error number.
Definition: cpl_error.h:79
cpl_minixml.h
Definitions for CPL mini XML Parser/Serializer.
GPtrDiff_t
int GPtrDiff_t
Integer type large enough to hold the difference between 2 addresses.
Definition: cpl_port.h:240
STRCASECMP
#define STRCASECMP(a, b)
Alias for strcasecmp()
Definition: cpl_port.h:528
CPL_NULL_TERMINATED
#define CPL_NULL_TERMINATED
Null terminated variadic.
Definition: cpl_port.h:926
GUIntBig
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:202
CPL_C_END
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:283
CPL_C_START
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:279
GInt64
GIntBig GInt64
Signed 64 bit integer type.
Definition: cpl_port.h:220
CPL_PRINT_FUNC_FORMAT
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition: cpl_port.h:938
CPL_DISALLOW_COPY_ASSIGN
#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:1030
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1179
GUInt64
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition: cpl_port.h:222
CPL_WARN_UNUSED_RESULT
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:964
GByte
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:169
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:199
cpl_string.h
Various convenience functions for working with strings and string lists.
CPLVirtualMem
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition: cpl_virtualmem.h:46
cpl_vsi.h
Standard C Covers.
vsi_l_offset
GUIntBig vsi_l_offset
Type for a file offset.
Definition: cpl_vsi.h:130
gdal.h
Public (C callable) GDAL entry points.
GSpacing
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:400
GDALQueryLoggerFunc
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:1407
GDALRATTableType
GDALRATTableType
RAT table type (thematic or athematic)
Definition: gdal.h:2132
GDALAccess
GDALAccess
Definition: gdal.h:110
GA_ReadOnly
@ GA_ReadOnly
Definition: gdal.h:111
GDALPaletteInterp
GDALPaletteInterp
Definition: gdal.h:338
GPI_RGB
@ GPI_RGB
Definition: gdal.h:340
GDALDataType
GDALDataType
Definition: gdal.h:48
GDT_Byte
@ GDT_Byte
Definition: gdal.h:50
GDT_Float64
@ GDT_Float64
Definition: gdal.h:59
GDT_Unknown
@ GDT_Unknown
Definition: gdal.h:49
GDALDatasetH
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition: gdal.h:376
GDALCreateRasterAttributeTableFromMDArrays
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:413
GDALExtendedDataTypeClass
GDALExtendedDataTypeClass
Enumeration giving the class of a GDALExtendedDataType.
Definition: gdal.h:406
GEDTC_NUMERIC
@ GEDTC_NUMERIC
Numeric value.
Definition: gdal.h:408
GDALRelationshipCardinality
GDALRelationshipCardinality
Cardinality of relationship.
Definition: gdal.h:2218
GRC_ONE_TO_MANY
@ GRC_ONE_TO_MANY
One-to-many.
Definition: gdal.h:2222
GDALRIOResampleAlg
GDALRIOResampleAlg
RasterIO() resampling method.
Definition: gdal.h:128
GRIORA_NearestNeighbour
@ GRIORA_NearestNeighbour
Definition: gdal.h:129
GDALClose
CPLErr GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition: gdaldataset.cpp:4194
GDALRelationshipH
void * GDALRelationshipH
Opaque type used for the C bindings of the C++ GDALRelationship class.
Definition: gdal.h:397
GDALGetThreadSafeDataset
GDALDatasetH GDALGetThreadSafeDataset(GDALDatasetH, int nScopeFlags, CSLConstList papszOptions)
Return a thread-safe dataset.
Definition: gdalthreadsafedataset.cpp:1262
GDALGetDataTypeSizeBytes
int GDALGetDataTypeSizeBytes(GDALDataType)
Get data type size in bytes.
Definition: gdal_misc.cpp:402
GDALOpenEx
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:3586
GDALExtendedDataTypeSubType
GDALExtendedDataTypeSubType
Enumeration giving the subtype of a GDALExtendedDataType.
Definition: gdal.h:419
GEDTST_NONE
@ GEDTST_NONE
None.
Definition: gdal.h:421
GDALMajorObjectH
void * GDALMajorObjectH
Opaque type used for the C bindings of the C++ GDALMajorObject class.
Definition: gdal.h:373
GDALColorInterp
GDALColorInterp
Types of color interpretation for raster bands.
Definition: gdal.h:257
GDALRelationshipType
GDALRelationshipType
Type of relationship.
Definition: gdal.h:2234
GRT_ASSOCIATION
@ GRT_ASSOCIATION
Association relationship.
Definition: gdal.h:2238
GDALAsyncStatusType
GDALAsyncStatusType
status of the asynchronous stream
Definition: gdal.h:96
GDALDriverH
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition: gdal.h:382
GDALRWFlag
GDALRWFlag
Definition: gdal.h:117
GDALRasterBandH
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:379
GDALColorTableH
void * GDALColorTableH
Opaque type used for the C bindings of the C++ GDALColorTable class.
Definition: gdal.h:385
GDALDatasetUniquePtr
std::unique_ptr< GDALDataset, GDALDatasetUniquePtrDeleter > GDALDatasetUniquePtr
Unique pointer type for GDALDataset.
Definition: gdal_priv.h:1193
GSBAP_UNKNOWN
constexpr GDALSuggestedBlockAccessPattern GSBAP_UNKNOWN
Unknown, or no particular read order is suggested.
Definition: gdal_priv.h:1501
GDALSuggestedBlockAccessPattern
int GDALSuggestedBlockAccessPattern
Suggested/most efficient access pattern to blocks.
Definition: gdal_priv.h:1498
GSBAP_RANDOM
constexpr GDALSuggestedBlockAccessPattern GSBAP_RANDOM
Random access to blocks is efficient.
Definition: gdal_priv.h:1504
GetGDALDriverManager
GDALDriverManager * GetGDALDriverManager(void)
Fetch the global GDAL driver manager.
Definition: gdaldrivermanager.cpp:86
GDALMaskValueRange
GDALMaskValueRange
Range of values found in a mask band.
Definition: gdal_priv.h:1490
GMVR_0_AND_1_ONLY
@ GMVR_0_AND_1_ONLY
Definition: gdal_priv.h:1493
GMVR_0_AND_255_ONLY
@ GMVR_0_AND_255_ONLY
Definition: gdal_priv.h:1494
GSBAP_TOP_TO_BOTTOM
constexpr GDALSuggestedBlockAccessPattern GSBAP_TOP_TO_BOTTOM
Reading by strips from top to bottom is the most efficient.
Definition: gdal_priv.h:1507
GDALIdentifyEnum
GDALIdentifyEnum
Enumeration used by GDALDriver::pfnIdentify().
Definition: gdal_priv.h:2098
GDAL_IDENTIFY_TRUE
@ GDAL_IDENTIFY_TRUE
Identify determined the file is recognized by the probed driver.
Definition: gdal_priv.h:2105
GDAL_IDENTIFY_FALSE
@ GDAL_IDENTIFY_FALSE
Identify determined the file is not recognized by the probed driver.
Definition: gdal_priv.h:2103
GDAL_IDENTIFY_UNKNOWN
@ GDAL_IDENTIFY_UNKNOWN
Identify could not determine if the file is recognized or not by the probed driver.
Definition: gdal_priv.h:2101
GSBAP_LARGEST_CHUNK_POSSIBLE
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:1514
GSBAP_BOTTOM_TO_TOP
constexpr GDALSuggestedBlockAccessPattern GSBAP_BOTTOM_TO_TOP
Reading by strips from bottom to top is the most efficient.
Definition: gdal_priv.h:1510
ogr_core.h
Core portability services for cross-platform OGR code.
OGRwkbGeometryType
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:407
wkbUnknown
@ wkbUnknown
unknown type, non-standard
Definition: ogr_core.h:408
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:371
ogr_feature.h
Simple feature classes.
OGRFeatureUniquePtr
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:1554
begin
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:421
end
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:429
CPLXMLNode
Document node structure.
Definition: cpl_minixml.h:55
GDALColorEntry
Color tuple.
Definition: gdal.h:2059
GDALDataset::FeatureLayerPair
Object returned by GetFeatures() iterators.
Definition: gdal_priv.h:919
GDALRasterIOExtraArg
Structure to pass extra arguments to RasterIO() method, must be initialized with INIT_RASTERIO_EXTRA_...
Definition: gdal.h:161
GDALSubdatasetInfo
The GDALSubdatasetInfo abstract class provides methods to extract and manipulate subdataset informati...
Definition: gdalsubdatasetinfo.h:27
GDAL_GCP
Ground Control Point.
Definition: gdal.h:1168
VSIVirtualHandle
Virtual file handle.
Definition: cpl_vsi_virtual.h:47