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