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 CPL_DLL GDALDefaultOverviews
211{
212 friend class GDALDataset;
213
214 GDALDataset *poDS;
215 GDALDataset *poODS;
216
217 CPLString osOvrFilename{};
218
219 bool bOvrIsAux;
220
221 bool bCheckedForMask;
222 bool bOwnMaskDS;
223 GDALDataset *poMaskDS;
224
225 // For "overview datasets" we record base level info so we can
226 // find our way back to get overview masks.
227 GDALDataset *poBaseDS;
228
229 // Stuff for deferred initialize/overviewscans.
230 bool bCheckedForOverviews;
231 void OverviewScan();
232 char *pszInitName;
233 bool bInitNameIsOVR;
234 char **papszInitSiblingFiles;
235
236 public:
237 GDALDefaultOverviews();
238 ~GDALDefaultOverviews();
239
240 void Initialize(GDALDataset *poDSIn, const char *pszName = nullptr,
241 char **papszSiblingFiles = nullptr, int bNameIsOVR = FALSE);
242
243 void TransferSiblingFiles(char **papszSiblingFiles);
244
245 int IsInitialized();
246
247 int CloseDependentDatasets();
248
249 // Overview Related
250
251 int GetOverviewCount(int nBand);
252 GDALRasterBand *GetOverview(int nBand, int iOverview);
253
254 CPLErr BuildOverviews(const char *pszBasename, const char *pszResampling,
255 int nOverviews, const int *panOverviewList,
256 int nBands, const int *panBandList,
257 GDALProgressFunc pfnProgress, void *pProgressData,
258 CSLConstList papszOptions);
259
260 CPLErr BuildOverviewsSubDataset(const char *pszPhysicalFile,
261 const char *pszResampling, int nOverviews,
262 const int *panOverviewList, int nBands,
263 const int *panBandList,
264 GDALProgressFunc pfnProgress,
265 void *pProgressData,
266 CSLConstList papszOptions);
267
268 CPLErr BuildOverviewsMask(const char *pszResampling, int nOverviews,
269 const int *panOverviewList,
270 GDALProgressFunc pfnProgress, void *pProgressData,
271 CSLConstList papszOptions);
272
273 CPLErr CleanOverviews();
274
275 // Mask Related
276
277 CPLErr CreateMaskBand(int nFlags, int nBand = -1);
278 GDALRasterBand *GetMaskBand(int nBand);
279 int GetMaskFlags(int nBand);
280
281 int HaveMaskFile(char **papszSiblings = nullptr,
282 const char *pszBasename = nullptr);
283
284 char **GetSiblingFiles()
285 {
286 return papszInitSiblingFiles;
287 }
288
289 private:
290 CPL_DISALLOW_COPY_ASSIGN(GDALDefaultOverviews)
291};
292
294
295/* ******************************************************************** */
296/* GDALOpenInfo */
297/* ******************************************************************** */
298
300class CPL_DLL GDALOpenInfo
301{
302 bool bHasGotSiblingFiles;
303 char **papszSiblingFiles;
304 int nHeaderBytesTried;
305
306 public:
307 GDALOpenInfo(const char *pszFile, int nOpenFlagsIn,
308 const char *const *papszSiblingFiles = nullptr);
309 ~GDALOpenInfo(void);
310
315
320
325
328
333
335 const char *const *papszAllowedDrivers;
336
337 int TryToIngest(int nBytes);
338 char **GetSiblingFiles();
339 char **StealSiblingFiles();
340 bool AreSiblingFilesLoaded() const;
341
342 private:
344};
345
346/* ******************************************************************** */
347/* gdal::GCP */
348/* ******************************************************************** */
349
350namespace gdal
351{
359class CPL_DLL GCP
360{
361 public:
362 explicit GCP(const char *pszId = "", const char *pszInfo = "",
363 double dfPixel = 0, double dfLine = 0, double dfX = 0,
364 double dfY = 0, double dfZ = 0);
365 ~GCP();
366 GCP(const GCP &);
367 explicit GCP(const GDAL_GCP &other);
368 GCP &operator=(const GCP &);
369 GCP(GCP &&);
370 GCP &operator=(GCP &&);
371
373 inline const char *Id() const
374 {
375 return gcp.pszId;
376 }
377
378 void SetId(const char *pszId);
379
381 inline const char *Info() const
382 {
383 return gcp.pszInfo;
384 }
385
386 void SetInfo(const char *pszInfo);
387
389 inline double Pixel() const
390 {
391 return gcp.dfGCPPixel;
392 }
393
395 inline double &Pixel()
396 {
397 return gcp.dfGCPPixel;
398 }
399
401 inline double Line() const
402 {
403 return gcp.dfGCPLine;
404 }
405
407 inline double &Line()
408 {
409 return gcp.dfGCPLine;
410 }
411
413 inline double X() const
414 {
415 return gcp.dfGCPX;
416 }
417
419 inline double &X()
420 {
421 return gcp.dfGCPX;
422 }
423
425 inline double Y() const
426 {
427 return gcp.dfGCPY;
428 }
429
431 inline double &Y()
432 {
433 return gcp.dfGCPY;
434 }
435
437 inline double Z() const
438 {
439 return gcp.dfGCPZ;
440 }
441
443 inline double &Z()
444 {
445 return gcp.dfGCPZ;
446 }
447
449 inline const GDAL_GCP *c_ptr() const
450 {
451 return &gcp;
452 }
453
454 static const GDAL_GCP *c_ptr(const std::vector<GCP> &asGCPs);
455
456 static std::vector<GCP> fromC(const GDAL_GCP *pasGCPList, int nGCPCount);
457
458 private:
459 GDAL_GCP gcp;
460};
461
462} /* namespace gdal */
463
464/* ******************************************************************** */
465/* GDALDataset */
466/* ******************************************************************** */
467
468class OGRLayer;
469class OGRGeometry;
471class OGRStyleTable;
472class swq_select;
473class swq_select_parse_options;
474class GDALGroup;
475
477typedef struct GDALSQLParseInfo GDALSQLParseInfo;
479
481#ifdef GDAL_COMPILATION
482#define OPTIONAL_OUTSIDE_GDAL(val)
483#else
484#define OPTIONAL_OUTSIDE_GDAL(val) = val
485#endif
487
489// This macro can be defined to check that GDALDataset::IRasterIO()
490// implementations do not alter the passed panBandList. It is not defined
491// by default (and should not!), hence int* is used.
492#if defined(GDAL_BANDMAP_TYPE_CONST_SAFE)
493#define BANDMAP_TYPE const int *
494#else
495#define BANDMAP_TYPE int *
496#endif
498
500class CPL_DLL GDALDataset : public GDALMajorObject
501{
502 friend GDALDatasetH CPL_STDCALL
503 GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags,
504 const char *const *papszAllowedDrivers,
505 const char *const *papszOpenOptions,
506 const char *const *papszSiblingFiles);
507 friend CPLErr CPL_STDCALL GDALClose(GDALDatasetH hDS);
508
509 friend class GDALDriver;
510 friend class GDALDefaultOverviews;
511 friend class GDALProxyDataset;
512 friend class GDALDriverManager;
513
514 CPL_INTERNAL void AddToDatasetOpenList();
515
516 CPL_INTERNAL void UnregisterFromSharedDataset();
517
518 CPL_INTERNAL static void ReportErrorV(const char *pszDSName,
519 CPLErr eErrClass, CPLErrorNum err_no,
520 const char *fmt, va_list args);
521
522 protected:
524 GDALDriver *poDriver = nullptr;
525 GDALAccess eAccess = GA_ReadOnly;
526
527 // Stored raster information.
528 int nRasterXSize = 512;
529 int nRasterYSize = 512;
530 int nBands = 0;
531 GDALRasterBand **papoBands = nullptr;
532
533 static constexpr int OPEN_FLAGS_CLOSED = -1;
534 int nOpenFlags =
535 0; // set to OPEN_FLAGS_CLOSED after Close() has been called
536
537 int nRefCount = 1;
538 bool bForceCachedIO = false;
539 bool bShared = false;
540 bool bIsInternal = true;
541 bool bSuppressOnClose = false;
542
543 mutable std::map<std::string, std::unique_ptr<OGRFieldDomain>>
544 m_oMapFieldDomains{};
545
546 GDALDataset(void);
547 explicit GDALDataset(int bForceCachedIO);
548
549 void RasterInitialize(int, int);
550 void SetBand(int nNewBand, GDALRasterBand *poBand);
551 void SetBand(int nNewBand, std::unique_ptr<GDALRasterBand> poBand);
552
553 GDALDefaultOverviews oOvManager{};
554
555 virtual CPLErr IBuildOverviews(const char *pszResampling, int nOverviews,
556 const int *panOverviewList, int nListBands,
557 const int *panBandList,
558 GDALProgressFunc pfnProgress,
559 void *pProgressData,
560 CSLConstList papszOptions);
561
562 virtual CPLErr
563 IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize,
564 void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType,
565 int nBandCount, BANDMAP_TYPE panBandMap, GSpacing nPixelSpace,
566 GSpacing nLineSpace, GSpacing nBandSpace,
568
569 CPLErr
570 BlockBasedRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
571 int nYSize, void *pData, int nBufXSize, int nBufYSize,
572 GDALDataType eBufType, int nBandCount,
573 const int *panBandMap, GSpacing nPixelSpace,
574 GSpacing nLineSpace, GSpacing nBandSpace,
576 CPLErr BlockBasedFlushCache(bool bAtClosing);
577
578 CPLErr
579 BandBasedRasterIO(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
586 CPLErr
587 RasterIOResampled(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
588 int nYSize, void *pData, int nBufXSize, int nBufYSize,
589 GDALDataType eBufType, int nBandCount,
590 const int *panBandMap, GSpacing nPixelSpace,
591 GSpacing nLineSpace, GSpacing nBandSpace,
593
594 CPLErr ValidateRasterIOOrAdviseReadParameters(
595 const char *pszCallingFunc, int *pbStopProcessingOnCENone, int nXOff,
596 int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize,
597 int nBandCount, const int *panBandMap);
598
599 CPLErr TryOverviewRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
600 int nXSize, int nYSize, void *pData,
601 int nBufXSize, int nBufYSize,
602 GDALDataType eBufType, int nBandCount,
603 const int *panBandMap, GSpacing nPixelSpace,
604 GSpacing nLineSpace, GSpacing nBandSpace,
605 GDALRasterIOExtraArg *psExtraArg, int *pbTried);
606
607 void ShareLockWithParentDataset(GDALDataset *poParentDataset);
608
610
611 void CleanupPostFileClosing();
612
613 virtual int CloseDependentDatasets();
615 int ValidateLayerCreationOptions(const char *const *papszLCO);
616
617 char **papszOpenOptions = nullptr;
618
619 friend class GDALRasterBand;
620
621 // The below methods related to read write mutex are fragile logic, and
622 // should not be used by out-of-tree code if possible.
623 int EnterReadWrite(GDALRWFlag eRWFlag);
624 void LeaveReadWrite();
625 void InitRWLock();
626
627 void TemporarilyDropReadWriteLock();
628 void ReacquireReadWriteLock();
629
630 void DisableReadWriteMutex();
631
632 int AcquireMutex();
633 void ReleaseMutex();
634
635 bool IsAllBands(int nBandCount, const int *panBandList) const;
637
638 public:
639 ~GDALDataset() override;
640
641 virtual CPLErr Close();
642
643 int GetRasterXSize() const;
644 int GetRasterYSize() const;
645 int GetRasterCount() const;
646 GDALRasterBand *GetRasterBand(int);
647 const GDALRasterBand *GetRasterBand(int) const;
648
655 virtual bool SetQueryLoggerFunc(GDALQueryLoggerFunc pfnQueryLoggerFuncIn,
656 void *poQueryLoggerArgIn);
657
660 class CPL_DLL Bands
661 {
662 private:
663 friend class GDALDataset;
664 GDALDataset *m_poSelf;
665
666 CPL_INTERNAL explicit Bands(GDALDataset *poSelf) : m_poSelf(poSelf)
667 {
668 }
669
670 class CPL_DLL Iterator
671 {
672 struct Private;
673 std::unique_ptr<Private> m_poPrivate;
674
675 public:
676 Iterator(GDALDataset *poDS, bool bStart);
677 Iterator(const Iterator &oOther); // declared but not defined.
678 // Needed for gcc 5.4 at least
679 Iterator(Iterator &&oOther) noexcept; // declared but not defined.
680 // Needed for gcc 5.4 at least
681 ~Iterator();
682 GDALRasterBand *operator*();
683 Iterator &operator++();
684 bool operator!=(const Iterator &it) const;
685 };
686
687 public:
688 const Iterator begin() const;
689
690 const Iterator end() const;
691
692 size_t size() const;
693
694 GDALRasterBand *operator[](int iBand);
695 GDALRasterBand *operator[](size_t iBand);
696 };
697
698 Bands GetBands();
699
700 virtual CPLErr FlushCache(bool bAtClosing = false);
701 virtual CPLErr DropCache();
702
703 virtual GIntBig GetEstimatedRAMUsage();
704
705 virtual const OGRSpatialReference *GetSpatialRef() const;
706 virtual CPLErr SetSpatialRef(const OGRSpatialReference *poSRS);
707
708 // Compatibility layer
709 const char *GetProjectionRef(void) const;
710 CPLErr SetProjection(const char *pszProjection);
711
712 virtual CPLErr GetGeoTransform(double *padfTransform);
713 virtual CPLErr SetGeoTransform(double *padfTransform);
714
715 virtual CPLErr AddBand(GDALDataType eType, char **papszOptions = nullptr);
716
717 virtual void *GetInternalHandle(const char *pszHandleName);
718 virtual GDALDriver *GetDriver(void);
719 virtual char **GetFileList(void);
720
721 virtual const char *GetDriverName();
722
723 virtual const OGRSpatialReference *GetGCPSpatialRef() const;
724 virtual int GetGCPCount();
725 virtual const GDAL_GCP *GetGCPs();
726 virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList,
727 const OGRSpatialReference *poGCP_SRS);
728
729 // Compatibility layer
730 const char *GetGCPProjection();
731 CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList,
732 const char *pszGCPProjection);
733
734 virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize,
735 int nBufXSize, int nBufYSize, GDALDataType eDT,
736 int nBandCount, int *panBandList,
737 char **papszOptions);
738
739 virtual CPLErr CreateMaskBand(int nFlagsIn);
740
741 virtual GDALAsyncReader *
742 BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize, void *pBuf,
743 int nBufXSize, int nBufYSize, GDALDataType eBufType,
744 int nBandCount, int *panBandMap, int nPixelSpace,
745 int nLineSpace, int nBandSpace, char **papszOptions);
746 virtual void EndAsyncReader(GDALAsyncReader *poARIO);
747
749 struct RawBinaryLayout
750 {
751 enum class Interleaving
752 {
753 UNKNOWN,
754 BIP,
755 BIL,
756 BSQ
757 };
758 std::string osRawFilename{};
759 Interleaving eInterleaving = Interleaving::UNKNOWN;
760 GDALDataType eDataType = GDT_Unknown;
761 bool bLittleEndianOrder = false;
762
763 vsi_l_offset nImageOffset = 0;
764 GIntBig nPixelOffset = 0;
765 GIntBig nLineOffset = 0;
766 GIntBig nBandOffset = 0;
767 };
768
769 virtual bool GetRawBinaryLayout(RawBinaryLayout &);
771
772#ifndef DOXYGEN_SKIP
773 CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
774 int nYSize, void *pData, int nBufXSize, int nBufYSize,
775 GDALDataType eBufType, int nBandCount,
776 const int *panBandMap, GSpacing nPixelSpace,
777 GSpacing nLineSpace, GSpacing nBandSpace,
778 GDALRasterIOExtraArg *psExtraArg
779 OPTIONAL_OUTSIDE_GDAL(nullptr)) CPL_WARN_UNUSED_RESULT;
780#else
781 CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
782 int nYSize, void *pData, int nBufXSize, int nBufYSize,
783 GDALDataType eBufType, int nBandCount,
784 const int *panBandMap, GSpacing nPixelSpace,
785 GSpacing nLineSpace, GSpacing nBandSpace,
787#endif
788
789 virtual CPLStringList GetCompressionFormats(int nXOff, int nYOff,
790 int nXSize, int nYSize,
791 int nBandCount,
792 const int *panBandList);
793 virtual CPLErr ReadCompressedData(const char *pszFormat, int nXOff,
794 int nYOff, int nXSize, int nYSize,
795 int nBands, const int *panBandList,
796 void **ppBuffer, size_t *pnBufferSize,
797 char **ppszDetailedFormat);
798
799 int Reference();
800 int Dereference();
801 int ReleaseRef();
802
807 {
808 return eAccess;
809 }
810
811 int GetShared() const;
812 void MarkAsShared();
813
814 void MarkSuppressOnClose();
815 void UnMarkSuppressOnClose();
816
821 {
822 return bSuppressOnClose;
823 }
824
829 {
830 return papszOpenOptions;
831 }
832
833 static GDALDataset **GetOpenDatasets(int *pnDatasetCount);
834
835#ifndef DOXYGEN_SKIP
836 CPLErr
837 BuildOverviews(const char *pszResampling, int nOverviews,
838 const int *panOverviewList, int nListBands,
839 const int *panBandList, GDALProgressFunc pfnProgress,
840 void *pProgressData,
841 CSLConstList papszOptions OPTIONAL_OUTSIDE_GDAL(nullptr));
842#else
843 CPLErr BuildOverviews(const char *pszResampling, int nOverviews,
844 const int *panOverviewList, int nListBands,
845 const int *panBandList, GDALProgressFunc pfnProgress,
846 void *pProgressData, CSLConstList papszOptions);
847#endif
848
849#ifndef DOXYGEN_XML
850 void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,
851 ...) const CPL_PRINT_FUNC_FORMAT(4, 5);
852
853 static void ReportError(const char *pszDSName, CPLErr eErrClass,
854 CPLErrorNum err_no, const char *fmt, ...)
856#endif
857
858 char **GetMetadata(const char *pszDomain = "") override;
859
860// Only defined when Doxygen enabled
861#ifdef DOXYGEN_SKIP
862 CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override;
863 CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
864 const char *pszDomain) override;
865#endif
866
867 char **GetMetadataDomainList() override;
868
869 virtual void ClearStatistics();
870
874 static inline GDALDatasetH ToHandle(GDALDataset *poDS)
875 {
876 return static_cast<GDALDatasetH>(poDS);
877 }
878
883 {
884 return static_cast<GDALDataset *>(hDS);
885 }
886
890 static GDALDataset *Open(const char *pszFilename,
891 unsigned int nOpenFlags = 0,
892 const char *const *papszAllowedDrivers = nullptr,
893 const char *const *papszOpenOptions = nullptr,
894 const char *const *papszSiblingFiles = nullptr)
895 {
896 return FromHandle(GDALOpenEx(pszFilename, nOpenFlags,
897 papszAllowedDrivers, papszOpenOptions,
898 papszSiblingFiles));
899 }
900
903 {
906
908 OGRLayer *layer = nullptr;
909 };
910
912 // SetEnableOverviews() only to be used by GDALOverviewDataset
913 void SetEnableOverviews(bool bEnable);
914
915 // Only to be used by driver's GetOverviewCount() method.
916 bool AreOverviewsEnabled() const;
918
919 private:
920 class Private;
921 Private *m_poPrivate;
922
923 CPL_INTERNAL OGRLayer *BuildLayerFromSelectInfo(
924 swq_select *psSelectInfo, OGRGeometry *poSpatialFilter,
925 const char *pszDialect, swq_select_parse_options *poSelectParseOptions);
926 CPLStringList oDerivedMetadataList{};
927
928 public:
929 virtual int GetLayerCount();
930 virtual OGRLayer *GetLayer(int iLayer);
931
932 virtual bool IsLayerPrivate(int iLayer) const;
933
937 class CPL_DLL Layers
938 {
939 private:
940 friend class GDALDataset;
941 GDALDataset *m_poSelf;
942
943 CPL_INTERNAL explicit Layers(GDALDataset *poSelf) : m_poSelf(poSelf)
944 {
945 }
946
947 public:
951 class CPL_DLL Iterator
952 {
953 struct Private;
954 std::unique_ptr<Private> m_poPrivate;
955
956 public:
958 using reference = OGRLayer *;
959 using difference_type = void;
960 using pointer = void;
962 std::input_iterator_tag;
964 Iterator();
965 Iterator(GDALDataset *poDS, bool bStart);
966 Iterator(const Iterator &oOther);
967 Iterator(Iterator &&oOther) noexcept;
970 Iterator &
971 operator=(const Iterator &oOther);
972 Iterator &operator=(
973 Iterator &&oOther) noexcept;
975 OGRLayer *operator*() const;
976 Iterator &operator++();
977 Iterator operator++(int);
978 bool operator!=(const Iterator &it)
979 const;
980 };
981
982 Iterator begin() const;
983 Iterator end() const;
984
985 size_t size() const;
986
987 OGRLayer *operator[](int iLayer);
988 OGRLayer *operator[](size_t iLayer);
989 OGRLayer *operator[](const char *pszLayername);
990 };
991
992 Layers GetLayers();
993
994 virtual OGRLayer *GetLayerByName(const char *);
995 virtual OGRErr DeleteLayer(int iLayer);
996
997 virtual void ResetReading();
998 virtual OGRFeature *GetNextFeature(OGRLayer **ppoBelongingLayer,
999 double *pdfProgressPct,
1000 GDALProgressFunc pfnProgress,
1001 void *pProgressData);
1002
1005 class CPL_DLL Features
1006 {
1007 private:
1008 friend class GDALDataset;
1009 GDALDataset *m_poSelf;
1010
1011 CPL_INTERNAL explicit Features(GDALDataset *poSelf) : m_poSelf(poSelf)
1012 {
1013 }
1014
1015 class CPL_DLL Iterator
1016 {
1017 struct Private;
1018 std::unique_ptr<Private> m_poPrivate;
1019
1020 public:
1021 Iterator(GDALDataset *poDS, bool bStart);
1022 Iterator(const Iterator &oOther); // declared but not defined.
1023 // Needed for gcc 5.4 at least
1024 Iterator(Iterator &&oOther) noexcept; // declared but not defined.
1025 // Needed for gcc 5.4 at least
1026 ~Iterator();
1027 const FeatureLayerPair &operator*() const;
1028 Iterator &operator++();
1029 bool operator!=(const Iterator &it) const;
1030 };
1031
1032 public:
1033 const Iterator begin() const;
1034
1035 const Iterator end() const;
1036 };
1037
1038 Features GetFeatures();
1039
1040 virtual int TestCapability(const char *);
1041
1042 virtual std::vector<std::string>
1043 GetFieldDomainNames(CSLConstList papszOptions = nullptr) const;
1044
1045 virtual const OGRFieldDomain *GetFieldDomain(const std::string &name) const;
1046
1047 virtual bool AddFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
1048 std::string &failureReason);
1049
1050 virtual bool DeleteFieldDomain(const std::string &name,
1051 std::string &failureReason);
1052
1053 virtual bool UpdateFieldDomain(std::unique_ptr<OGRFieldDomain> &&domain,
1054 std::string &failureReason);
1055
1056 virtual std::vector<std::string>
1057 GetRelationshipNames(CSLConstList papszOptions = nullptr) const;
1058
1059 virtual const GDALRelationship *
1060 GetRelationship(const std::string &name) const;
1061
1062 virtual bool
1063 AddRelationship(std::unique_ptr<GDALRelationship> &&relationship,
1064 std::string &failureReason);
1065
1066 virtual bool DeleteRelationship(const std::string &name,
1067 std::string &failureReason);
1068
1069 virtual bool
1070 UpdateRelationship(std::unique_ptr<GDALRelationship> &&relationship,
1071 std::string &failureReason);
1072
1074 OGRLayer *CreateLayer(const char *pszName);
1075
1076 OGRLayer *CreateLayer(const char *pszName, std::nullptr_t);
1078
1079 OGRLayer *CreateLayer(const char *pszName,
1080 const OGRSpatialReference *poSpatialRef,
1082 CSLConstList papszOptions = nullptr);
1083
1084 OGRLayer *CreateLayer(const char *pszName,
1085 const OGRGeomFieldDefn *poGeomFieldDefn,
1086 CSLConstList papszOptions = nullptr);
1087
1088 virtual OGRLayer *CopyLayer(OGRLayer *poSrcLayer, const char *pszNewName,
1089 char **papszOptions = nullptr);
1090
1091 virtual OGRStyleTable *GetStyleTable();
1092 virtual void SetStyleTableDirectly(OGRStyleTable *poStyleTable);
1093
1094 virtual void SetStyleTable(OGRStyleTable *poStyleTable);
1095
1096 virtual OGRLayer *ExecuteSQL(const char *pszStatement,
1097 OGRGeometry *poSpatialFilter,
1098 const char *pszDialect);
1099 virtual void ReleaseResultSet(OGRLayer *poResultsSet);
1100 virtual OGRErr AbortSQL();
1101
1102 int GetRefCount() const;
1103 int GetSummaryRefCount() const;
1104 OGRErr Release();
1105
1106 virtual OGRErr StartTransaction(int bForce = FALSE);
1107 virtual OGRErr CommitTransaction();
1108 virtual OGRErr RollbackTransaction();
1109
1110 virtual std::shared_ptr<GDALGroup> GetRootGroup() const;
1111
1113 static int IsGenericSQLDialect(const char *pszDialect);
1114
1115 // Semi-public methods. Only to be used by in-tree drivers.
1116 GDALSQLParseInfo *
1117 BuildParseInfo(swq_select *psSelectInfo,
1118 swq_select_parse_options *poSelectParseOptions);
1119 static void DestroyParseInfo(GDALSQLParseInfo *psParseInfo);
1120 OGRLayer *ExecuteSQL(const char *pszStatement, OGRGeometry *poSpatialFilter,
1121 const char *pszDialect,
1122 swq_select_parse_options *poSelectParseOptions);
1124
1125 protected:
1126 virtual OGRLayer *ICreateLayer(const char *pszName,
1127 const OGRGeomFieldDefn *poGeomFieldDefn,
1128 CSLConstList papszOptions);
1129
1131 OGRErr ProcessSQLCreateIndex(const char *);
1132 OGRErr ProcessSQLDropIndex(const char *);
1133 OGRErr ProcessSQLDropTable(const char *);
1134 OGRErr ProcessSQLAlterTableAddColumn(const char *);
1135 OGRErr ProcessSQLAlterTableDropColumn(const char *);
1136 OGRErr ProcessSQLAlterTableAlterColumn(const char *);
1137 OGRErr ProcessSQLAlterTableRenameColumn(const char *);
1138
1139 OGRStyleTable *m_poStyleTable = nullptr;
1140
1141 friend class GDALProxyPoolDataset;
1143
1144 private:
1146};
1147
1149struct CPL_DLL GDALDatasetUniquePtrDeleter
1150{
1151 void operator()(GDALDataset *poDataset) const
1152 {
1153 GDALClose(poDataset);
1154 }
1155};
1156
1158
1160struct CPL_DLL GDALDatasetUniquePtrReleaser
1161{
1162 void operator()(GDALDataset *poDataset) const
1163 {
1164 if (poDataset)
1165 poDataset->Release();
1166 }
1167};
1168
1170
1177 std::unique_ptr<GDALDataset, GDALDatasetUniquePtrDeleter>;
1178
1179/* ******************************************************************** */
1180/* GDALRasterBlock */
1181/* ******************************************************************** */
1182
1187class CPL_DLL GDALRasterBlock
1188{
1189 friend class GDALAbstractBandBlockCache;
1190
1191 GDALDataType eType;
1192
1193 bool bDirty;
1194 volatile int nLockCount;
1195
1196 int nXOff;
1197 int nYOff;
1198
1199 int nXSize;
1200 int nYSize;
1201
1202 void *pData;
1203
1204 GDALRasterBand *poBand;
1205
1206 GDALRasterBlock *poNext;
1207 GDALRasterBlock *poPrevious;
1208
1209 bool bMustDetach;
1210
1211 CPL_INTERNAL void Detach_unlocked(void);
1212 CPL_INTERNAL void Touch_unlocked(void);
1213
1214 CPL_INTERNAL void RecycleFor(int nXOffIn, int nYOffIn);
1215
1216 public:
1217 GDALRasterBlock(GDALRasterBand *, int, int);
1218 GDALRasterBlock(int nXOffIn, int nYOffIn); /* only for lookup purpose */
1219 virtual ~GDALRasterBlock();
1220
1221 CPLErr Internalize(void);
1222 void Touch(void);
1223 void MarkDirty(void);
1224 void MarkClean(void);
1225
1227 int AddLock(void)
1228 {
1229 return CPLAtomicInc(&nLockCount);
1230 }
1231
1233 int DropLock(void)
1234 {
1235 return CPLAtomicDec(&nLockCount);
1236 }
1237
1238 void Detach();
1239
1240 CPLErr Write();
1241
1246 {
1247 return eType;
1248 }
1249
1253 int GetXOff() const
1254 {
1255 return nXOff;
1256 }
1257
1261 int GetYOff() const
1262 {
1263 return nYOff;
1264 }
1265
1269 int GetXSize() const
1270 {
1271 return nXSize;
1272 }
1273
1277 int GetYSize() const
1278 {
1279 return nYSize;
1280 }
1281
1285 int GetDirty() const
1286 {
1287 return bDirty;
1288 }
1289
1293 void *GetDataRef(void)
1294 {
1295 return pData;
1296 }
1297
1302 {
1303 return static_cast<GPtrDiff_t>(nXSize) * nYSize *
1305 }
1306
1307 int TakeLock();
1308 int DropLockForRemovalFromStorage();
1309
1313 {
1314 return poBand;
1315 }
1316
1317 static void FlushDirtyBlocks();
1318 static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE);
1319 static void Verify();
1320
1321 static void EnterDisableDirtyBlockFlush();
1322 static void LeaveDisableDirtyBlockFlush();
1323
1324#ifdef notdef
1325 static void CheckNonOrphanedBlocks(GDALRasterBand *poBand);
1326 void DumpBlock();
1327 static void DumpAll();
1328#endif
1329
1330 /* Should only be called by GDALDestroyDriverManager() */
1332 CPL_INTERNAL static void DestroyRBMutex();
1334
1335 private:
1337};
1338
1339/* ******************************************************************** */
1340/* GDALColorTable */
1341/* ******************************************************************** */
1342
1345class CPL_DLL GDALColorTable
1346{
1347 GDALPaletteInterp eInterp;
1348
1349 std::vector<GDALColorEntry> aoEntries{};
1350
1351 public:
1354
1355 GDALColorTable *Clone() const;
1356 int IsSame(const GDALColorTable *poOtherCT) const;
1357
1358 GDALPaletteInterp GetPaletteInterpretation() const;
1359
1360 int GetColorEntryCount() const;
1361 const GDALColorEntry *GetColorEntry(int i) const;
1362 int GetColorEntryAsRGB(int i, GDALColorEntry *poEntry) const;
1363 void SetColorEntry(int i, const GDALColorEntry *poEntry);
1364 int CreateColorRamp(int nStartIndex, const GDALColorEntry *psStartColor,
1365 int nEndIndex, const GDALColorEntry *psEndColor);
1366 bool IsIdentity() const;
1367
1372 {
1373 return static_cast<GDALColorTableH>(poCT);
1374 }
1375
1380 {
1381 return static_cast<GDALColorTable *>(hCT);
1382 }
1383};
1384
1385/* ******************************************************************** */
1386/* GDALAbstractBandBlockCache */
1387/* ******************************************************************** */
1388
1390
1392// only used by GDALRasterBand implementation.
1393
1394class GDALAbstractBandBlockCache
1395{
1396 // List of blocks that can be freed or recycled, and its lock
1397 CPLLock *hSpinLock = nullptr;
1398 GDALRasterBlock *psListBlocksToFree = nullptr;
1399
1400 // Band keep alive counter, and its lock & condition
1401 CPLCond *hCond = nullptr;
1402 CPLMutex *hCondMutex = nullptr;
1403 volatile int nKeepAliveCounter = 0;
1404
1405 volatile int m_nDirtyBlocks = 0;
1406
1407 CPL_DISALLOW_COPY_ASSIGN(GDALAbstractBandBlockCache)
1408
1409 protected:
1410 GDALRasterBand *poBand;
1411
1412 int m_nInitialDirtyBlocksInFlushCache = 0;
1413 int m_nLastTick = -1;
1414 size_t m_nWriteDirtyBlocksDisabled = 0;
1415
1416 void FreeDanglingBlocks();
1417 void UnreferenceBlockBase();
1418
1419 void StartDirtyBlockFlushingLog();
1420 void UpdateDirtyBlockFlushingLog();
1421 void EndDirtyBlockFlushingLog();
1422
1423 public:
1424 explicit GDALAbstractBandBlockCache(GDALRasterBand *poBand);
1425 virtual ~GDALAbstractBandBlockCache();
1426
1427 GDALRasterBlock *CreateBlock(int nXBlockOff, int nYBlockOff);
1428 void AddBlockToFreeList(GDALRasterBlock *poBlock);
1429 void IncDirtyBlocks(int nInc);
1430 void WaitCompletionPendingTasks();
1431
1432 void EnableDirtyBlockWriting()
1433 {
1434 --m_nWriteDirtyBlocksDisabled;
1435 }
1436
1437 void DisableDirtyBlockWriting()
1438 {
1439 ++m_nWriteDirtyBlocksDisabled;
1440 }
1441
1442 bool HasDirtyBlocks() const
1443 {
1444 return m_nDirtyBlocks > 0;
1445 }
1446
1447 virtual bool Init() = 0;
1448 virtual bool IsInitOK() = 0;
1449 virtual CPLErr FlushCache() = 0;
1450 virtual CPLErr AdoptBlock(GDALRasterBlock *poBlock) = 0;
1451 virtual GDALRasterBlock *TryGetLockedBlockRef(int nXBlockOff,
1452 int nYBlockYOff) = 0;
1453 virtual CPLErr UnreferenceBlock(GDALRasterBlock *poBlock) = 0;
1454 virtual CPLErr FlushBlock(int nXBlockOff, int nYBlockOff,
1455 int bWriteDirtyBlock) = 0;
1456};
1457
1458GDALAbstractBandBlockCache *
1459GDALArrayBandBlockCacheCreate(GDALRasterBand *poBand);
1460GDALAbstractBandBlockCache *
1461GDALHashSetBandBlockCacheCreate(GDALRasterBand *poBand);
1462
1464
1465/* ******************************************************************** */
1466/* GDALRasterBand */
1467/* ******************************************************************** */
1468
1469class GDALMDArray;
1470
1472typedef enum
1473{
1474 GMVR_UNKNOWN,
1479
1482
1485
1488
1491
1494
1498
1501class CPL_DLL GDALRasterBand : public GDALMajorObject
1502{
1503 private:
1504 friend class GDALArrayBandBlockCache;
1505 friend class GDALHashSetBandBlockCache;
1506 friend class GDALRasterBlock;
1507 friend class GDALDataset;
1508
1509 CPLErr eFlushBlockErr = CE_None;
1510 GDALAbstractBandBlockCache *poBandBlockCache = nullptr;
1511
1512 CPL_INTERNAL void SetFlushBlockErr(CPLErr eErr);
1513 CPL_INTERNAL CPLErr UnreferenceBlock(GDALRasterBlock *poBlock);
1514 CPL_INTERNAL void IncDirtyBlocks(int nInc);
1515
1516 protected:
1518 GDALDataset *poDS = nullptr;
1519 int nBand = 0; /* 1 based */
1520
1521 int nRasterXSize = 0;
1522 int nRasterYSize = 0;
1523
1524 GDALDataType eDataType = GDT_Byte;
1525 GDALAccess eAccess = GA_ReadOnly;
1526
1527 /* stuff related to blocking, and raster cache */
1528 int nBlockXSize = -1;
1529 int nBlockYSize = -1;
1530 int nBlocksPerRow = 0;
1531 int nBlocksPerColumn = 0;
1532
1533 int nBlockReads = 0;
1534 int bForceCachedIO = 0;
1535
1536 class GDALRasterBandOwnedOrNot
1537 {
1538 public:
1539 GDALRasterBandOwnedOrNot()
1540 {
1541 }
1542
1543 GDALRasterBandOwnedOrNot(GDALRasterBand *poBand, bool bOwned)
1544 : m_poBandOwned(bOwned ? poBand : nullptr),
1545 m_poBandRef(bOwned ? nullptr : poBand)
1546 {
1547 }
1548
1549 void reset()
1550 {
1551 m_poBandOwned.reset();
1552 m_poBandRef = nullptr;
1553 }
1554
1555 void reset(GDALRasterBand *poBand, bool bOwned)
1556 {
1557 m_poBandOwned.reset(bOwned ? poBand : nullptr);
1558 m_poBandRef = bOwned ? nullptr : poBand;
1559 }
1560
1561 GDALRasterBand *get()
1562 {
1563 return static_cast<GDALRasterBand *>(*this);
1564 }
1565
1566 bool IsOwned() const
1567 {
1568 return m_poBandOwned != nullptr;
1569 }
1570
1571 operator GDALRasterBand *()
1572 {
1573 return m_poBandOwned ? m_poBandOwned.get() : m_poBandRef;
1574 }
1575
1576 private:
1577 CPL_DISALLOW_COPY_ASSIGN(GDALRasterBandOwnedOrNot)
1578 std::unique_ptr<GDALRasterBand> m_poBandOwned{};
1579 GDALRasterBand *m_poBandRef = nullptr;
1580 };
1581
1582 GDALRasterBandOwnedOrNot poMask{};
1583 bool m_bEnablePixelTypeSignedByteWarning =
1584 true; // Remove me in GDAL 4.0. See GetMetadataItem() implementation
1585 int nMaskFlags = 0;
1586
1587 void InvalidateMaskBand();
1588
1589 friend class GDALProxyRasterBand;
1590 friend class GDALDefaultOverviews;
1591
1592 CPLErr
1593 RasterIOResampled(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1594 int nYSize, void *pData, int nBufXSize, int nBufYSize,
1595 GDALDataType eBufType, GSpacing nPixelSpace,
1596 GSpacing nLineSpace,
1598
1599 int EnterReadWrite(GDALRWFlag eRWFlag);
1600 void LeaveReadWrite();
1601 void InitRWLock();
1602 void SetValidPercent(GUIntBig nSampleCount, GUIntBig nValidCount);
1603
1605
1606 protected:
1607 virtual CPLErr IReadBlock(int nBlockXOff, int nBlockYOff, void *pData) = 0;
1608 virtual CPLErr IWriteBlock(int nBlockXOff, int nBlockYOff, void *pData);
1609
1610 virtual CPLErr
1611 IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize,
1612 void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType,
1613 GSpacing nPixelSpace, GSpacing nLineSpace,
1615
1616 virtual int IGetDataCoverageStatus(int nXOff, int nYOff, int nXSize,
1617 int nYSize, int nMaskFlagStop,
1618 double *pdfDataPct);
1620 CPLErr
1621 OverviewRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1622 int nYSize, void *pData, int nBufXSize, int nBufYSize,
1623 GDALDataType eBufType, GSpacing nPixelSpace,
1624 GSpacing nLineSpace,
1626
1627 CPLErr TryOverviewRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
1628 int nXSize, int nYSize, void *pData,
1629 int nBufXSize, int nBufYSize,
1630 GDALDataType eBufType, GSpacing nPixelSpace,
1631 GSpacing nLineSpace,
1632 GDALRasterIOExtraArg *psExtraArg, int *pbTried);
1633
1634 int InitBlockInfo();
1635
1636 void AddBlockToFreeList(GDALRasterBlock *);
1637
1638 bool HasBlockCache() const
1639 {
1640 return poBandBlockCache != nullptr;
1641 }
1642
1643 bool HasDirtyBlocks() const
1644 {
1645 return poBandBlockCache && poBandBlockCache->HasDirtyBlocks();
1646 }
1647
1649
1650 public:
1652 explicit GDALRasterBand(int bForceCachedIO);
1653
1654 ~GDALRasterBand() override;
1655
1656 int GetXSize();
1657 int GetYSize();
1658 int GetBand();
1659 GDALDataset *GetDataset();
1660
1661 GDALDataType GetRasterDataType(void);
1662 void GetBlockSize(int *pnXSize, int *pnYSize);
1663 CPLErr GetActualBlockSize(int nXBlockOff, int nYBlockOff, int *pnXValid,
1664 int *pnYValid);
1665
1667 GetSuggestedBlockAccessPattern() const;
1668
1669 GDALAccess GetAccess();
1670
1671#ifndef DOXYGEN_SKIP
1672 CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1673 int nYSize, void *pData, int nBufXSize, int nBufYSize,
1674 GDALDataType eBufType, GSpacing nPixelSpace,
1675 GSpacing nLineSpace,
1676 GDALRasterIOExtraArg *psExtraArg
1677 OPTIONAL_OUTSIDE_GDAL(nullptr)) CPL_WARN_UNUSED_RESULT;
1678#else
1679 CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
1680 int nYSize, void *pData, int nBufXSize, int nBufYSize,
1681 GDALDataType eBufType, GSpacing nPixelSpace,
1682 GSpacing nLineSpace,
1684#endif
1685 CPLErr ReadBlock(int nXBlockOff, int nYBlockOff,
1686 void *pImage) CPL_WARN_UNUSED_RESULT;
1687
1688 CPLErr WriteBlock(int nXBlockOff, int nYBlockOff,
1689 void *pImage) CPL_WARN_UNUSED_RESULT;
1690
1692 GetLockedBlockRef(int nXBlockOff, int nYBlockOff,
1693 int bJustInitialize = FALSE) CPL_WARN_UNUSED_RESULT;
1694 GDALRasterBlock *TryGetLockedBlockRef(int nXBlockOff, int nYBlockYOff)
1696 CPLErr FlushBlock(int nXBlockOff, int nYBlockOff,
1697 int bWriteDirtyBlock = TRUE);
1698
1699 unsigned char *
1700 GetIndexColorTranslationTo(/* const */ GDALRasterBand *poReferenceBand,
1701 unsigned char *pTranslationTable = nullptr,
1702 int *pApproximateMatching = nullptr);
1703
1704 // New OpengIS CV_SampleDimension stuff.
1705
1706 virtual CPLErr FlushCache(bool bAtClosing = false);
1707 virtual CPLErr DropCache();
1708 virtual char **GetCategoryNames();
1709 virtual double GetNoDataValue(int *pbSuccess = nullptr);
1710 virtual int64_t GetNoDataValueAsInt64(int *pbSuccess = nullptr);
1711 virtual uint64_t GetNoDataValueAsUInt64(int *pbSuccess = nullptr);
1712 virtual double GetMinimum(int *pbSuccess = nullptr);
1713 virtual double GetMaximum(int *pbSuccess = nullptr);
1714 virtual double GetOffset(int *pbSuccess = nullptr);
1715 virtual double GetScale(int *pbSuccess = nullptr);
1716 virtual const char *GetUnitType();
1717 virtual GDALColorInterp GetColorInterpretation();
1718 virtual GDALColorTable *GetColorTable();
1719 virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
1720
1721 virtual CPLErr SetCategoryNames(char **papszNames);
1722 virtual CPLErr SetNoDataValue(double dfNoData);
1723 virtual CPLErr SetNoDataValueAsInt64(int64_t nNoData);
1724 virtual CPLErr SetNoDataValueAsUInt64(uint64_t nNoData);
1725 virtual CPLErr DeleteNoDataValue();
1726 virtual CPLErr SetColorTable(GDALColorTable *poCT);
1727 virtual CPLErr SetColorInterpretation(GDALColorInterp eColorInterp);
1728 virtual CPLErr SetOffset(double dfNewOffset);
1729 virtual CPLErr SetScale(double dfNewScale);
1730 virtual CPLErr SetUnitType(const char *pszNewValue);
1731
1732 virtual CPLErr GetStatistics(int bApproxOK, int bForce, double *pdfMin,
1733 double *pdfMax, double *pdfMean,
1734 double *padfStdDev);
1735 virtual CPLErr ComputeStatistics(int bApproxOK, double *pdfMin,
1736 double *pdfMax, double *pdfMean,
1737 double *pdfStdDev, GDALProgressFunc,
1738 void *pProgressData);
1739 virtual CPLErr SetStatistics(double dfMin, double dfMax, double dfMean,
1740 double dfStdDev);
1741 virtual CPLErr ComputeRasterMinMax(int bApproxOK, double *adfMinMax);
1742
1743// Only defined when Doxygen enabled
1744#ifdef DOXYGEN_SKIP
1745 CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override;
1746 CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
1747 const char *pszDomain) override;
1748#endif
1749 virtual const char *GetMetadataItem(const char *pszName,
1750 const char *pszDomain = "") override;
1751
1752 virtual int HasArbitraryOverviews();
1753 virtual int GetOverviewCount();
1754 virtual GDALRasterBand *GetOverview(int i);
1755 virtual GDALRasterBand *GetRasterSampleOverview(GUIntBig);
1756 virtual CPLErr BuildOverviews(const char *pszResampling, int nOverviews,
1757 const int *panOverviewList,
1758 GDALProgressFunc pfnProgress,
1759 void *pProgressData,
1760 CSLConstList papszOptions);
1761
1762 virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize,
1763 int nBufXSize, int nBufYSize,
1764 GDALDataType eBufType, char **papszOptions);
1765
1766 virtual CPLErr GetHistogram(double dfMin, double dfMax, int nBuckets,
1767 GUIntBig *panHistogram, int bIncludeOutOfRange,
1768 int bApproxOK, GDALProgressFunc,
1769 void *pProgressData);
1770
1771 virtual CPLErr GetDefaultHistogram(double *pdfMin, double *pdfMax,
1772 int *pnBuckets, GUIntBig **ppanHistogram,
1773 int bForce, GDALProgressFunc,
1774 void *pProgressData);
1775 virtual CPLErr SetDefaultHistogram(double dfMin, double dfMax, int nBuckets,
1776 GUIntBig *panHistogram);
1777
1778 virtual GDALRasterAttributeTable *GetDefaultRAT();
1779 virtual CPLErr SetDefaultRAT(const GDALRasterAttributeTable *poRAT);
1780
1781 virtual GDALRasterBand *GetMaskBand();
1782 virtual int GetMaskFlags();
1783 virtual CPLErr CreateMaskBand(int nFlagsIn);
1784 virtual bool IsMaskBand() const;
1785 virtual GDALMaskValueRange GetMaskValueRange() const;
1786
1787 virtual CPLVirtualMem *
1788 GetVirtualMemAuto(GDALRWFlag eRWFlag, int *pnPixelSpace,
1789 GIntBig *pnLineSpace,
1790 char **papszOptions) CPL_WARN_UNUSED_RESULT;
1791
1792 int GetDataCoverageStatus(int nXOff, int nYOff, int nXSize, int nYSize,
1793 int nMaskFlagStop = 0,
1794 double *pdfDataPct = nullptr);
1795
1796 std::shared_ptr<GDALMDArray> AsMDArray() const;
1797
1798#ifndef DOXYGEN_XML
1799 void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...)
1801#endif
1802
1807 {
1808 return static_cast<GDALRasterBandH>(poBand);
1809 }
1810
1815 {
1816 return static_cast<GDALRasterBand *>(hBand);
1817 }
1818
1820 // Remove me in GDAL 4.0. See GetMetadataItem() implementation
1821 // Internal use in GDAL only !
1822 void EnablePixelTypeSignedByteWarning(bool b)
1823#ifndef GDAL_COMPILATION
1824 CPL_WARN_DEPRECATED("Do not use that method outside of GDAL!")
1825#endif
1826 ;
1827
1829
1830 private:
1832};
1833
1835/* ******************************************************************** */
1836/* GDALAllValidMaskBand */
1837/* ******************************************************************** */
1838
1839class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
1840{
1841 protected:
1842 CPLErr IReadBlock(int, int, void *) override;
1843
1844 CPL_DISALLOW_COPY_ASSIGN(GDALAllValidMaskBand)
1845
1846 public:
1847 explicit GDALAllValidMaskBand(GDALRasterBand *);
1848 ~GDALAllValidMaskBand() override;
1849
1850 GDALRasterBand *GetMaskBand() override;
1851 int GetMaskFlags() override;
1852
1853 bool IsMaskBand() const override
1854 {
1855 return true;
1856 }
1857
1858 GDALMaskValueRange GetMaskValueRange() const override
1859 {
1860 return GMVR_0_AND_255_ONLY;
1861 }
1862
1863 CPLErr ComputeStatistics(int bApproxOK, double *pdfMin, double *pdfMax,
1864 double *pdfMean, double *pdfStdDev,
1865 GDALProgressFunc, void *pProgressData) override;
1866};
1867
1868/* ******************************************************************** */
1869/* GDALNoDataMaskBand */
1870/* ******************************************************************** */
1871
1872class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
1873{
1874 friend class GDALRasterBand;
1875 double m_dfNoDataValue = 0;
1876 int64_t m_nNoDataValueInt64 = 0;
1877 uint64_t m_nNoDataValueUInt64 = 0;
1878 GDALRasterBand *m_poParent = nullptr;
1879
1880 CPL_DISALLOW_COPY_ASSIGN(GDALNoDataMaskBand)
1881
1882 protected:
1883 CPLErr IReadBlock(int, int, void *) override;
1884 CPLErr IRasterIO(GDALRWFlag, int, int, int, int, void *, int, int,
1886 GDALRasterIOExtraArg *psExtraArg) override;
1887
1888 public:
1889 explicit GDALNoDataMaskBand(GDALRasterBand *);
1890 explicit GDALNoDataMaskBand(GDALRasterBand *, double dfNoDataValue);
1891 ~GDALNoDataMaskBand() override;
1892
1893 bool IsMaskBand() const override
1894 {
1895 return true;
1896 }
1897
1898 GDALMaskValueRange GetMaskValueRange() const override
1899 {
1900 return GMVR_0_AND_255_ONLY;
1901 }
1902
1903 static bool IsNoDataInRange(double dfNoDataValue, GDALDataType eDataType);
1904};
1905
1906/* ******************************************************************** */
1907/* GDALNoDataValuesMaskBand */
1908/* ******************************************************************** */
1909
1910class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
1911{
1912 double *padfNodataValues;
1913
1914 CPL_DISALLOW_COPY_ASSIGN(GDALNoDataValuesMaskBand)
1915
1916 protected:
1917 CPLErr IReadBlock(int, int, void *) override;
1918
1919 public:
1920 explicit GDALNoDataValuesMaskBand(GDALDataset *);
1921 ~GDALNoDataValuesMaskBand() override;
1922
1923 bool IsMaskBand() const override
1924 {
1925 return true;
1926 }
1927
1928 GDALMaskValueRange GetMaskValueRange() const override
1929 {
1930 return GMVR_0_AND_255_ONLY;
1931 }
1932};
1933
1934/* ******************************************************************** */
1935/* GDALRescaledAlphaBand */
1936/* ******************************************************************** */
1937
1938class GDALRescaledAlphaBand : public GDALRasterBand
1939{
1940 GDALRasterBand *poParent;
1941 void *pTemp;
1942
1943 CPL_DISALLOW_COPY_ASSIGN(GDALRescaledAlphaBand)
1944
1945 protected:
1946 CPLErr IReadBlock(int, int, void *) override;
1947 CPLErr IRasterIO(GDALRWFlag, int, int, int, int, void *, int, int,
1949 GDALRasterIOExtraArg *psExtraArg) override;
1950
1951 public:
1952 explicit GDALRescaledAlphaBand(GDALRasterBand *);
1953 ~GDALRescaledAlphaBand() override;
1954
1955 bool IsMaskBand() const override
1956 {
1957 return true;
1958 }
1959};
1960
1962
1963/* ******************************************************************** */
1964/* GDALIdentifyEnum */
1965/* ******************************************************************** */
1966
1982
1983/* ******************************************************************** */
1984/* GDALDriver */
1985/* ******************************************************************** */
1986
1998class CPL_DLL GDALDriver : public GDALMajorObject
1999{
2000 public:
2001 GDALDriver();
2002 ~GDALDriver() override;
2003
2004 CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
2005 const char *pszDomain = "") override;
2006
2007 /* -------------------------------------------------------------------- */
2008 /* Public C++ methods. */
2009 /* -------------------------------------------------------------------- */
2010 GDALDataset *Create(const char *pszName, int nXSize, int nYSize, int nBands,
2011 GDALDataType eType,
2013
2014 GDALDataset *
2015 CreateMultiDimensional(const char *pszName,
2016 CSLConstList papszRootGroupOptions,
2018
2019 CPLErr Delete(const char *pszName);
2020 CPLErr Rename(const char *pszNewName, const char *pszOldName);
2021 CPLErr CopyFiles(const char *pszNewName, const char *pszOldName);
2022
2023 GDALDataset *CreateCopy(const char *, GDALDataset *, int,
2024 CSLConstList papszOptions,
2025 GDALProgressFunc pfnProgress,
2026 void *pProgressData) CPL_WARN_UNUSED_RESULT;
2027
2028 bool CanVectorTranslateFrom(const char *pszDestName,
2029 GDALDataset *poSourceDS,
2030 CSLConstList papszVectorTranslateArguments,
2031 char ***ppapszFailureReasons);
2032
2033 GDALDataset *
2034 VectorTranslateFrom(const char *pszDestName, GDALDataset *poSourceDS,
2035 CSLConstList papszVectorTranslateArguments,
2036 GDALProgressFunc pfnProgress,
2037 void *pProgressData) CPL_WARN_UNUSED_RESULT;
2038
2039 /* -------------------------------------------------------------------- */
2040 /* The following are semiprivate, not intended to be accessed */
2041 /* by anyone but the formats instantiating and populating the */
2042 /* drivers. */
2043 /* -------------------------------------------------------------------- */
2045
2046 // Not aimed at being used outside of GDAL. Use GDALDataset::Open() instead
2047 GDALDataset *Open(GDALOpenInfo *poOpenInfo, bool bSetOpenOptions);
2048
2049 typedef GDALDataset *(*OpenCallback)(GDALOpenInfo *);
2050
2051 OpenCallback pfnOpen = nullptr;
2052
2053 virtual OpenCallback GetOpenCallback()
2054 {
2055 return pfnOpen;
2056 }
2057
2058 typedef GDALDataset *(*CreateCallback)(const char *pszName, int nXSize,
2059 int nYSize, int nBands,
2060 GDALDataType eType,
2061 char **papszOptions);
2062
2063 CreateCallback pfnCreate = nullptr;
2064
2065 virtual CreateCallback GetCreateCallback()
2066 {
2067 return pfnCreate;
2068 }
2069
2070 GDALDataset *(*pfnCreateEx)(GDALDriver *, const char *pszName, int nXSize,
2071 int nYSize, int nBands, GDALDataType eType,
2072 char **papszOptions) = nullptr;
2073
2074 typedef GDALDataset *(*CreateMultiDimensionalCallback)(
2075 const char *pszName, CSLConstList papszRootGroupOptions,
2076 CSLConstList papszOptions);
2077
2078 CreateMultiDimensionalCallback pfnCreateMultiDimensional = nullptr;
2079
2080 virtual CreateMultiDimensionalCallback GetCreateMultiDimensionalCallback()
2081 {
2082 return pfnCreateMultiDimensional;
2083 }
2084
2085 typedef CPLErr (*DeleteCallback)(const char *pszName);
2086 DeleteCallback pfnDelete = nullptr;
2087
2088 virtual DeleteCallback GetDeleteCallback()
2089 {
2090 return pfnDelete;
2091 }
2092
2093 typedef GDALDataset *(*CreateCopyCallback)(const char *, GDALDataset *, int,
2094 char **,
2095 GDALProgressFunc pfnProgress,
2096 void *pProgressData);
2097
2098 CreateCopyCallback pfnCreateCopy = nullptr;
2099
2100 virtual CreateCopyCallback GetCreateCopyCallback()
2101 {
2102 return pfnCreateCopy;
2103 }
2104
2105 void *pDriverData = nullptr;
2106
2107 void (*pfnUnloadDriver)(GDALDriver *) = nullptr;
2108
2117 int (*pfnIdentify)(GDALOpenInfo *) = nullptr;
2118 int (*pfnIdentifyEx)(GDALDriver *, GDALOpenInfo *) = nullptr;
2119
2120 typedef CPLErr (*RenameCallback)(const char *pszNewName,
2121 const char *pszOldName);
2122 RenameCallback pfnRename = nullptr;
2123
2124 virtual RenameCallback GetRenameCallback()
2125 {
2126 return pfnRename;
2127 }
2128
2129 typedef CPLErr (*CopyFilesCallback)(const char *pszNewName,
2130 const char *pszOldName);
2131 CopyFilesCallback pfnCopyFiles = nullptr;
2132
2133 virtual CopyFilesCallback GetCopyFilesCallback()
2134 {
2135 return pfnCopyFiles;
2136 }
2137
2138 // Used for legacy OGR drivers, and Python drivers
2139 GDALDataset *(*pfnOpenWithDriverArg)(GDALDriver *,
2140 GDALOpenInfo *) = nullptr;
2141
2142 /* For legacy OGR drivers */
2143 GDALDataset *(*pfnCreateVectorOnly)(GDALDriver *, const char *pszName,
2144 char **papszOptions) = nullptr;
2145 CPLErr (*pfnDeleteDataSource)(GDALDriver *, const char *pszName) = nullptr;
2146
2151 bool (*pfnCanVectorTranslateFrom)(
2152 const char *pszDestName, GDALDataset *poSourceDS,
2153 CSLConstList papszVectorTranslateArguments,
2154 char ***ppapszFailureReasons) = nullptr;
2155
2160 GDALDataset *(*pfnVectorTranslateFrom)(
2161 const char *pszDestName, GDALDataset *poSourceDS,
2162 CSLConstList papszVectorTranslateArguments,
2163 GDALProgressFunc pfnProgress, void *pProgressData) = nullptr;
2164
2169 GDALSubdatasetInfo *(*pfnGetSubdatasetInfoFunc)(const char *pszFileName) =
2170 nullptr;
2171
2173
2174 /* -------------------------------------------------------------------- */
2175 /* Helper methods. */
2176 /* -------------------------------------------------------------------- */
2178 GDALDataset *DefaultCreateCopy(const char *, GDALDataset *, int,
2179 CSLConstList papszOptions,
2180 GDALProgressFunc pfnProgress,
2181 void *pProgressData) CPL_WARN_UNUSED_RESULT;
2182
2183 static CPLErr DefaultCreateCopyMultiDimensional(
2184 GDALDataset *poSrcDS, GDALDataset *poDstDS, bool bStrict,
2185 CSLConstList /*papszOptions*/, GDALProgressFunc pfnProgress,
2186 void *pProgressData);
2187
2188 static CPLErr DefaultCopyMasks(GDALDataset *poSrcDS, GDALDataset *poDstDS,
2189 int bStrict);
2190 static CPLErr DefaultCopyMasks(GDALDataset *poSrcDS, GDALDataset *poDstDS,
2191 int bStrict, CSLConstList papszOptions,
2192 GDALProgressFunc pfnProgress,
2193 void *pProgressData);
2194
2195 CPLErr QuietDeleteForCreateCopy(const char *pszFilename,
2196 GDALDataset *poSrcDS);
2197
2199 static CPLErr QuietDelete(const char *pszName,
2200 CSLConstList papszAllowedDrivers = nullptr);
2201
2203 static CPLErr DefaultRename(const char *pszNewName, const char *pszOldName);
2204 static CPLErr DefaultCopyFiles(const char *pszNewName,
2205 const char *pszOldName);
2206 static void DefaultCopyMetadata(GDALDataset *poSrcDS, GDALDataset *poDstDS,
2207 CSLConstList papszOptions,
2208 CSLConstList papszExcludedDomains);
2209
2211
2215 static inline GDALDriverH ToHandle(GDALDriver *poDriver)
2216 {
2217 return static_cast<GDALDriverH>(poDriver);
2218 }
2219
2223 static inline GDALDriver *FromHandle(GDALDriverH hDriver)
2224 {
2225 return static_cast<GDALDriver *>(hDriver);
2226 }
2227
2228 private:
2230};
2231
2232/************************************************************************/
2233/* GDALPluginDriverProxy */
2234/************************************************************************/
2235
2236// clang-format off
2274// clang-format on
2275
2277{
2278 const std::string m_osPluginFileName;
2279 std::string m_osPluginFullPath{};
2280 std::unique_ptr<GDALDriver> m_poRealDriver{};
2281 std::set<std::string> m_oSetMetadataItems{};
2282
2283 GDALDriver *GetRealDriver();
2284
2286
2287 protected:
2288 friend class GDALDriverManager;
2289
2291 void SetPluginFullPath(const std::string &osFullPath)
2292 {
2293 m_osPluginFullPath = osFullPath;
2294 }
2295
2297
2298 public:
2299 explicit GDALPluginDriverProxy(const std::string &osPluginFileName);
2300
2302 const std::string &GetPluginFileName() const
2303 {
2304 return m_osPluginFileName;
2305 }
2306
2308 OpenCallback GetOpenCallback() override;
2309
2310 CreateCallback GetCreateCallback() override;
2311
2312 CreateMultiDimensionalCallback GetCreateMultiDimensionalCallback() override;
2313
2314 CreateCopyCallback GetCreateCopyCallback() override;
2315
2316 DeleteCallback GetDeleteCallback() override;
2317
2318 RenameCallback GetRenameCallback() override;
2319
2320 CopyFilesCallback GetCopyFilesCallback() override;
2322
2323 CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
2324 const char *pszDomain = "") override;
2325
2326 char **GetMetadata(const char *pszDomain) override;
2327
2328 const char *GetMetadataItem(const char *pszName,
2329 const char *pszDomain = "") override;
2330};
2331
2332/* ******************************************************************** */
2333/* GDALDriverManager */
2334/* ******************************************************************** */
2335
2344{
2345 int nDrivers = 0;
2346 GDALDriver **papoDrivers = nullptr;
2347 std::map<CPLString, GDALDriver *> oMapNameToDrivers{};
2348 std::string m_osPluginPath{};
2349 std::string m_osDriversIniPath{};
2350 mutable std::string m_osLastTriedDirectory{};
2351 std::set<std::string> m_oSetPluginFileNames{};
2352 bool m_bInDeferredDriverLoading = false;
2353 std::map<std::string, std::unique_ptr<GDALDriver>> m_oMapRealDrivers{};
2354 std::vector<std::unique_ptr<GDALDriver>> m_aoHiddenDrivers{};
2355
2356 GDALDriver *GetDriver_unlocked(int iDriver)
2357 {
2358 return (iDriver >= 0 && iDriver < nDrivers) ? papoDrivers[iDriver]
2359 : nullptr;
2360 }
2361
2362 GDALDriver *GetDriverByName_unlocked(const char *pszName) const
2363 {
2364 auto oIter = oMapNameToDrivers.find(CPLString(pszName).toupper());
2365 return oIter == oMapNameToDrivers.end() ? nullptr : oIter->second;
2366 }
2367
2368 static void CleanupPythonDrivers();
2369
2370 std::string GetPluginFullPath(const char *pszFilename) const;
2371
2372 int RegisterDriver(GDALDriver *, bool bHidden);
2373
2375
2376 protected:
2377 friend class GDALPluginDriverProxy;
2378 friend GDALDatasetH CPL_STDCALL
2379 GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags,
2380 const char *const *papszAllowedDrivers,
2381 const char *const *papszOpenOptions,
2382 const char *const *papszSiblingFiles);
2383
2385 static char **GetSearchPaths(const char *pszGDAL_DRIVER_PATH);
2387
2388 public:
2391
2392 int GetDriverCount(void) const;
2393 GDALDriver *GetDriver(int);
2394 GDALDriver *GetDriverByName(const char *);
2395
2396 int RegisterDriver(GDALDriver *);
2397 void DeregisterDriver(GDALDriver *);
2398
2399 // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
2400 void AutoLoadDrivers();
2401 void AutoSkipDrivers();
2402 void ReorderDrivers();
2403 static CPLErr LoadPlugin(const char *name);
2404
2405 static void AutoLoadPythonDrivers();
2406
2407 void DeclareDeferredPluginDriver(GDALPluginDriverProxy *poProxyDriver);
2408
2410 int GetDriverCount(bool bIncludeHidden) const;
2411 GDALDriver *GetDriver(int iDriver, bool bIncludeHidden);
2413};
2414
2418
2419/* ******************************************************************** */
2420/* GDALAsyncReader */
2421/* ******************************************************************** */
2422
2428class CPL_DLL GDALAsyncReader
2429{
2430
2432
2433 protected:
2435 GDALDataset *poDS;
2436 int nXOff;
2437 int nYOff;
2438 int nXSize;
2439 int nYSize;
2440 void *pBuf;
2441 int nBufXSize;
2442 int nBufYSize;
2443 GDALDataType eBufType;
2444 int nBandCount;
2445 int *panBandMap;
2446 int nPixelSpace;
2447 int nLineSpace;
2448 int nBandSpace;
2450
2451 public:
2453 virtual ~GDALAsyncReader();
2454
2459 {
2460 return poDS;
2461 }
2462
2466 int GetXOffset() const
2467 {
2468 return nXOff;
2469 }
2470
2474 int GetYOffset() const
2475 {
2476 return nYOff;
2477 }
2478
2482 int GetXSize() const
2483 {
2484 return nXSize;
2485 }
2486
2490 int GetYSize() const
2491 {
2492 return nYSize;
2493 }
2494
2499 {
2500 return pBuf;
2501 }
2502
2506 int GetBufferXSize() const
2507 {
2508 return nBufXSize;
2509 }
2510
2514 int GetBufferYSize() const
2515 {
2516 return nBufYSize;
2517 }
2518
2523 {
2524 return eBufType;
2525 }
2526
2530 int GetBandCount() const
2531 {
2532 return nBandCount;
2533 }
2534
2539 {
2540 return panBandMap;
2541 }
2542
2546 int GetPixelSpace() const
2547 {
2548 return nPixelSpace;
2549 }
2550
2554 int GetLineSpace() const
2555 {
2556 return nLineSpace;
2557 }
2558
2562 int GetBandSpace() const
2563 {
2564 return nBandSpace;
2565 }
2566
2567 virtual GDALAsyncStatusType
2568 GetNextUpdatedRegion(double dfTimeout, int *pnBufXOff, int *pnBufYOff,
2569 int *pnBufXSize, int *pnBufYSize) = 0;
2570 virtual int LockBuffer(double dfTimeout = -1.0);
2571 virtual void UnlockBuffer();
2572};
2573
2574/* ******************************************************************** */
2575/* Multidimensional array API */
2576/* ******************************************************************** */
2577
2578class GDALMDArray;
2579class GDALAttribute;
2580class GDALDimension;
2581class GDALEDTComponent;
2582
2583/* ******************************************************************** */
2584/* GDALExtendedDataType */
2585/* ******************************************************************** */
2586
2595{
2596 public:
2598
2600
2601 GDALExtendedDataType &operator=(const GDALExtendedDataType &);
2603
2604 static GDALExtendedDataType Create(GDALDataType eType);
2606 Create(const std::string &osName, size_t nTotalSize,
2607 std::vector<std::unique_ptr<GDALEDTComponent>> &&components);
2609 CreateString(size_t nMaxStringLength = 0,
2611
2612 bool operator==(const GDALExtendedDataType &) const;
2613
2615 bool operator!=(const GDALExtendedDataType &other) const
2616 {
2617 return !(operator==(other));
2618 }
2619
2624 const std::string &GetName() const
2625 {
2626 return m_osName;
2627 }
2628
2634 {
2635 return m_eClass;
2636 }
2637
2644 {
2645 return m_eNumericDT;
2646 }
2647
2655 {
2656 return m_eSubType;
2657 }
2658
2664 const std::vector<std::unique_ptr<GDALEDTComponent>> &GetComponents() const
2665 {
2666 return m_aoComponents;
2667 }
2668
2675 size_t GetSize() const
2676 {
2677 return m_nSize;
2678 }
2679
2684 size_t GetMaxStringLength() const
2685 {
2686 return m_nMaxStringLength;
2687 }
2688
2689 bool CanConvertTo(const GDALExtendedDataType &other) const;
2690
2691 bool NeedsFreeDynamicMemory() const;
2692
2693 void FreeDynamicMemory(void *pBuffer) const;
2694
2695 static bool CopyValue(const void *pSrc, const GDALExtendedDataType &srcType,
2696 void *pDst, const GDALExtendedDataType &dstType);
2697
2698 static bool CopyValues(const void *pSrc,
2699 const GDALExtendedDataType &srcType,
2700 GPtrDiff_t nSrcStrideInElts, void *pDst,
2701 const GDALExtendedDataType &dstType,
2702 GPtrDiff_t nDstStrideInElts, size_t nValues);
2703
2704 private:
2705 GDALExtendedDataType(size_t nMaxStringLength,
2707 explicit GDALExtendedDataType(GDALDataType eType);
2709 const std::string &osName, size_t nTotalSize,
2710 std::vector<std::unique_ptr<GDALEDTComponent>> &&components);
2711
2712 std::string m_osName{};
2715 GDALDataType m_eNumericDT = GDT_Unknown;
2716 std::vector<std::unique_ptr<GDALEDTComponent>> m_aoComponents{};
2717 size_t m_nSize = 0;
2718 size_t m_nMaxStringLength = 0;
2719};
2720
2721/* ******************************************************************** */
2722/* GDALEDTComponent */
2723/* ******************************************************************** */
2724
2730class CPL_DLL GDALEDTComponent
2731{
2732 public:
2734 GDALEDTComponent(const std::string &name, size_t offset,
2735 const GDALExtendedDataType &type);
2737
2738 bool operator==(const GDALEDTComponent &) const;
2739
2744 const std::string &GetName() const
2745 {
2746 return m_osName;
2747 }
2748
2753 size_t GetOffset() const
2754 {
2755 return m_nOffset;
2756 }
2757
2763 {
2764 return m_oType;
2765 }
2766
2767 private:
2768 std::string m_osName;
2769 size_t m_nOffset;
2770 GDALExtendedDataType m_oType;
2771};
2772
2773/* ******************************************************************** */
2774/* GDALIHasAttribute */
2775/* ******************************************************************** */
2776
2783{
2784 protected:
2785 std::shared_ptr<GDALAttribute>
2786 GetAttributeFromAttributes(const std::string &osName) const;
2787
2788 public:
2789 virtual ~GDALIHasAttribute();
2790
2791 virtual std::shared_ptr<GDALAttribute>
2792 GetAttribute(const std::string &osName) const;
2793
2794 virtual std::vector<std::shared_ptr<GDALAttribute>>
2795 GetAttributes(CSLConstList papszOptions = nullptr) const;
2796
2797 virtual std::shared_ptr<GDALAttribute>
2798 CreateAttribute(const std::string &osName,
2799 const std::vector<GUInt64> &anDimensions,
2800 const GDALExtendedDataType &oDataType,
2801 CSLConstList papszOptions = nullptr);
2802
2803 virtual bool DeleteAttribute(const std::string &osName,
2804 CSLConstList papszOptions = nullptr);
2805};
2806
2807/* ******************************************************************** */
2808/* GDALGroup */
2809/* ******************************************************************** */
2810
2811/* clang-format off */
2821/* clang-format on */
2822
2823class CPL_DLL GDALGroup : public GDALIHasAttribute
2824{
2825 protected:
2827 std::string m_osName{};
2828
2829 // This is actually a path of the form "/parent_path/{m_osName}"
2830 std::string m_osFullName{};
2831
2832 // Used for example by GDALSubsetGroup to distinguish a derived group
2833 //from its original, without altering its name
2834 const std::string m_osContext{};
2835
2836 std::weak_ptr<GDALGroup> m_pSelf{};
2837
2839 bool m_bValid = true;
2840
2841 GDALGroup(const std::string &osParentName, const std::string &osName,
2842 const std::string &osContext = std::string());
2843
2844 const GDALGroup *
2845 GetInnerMostGroup(const std::string &osPathOrArrayOrDim,
2846 std::shared_ptr<GDALGroup> &curGroupHolder,
2847 std::string &osLastPart) const;
2848
2849 void BaseRename(const std::string &osNewName);
2850
2851 bool CheckValidAndErrorOutIfNot() const;
2852
2853 void SetSelf(const std::shared_ptr<GDALGroup> &self)
2854 {
2855 m_pSelf = self;
2856 }
2857
2858 virtual void NotifyChildrenOfRenaming()
2859 {
2860 }
2861
2862 virtual void NotifyChildrenOfDeletion()
2863 {
2864 }
2865
2867
2868 public:
2869 virtual ~GDALGroup();
2870
2875 const std::string &GetName() const
2876 {
2877 return m_osName;
2878 }
2879
2884 const std::string &GetFullName() const
2885 {
2886 return m_osFullName;
2887 }
2888
2889 virtual std::vector<std::string>
2890 GetMDArrayNames(CSLConstList papszOptions = nullptr) const;
2891 virtual std::shared_ptr<GDALMDArray>
2892 OpenMDArray(const std::string &osName,
2893 CSLConstList papszOptions = nullptr) const;
2894
2895 virtual std::vector<std::string>
2896 GetGroupNames(CSLConstList papszOptions = nullptr) const;
2897 virtual std::shared_ptr<GDALGroup>
2898 OpenGroup(const std::string &osName,
2899 CSLConstList papszOptions = nullptr) const;
2900
2901 virtual std::vector<std::string>
2902 GetVectorLayerNames(CSLConstList papszOptions = nullptr) const;
2903 virtual OGRLayer *
2904 OpenVectorLayer(const std::string &osName,
2905 CSLConstList papszOptions = nullptr) const;
2906
2907 virtual std::vector<std::shared_ptr<GDALDimension>>
2908 GetDimensions(CSLConstList papszOptions = nullptr) const;
2909
2910 virtual std::shared_ptr<GDALGroup>
2911 CreateGroup(const std::string &osName, CSLConstList papszOptions = nullptr);
2912
2913 virtual bool DeleteGroup(const std::string &osName,
2914 CSLConstList papszOptions = nullptr);
2915
2916 virtual std::shared_ptr<GDALDimension>
2917 CreateDimension(const std::string &osName, const std::string &osType,
2918 const std::string &osDirection, GUInt64 nSize,
2919 CSLConstList papszOptions = nullptr);
2920
2921 virtual std::shared_ptr<GDALMDArray> CreateMDArray(
2922 const std::string &osName,
2923 const std::vector<std::shared_ptr<GDALDimension>> &aoDimensions,
2924 const GDALExtendedDataType &oDataType,
2925 CSLConstList papszOptions = nullptr);
2926
2927 virtual bool DeleteMDArray(const std::string &osName,
2928 CSLConstList papszOptions = nullptr);
2929
2930 GUInt64 GetTotalCopyCost() const;
2931
2932 virtual bool CopyFrom(const std::shared_ptr<GDALGroup> &poDstRootGroup,
2933 GDALDataset *poSrcDS,
2934 const std::shared_ptr<GDALGroup> &poSrcGroup,
2935 bool bStrict, GUInt64 &nCurCost,
2936 const GUInt64 nTotalCost,
2937 GDALProgressFunc pfnProgress, void *pProgressData,
2938 CSLConstList papszOptions = nullptr);
2939
2940 virtual CSLConstList GetStructuralInfo() const;
2941
2942 std::shared_ptr<GDALMDArray>
2943 OpenMDArrayFromFullname(const std::string &osFullName,
2944 CSLConstList papszOptions = nullptr) const;
2945
2946 std::shared_ptr<GDALMDArray>
2947 ResolveMDArray(const std::string &osName, const std::string &osStartingPath,
2948 CSLConstList papszOptions = nullptr) const;
2949
2950 std::shared_ptr<GDALGroup>
2951 OpenGroupFromFullname(const std::string &osFullName,
2952 CSLConstList papszOptions = nullptr) const;
2953
2954 std::shared_ptr<GDALDimension>
2955 OpenDimensionFromFullname(const std::string &osFullName) const;
2956
2957 virtual void ClearStatistics();
2958
2959 virtual bool Rename(const std::string &osNewName);
2960
2961 std::shared_ptr<GDALGroup>
2962 SubsetDimensionFromSelection(const std::string &osSelection) const;
2963
2965 virtual void ParentRenamed(const std::string &osNewParentFullName);
2966
2967 virtual void Deleted();
2968
2969 virtual void ParentDeleted();
2970
2971 const std::string &GetContext() const
2972 {
2973 return m_osContext;
2974 }
2975
2977
2979 static constexpr GUInt64 COPY_COST = 1000;
2981};
2982
2983/* ******************************************************************** */
2984/* GDALAbstractMDArray */
2985/* ******************************************************************** */
2986
2993{
2994 protected:
2996 std::string m_osName{};
2997
2998 // This is actually a path of the form "/parent_path/{m_osName}"
2999 std::string m_osFullName{};
3000 std::weak_ptr<GDALAbstractMDArray> m_pSelf{};
3001
3003 bool m_bValid = true;
3004
3005 GDALAbstractMDArray(const std::string &osParentName,
3006 const std::string &osName);
3007
3008 void SetSelf(const std::shared_ptr<GDALAbstractMDArray> &self)
3009 {
3010 m_pSelf = self;
3011 }
3012
3013 bool CheckValidAndErrorOutIfNot() const;
3014
3015 bool CheckReadWriteParams(const GUInt64 *arrayStartIdx, const size_t *count,
3016 const GInt64 *&arrayStep,
3017 const GPtrDiff_t *&bufferStride,
3018 const GDALExtendedDataType &bufferDataType,
3019 const void *buffer,
3020 const void *buffer_alloc_start,
3021 size_t buffer_alloc_size,
3022 std::vector<GInt64> &tmp_arrayStep,
3023 std::vector<GPtrDiff_t> &tmp_bufferStride) const;
3024
3025 virtual bool
3026 IRead(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3027 const size_t *count, // array of size GetDimensionCount()
3028 const GInt64 *arrayStep, // step in elements
3029 const GPtrDiff_t *bufferStride, // stride in elements
3030 const GDALExtendedDataType &bufferDataType,
3031 void *pDstBuffer) const = 0;
3032
3033 virtual bool
3034 IWrite(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3035 const size_t *count, // array of size GetDimensionCount()
3036 const GInt64 *arrayStep, // step in elements
3037 const GPtrDiff_t *bufferStride, // stride in elements
3038 const GDALExtendedDataType &bufferDataType, const void *pSrcBuffer);
3039
3040 void BaseRename(const std::string &osNewName);
3041
3042 virtual void NotifyChildrenOfRenaming()
3043 {
3044 }
3045
3046 virtual void NotifyChildrenOfDeletion()
3047 {
3048 }
3049
3051
3052 public:
3053 virtual ~GDALAbstractMDArray();
3054
3060 const std::string &GetName() const
3061 {
3062 return m_osName;
3063 }
3064
3070 const std::string &GetFullName() const
3071 {
3072 return m_osFullName;
3073 }
3074
3075 GUInt64 GetTotalElementsCount() const;
3076
3077 virtual size_t GetDimensionCount() const;
3078
3079 virtual const std::vector<std::shared_ptr<GDALDimension>> &
3080 GetDimensions() const = 0;
3081
3082 virtual const GDALExtendedDataType &GetDataType() const = 0;
3083
3084 virtual std::vector<GUInt64> GetBlockSize() const;
3085
3086 virtual std::vector<size_t>
3087 GetProcessingChunkSize(size_t nMaxChunkMemory) const;
3088
3089 /* clang-format off */
3105 typedef bool (*FuncProcessPerChunkType)(
3106 GDALAbstractMDArray *array,
3107 const GUInt64 *chunkArrayStartIdx,
3108 const size_t *chunkCount,
3109 GUInt64 iCurChunk,
3110 GUInt64 nChunkCount,
3111 void *pUserData);
3112 /* clang-format on */
3113
3114 virtual bool ProcessPerChunk(const GUInt64 *arrayStartIdx,
3115 const GUInt64 *count, const size_t *chunkSize,
3116 FuncProcessPerChunkType pfnFunc,
3117 void *pUserData);
3118
3119 virtual bool
3120 Read(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3121 const size_t *count, // array of size GetDimensionCount()
3122 const GInt64 *arrayStep, // step in elements
3123 const GPtrDiff_t *bufferStride, // stride in elements
3124 const GDALExtendedDataType &bufferDataType, void *pDstBuffer,
3125 const void *pDstBufferAllocStart = nullptr,
3126 size_t nDstBufferAllocSize = 0) const;
3127
3128 bool
3129 Write(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3130 const size_t *count, // array of size GetDimensionCount()
3131 const GInt64 *arrayStep, // step in elements
3132 const GPtrDiff_t *bufferStride, // stride in elements
3133 const GDALExtendedDataType &bufferDataType, const void *pSrcBuffer,
3134 const void *pSrcBufferAllocStart = nullptr,
3135 size_t nSrcBufferAllocSize = 0);
3136
3137 virtual bool Rename(const std::string &osNewName);
3138
3140 virtual void Deleted();
3141
3142 virtual void ParentDeleted();
3143
3144 virtual void ParentRenamed(const std::string &osNewParentFullName);
3146};
3147
3148/* ******************************************************************** */
3149/* GDALRawResult */
3150/* ******************************************************************** */
3151
3158class CPL_DLL GDALRawResult
3159{
3160 private:
3162 size_t m_nEltCount;
3163 size_t m_nSize;
3164 GByte *m_raw;
3165
3166 void FreeMe();
3167
3168 GDALRawResult(const GDALRawResult &) = delete;
3169 GDALRawResult &operator=(const GDALRawResult &) = delete;
3170
3171 protected:
3172 friend class GDALAttribute;
3174 GDALRawResult(GByte *raw, const GDALExtendedDataType &dt, size_t nEltCount);
3176
3177 public:
3180 GDALRawResult &operator=(GDALRawResult &&);
3181
3183 const GByte &operator[](size_t idx) const
3184 {
3185 return m_raw[idx];
3186 }
3187
3189 const GByte *data() const
3190 {
3191 return m_raw;
3192 }
3193
3195 size_t size() const
3196 {
3197 return m_nSize;
3198 }
3199
3201 GByte *StealData();
3203};
3204
3205/* ******************************************************************** */
3206/* GDALAttribute */
3207/* ******************************************************************** */
3208
3209/* clang-format off */
3221/* clang-format on */
3222
3223class CPL_DLL GDALAttribute : virtual public GDALAbstractMDArray
3224{
3225 mutable std::string m_osCachedVal{};
3226
3227 protected:
3229 GDALAttribute(const std::string &osParentName, const std::string &osName);
3231
3232 public:
3233 std::vector<GUInt64> GetDimensionsSize() const;
3234
3235 GDALRawResult ReadAsRaw() const;
3236 const char *ReadAsString() const;
3237 int ReadAsInt() const;
3238 int64_t ReadAsInt64() const;
3239 double ReadAsDouble() const;
3240 CPLStringList ReadAsStringArray() const;
3241 std::vector<int> ReadAsIntArray() const;
3242 std::vector<int64_t> ReadAsInt64Array() const;
3243 std::vector<double> ReadAsDoubleArray() const;
3244
3246 bool Write(const void *pabyValue, size_t nLen);
3247 bool Write(const char *);
3248 bool WriteInt(int);
3249 bool WriteInt64(int64_t);
3250 bool Write(double);
3251 bool Write(CSLConstList);
3252 bool Write(const int *, size_t);
3253 bool Write(const int64_t *, size_t);
3254 bool Write(const double *, size_t);
3255
3257 static constexpr GUInt64 COPY_COST = 100;
3259};
3260
3261/************************************************************************/
3262/* GDALAttributeString */
3263/************************************************************************/
3264
3266class CPL_DLL GDALAttributeString final : public GDALAttribute
3267{
3268 std::vector<std::shared_ptr<GDALDimension>> m_dims{};
3270 std::string m_osValue;
3271
3272 protected:
3273 bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
3274 const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
3275 void *pDstBuffer) const override;
3276
3277 public:
3278 GDALAttributeString(const std::string &osParentName,
3279 const std::string &osName, const std::string &osValue,
3281
3282 const std::vector<std::shared_ptr<GDALDimension>> &
3283 GetDimensions() const override;
3284
3285 const GDALExtendedDataType &GetDataType() const override;
3286};
3287
3289
3290/************************************************************************/
3291/* GDALAttributeNumeric */
3292/************************************************************************/
3293
3295class CPL_DLL GDALAttributeNumeric final : public GDALAttribute
3296{
3297 std::vector<std::shared_ptr<GDALDimension>> m_dims{};
3299 int m_nValue = 0;
3300 double m_dfValue = 0;
3301 std::vector<GUInt32> m_anValuesUInt32{};
3302
3303 protected:
3304 bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
3305 const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
3306 void *pDstBuffer) const override;
3307
3308 public:
3309 GDALAttributeNumeric(const std::string &osParentName,
3310 const std::string &osName, double dfValue);
3311 GDALAttributeNumeric(const std::string &osParentName,
3312 const std::string &osName, int nValue);
3313 GDALAttributeNumeric(const std::string &osParentName,
3314 const std::string &osName,
3315 const std::vector<GUInt32> &anValues);
3316
3317 const std::vector<std::shared_ptr<GDALDimension>> &
3318 GetDimensions() const override;
3319
3320 const GDALExtendedDataType &GetDataType() const override;
3321};
3322
3324
3325/* ******************************************************************** */
3326/* GDALMDArray */
3327/* ******************************************************************** */
3328
3329/* clang-format off */
3339/* clang-format on */
3340
3341class CPL_DLL GDALMDArray : virtual public GDALAbstractMDArray,
3342 public GDALIHasAttribute
3343{
3344 friend class GDALMDArrayResampled;
3345 std::shared_ptr<GDALMDArray>
3346 GetView(const std::vector<GUInt64> &indices) const;
3347
3348 inline std::shared_ptr<GDALMDArray>
3349 atInternal(const std::vector<GUInt64> &indices) const
3350 {
3351 return GetView(indices);
3352 }
3353
3354 template <typename... GUInt64VarArg>
3355 // cppcheck-suppress functionStatic
3356 inline std::shared_ptr<GDALMDArray>
3357 atInternal(std::vector<GUInt64> &indices, GUInt64 idx,
3358 GUInt64VarArg... tail) const
3359 {
3360 indices.push_back(idx);
3361 return atInternal(indices, tail...);
3362 }
3363
3364 // Used for example by GDALSubsetGroup to distinguish a derived group
3365 //from its original, without altering its name
3366 const std::string m_osContext{};
3367
3368 mutable bool m_bHasTriedCachedArray = false;
3369 mutable std::shared_ptr<GDALMDArray> m_poCachedArray{};
3370
3371 protected:
3373 GDALMDArray(const std::string &osParentName, const std::string &osName,
3374 const std::string &osContext = std::string());
3375
3376 virtual bool IAdviseRead(const GUInt64 *arrayStartIdx, const size_t *count,
3377 CSLConstList papszOptions) const;
3378
3379 virtual bool IsCacheable() const
3380 {
3381 return true;
3382 }
3383
3384 virtual bool SetStatistics(bool bApproxStats, double dfMin, double dfMax,
3385 double dfMean, double dfStdDev,
3386 GUInt64 nValidCount, CSLConstList papszOptions);
3387
3388 static std::string MassageName(const std::string &inputName);
3389
3390 std::shared_ptr<GDALGroup>
3391 GetCacheRootGroup(bool bCanCreate, std::string &osCacheFilenameOut) const;
3392
3393 // Returns if bufferStride values express a transposed view of the array
3394 bool IsTransposedRequest(const size_t *count,
3395 const GPtrDiff_t *bufferStride) const;
3396
3397 // Should only be called if IsTransposedRequest() returns true
3398 bool ReadForTransposedRequest(const GUInt64 *arrayStartIdx,
3399 const size_t *count, const GInt64 *arrayStep,
3400 const GPtrDiff_t *bufferStride,
3401 const GDALExtendedDataType &bufferDataType,
3402 void *pDstBuffer) const;
3403
3404 bool IsStepOneContiguousRowMajorOrderedSameDataType(
3405 const size_t *count, const GInt64 *arrayStep,
3406 const GPtrDiff_t *bufferStride,
3407 const GDALExtendedDataType &bufferDataType) const;
3408
3409 // Should only be called if IsStepOneContiguousRowMajorOrderedSameDataType()
3410 // returns false
3411 bool ReadUsingContiguousIRead(const GUInt64 *arrayStartIdx,
3412 const size_t *count, const GInt64 *arrayStep,
3413 const GPtrDiff_t *bufferStride,
3414 const GDALExtendedDataType &bufferDataType,
3415 void *pDstBuffer) const;
3416
3417 static std::shared_ptr<GDALMDArray>
3418 CreateGLTOrthorectified(const std::shared_ptr<GDALMDArray> &poParent,
3419 const std::shared_ptr<GDALMDArray> &poGLTX,
3420 const std::shared_ptr<GDALMDArray> &poGLTY,
3421 int nGLTIndexOffset,
3422 const std::vector<double> &adfGeoTransform);
3423
3425
3426 public:
3427 GUInt64 GetTotalCopyCost() const;
3428
3429 virtual bool CopyFrom(GDALDataset *poSrcDS, const GDALMDArray *poSrcArray,
3430 bool bStrict, GUInt64 &nCurCost,
3431 const GUInt64 nTotalCost,
3432 GDALProgressFunc pfnProgress, void *pProgressData);
3433
3435 virtual bool IsWritable() const = 0;
3436
3445 virtual const std::string &GetFilename() const = 0;
3446
3447 virtual CSLConstList GetStructuralInfo() const;
3448
3449 virtual const std::string &GetUnit() const;
3450
3451 virtual bool SetUnit(const std::string &osUnit);
3452
3453 virtual bool SetSpatialRef(const OGRSpatialReference *poSRS);
3454
3455 virtual std::shared_ptr<OGRSpatialReference> GetSpatialRef() const;
3456
3457 virtual const void *GetRawNoDataValue() const;
3458
3459 double GetNoDataValueAsDouble(bool *pbHasNoData = nullptr) const;
3460
3461 int64_t GetNoDataValueAsInt64(bool *pbHasNoData = nullptr) const;
3462
3463 uint64_t GetNoDataValueAsUInt64(bool *pbHasNoData = nullptr) const;
3464
3465 virtual bool SetRawNoDataValue(const void *pRawNoData);
3466
3468 bool SetNoDataValue(int nNoData)
3469 {
3470 return SetNoDataValue(static_cast<int64_t>(nNoData));
3471 }
3472
3474
3475 bool SetNoDataValue(double dfNoData);
3476
3477 bool SetNoDataValue(int64_t nNoData);
3478
3479 bool SetNoDataValue(uint64_t nNoData);
3480
3481 virtual bool Resize(const std::vector<GUInt64> &anNewDimSizes,
3482 CSLConstList papszOptions);
3483
3484 virtual double GetOffset(bool *pbHasOffset = nullptr,
3485 GDALDataType *peStorageType = nullptr) const;
3486
3487 virtual double GetScale(bool *pbHasScale = nullptr,
3488 GDALDataType *peStorageType = nullptr) const;
3489
3490 virtual bool SetOffset(double dfOffset,
3491 GDALDataType eStorageType = GDT_Unknown);
3492
3493 virtual bool SetScale(double dfScale,
3494 GDALDataType eStorageType = GDT_Unknown);
3495
3496 std::shared_ptr<GDALMDArray> GetView(const std::string &viewExpr) const;
3497
3498 std::shared_ptr<GDALMDArray> operator[](const std::string &fieldName) const;
3499
3509 // sphinx 4.1.0 / breathe 4.30.0 don't like typename...
3511 template <typename... GUInt64VarArg>
3513 // cppcheck-suppress functionStatic
3514 std::shared_ptr<GDALMDArray> at(GUInt64 idx, GUInt64VarArg... tail) const
3515 {
3516 std::vector<GUInt64> indices;
3517 indices.push_back(idx);
3518 return atInternal(indices, tail...);
3519 }
3520
3521 virtual std::shared_ptr<GDALMDArray>
3522 Transpose(const std::vector<int> &anMapNewAxisToOldAxis) const;
3523
3524 std::shared_ptr<GDALMDArray> GetUnscaled(
3525 double dfOverriddenScale = std::numeric_limits<double>::quiet_NaN(),
3526 double dfOverriddenOffset = std::numeric_limits<double>::quiet_NaN(),
3527 double dfOverriddenDstNodata =
3528 std::numeric_limits<double>::quiet_NaN()) const;
3529
3530 virtual std::shared_ptr<GDALMDArray>
3531 GetMask(CSLConstList papszOptions) const;
3532
3533 virtual std::shared_ptr<GDALMDArray>
3534 GetResampled(const std::vector<std::shared_ptr<GDALDimension>> &apoNewDims,
3535 GDALRIOResampleAlg resampleAlg,
3536 const OGRSpatialReference *poTargetSRS,
3537 CSLConstList papszOptions) const;
3538
3539 std::shared_ptr<GDALMDArray>
3540 GetGridded(const std::string &osGridOptions,
3541 const std::shared_ptr<GDALMDArray> &poXArray = nullptr,
3542 const std::shared_ptr<GDALMDArray> &poYArray = nullptr,
3543 CSLConstList papszOptions = nullptr) const;
3544
3545 virtual GDALDataset *
3546 AsClassicDataset(size_t iXDim, size_t iYDim,
3547 const std::shared_ptr<GDALGroup> &poRootGroup = nullptr,
3548 CSLConstList papszOptions = nullptr) const;
3549
3550 virtual CPLErr GetStatistics(bool bApproxOK, bool bForce, double *pdfMin,
3551 double *pdfMax, double *pdfMean,
3552 double *padfStdDev, GUInt64 *pnValidCount,
3553 GDALProgressFunc pfnProgress,
3554 void *pProgressData);
3555
3556 virtual bool ComputeStatistics(bool bApproxOK, double *pdfMin,
3557 double *pdfMax, double *pdfMean,
3558 double *pdfStdDev, GUInt64 *pnValidCount,
3559 GDALProgressFunc, void *pProgressData,
3560 CSLConstList papszOptions);
3561
3562 virtual void ClearStatistics();
3563
3564 virtual std::vector<std::shared_ptr<GDALMDArray>>
3565 GetCoordinateVariables() const;
3566
3567 bool AdviseRead(const GUInt64 *arrayStartIdx, const size_t *count,
3568 CSLConstList papszOptions = nullptr) const;
3569
3570 bool IsRegularlySpaced(double &dfStart, double &dfIncrement) const;
3571
3572 bool GuessGeoTransform(size_t nDimX, size_t nDimY, bool bPixelIsPoint,
3573 double adfGeoTransform[6]) const;
3574
3575 bool Cache(CSLConstList papszOptions = nullptr) const;
3576
3577 bool
3578 Read(const GUInt64 *arrayStartIdx, // array of size GetDimensionCount()
3579 const size_t *count, // array of size GetDimensionCount()
3580 const GInt64 *arrayStep, // step in elements
3581 const GPtrDiff_t *bufferStride, // stride in elements
3582 const GDALExtendedDataType &bufferDataType, void *pDstBuffer,
3583 const void *pDstBufferAllocStart = nullptr,
3584 size_t nDstBufferAllocSize = 0) const override final;
3585
3586 virtual std::shared_ptr<GDALGroup> GetRootGroup() const;
3587
3589 static constexpr GUInt64 COPY_COST = 1000;
3590
3591 bool CopyFromAllExceptValues(const GDALMDArray *poSrcArray, bool bStrict,
3592 GUInt64 &nCurCost, const GUInt64 nTotalCost,
3593 GDALProgressFunc pfnProgress,
3594 void *pProgressData);
3595
3596 struct Range
3597 {
3598 GUInt64 m_nStartIdx;
3599 GInt64 m_nIncr;
3600
3601 explicit Range(GUInt64 nStartIdx = 0, GInt64 nIncr = 0)
3602 : m_nStartIdx(nStartIdx), m_nIncr(nIncr)
3603 {
3604 }
3605 };
3606
3607 struct ViewSpec
3608 {
3609 std::string m_osFieldName{};
3610
3611 // or
3612
3613 std::vector<size_t>
3614 m_mapDimIdxToParentDimIdx{}; // of size m_dims.size()
3615 std::vector<Range>
3616 m_parentRanges{}; // of size m_poParent->GetDimensionCount()
3617 };
3618
3619 virtual std::shared_ptr<GDALMDArray>
3620 GetView(const std::string &viewExpr, bool bRenameDimensions,
3621 std::vector<ViewSpec> &viewSpecs) const;
3622
3623 const std::string &GetContext() const
3624 {
3625 return m_osContext;
3626 }
3627
3629};
3630
3632bool GDALMDRasterIOFromBand(GDALRasterBand *poBand, GDALRWFlag eRWFlag,
3633 size_t iDimX, size_t iDimY,
3634 const GUInt64 *arrayStartIdx, const size_t *count,
3635 const GInt64 *arrayStep,
3636 const GPtrDiff_t *bufferStride,
3637 const GDALExtendedDataType &bufferDataType,
3638 void *pBuffer);
3639
3641
3642/************************************************************************/
3643/* GDALMDArrayRegularlySpaced */
3644/************************************************************************/
3645
3647class CPL_DLL GDALMDArrayRegularlySpaced : public GDALMDArray
3648{
3649 double m_dfStart;
3650 double m_dfIncrement;
3651 double m_dfOffsetInIncrement;
3653 std::vector<std::shared_ptr<GDALDimension>> m_dims;
3654 std::vector<std::shared_ptr<GDALAttribute>> m_attributes{};
3655 std::string m_osEmptyFilename{};
3656
3657 protected:
3658 bool IRead(const GUInt64 *, const size_t *, const GInt64 *,
3659 const GPtrDiff_t *, const GDALExtendedDataType &bufferDataType,
3660 void *pDstBuffer) const override;
3661
3662 public:
3663 GDALMDArrayRegularlySpaced(const std::string &osParentName,
3664 const std::string &osName,
3665 const std::shared_ptr<GDALDimension> &poDim,
3666 double dfStart, double dfIncrement,
3667 double dfOffsetInIncrement);
3668
3669 static std::shared_ptr<GDALMDArrayRegularlySpaced>
3670 Create(const std::string &osParentName, const std::string &osName,
3671 const std::shared_ptr<GDALDimension> &poDim, double dfStart,
3672 double dfIncrement, double dfOffsetInIncrement);
3673
3674 bool IsWritable() const override
3675 {
3676 return false;
3677 }
3678
3679 const std::string &GetFilename() const override
3680 {
3681 return m_osEmptyFilename;
3682 }
3683
3684 const std::vector<std::shared_ptr<GDALDimension>> &
3685 GetDimensions() const override;
3686
3687 const GDALExtendedDataType &GetDataType() const override;
3688
3689 std::vector<std::shared_ptr<GDALAttribute>>
3690 GetAttributes(CSLConstList) const override;
3691
3692 void AddAttribute(const std::shared_ptr<GDALAttribute> &poAttr);
3693};
3694
3696
3697/* ******************************************************************** */
3698/* GDALDimension */
3699/* ******************************************************************** */
3700
3712class CPL_DLL GDALDimension
3713{
3714 public:
3716 GDALDimension(const std::string &osParentName, const std::string &osName,
3717 const std::string &osType, const std::string &osDirection,
3718 GUInt64 nSize);
3720
3721 virtual ~GDALDimension();
3722
3727 const std::string &GetName() const
3728 {
3729 return m_osName;
3730 }
3731
3736 const std::string &GetFullName() const
3737 {
3738 return m_osFullName;
3739 }
3740
3749 const std::string &GetType() const
3750 {
3751 return m_osType;
3752 }
3753
3762 const std::string &GetDirection() const
3763 {
3764 return m_osDirection;
3765 }
3766
3772 {
3773 return m_nSize;
3774 }
3775
3776 virtual std::shared_ptr<GDALMDArray> GetIndexingVariable() const;
3777
3778 virtual bool
3779 SetIndexingVariable(std::shared_ptr<GDALMDArray> poIndexingVariable);
3780
3781 virtual bool Rename(const std::string &osNewName);
3782
3784 virtual void ParentRenamed(const std::string &osNewParentFullName);
3785
3786 virtual void ParentDeleted();
3788
3789 protected:
3791 std::string m_osName;
3792 std::string m_osFullName;
3793 std::string m_osType;
3794 std::string m_osDirection;
3795 GUInt64 m_nSize;
3796
3797 void BaseRename(const std::string &osNewName);
3798
3800};
3801
3802/************************************************************************/
3803/* GDALDimensionWeakIndexingVar() */
3804/************************************************************************/
3805
3807class CPL_DLL GDALDimensionWeakIndexingVar : public GDALDimension
3808{
3809 std::weak_ptr<GDALMDArray> m_poIndexingVariable{};
3810
3811 public:
3812 GDALDimensionWeakIndexingVar(const std::string &osParentName,
3813 const std::string &osName,
3814 const std::string &osType,
3815 const std::string &osDirection, GUInt64 nSize);
3816
3817 std::shared_ptr<GDALMDArray> GetIndexingVariable() const override;
3818
3819 bool SetIndexingVariable(
3820 std::shared_ptr<GDALMDArray> poIndexingVariable) override;
3821
3822 void SetSize(GUInt64 nNewSize);
3823};
3825
3826/************************************************************************/
3827/* GDALAntiRecursionGuard */
3828/************************************************************************/
3829
3831struct GDALAntiRecursionStruct;
3832
3833class GDALAntiRecursionGuard
3834{
3835 GDALAntiRecursionStruct *m_psAntiRecursionStruct;
3836 std::string m_osIdentifier;
3837 int m_nDepth;
3838
3839 GDALAntiRecursionGuard(const GDALAntiRecursionGuard &) = delete;
3840 GDALAntiRecursionGuard &operator=(const GDALAntiRecursionGuard &) = delete;
3841
3842 public:
3843 explicit GDALAntiRecursionGuard(const std::string &osIdentifier);
3844 GDALAntiRecursionGuard(const GDALAntiRecursionGuard &other,
3845 const std::string &osIdentifier);
3846 ~GDALAntiRecursionGuard();
3847
3848 int GetCallDepth() const
3849 {
3850 return m_nDepth;
3851 }
3852};
3853
3855
3856/************************************************************************/
3857/* Relationships */
3858/************************************************************************/
3859
3871class CPL_DLL GDALRelationship
3872{
3873 protected:
3875 std::string m_osName{};
3876 std::string m_osLeftTableName{};
3877 std::string m_osRightTableName{};
3878 GDALRelationshipCardinality m_eCardinality =
3880 std::string m_osMappingTableName{};
3881 std::vector<std::string> m_osListLeftTableFields{};
3882 std::vector<std::string> m_osListRightTableFields{};
3883 std::vector<std::string> m_osListLeftMappingTableFields{};
3884 std::vector<std::string> m_osListRightMappingTableFields{};
3886 std::string m_osForwardPathLabel{};
3887 std::string m_osBackwardPathLabel{};
3888 std::string m_osRelatedTableType{};
3889
3892 public:
3900 GDALRelationship(const std::string &osName,
3901 const std::string &osLeftTableName,
3902 const std::string &osRightTableName,
3903 GDALRelationshipCardinality eCardinality =
3905 : m_osName(osName), m_osLeftTableName(osLeftTableName),
3906 m_osRightTableName(osRightTableName), m_eCardinality(eCardinality)
3907 {
3908 }
3909
3911 const std::string &GetName() const
3912 {
3913 return m_osName;
3914 }
3915
3918 {
3919 return m_eCardinality;
3920 }
3921
3926 const std::string &GetLeftTableName() const
3927 {
3928 return m_osLeftTableName;
3929 }
3930
3933 const std::string &GetRightTableName() const
3934 {
3935 return m_osRightTableName;
3936 }
3937
3942 const std::string &GetMappingTableName() const
3943 {
3944 return m_osMappingTableName;
3945 }
3946
3951 void SetMappingTableName(const std::string &osName)
3952 {
3953 m_osMappingTableName = osName;
3954 }
3955
3962 const std::vector<std::string> &GetLeftTableFields() const
3963 {
3964 return m_osListLeftTableFields;
3965 }
3966
3973 const std::vector<std::string> &GetRightTableFields() const
3974 {
3975 return m_osListRightTableFields;
3976 }
3977
3984 void SetLeftTableFields(const std::vector<std::string> &osListFields)
3985 {
3986 m_osListLeftTableFields = osListFields;
3987 }
3988
3995 void SetRightTableFields(const std::vector<std::string> &osListFields)
3996 {
3997 m_osListRightTableFields = osListFields;
3998 }
3999
4006 const std::vector<std::string> &GetLeftMappingTableFields() const
4007 {
4008 return m_osListLeftMappingTableFields;
4009 }
4010
4017 const std::vector<std::string> &GetRightMappingTableFields() const
4018 {
4019 return m_osListRightMappingTableFields;
4020 }
4021
4028 void SetLeftMappingTableFields(const std::vector<std::string> &osListFields)
4029 {
4030 m_osListLeftMappingTableFields = osListFields;
4031 }
4032
4039 void
4040 SetRightMappingTableFields(const std::vector<std::string> &osListFields)
4041 {
4042 m_osListRightMappingTableFields = osListFields;
4043 }
4044
4050 {
4051 return m_eType;
4052 }
4053
4059 {
4060 m_eType = eType;
4061 }
4062
4078 const std::string &GetForwardPathLabel() const
4079 {
4080 return m_osForwardPathLabel;
4081 }
4082
4098 void SetForwardPathLabel(const std::string &osLabel)
4099 {
4100 m_osForwardPathLabel = osLabel;
4101 }
4102
4118 const std::string &GetBackwardPathLabel() const
4119 {
4120 return m_osBackwardPathLabel;
4121 }
4122
4138 void SetBackwardPathLabel(const std::string &osLabel)
4139 {
4140 m_osBackwardPathLabel = osLabel;
4141 }
4142
4153 const std::string &GetRelatedTableType() const
4154 {
4155 return m_osRelatedTableType;
4156 }
4157
4168 void SetRelatedTableType(const std::string &osType)
4169 {
4170 m_osRelatedTableType = osType;
4171 }
4172
4175 static inline GDALRelationshipH ToHandle(GDALRelationship *poRelationship)
4176 {
4177 return static_cast<GDALRelationshipH>(poRelationship);
4178 }
4179
4182 static inline GDALRelationship *FromHandle(GDALRelationshipH hRelationship)
4183 {
4184 return static_cast<GDALRelationship *>(hRelationship);
4185 }
4186};
4187
4188/* ==================================================================== */
4189/* An assortment of overview related stuff. */
4190/* ==================================================================== */
4191
4193/* Only exported for drivers as plugin. Signature may change */
4194CPLErr CPL_DLL GDALRegenerateOverviewsMultiBand(
4195 int nBands, GDALRasterBand *const *papoSrcBands, int nOverviews,
4196 GDALRasterBand *const *const *papapoOverviewBands,
4197 const char *pszResampling, GDALProgressFunc pfnProgress,
4198 void *pProgressData, CSLConstList papszOptions);
4199
4200CPLErr CPL_DLL GDALRegenerateOverviewsMultiBand(
4201 const std::vector<GDALRasterBand *> &apoSrcBands,
4202 // First level of array is indexed by band (thus aapoOverviewBands.size() must be equal to apoSrcBands.size())
4203 // Second level is indexed by overview
4204 const std::vector<std::vector<GDALRasterBand *>> &aapoOverviewBands,
4205 const char *pszResampling, GDALProgressFunc pfnProgress,
4206 void *pProgressData, CSLConstList papszOptions);
4207
4208typedef CPLErr (*GDALResampleFunction)(
4209 double dfXRatioDstToSrc, double dfYRatioDstToSrc, double dfSrcXDelta,
4210 double dfSrcYDelta, GDALDataType eWrkDataType, const void *pChunk,
4211 const GByte *pabyChunkNodataMask, int nChunkXOff, int nChunkXSize,
4212 int nChunkYOff, int nChunkYSize, int nDstXOff, int nDstXOff2, int nDstYOff,
4213 int nDstYOff2, GDALRasterBand *poOverview, void **ppDstBuffer,
4214 GDALDataType *peDstBufferDataType, const char *pszResampling,
4215 bool bHasNoData, double dfNoDataValue, GDALColorTable *poColorTable,
4216 GDALDataType eSrcDataType, bool bPropagateNoData);
4217
4218GDALResampleFunction GDALGetResampleFunction(const char *pszResampling,
4219 int *pnRadius);
4220
4221std::string CPL_DLL GDALGetNormalizedOvrResampling(const char *pszResampling);
4222
4223GDALDataType GDALGetOvrWorkDataType(const char *pszResampling,
4224 GDALDataType eSrcDataType);
4225
4227
4228CPLErr CPL_DLL
4229HFAAuxBuildOverviews(const char *pszOvrFilename, GDALDataset *poParentDS,
4230 GDALDataset **ppoDS, int nBands, const int *panBandList,
4231 int nNewOverviews, const int *panNewOverviewList,
4232 const char *pszResampling, GDALProgressFunc pfnProgress,
4233 void *pProgressData, CSLConstList papszOptions);
4234
4235CPLErr CPL_DLL GTIFFBuildOverviews(const char *pszFilename, int nBands,
4236 GDALRasterBand *const *papoBandList,
4237 int nOverviews, const int *panOverviewList,
4238 const char *pszResampling,
4239 GDALProgressFunc pfnProgress,
4240 void *pProgressData,
4241 CSLConstList papszOptions);
4242
4243int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand *poBand, int &nXOff,
4244 int &nYOff, int &nXSize, int &nYSize,
4245 int nBufXSize, int nBufYSize)
4246 CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead");
4247int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand *poBand, int &nXOff,
4248 int &nYOff, int &nXSize, int &nYSize,
4249 int nBufXSize, int nBufYSize,
4250 GDALRasterIOExtraArg *psExtraArg);
4251
4252int CPL_DLL GDALOvLevelAdjust(int nOvLevel, int nXSize)
4253 CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead");
4254int CPL_DLL GDALOvLevelAdjust2(int nOvLevel, int nXSize, int nYSize);
4255int CPL_DLL GDALComputeOvFactor(int nOvrXSize, int nRasterXSize, int nOvrYSize,
4256 int nRasterYSize);
4257
4258GDALDataset CPL_DLL *GDALFindAssociatedAuxFile(const char *pszBasefile,
4259 GDALAccess eAccess,
4260 GDALDataset *poDependentDS);
4261
4262/* ==================================================================== */
4263/* Infrastructure to check that dataset characteristics are valid */
4264/* ==================================================================== */
4265
4266int CPL_DLL GDALCheckDatasetDimensions(int nXSize, int nYSize);
4267int CPL_DLL GDALCheckBandCount(int nBands, int bIsZeroAllowed);
4268
4269/* Internal use only */
4270
4271/* CPL_DLL exported, but only for in-tree drivers that can be built as plugins
4272 */
4273int CPL_DLL GDALReadWorldFile2(const char *pszBaseFilename,
4274 const char *pszExtension,
4275 double *padfGeoTransform,
4276 char **papszSiblingFiles,
4277 char **ppszWorldFileNameOut);
4278int CPL_DLL GDALReadTabFile2(const char *pszBaseFilename,
4279 double *padfGeoTransform, char **ppszWKT,
4280 int *pnGCPCount, GDAL_GCP **ppasGCPs,
4281 char **papszSiblingFiles,
4282 char **ppszTabFileNameOut);
4283
4284void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg *psDestArg,
4285 GDALRasterIOExtraArg *psSrcArg);
4286
4288
4289void GDALNullifyOpenDatasetsList();
4290CPLMutex **GDALGetphDMMutex();
4291CPLMutex **GDALGetphDLMutex();
4292void GDALNullifyProxyPoolSingleton();
4293void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
4294GIntBig GDALGetResponsiblePIDForCurrentThread();
4295
4296CPLString GDALFindAssociatedFile(const char *pszBasename, const char *pszExt,
4297 CSLConstList papszSiblingFiles, int nFlags);
4298
4299CPLErr CPL_DLL EXIFExtractMetadata(char **&papszMetadata, void *fpL,
4300 int nOffset, int bSwabflag, int nTIFFHEADER,
4301 int &nExifOffset, int &nInterOffset,
4302 int &nGPSOffset);
4303
4304int GDALValidateOpenOptions(GDALDriverH hDriver,
4305 const char *const *papszOptionOptions);
4306int GDALValidateOptions(const char *pszOptionList,
4307 const char *const *papszOptionsToValidate,
4308 const char *pszErrorMessageOptionType,
4309 const char *pszErrorMessageContainerName);
4310
4311GDALRIOResampleAlg GDALRasterIOGetResampleAlg(const char *pszResampling);
4312const char *GDALRasterIOGetResampleAlg(GDALRIOResampleAlg eResampleAlg);
4313
4314void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg *psExtraArg,
4315 int nXSize, int nYSize, int nBufXSize,
4316 int nBufYSize);
4317
4318GDALDataset *GDALCreateOverviewDataset(GDALDataset *poDS, int nOvrLevel,
4319 bool bThisLevelOnly);
4320
4321// Should cover particular cases of #3573, #4183, #4506, #6578
4322// Behavior is undefined if fVal1 or fVal2 are NaN (should be tested before
4323// calling this function)
4324template <class T> inline bool ARE_REAL_EQUAL(T fVal1, T fVal2, int ulp = 2)
4325{
4326 return fVal1 == fVal2 || /* Should cover infinity */
4327 std::abs(fVal1 - fVal2) < std::numeric_limits<float>::epsilon() *
4328 std::abs(fVal1 + fVal2) * ulp;
4329}
4330
4331double GDALAdjustNoDataCloseToFloatMax(double dfVal);
4332
4333#define DIV_ROUND_UP(a, b) (((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1))
4334
4335// Number of data samples that will be used to compute approximate statistics
4336// (minimum value, maximum value, etc.)
4337#define GDALSTAT_APPROX_NUMSAMPLES 2500
4338
4339void GDALSerializeGCPListToXML(CPLXMLNode *psParentNode,
4340 const std::vector<gdal::GCP> &asGCPs,
4341 const OGRSpatialReference *poGCP_SRS);
4342void GDALDeserializeGCPListFromXML(const CPLXMLNode *psGCPList,
4343 std::vector<gdal::GCP> &asGCPs,
4344 OGRSpatialReference **ppoGCP_SRS);
4345
4346void GDALSerializeOpenOptionsToXML(CPLXMLNode *psParentNode,
4347 char **papszOpenOptions);
4348char **GDALDeserializeOpenOptionsFromXML(const CPLXMLNode *psParentNode);
4349
4350int GDALCanFileAcceptSidecarFile(const char *pszFilename);
4351
4352bool GDALCanReliablyUseSiblingFileList(const char *pszFilename);
4353
4354typedef enum
4355{
4356 GSF_UNSIGNED_INT,
4357 GSF_SIGNED_INT,
4358 GSF_FLOATING_POINT,
4359} GDALBufferSampleFormat;
4360
4361bool CPL_DLL GDALBufferHasOnlyNoData(const void *pBuffer, double dfNoDataValue,
4362 size_t nWidth, size_t nHeight,
4363 size_t nLineStride, size_t nComponents,
4364 int nBitsPerSample,
4365 GDALBufferSampleFormat nSampleFormat);
4366
4367void CPL_DLL GDALCopyNoDataValue(GDALRasterBand *poDstBand,
4368 GDALRasterBand *poSrcBand);
4369
4370double CPL_DLL GDALGetNoDataValueCastToDouble(int64_t nVal);
4371double CPL_DLL GDALGetNoDataValueCastToDouble(uint64_t nVal);
4372
4373// Remove me in GDAL 4.0. See GetMetadataItem() implementation
4374// Internal use in GDAL only !
4375// Declaration copied in swig/include/gdal.i
4376void CPL_DLL GDALEnablePixelTypeSignedByteWarning(GDALRasterBandH hBand,
4377 bool b);
4378
4379std::string CPL_DLL GDALGetCompressionFormatForJPEG(VSILFILE *fp);
4380std::string CPL_DLL GDALGetCompressionFormatForJPEG(const void *pBuffer,
4381 size_t nBufferSize);
4382
4384 GDALRATTableType eTableType,
4385 const std::vector<std::shared_ptr<GDALMDArray>> &apoArrays,
4386 const std::vector<GDALRATFieldUsage> &aeUsages);
4387
4388// Macro used so that Identify and driver metadata methods in drivers built
4389// as plugin can be duplicated in libgdal core and in the driver under different
4390// names
4391#ifdef PLUGIN_FILENAME
4392#define PLUGIN_SYMBOL_NAME(x) GDAL_core_##x
4393#else
4394#define PLUGIN_SYMBOL_NAME(x) GDAL_driver_##x
4395#endif
4396
4398
4399#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:2993
const std::string & GetFullName() const
Return the name of an array or attribute.
Definition gdal_priv.h:3070
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:3060
bool Write(const GUInt64 *arrayStartIdx, const size_t *count, const GInt64 *arrayStep, const GPtrDiff_t *bufferStride, const GDALExtendedDataType &bufferDataType, const void *pSrcBuffer, const void *pSrcBufferAllocStart=nullptr, size_t nSrcBufferAllocSize=0)
Write part or totality of a multidimensional array or attribute.
Definition gdalmultidim.cpp:2245
Class used as a session object for asynchronous requests.
Definition gdal_priv.h:2429
int GetXOffset() const
Return x offset.
Definition gdal_priv.h:2466
int GetYOffset() const
Return y offset.
Definition gdal_priv.h:2474
int GetYSize() const
Return height.
Definition gdal_priv.h:2490
int GetBandCount() const
Return band count.
Definition gdal_priv.h:2530
GDALDataType GetBufferType() const
Return buffer data type.
Definition gdal_priv.h:2522
int GetBandSpace() const
Return band spacing.
Definition gdal_priv.h:2562
int GetBufferYSize() const
Return buffer height.
Definition gdal_priv.h:2514
int GetXSize() const
Return width.
Definition gdal_priv.h:2482
virtual GDALAsyncStatusType GetNextUpdatedRegion(double dfTimeout, int *pnBufXOff, int *pnBufYOff, int *pnBufXSize, int *pnBufYSize)=0
= 0;
void * GetBuffer()
Return buffer.
Definition gdal_priv.h:2498
int GetPixelSpace() const
Return pixel spacing.
Definition gdal_priv.h:2546
int * GetBandMap()
Return band map.
Definition gdal_priv.h:2538
GDALDataset * GetGDALDataset()
Return dataset.
Definition gdal_priv.h:2458
int GetLineSpace() const
Return line spacing.
Definition gdal_priv.h:2554
int GetBufferXSize() const
Return buffer width.
Definition gdal_priv.h:2506
Class modeling an attribute that has a name, a value and a type, and is typically used to describe a ...
Definition gdal_priv.h:3224
A color table / palette.
Definition gdal_priv.h:1346
static GDALColorTableH ToHandle(GDALColorTable *poCT)
Convert a GDALColorTable* to a GDALRasterBandH.
Definition gdal_priv.h:1371
~GDALColorTable()
Destructor.
static GDALColorTable * FromHandle(GDALColorTableH hCT)
Convert a GDALColorTableH to a GDALColorTable*.
Definition gdal_priv.h:1379
Class returned by GetBands() that act as a container for raster bands.
Definition gdal_priv.h:661
Class returned by GetFeatures() that act as a container for vector features.
Definition gdal_priv.h:1006
Layer iterator.
Definition gdal_priv.h:952
void pointer
pointer
Definition gdal_priv.h:960
void difference_type
difference_type
Definition gdal_priv.h:959
std::input_iterator_tag iterator_category
iterator_category
Definition gdal_priv.h:962
Class returned by GetLayers() that acts as a range of layers.
Definition gdal_priv.h:938
A set of associated raster bands, usually from one file.
Definition gdal_priv.h:501
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:890
bool IsMarkedSuppressOnClose()
Return MarkSuppressOnClose flag.
Definition gdal_priv.h:820
OGRErr Release()
Drop a reference to this dataset, and if the reference count drops to one close (destroy) the dataset...
Definition gdaldataset.cpp:5515
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
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:828
static GDALDataset * FromHandle(GDALDatasetH hDS)
Convert a GDALDatasetH to a GDALDataset*.
Definition gdal_priv.h:882
static GDALDatasetH ToHandle(GDALDataset *poDS)
Convert a GDALDataset* to a GDALDatasetH.
Definition gdal_priv.h:874
GDALAccess GetAccess() const
Return access mode.
Definition gdal_priv.h:806
Class modeling a a dimension / axis used to index multidimensional arrays.
Definition gdal_priv.h:3713
const std::string & GetName() const
Return the name.
Definition gdal_priv.h:3727
const std::string & GetDirection() const
Return the axis direction.
Definition gdal_priv.h:3762
const std::string & GetFullName() const
Return the full name.
Definition gdal_priv.h:3736
GUInt64 GetSize() const
Return the size, that is the number of values along the dimension.
Definition gdal_priv.h:3771
const std::string & GetType() const
Return the axis type.
Definition gdal_priv.h:3749
Class for managing the registration of file format drivers.
Definition gdal_priv.h:2344
Format specific driver.
Definition gdal_priv.h:1999
static GDALDriver * FromHandle(GDALDriverH hDriver)
Convert a GDALDriverH to a GDALDriver*.
Definition gdal_priv.h:2223
static GDALDriverH ToHandle(GDALDriver *poDriver)
Convert a GDALDriver* to a GDALDriverH.
Definition gdal_priv.h:2215
Class for a component of a compound extended data type.
Definition gdal_priv.h:2731
const GDALExtendedDataType & GetType() const
Return the data type of the component.
Definition gdal_priv.h:2762
size_t GetOffset() const
Return the offset (in bytes) of the component in the compound data type.
Definition gdal_priv.h:2753
const std::string & GetName() const
Return the name.
Definition gdal_priv.h:2744
GDALEDTComponent(const GDALEDTComponent &)
Copy constructor.
Class used to represent potentially complex data types.
Definition gdal_priv.h:2595
bool operator!=(const GDALExtendedDataType &other) const
Non-equality operator.
Definition gdal_priv.h:2615
GDALExtendedDataTypeSubType GetSubType() const
Return subtype.
Definition gdal_priv.h:2654
size_t GetSize() const
Return data type size in bytes.
Definition gdal_priv.h:2675
size_t GetMaxStringLength() const
Return the maximum length of a string in bytes.
Definition gdal_priv.h:2684
static GDALExtendedDataType Create(GDALDataType eType)
Return a new GDALExtendedDataType of class GEDTC_NUMERIC.
Definition gdalmultidim.cpp:10035
static GDALExtendedDataType CreateString(size_t nMaxStringLength=0, GDALExtendedDataTypeSubType eSubType=GEDTST_NONE)
Return a new GDALExtendedDataType of class GEDTC_STRING.
Definition gdalmultidim.cpp:10100
GDALDataType GetNumericDataType() const
Return numeric data type (only valid when GetClass() == GEDTC_NUMERIC)
Definition gdal_priv.h:2643
GDALExtendedDataTypeClass GetClass() const
Return type class.
Definition gdal_priv.h:2633
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:2664
const std::string & GetName() const
Return type name.
Definition gdal_priv.h:2624
Class modeling a named container of GDALAttribute, GDALMDArray, OGRLayer or other GDALGroup.
Definition gdal_priv.h:2824
const std::string & GetName() const
Return the name of the group.
Definition gdal_priv.h:2875
const std::string & GetFullName() const
Return the full name of the group.
Definition gdal_priv.h:2884
Interface used to get a single GDALAttribute or a set of GDALAttribute.
Definition gdal_priv.h:2783
Class modeling a multi-dimensional array.
Definition gdal_priv.h:3343
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:3514
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:301
int bStatOK
Whether stat()'ing the file was successful.
Definition gdal_priv.h:322
GByte * pabyHeader
Buffer with first bytes of the file.
Definition gdal_priv.h:332
int bIsDirectory
Whether the file is a directory.
Definition gdal_priv.h:324
char ** papszOpenOptions
Open options.
Definition gdal_priv.h:314
GDALAccess eAccess
Access flag.
Definition gdal_priv.h:317
int nOpenFlags
Open flags.
Definition gdal_priv.h:319
VSILFILE * fpL
Pointer to the file.
Definition gdal_priv.h:327
char * pszFilename
Filename.
Definition gdal_priv.h:312
int nHeaderBytes
Number of bytes in pabyHeader.
Definition gdal_priv.h:330
const char *const * papszAllowedDrivers
Allowed drivers (NULL for all)
Definition gdal_priv.h:335
Proxy for a plugin driver.
Definition gdal_priv.h:2277
const char * GetMetadataItem(const char *pszName, const char *pszDomain="") override
Fetch single metadata item.
Definition gdaldrivermanager.cpp:1303
char ** GetMetadata(const char *pszDomain) override
Fetch metadata.
Definition gdaldrivermanager.cpp:1260
const std::string & GetPluginFileName() const
Return the plugin file name (not a full path)
Definition gdal_priv.h:2302
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain="") override
Set single metadata item.
Definition gdaldrivermanager.cpp:1268
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition gdal_rat.h:48
A single raster band (or channel).
Definition gdal_priv.h:1502
void static GDALRasterBandH ToHandle(GDALRasterBand *poBand)
Convert a GDALRasterBand* to a GDALRasterBandH.
Definition gdal_priv.h:1806
virtual bool IsMaskBand() const
Returns whether a band is a mask band.
Definition gdalrasterband.cpp:7625
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:1814
A single raster block in the block cache.
Definition gdal_priv.h:1188
int GetDirty() const
Return the dirty flag.
Definition gdal_priv.h:1285
GDALRasterBand * GetBand()
Accessor to source GDALRasterBand object.
Definition gdal_priv.h:1312
int GetXSize() const
Return the width of the block.
Definition gdal_priv.h:1269
GPtrDiff_t GetBlockSize() const
Return the block size in bytes.
Definition gdal_priv.h:1301
int GetYSize() const
Return the height of the block.
Definition gdal_priv.h:1277
GDALDataType GetDataType() const
Return the data type.
Definition gdal_priv.h:1245
int GetXOff() const
Return the x offset of the top-left corner of the block.
Definition gdal_priv.h:1253
int AddLock(void)
Increment the lock count.
Definition gdal_priv.h:1227
void * GetDataRef(void)
Return the data buffer.
Definition gdal_priv.h:1293
int GetYOff() const
Return the y offset of the top-left corner of the block.
Definition gdal_priv.h:1261
int DropLock(void)
Decrement the lock count.
Definition gdal_priv.h:1233
Store the raw result of an attribute value, which might contain dynamically allocated structures (lik...
Definition gdal_priv.h:3159
size_t size() const
Return the size in bytes of the raw result.
Definition gdal_priv.h:3195
const GByte * data() const
Return pointer to the start of data.
Definition gdal_priv.h:3189
const GByte & operator[](size_t idx) const
Return byte at specified index.
Definition gdal_priv.h:3183
Definition of a table relationship.
Definition gdal_priv.h:3872
const std::string & GetName() const
Get the name of the relationship.
Definition gdal_priv.h:3911
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:4006
void SetType(GDALRelationshipType eType)
Sets the type of the relationship.
Definition gdal_priv.h:4058
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:4028
void SetMappingTableName(const std::string &osName)
Sets the name of the mapping table for many-to-many relationships.
Definition gdal_priv.h:3951
static GDALRelationshipH ToHandle(GDALRelationship *poRelationship)
Convert a GDALRelationship* to a GDALRelationshipH.
Definition gdal_priv.h:4175
const std::string & GetForwardPathLabel() const
Get the label of the forward path for the relationship.
Definition gdal_priv.h:4078
const std::string & GetLeftTableName() const
Get the name of the left (or base/origin) table in the relationship.
Definition gdal_priv.h:3926
const std::string & GetBackwardPathLabel() const
Get the label of the backward path for the relationship.
Definition gdal_priv.h:4118
const std::string & GetRelatedTableType() const
Get the type string of the related table.
Definition gdal_priv.h:4153
const std::string & GetMappingTableName() const
Get the name of the mapping table for many-to-many relationships.
Definition gdal_priv.h:3942
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:3984
GDALRelationshipCardinality GetCardinality() const
Get the cardinality of the relationship.
Definition gdal_priv.h:3917
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:3995
void SetForwardPathLabel(const std::string &osLabel)
Sets the label of the forward path for the relationship.
Definition gdal_priv.h:4098
void SetBackwardPathLabel(const std::string &osLabel)
Sets the label of the backward path for the relationship.
Definition gdal_priv.h:4138
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:3973
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:4040
static GDALRelationship * FromHandle(GDALRelationshipH hRelationship)
Convert a GDALRelationshipH to a GDALRelationship*.
Definition gdal_priv.h:4182
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:4017
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:3900
GDALRelationshipType GetType() const
Get the type of the relationship.
Definition gdal_priv.h:4049
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:3962
const std::string & GetRightTableName() const
Get the name of the right (or related/destination) table in the relationship.
Definition gdal_priv.h:3933
void SetRelatedTableType(const std::string &osType)
Sets the type string of the related table.
Definition gdal_priv.h:4168
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:1183
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition cpl_port.h:238
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition cpl_port.h:976
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:185
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:215
Various convenience functions for working with strings and string lists.
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition cpl_virtualmem.h:62
Standard C Covers.
GUIntBig vsi_l_offset
Type for a file offset.
Definition cpl_vsi.h:146
Public (C callable) GDAL entry points.
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition gdal.h:315
void(* GDALQueryLoggerFunc)(const char *pszSQL, const char *pszError, int64_t lNumRecords, int64_t lExecutionTimeMilliseconds, void *pQueryLoggerArg)
Type of functions to pass to GDALDatasetSetQueryLoggerFunc.
Definition gdal.h:1309
GDALRATTableType
RAT table type (thematic or athematic)
Definition gdal.h:2028
GDALAccess
Definition gdal.h:125
@ GA_ReadOnly
Definition gdal.h:126
GDALPaletteInterp
Definition gdal.h:253
@ GPI_RGB
Definition gdal.h:255
GDALDataType
Definition gdal.h:64
@ GDT_Byte
Definition gdal.h:66
@ GDT_Float64
Definition gdal.h:75
@ GDT_Unknown
Definition gdal.h:65
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition gdal.h:291
GDALRasterAttributeTableH GDALCreateRasterAttributeTableFromMDArrays(GDALRATTableType eTableType, int nArrays, const GDALMDArrayH *ahArrays, const GDALRATFieldUsage *paeUsages)
Return a virtual Raster Attribute Table from several GDALMDArray's.
Definition gdalmultidim_rat.cpp:429
GDALExtendedDataTypeClass
Enumeration giving the class of a GDALExtendedDataType.
Definition gdal.h:321
@ GEDTC_NUMERIC
Numeric value.
Definition gdal.h:323
GDALRelationshipCardinality
Cardinality of relationship.
Definition gdal.h:2114
@ GRC_ONE_TO_MANY
One-to-many.
Definition gdal.h:2118
GDALRIOResampleAlg
RasterIO() resampling method.
Definition gdal.h:143
CPLErr GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition gdaldataset.cpp:4119
void * GDALRelationshipH
Opaque type used for the C bindings of the C++ GDALRelationship class.
Definition gdal.h:312
int GDALGetDataTypeSizeBytes(GDALDataType)
Get data type size in bytes.
Definition gdal_misc.cpp:337
GDALDatasetH GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags, const char *const *papszAllowedDrivers, const char *const *papszOpenOptions, const char *const *papszSiblingFiles)
Open a raster or vector file as a GDALDataset.
Definition gdaldataset.cpp:3569
GDALExtendedDataTypeSubType
Enumeration giving the subtype of a GDALExtendedDataType.
Definition gdal.h:334
@ GEDTST_NONE
None.
Definition gdal.h:336
void * GDALMajorObjectH
Opaque type used for the C bindings of the C++ GDALMajorObject class.
Definition gdal.h:288
GDALColorInterp
Definition gdal.h:227
GDALRelationshipType
Type of relationship.
Definition gdal.h:2130
@ GRT_ASSOCIATION
Association relationship.
Definition gdal.h:2134
GDALAsyncStatusType
status of the asynchronous stream
Definition gdal.h:111
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition gdal.h:297
GDALRWFlag
Definition gdal.h:132
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition gdal.h:294
void * GDALColorTableH
Opaque type used for the C bindings of the C++ GDALColorTable class.
Definition gdal.h:300
std::unique_ptr< GDALDataset, GDALDatasetUniquePtrDeleter > GDALDatasetUniquePtr
Unique pointer type for GDALDataset.
Definition gdal_priv.h:1177
constexpr GDALSuggestedBlockAccessPattern GSBAP_UNKNOWN
Unknown, or no particular read order is suggested.
Definition gdal_priv.h:1484
int GDALSuggestedBlockAccessPattern
Suggested/most efficient access pattern to blocks.
Definition gdal_priv.h:1481
constexpr GDALSuggestedBlockAccessPattern GSBAP_RANDOM
Random access to blocks is efficient.
Definition gdal_priv.h:1487
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:1473
@ GMVR_0_AND_1_ONLY
Definition gdal_priv.h:1476
@ GMVR_0_AND_255_ONLY
Definition gdal_priv.h:1477
constexpr GDALSuggestedBlockAccessPattern GSBAP_TOP_TO_BOTTOM
Reading by strips from top to bottom is the most efficient.
Definition gdal_priv.h:1490
GDALIdentifyEnum
Enumeration used by GDALDriver::pfnIdentify().
Definition gdal_priv.h:1973
@ GDAL_IDENTIFY_TRUE
Identify determined the file is recognized by the probed driver.
Definition gdal_priv.h:1980
@ GDAL_IDENTIFY_FALSE
Identify determined the file is not recognized by the probed driver.
Definition gdal_priv.h:1978
@ GDAL_IDENTIFY_UNKNOWN
Identify could not determine if the file is recognized or not by the probed driver.
Definition gdal_priv.h:1976
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:1497
constexpr GDALSuggestedBlockAccessPattern GSBAP_BOTTOM_TO_TOP
Reading by strips from bottom to top is the most efficient.
Definition gdal_priv.h:1493
Core portability services for cross-platform OGR code.
OGRwkbGeometryType
List of well known binary geometry types.
Definition ogr_core.h:416
@ wkbUnknown
unknown type, non-standard
Definition ogr_core.h:417
int OGRErr
Type for a OGR error.
Definition ogr_core.h:387
Simple feature classes.
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition ogr_feature.h:1570
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition ogrsf_frmts.h:434
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition ogrsf_frmts.h:442
Document node structure.
Definition cpl_minixml.h:71
Color tuple.
Definition gdal.h:1955
Object returned by GetFeatures() iterators.
Definition gdal_priv.h:903
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