GDAL
gdal_priv.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: gdal_priv.h f02356245e81e2f9d95069b6d126219d1d85736b 2020-10-13 23:40:17 +0200 Even Rouault $
3  *
4  * Name: gdal_priv.h
5  * Project: GDAL Core
6  * Purpose: GDAL Core C++/Private declarations.
7  * Author: Frank Warmerdam, warmerdam@pobox.com
8  *
9  ******************************************************************************
10  * Copyright (c) 1998, Frank Warmerdam
11  * Copyright (c) 2007-2014, Even Rouault <even dot rouault at spatialys.com>
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a
14  * copy of this software and associated documentation files (the "Software"),
15  * to deal in the Software without restriction, including without limitation
16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  * and/or sell copies of the Software, and to permit persons to whom the
18  * Software is furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included
21  * in all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29  * DEALINGS IN THE SOFTWARE.
30  ****************************************************************************/
31 
32 #ifndef GDAL_PRIV_H_INCLUDED
33 #define GDAL_PRIV_H_INCLUDED
34 
41 /* -------------------------------------------------------------------- */
42 /* Predeclare various classes before pulling in gdal.h, the */
43 /* public declarations. */
44 /* -------------------------------------------------------------------- */
45 class GDALMajorObject;
46 class GDALDataset;
47 class GDALRasterBand;
48 class GDALDriver;
50 class GDALProxyDataset;
51 class GDALProxyRasterBand;
52 class GDALAsyncReader;
53 
54 /* -------------------------------------------------------------------- */
55 /* Pull in the public declarations. This gets the C apis, and */
56 /* also various constants. However, we will still get to */
57 /* provide the real class definitions for the GDAL classes. */
58 /* -------------------------------------------------------------------- */
59 
60 #include "gdal.h"
61 #include "gdal_frmts.h"
62 #include "cpl_vsi.h"
63 #include "cpl_conv.h"
64 #include "cpl_string.h"
65 #include "cpl_minixml.h"
66 #include "cpl_multiproc.h"
67 #include "cpl_atomic_ops.h"
68 
69 #include <stdarg.h>
70 
71 #include <cmath>
72 #include <cstdint>
73 #include <iterator>
74 #include <limits>
75 #include <map>
76 #include <memory>
77 #include <vector>
78 
79 #include "ogr_core.h"
80 #include "ogr_feature.h"
81 
83 #define GMO_VALID 0x0001
84 #define GMO_IGNORE_UNIMPLEMENTED 0x0002
85 #define GMO_SUPPORT_MD 0x0004
86 #define GMO_SUPPORT_MDMD 0x0008
87 #define GMO_MD_DIRTY 0x0010
88 #define GMO_PAM_CLASS 0x0020
89 
91 /************************************************************************/
92 /* GDALMultiDomainMetadata */
93 /************************************************************************/
94 
96 class CPL_DLL GDALMultiDomainMetadata
97 {
98 private:
99  char **papszDomainList;
100  CPLStringList **papoMetadataLists;
101 
102 public:
103  GDALMultiDomainMetadata();
104  ~GDALMultiDomainMetadata();
105 
106  int XMLInit( CPLXMLNode *psMetadata, int bMerge );
107  CPLXMLNode *Serialize();
108 
109  char **GetDomainList() { return papszDomainList; }
110 
111  char **GetMetadata( const char * pszDomain = "" );
112  CPLErr SetMetadata( char ** papszMetadata,
113  const char * pszDomain = "" );
114  const char *GetMetadataItem( const char * pszName,
115  const char * pszDomain = "" );
116  CPLErr SetMetadataItem( const char * pszName,
117  const char * pszValue,
118  const char * pszDomain = "" );
119 
120  void Clear();
121 
122  private:
123  CPL_DISALLOW_COPY_ASSIGN(GDALMultiDomainMetadata)
124 };
126 
127 /* ******************************************************************** */
128 /* GDALMajorObject */
129 /* */
130 /* Base class providing metadata, description and other */
131 /* services shared by major objects. */
132 /* ******************************************************************** */
133 
135 class CPL_DLL GDALMajorObject
136 {
137  protected:
139  int nFlags; // GMO_* flags.
140  CPLString sDescription{};
141  GDALMultiDomainMetadata oMDMD{};
142 
144 
145  char **BuildMetadataDomainList( char** papszList,
146  int bCheckNonEmpty, ... ) CPL_NULL_TERMINATED;
147  public:
148  GDALMajorObject();
149  virtual ~GDALMajorObject();
150 
151  int GetMOFlags() const;
152  void SetMOFlags( int nFlagsIn );
153 
154  virtual const char *GetDescription() const;
155  virtual void SetDescription( const char * );
156 
157  virtual char **GetMetadataDomainList();
158 
159  virtual char **GetMetadata( const char * pszDomain = "" );
160  virtual CPLErr SetMetadata( char ** papszMetadata,
161  const char * pszDomain = "" );
162  virtual const char *GetMetadataItem( const char * pszName,
163  const char * pszDomain = "" );
164  virtual CPLErr SetMetadataItem( const char * pszName,
165  const char * pszValue,
166  const char * pszDomain = "" );
167 
171  static inline GDALMajorObjectH ToHandle(GDALMajorObject* poMajorObject)
172  { return static_cast<GDALMajorObjectH>(poMajorObject); }
173 
177  static inline GDALMajorObject* FromHandle(GDALMajorObjectH hMajorObject)
178  { return static_cast<GDALMajorObject*>(hMajorObject); }
179 };
180 
181 /* ******************************************************************** */
182 /* GDALDefaultOverviews */
183 /* ******************************************************************** */
184 
186 class CPL_DLL GDALDefaultOverviews
187 {
188  friend class GDALDataset;
189 
190  GDALDataset *poDS;
191  GDALDataset *poODS;
192 
193  CPLString osOvrFilename{};
194 
195  bool bOvrIsAux;
196 
197  bool bCheckedForMask;
198  bool bOwnMaskDS;
199  GDALDataset *poMaskDS;
200 
201  // For "overview datasets" we record base level info so we can
202  // find our way back to get overview masks.
203  GDALDataset *poBaseDS;
204 
205  // Stuff for deferred initialize/overviewscans.
206  bool bCheckedForOverviews;
207  void OverviewScan();
208  char *pszInitName;
209  bool bInitNameIsOVR;
210  char **papszInitSiblingFiles;
211 
212  public:
213  GDALDefaultOverviews();
214  ~GDALDefaultOverviews();
215 
216  void Initialize( GDALDataset *poDSIn, const char *pszName = nullptr,
217  char **papszSiblingFiles = nullptr,
218  int bNameIsOVR = FALSE );
219 
220  void TransferSiblingFiles( char** papszSiblingFiles );
221 
222  int IsInitialized();
223 
225 
226  // Overview Related
227 
228  int GetOverviewCount( int nBand );
229  GDALRasterBand *GetOverview( int nBand, int iOverview );
230 
231  CPLErr BuildOverviews( const char * pszBasename,
232  const char * pszResampling,
233  int nOverviews, int * panOverviewList,
234  int nBands, int * panBandList,
235  GDALProgressFunc pfnProgress,
236  void *pProgressData );
237 
238  CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile,
239  const char * pszResampling,
240  int nOverviews, int * panOverviewList,
241  int nBands, int * panBandList,
242  GDALProgressFunc pfnProgress,
243  void *pProgressData );
244 
245  CPLErr CleanOverviews();
246 
247  // Mask Related
248 
249  CPLErr CreateMaskBand( int nFlags, int nBand = -1 );
250  GDALRasterBand *GetMaskBand( int nBand );
251  int GetMaskFlags( int nBand );
252 
253  int HaveMaskFile( char **papszSiblings = nullptr,
254  const char *pszBasename = nullptr );
255 
256  char** GetSiblingFiles() { return papszInitSiblingFiles; }
257 
258  private:
259  CPL_DISALLOW_COPY_ASSIGN(GDALDefaultOverviews)
260 };
262 
263 /* ******************************************************************** */
264 /* GDALOpenInfo */
265 /* ******************************************************************** */
266 
268 class CPL_DLL GDALOpenInfo
269 {
270  bool bHasGotSiblingFiles;
271  char **papszSiblingFiles;
272  int nHeaderBytesTried;
273 
274  public:
275  GDALOpenInfo( const char * pszFile, int nOpenFlagsIn,
276  const char * const * papszSiblingFiles = nullptr );
277  ~GDALOpenInfo( void );
278 
280  char *pszFilename;
283 
288 
290  int bStatOK;
293 
296 
301 
303  const char* const* papszAllowedDrivers;
304 
305  int TryToIngest(int nBytes);
306  char **GetSiblingFiles();
307  char **StealSiblingFiles();
308  bool AreSiblingFilesLoaded() const;
309 
310  private:
312 };
313 
314 /* ******************************************************************** */
315 /* GDALDataset */
316 /* ******************************************************************** */
317 
318 class OGRLayer;
319 class OGRGeometry;
320 class OGRSpatialReference;
321 class OGRStyleTable;
322 class swq_select;
323 class swq_select_parse_options;
324 class GDALGroup;
325 
327 typedef struct GDALSQLParseInfo GDALSQLParseInfo;
329 
331 #ifdef GDAL_COMPILATION
332 #define OPTIONAL_OUTSIDE_GDAL(val)
333 #else
334 #define OPTIONAL_OUTSIDE_GDAL(val) = val
335 #endif
336 
339 class CPL_DLL GDALDataset : public GDALMajorObject
340 {
341  friend GDALDatasetH CPL_STDCALL GDALOpenEx( const char* pszFilename,
342  unsigned int nOpenFlags,
343  const char* const* papszAllowedDrivers,
344  const char* const* papszOpenOptions,
345  const char* const* papszSiblingFiles );
346  friend void CPL_STDCALL GDALClose( GDALDatasetH hDS );
347 
348  friend class GDALDriver;
349  friend class GDALDefaultOverviews;
350  friend class GDALProxyDataset;
351  friend class GDALDriverManager;
352 
353  CPL_INTERNAL void AddToDatasetOpenList();
354 
355  CPL_INTERNAL static void ReportErrorV(
356  const char* pszDSName,
357  CPLErr eErrClass, CPLErrorNum err_no,
358  const char *fmt, va_list args);
359  protected:
361  GDALDriver *poDriver = nullptr;
362  GDALAccess eAccess = GA_ReadOnly;
363 
364  // Stored raster information.
365  int nRasterXSize = 512;
366  int nRasterYSize = 512;
367  int nBands = 0;
368  GDALRasterBand **papoBands = nullptr;
369 
370  int nOpenFlags = 0;
371 
372  int nRefCount = 1;
373  bool bForceCachedIO = false;
374  bool bShared = false;
375  bool bIsInternal = true;
376  bool bSuppressOnClose = false;
377 
378  GDALDataset(void);
379  explicit GDALDataset(int bForceCachedIO);
380 
381  void RasterInitialize( int, int );
382  void SetBand( int, GDALRasterBand * );
383 
384  GDALDefaultOverviews oOvManager{};
385 
386  virtual CPLErr IBuildOverviews( const char *, int, int *,
387  int, int *, GDALProgressFunc, void * );
388 
389  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
390  void *, int, int, GDALDataType,
391  int, int *, GSpacing, GSpacing, GSpacing,
393 
394  CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
395  void *, int, int, GDALDataType,
396  int, int *, GSpacing, GSpacing, GSpacing,
398  void BlockBasedFlushCache();
399 
400  CPLErr BandBasedRasterIO( GDALRWFlag eRWFlag,
401  int nXOff, int nYOff, int nXSize, int nYSize,
402  void * pData, int nBufXSize, int nBufYSize,
403  GDALDataType eBufType,
404  int nBandCount, int *panBandMap,
405  GSpacing nPixelSpace, GSpacing nLineSpace,
406  GSpacing nBandSpace,
408 
409  CPLErr RasterIOResampled( GDALRWFlag eRWFlag,
410  int nXOff, int nYOff, int nXSize, int nYSize,
411  void * pData, int nBufXSize, int nBufYSize,
412  GDALDataType eBufType,
413  int nBandCount, int *panBandMap,
414  GSpacing nPixelSpace, GSpacing nLineSpace,
415  GSpacing nBandSpace,
417 
418  CPLErr ValidateRasterIOOrAdviseReadParameters(
419  const char* pszCallingFunc,
420  int* pbStopProcessingOnCENone,
421  int nXOff, int nYOff, int nXSize, int nYSize,
422  int nBufXSize, int nBufYSize,
423  int nBandCount, int *panBandMap);
424 
425  CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
426  int nXOff, int nYOff, int nXSize, int nYSize,
427  void * pData, int nBufXSize, int nBufYSize,
428  GDALDataType eBufType,
429  int nBandCount, int *panBandMap,
430  GSpacing nPixelSpace, GSpacing nLineSpace,
431  GSpacing nBandSpace,
432  GDALRasterIOExtraArg* psExtraArg,
433  int* pbTried);
434 
435  void ShareLockWithParentDataset(GDALDataset* poParentDataset);
436 
438  virtual int CloseDependentDatasets();
440  int ValidateLayerCreationOptions( const char* const* papszLCO );
441 
442  char **papszOpenOptions = nullptr;
443 
444  friend class GDALRasterBand;
445 
446  // The below methods related to read write mutex are fragile logic, and
447  // should not be used by out-of-tree code if possible.
448  int EnterReadWrite(GDALRWFlag eRWFlag);
449  void LeaveReadWrite();
450  void InitRWLock();
451 
452  void TemporarilyDropReadWriteLock();
453  void ReacquireReadWriteLock();
454 
455  void DisableReadWriteMutex();
456 
457  int AcquireMutex();
458  void ReleaseMutex();
460 
461  public:
462  ~GDALDataset() override;
463 
464  int GetRasterXSize();
465  int GetRasterYSize();
466  int GetRasterCount();
467  GDALRasterBand *GetRasterBand( int );
468 
470  class CPL_DLL Bands
471  {
472  private:
473 
474  friend class GDALDataset;
475  GDALDataset* m_poSelf;
476  CPL_INTERNAL explicit Bands(GDALDataset* poSelf): m_poSelf(poSelf) {}
477 
478  class CPL_DLL Iterator
479  {
480  struct Private;
481  std::unique_ptr<Private> m_poPrivate;
482  public:
483  Iterator(GDALDataset* poDS, bool bStart);
484  Iterator(const Iterator& oOther); // declared but not defined. Needed for gcc 5.4 at least
485  Iterator(Iterator&& oOther) noexcept; // declared but not defined. Needed for gcc 5.4 at least
486  ~Iterator();
487  GDALRasterBand* operator*();
488  Iterator& operator++();
489  bool operator!=(const Iterator& it) const;
490  };
491 
492  public:
493 
494  const Iterator begin() const;
495 
496  const Iterator end() const;
497 
498  size_t size() const;
499 
500  GDALRasterBand* operator[](int iBand);
501  GDALRasterBand* operator[](size_t iBand);
502  };
503 
504  Bands GetBands();
505 
506  virtual void FlushCache(void);
507 
508  virtual const OGRSpatialReference* GetSpatialRef() const;
509  virtual CPLErr SetSpatialRef(const OGRSpatialReference* poSRS);
510 
511  // Compatibility layer
512  const char *GetProjectionRef(void) const;
513  CPLErr SetProjection( const char * pszProjection );
514 
515  virtual CPLErr GetGeoTransform( double * padfTransform );
516  virtual CPLErr SetGeoTransform( double * padfTransform );
517 
518  virtual CPLErr AddBand( GDALDataType eType,
519  char **papszOptions=nullptr );
520 
521  virtual void *GetInternalHandle( const char * pszHandleName );
522  virtual GDALDriver *GetDriver(void);
523  virtual char **GetFileList(void);
524 
525  virtual const char* GetDriverName();
526 
527  virtual const OGRSpatialReference* GetGCPSpatialRef() const;
528  virtual int GetGCPCount();
529  virtual const GDAL_GCP *GetGCPs();
530  virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
531  const OGRSpatialReference * poGCP_SRS );
532 
533  // Compatibility layer
534  const char *GetGCPProjection();
535  CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
536  const char *pszGCPProjection );
537 
538  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
539  int nBufXSize, int nBufYSize,
540  GDALDataType eDT,
541  int nBandCount, int *panBandList,
542  char **papszOptions );
543 
544  virtual CPLErr CreateMaskBand( int nFlagsIn );
545 
546  virtual GDALAsyncReader*
547  BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize,
548  void *pBuf, int nBufXSize, int nBufYSize,
549  GDALDataType eBufType,
550  int nBandCount, int* panBandMap,
551  int nPixelSpace, int nLineSpace, int nBandSpace,
552  char **papszOptions);
553  virtual void EndAsyncReader(GDALAsyncReader *);
554 
556  struct RawBinaryLayout
557  {
558  enum class Interleaving
559  {
560  UNKNOWN,
561  BIP,
562  BIL,
563  BSQ
564  };
565  std::string osRawFilename{};
566  Interleaving eInterleaving = Interleaving::UNKNOWN;
567  GDALDataType eDataType = GDT_Unknown;
568  bool bLittleEndianOrder = false;
569 
570  vsi_l_offset nImageOffset = 0;
571  GIntBig nPixelOffset = 0;
572  GIntBig nLineOffset = 0;
573  GIntBig nBandOffset = 0;
574  };
575 
576  virtual bool GetRawBinaryLayout(RawBinaryLayout&);
578 
579  CPLErr RasterIO( GDALRWFlag, int, int, int, int,
580  void *, int, int, GDALDataType,
581  int, int *, GSpacing, GSpacing, GSpacing,
582  GDALRasterIOExtraArg* psExtraArg
583 #ifndef DOXYGEN_SKIP
584  OPTIONAL_OUTSIDE_GDAL(nullptr)
585 #endif
587 
588  int Reference();
589  int Dereference();
590  int ReleaseRef();
591 
595  GDALAccess GetAccess() const { return eAccess; }
596 
597  int GetShared() const;
598  void MarkAsShared();
599 
601  void MarkSuppressOnClose() { bSuppressOnClose = true; }
602 
606  char **GetOpenOptions() { return papszOpenOptions; }
607 
608  static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
609 
610  CPLErr BuildOverviews( const char *, int, int *,
611  int, int *, GDALProgressFunc, void * );
612 
613 #ifndef DOXYGEN_XML
614  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
615 
616  static void ReportError(const char* pszDSName,
617  CPLErr eErrClass, CPLErrorNum err_no,
618  const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
619 #endif
620 
621  char ** GetMetadata(const char * pszDomain = "") override;
622 
623 // Only defined when Doxygen enabled
624 #ifdef DOXYGEN_SKIP
625  CPLErr SetMetadata( char ** papszMetadata,
626  const char * pszDomain ) override;
627  CPLErr SetMetadataItem( const char * pszName,
628  const char * pszValue,
629  const char * pszDomain ) override;
630 #endif
631 
632  char **GetMetadataDomainList() override;
633 
634  virtual void ClearStatistics();
635 
639  static inline GDALDatasetH ToHandle(GDALDataset* poDS)
640  { return static_cast<GDALDatasetH>(poDS); }
641 
645  static inline GDALDataset* FromHandle(GDALDatasetH hDS)
646  { return static_cast<GDALDataset*>(hDS); }
647 
651  static GDALDataset* Open( const char* pszFilename,
652  unsigned int nOpenFlags = 0,
653  const char* const* papszAllowedDrivers = nullptr,
654  const char* const* papszOpenOptions = nullptr,
655  const char* const* papszSiblingFiles = nullptr )
656  {
657  return FromHandle(GDALOpenEx(pszFilename, nOpenFlags,
658  papszAllowedDrivers,
659  papszOpenOptions,
660  papszSiblingFiles));
661  }
662 
665  {
668 
670  OGRLayer* layer = nullptr;
671  };
672 
673 private:
674  class Private;
675  Private *m_poPrivate;
676 
677  CPL_INTERNAL OGRLayer* BuildLayerFromSelectInfo(swq_select* psSelectInfo,
678  OGRGeometry *poSpatialFilter,
679  const char *pszDialect,
680  swq_select_parse_options* poSelectParseOptions);
681  CPLStringList oDerivedMetadataList{};
682 
683  public:
684 
685  virtual int GetLayerCount();
686  virtual OGRLayer *GetLayer(int iLayer);
687 
691  class CPL_DLL Layers
692  {
693  private:
694 
695  friend class GDALDataset;
696  GDALDataset* m_poSelf;
697  CPL_INTERNAL explicit Layers(GDALDataset* poSelf): m_poSelf(poSelf) {}
698 
699  public:
700 
704  class CPL_DLL Iterator
705  {
706  struct Private;
707  std::unique_ptr<Private> m_poPrivate;
708  public:
709 
710  using value_type = OGRLayer*;
711  using reference = OGRLayer*;
712  using difference_type = void;
713  using pointer = void;
714  using iterator_category = std::input_iterator_tag;
716  Iterator();
717  Iterator(GDALDataset* poDS, bool bStart);
718  Iterator(const Iterator& oOther);
719  Iterator(Iterator&& oOther) noexcept;
722  Iterator& operator=(const Iterator& oOther);
723  Iterator& operator=(Iterator&& oOther) noexcept;
725  OGRLayer* operator*() const;
726  Iterator& operator++();
727  Iterator operator++(int);
728  bool operator!=(const Iterator& it) const;
729  };
730 
731  Iterator begin() const;
732  Iterator end() const;
733 
734  size_t size() const;
735 
736  OGRLayer* operator[](int iLayer);
737  OGRLayer* operator[](size_t iLayer);
738  OGRLayer* operator[](const char* pszLayername);
739  };
740 
741  Layers GetLayers();
742 
743  virtual OGRLayer *GetLayerByName(const char *);
744  virtual OGRErr DeleteLayer(int iLayer);
745 
746  virtual void ResetReading();
747  virtual OGRFeature* GetNextFeature( OGRLayer** ppoBelongingLayer,
748  double* pdfProgressPct,
749  GDALProgressFunc pfnProgress,
750  void* pProgressData );
751 
752 
754  class CPL_DLL Features
755  {
756  private:
757 
758  friend class GDALDataset;
759  GDALDataset* m_poSelf;
760  CPL_INTERNAL explicit Features(GDALDataset* poSelf): m_poSelf(poSelf) {}
761 
762  class CPL_DLL Iterator
763  {
764  struct Private;
765  std::unique_ptr<Private> m_poPrivate;
766  public:
767  Iterator(GDALDataset* poDS, bool bStart);
768  Iterator(const Iterator& oOther); // declared but not defined. Needed for gcc 5.4 at least
769  Iterator(Iterator&& oOther) noexcept; // declared but not defined. Needed for gcc 5.4 at least
770  ~Iterator();
771  const FeatureLayerPair& operator*() const;
772  Iterator& operator++();
773  bool operator!=(const Iterator& it) const;
774  };
775 
776  public:
777 
778  const Iterator begin() const;
779 
780  const Iterator end() const;
781  };
782 
783  Features GetFeatures();
784 
785  virtual int TestCapability( const char * );
786 
787  virtual OGRLayer *CreateLayer( const char *pszName,
788  OGRSpatialReference *poSpatialRef = nullptr,
790  char ** papszOptions = nullptr );
791  virtual OGRLayer *CopyLayer( OGRLayer *poSrcLayer,
792  const char *pszNewName,
793  char **papszOptions = nullptr );
794 
795  virtual OGRStyleTable *GetStyleTable();
796  virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
797 
798  virtual void SetStyleTable(OGRStyleTable *poStyleTable);
799 
800  virtual OGRLayer * ExecuteSQL( const char *pszStatement,
801  OGRGeometry *poSpatialFilter,
802  const char *pszDialect );
803  virtual void ReleaseResultSet( OGRLayer * poResultsSet );
804  virtual OGRErr AbortSQL( );
805 
806  int GetRefCount() const;
807  int GetSummaryRefCount() const;
808  OGRErr Release();
809 
810  virtual OGRErr StartTransaction(int bForce=FALSE);
811  virtual OGRErr CommitTransaction();
812  virtual OGRErr RollbackTransaction();
813 
814  virtual std::shared_ptr<GDALGroup> GetRootGroup() const;
815 
817  static int IsGenericSQLDialect(const char* pszDialect);
818 
819  // Semi-public methods. Only to be used by in-tree drivers.
820  GDALSQLParseInfo* BuildParseInfo(swq_select* psSelectInfo,
821  swq_select_parse_options* poSelectParseOptions);
822  static void DestroyParseInfo(GDALSQLParseInfo* psParseInfo );
823  OGRLayer * ExecuteSQL( const char *pszStatement,
824  OGRGeometry *poSpatialFilter,
825  const char *pszDialect,
826  swq_select_parse_options* poSelectParseOptions);
828 
829  protected:
830  virtual OGRLayer *ICreateLayer( const char *pszName,
831  OGRSpatialReference *poSpatialRef = nullptr,
833  char ** papszOptions = nullptr );
834 
836  OGRErr ProcessSQLCreateIndex( const char * );
837  OGRErr ProcessSQLDropIndex( const char * );
838  OGRErr ProcessSQLDropTable( const char * );
839  OGRErr ProcessSQLAlterTableAddColumn( const char * );
840  OGRErr ProcessSQLAlterTableDropColumn( const char * );
841  OGRErr ProcessSQLAlterTableAlterColumn( const char * );
842  OGRErr ProcessSQLAlterTableRenameColumn( const char * );
843 
844  OGRStyleTable *m_poStyleTable = nullptr;
845 
846  // Compatibility layers
847  const OGRSpatialReference* GetSpatialRefFromOldGetProjectionRef() const;
848  CPLErr OldSetProjectionFromSetSpatialRef(const OGRSpatialReference* poSRS);
849  const OGRSpatialReference* GetGCPSpatialRefFromOldGetGCPProjection() const;
850  CPLErr OldSetGCPsFromNew( int nGCPCount, const GDAL_GCP *pasGCPList,
851  const OGRSpatialReference * poGCP_SRS );
852 
853  friend class GDALProxyPoolDataset;
854  virtual const char *_GetProjectionRef();
855  const char *GetProjectionRefFromSpatialRef(const OGRSpatialReference*) const;
856  virtual const char *_GetGCPProjection();
857  const char *GetGCPProjectionFromSpatialRef(const OGRSpatialReference* poSRS) const;
858  virtual CPLErr _SetProjection( const char * pszProjection );
859  virtual CPLErr _SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
860  const char *pszGCPProjection );
862 
863  private:
865 };
866 
868 struct CPL_DLL GDALDatasetUniquePtrDeleter
869 {
870  void operator()(GDALDataset* poDataset) const
871  { GDALClose(poDataset); }
872 };
874 
880 using GDALDatasetUniquePtr = std::unique_ptr<GDALDataset, GDALDatasetUniquePtrDeleter>;
881 
882 /* ******************************************************************** */
883 /* GDALRasterBlock */
884 /* ******************************************************************** */
885 
890 class CPL_DLL GDALRasterBlock
891 {
892  friend class GDALAbstractBandBlockCache;
893 
894  GDALDataType eType;
895 
896  bool bDirty;
897  volatile int nLockCount;
898 
899  int nXOff;
900  int nYOff;
901 
902  int nXSize;
903  int nYSize;
904 
905  void *pData;
906 
907  GDALRasterBand *poBand;
908 
909  GDALRasterBlock *poNext;
910  GDALRasterBlock *poPrevious;
911 
912  bool bMustDetach;
913 
914  CPL_INTERNAL void Detach_unlocked( void );
915  CPL_INTERNAL void Touch_unlocked( void );
916 
917  CPL_INTERNAL void RecycleFor( int nXOffIn, int nYOffIn );
918 
919  public:
920  GDALRasterBlock( GDALRasterBand *, int, int );
921  GDALRasterBlock( int nXOffIn, int nYOffIn ); /* only for lookup purpose */
922  virtual ~GDALRasterBlock();
923 
924  CPLErr Internalize( void );
925  void Touch( void );
926  void MarkDirty( void );
927  void MarkClean( void );
929  int AddLock( void ) { return CPLAtomicInc(&nLockCount); }
931  int DropLock( void ) { return CPLAtomicDec(&nLockCount); }
932  void Detach();
933 
934  CPLErr Write();
935 
939  GDALDataType GetDataType() const { return eType; }
943  int GetXOff() const { return nXOff; }
947  int GetYOff() const { return nYOff; }
951  int GetXSize() const { return nXSize; }
955  int GetYSize() const { return nYSize; }
959  int GetDirty() const { return bDirty; }
963  void *GetDataRef( void ) { return pData; }
968  return static_cast<GPtrDiff_t>(nXSize) * nYSize * GDALGetDataTypeSizeBytes(eType); }
969 
970  int TakeLock();
971  int DropLockForRemovalFromStorage();
972 
975  GDALRasterBand *GetBand() { return poBand; }
976 
977  static void FlushDirtyBlocks();
978  static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE);
979  static void Verify();
980 
981  static void EnterDisableDirtyBlockFlush();
982  static void LeaveDisableDirtyBlockFlush();
983 
984 #ifdef notdef
985  static void CheckNonOrphanedBlocks(GDALRasterBand* poBand);
986  void DumpBlock();
987  static void DumpAll();
988 #endif
989 
990  /* Should only be called by GDALDestroyDriverManager() */
992  CPL_INTERNAL static void DestroyRBMutex();
994 
995  private:
997 };
998 
999 /* ******************************************************************** */
1000 /* GDALColorTable */
1001 /* ******************************************************************** */
1002 
1005 class CPL_DLL GDALColorTable
1006 {
1007  GDALPaletteInterp eInterp;
1008 
1009  std::vector<GDALColorEntry> aoEntries{};
1010 
1011 public:
1014 
1015  GDALColorTable *Clone() const;
1016  int IsSame(const GDALColorTable* poOtherCT) const;
1017 
1018  GDALPaletteInterp GetPaletteInterpretation() const;
1019 
1020  int GetColorEntryCount() const;
1021  const GDALColorEntry *GetColorEntry( int ) const;
1022  int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
1023  void SetColorEntry( int, const GDALColorEntry * );
1024  int CreateColorRamp( int, const GDALColorEntry * ,
1025  int, const GDALColorEntry * );
1026 
1031  { return static_cast<GDALColorTableH>(poCT); }
1032 
1037  { return static_cast<GDALColorTable*>(hCT); }
1038 
1039 };
1040 
1041 /* ******************************************************************** */
1042 /* GDALAbstractBandBlockCache */
1043 /* ******************************************************************** */
1044 
1046 
1048 // only used by GDALRasterBand implementation.
1049 
1050 class GDALAbstractBandBlockCache
1051 {
1052  // List of blocks that can be freed or recycled, and its lock
1053  CPLLock *hSpinLock = nullptr;
1054  GDALRasterBlock *psListBlocksToFree = nullptr;
1055 
1056  // Band keep alive counter, and its lock & condition
1057  CPLCond *hCond = nullptr;
1058  CPLMutex *hCondMutex = nullptr;
1059  volatile int nKeepAliveCounter = 0;
1060 
1061  volatile int m_nDirtyBlocks = 0;
1062 
1063  CPL_DISALLOW_COPY_ASSIGN(GDALAbstractBandBlockCache)
1064 
1065  protected:
1066  GDALRasterBand *poBand;
1067 
1068  int m_nInitialDirtyBlocksInFlushCache = 0;
1069  int m_nLastTick = -1;
1070 
1071  void FreeDanglingBlocks();
1072  void UnreferenceBlockBase();
1073 
1074  void StartDirtyBlockFlushingLog();
1075  void UpdateDirtyBlockFlushingLog();
1076  void EndDirtyBlockFlushingLog();
1077 
1078  public:
1079  explicit GDALAbstractBandBlockCache(GDALRasterBand* poBand);
1080  virtual ~GDALAbstractBandBlockCache();
1081 
1082  GDALRasterBlock* CreateBlock(int nXBlockOff, int nYBlockOff);
1083  void AddBlockToFreeList( GDALRasterBlock * );
1084  void IncDirtyBlocks(int nInc);
1085  void WaitCompletionPendingTasks();
1086 
1087  virtual bool Init() = 0;
1088  virtual bool IsInitOK() = 0;
1089  virtual CPLErr FlushCache() = 0;
1090  virtual CPLErr AdoptBlock( GDALRasterBlock* poBlock ) = 0;
1091  virtual GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff,
1092  int nYBlockYOff ) = 0;
1093  virtual CPLErr UnreferenceBlock( GDALRasterBlock* poBlock ) = 0;
1094  virtual CPLErr FlushBlock( int nXBlockOff, int nYBlockOff,
1095  int bWriteDirtyBlock ) = 0;
1096 };
1097 
1098 GDALAbstractBandBlockCache* GDALArrayBandBlockCacheCreate(GDALRasterBand* poBand);
1099 GDALAbstractBandBlockCache* GDALHashSetBandBlockCacheCreate(GDALRasterBand* poBand);
1100 
1102 
1103 /* ******************************************************************** */
1104 /* GDALRasterBand */
1105 /* ******************************************************************** */
1106 
1107 class GDALMDArray;
1108 
1111 class CPL_DLL GDALRasterBand : public GDALMajorObject
1112 {
1113  private:
1114  friend class GDALArrayBandBlockCache;
1115  friend class GDALHashSetBandBlockCache;
1116  friend class GDALRasterBlock;
1117  friend class GDALDataset;
1118 
1119  CPLErr eFlushBlockErr = CE_None;
1120  GDALAbstractBandBlockCache* poBandBlockCache = nullptr;
1121 
1122  CPL_INTERNAL void SetFlushBlockErr( CPLErr eErr );
1123  CPL_INTERNAL CPLErr UnreferenceBlock( GDALRasterBlock* poBlock );
1124  CPL_INTERNAL void SetValidPercent( GUIntBig nSampleCount, GUIntBig nValidCount );
1125  CPL_INTERNAL void IncDirtyBlocks(int nInc);
1126 
1127  protected:
1129  GDALDataset *poDS = nullptr;
1130  int nBand = 0; /* 1 based */
1131 
1132  int nRasterXSize = 0;
1133  int nRasterYSize = 0;
1134 
1135  GDALDataType eDataType = GDT_Byte;
1136  GDALAccess eAccess = GA_ReadOnly;
1137 
1138  /* stuff related to blocking, and raster cache */
1139  int nBlockXSize = -1;
1140  int nBlockYSize = -1;
1141  int nBlocksPerRow = 0;
1142  int nBlocksPerColumn = 0;
1143 
1144  int nBlockReads = 0;
1145  int bForceCachedIO = 0;
1146 
1147  GDALRasterBand *poMask = nullptr;
1148  bool bOwnMask = false;
1149  int nMaskFlags = 0;
1150 
1151  void InvalidateMaskBand();
1152 
1153  friend class GDALProxyRasterBand;
1154  friend class GDALDefaultOverviews;
1155 
1156  CPLErr RasterIOResampled( GDALRWFlag, int, int, int, int,
1157  void *, int, int, GDALDataType,
1159 
1160  int EnterReadWrite(GDALRWFlag eRWFlag);
1161  void LeaveReadWrite();
1162  void InitRWLock();
1164 
1165  protected:
1166  virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void * pData ) = 0;
1167  virtual CPLErr IWriteBlock( int nBlockXOff, int nBlockYOff, void * pData );
1168 
1169  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1170  void *, int, int, GDALDataType,
1172 
1173  virtual int IGetDataCoverageStatus( int nXOff, int nYOff,
1174  int nXSize, int nYSize,
1175  int nMaskFlagStop,
1176  double* pdfDataPct);
1178  CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
1179  void *, int, int, GDALDataType,
1181 
1182  CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
1183  int nXOff, int nYOff, int nXSize, int nYSize,
1184  void * pData, int nBufXSize, int nBufYSize,
1185  GDALDataType eBufType,
1186  GSpacing nPixelSpace, GSpacing nLineSpace,
1187  GDALRasterIOExtraArg* psExtraArg,
1188  int* pbTried );
1189 
1190  int InitBlockInfo();
1191 
1192  void AddBlockToFreeList( GDALRasterBlock * );
1194 
1195  GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
1196 
1197  public:
1198  GDALRasterBand();
1199  explicit GDALRasterBand(int bForceCachedIO);
1200 
1201  ~GDALRasterBand() override;
1202 
1203  int GetXSize();
1204  int GetYSize();
1205  int GetBand();
1206  GDALDataset*GetDataset();
1207 
1208  GDALDataType GetRasterDataType( void );
1209  void GetBlockSize( int *, int * );
1210  CPLErr GetActualBlockSize ( int, int, int *, int * );
1211  GDALAccess GetAccess();
1212 
1213  CPLErr RasterIO( GDALRWFlag, int, int, int, int,
1214  void *, int, int, GDALDataType,
1215  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg
1216 #ifndef DOXYGEN_SKIP
1217  OPTIONAL_OUTSIDE_GDAL(nullptr)
1218 #endif
1220  CPLErr ReadBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
1221 
1222  CPLErr WriteBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
1223 
1224  GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
1225  int bJustInitialize = FALSE ) CPL_WARN_UNUSED_RESULT;
1226  CPLErr FlushBlock( int, int, int bWriteDirtyBlock = TRUE );
1227 
1228  unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand,
1229  unsigned char* pTranslationTable = nullptr,
1230  int* pApproximateMatching = nullptr);
1231 
1232  // New OpengIS CV_SampleDimension stuff.
1233 
1234  virtual CPLErr FlushCache();
1235  virtual char **GetCategoryNames();
1236  virtual double GetNoDataValue( int *pbSuccess = nullptr );
1237  virtual double GetMinimum( int *pbSuccess = nullptr );
1238  virtual double GetMaximum(int *pbSuccess = nullptr );
1239  virtual double GetOffset( int *pbSuccess = nullptr );
1240  virtual double GetScale( int *pbSuccess = nullptr );
1241  virtual const char *GetUnitType();
1242  virtual GDALColorInterp GetColorInterpretation();
1243  virtual GDALColorTable *GetColorTable();
1244  virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
1245 
1246  virtual CPLErr SetCategoryNames( char ** papszNames );
1247  virtual CPLErr SetNoDataValue( double dfNoData );
1248  virtual CPLErr DeleteNoDataValue();
1249  virtual CPLErr SetColorTable( GDALColorTable * poCT );
1250  virtual CPLErr SetColorInterpretation( GDALColorInterp eColorInterp );
1251  virtual CPLErr SetOffset( double dfNewOffset );
1252  virtual CPLErr SetScale( double dfNewScale );
1253  virtual CPLErr SetUnitType( const char * pszNewValue );
1254 
1255  virtual CPLErr GetStatistics( int bApproxOK, int bForce,
1256  double *pdfMin, double *pdfMax,
1257  double *pdfMean, double *padfStdDev );
1258  virtual CPLErr ComputeStatistics( int bApproxOK,
1259  double *pdfMin, double *pdfMax,
1260  double *pdfMean, double *pdfStdDev,
1261  GDALProgressFunc, void *pProgressData );
1262  virtual CPLErr SetStatistics( double dfMin, double dfMax,
1263  double dfMean, double dfStdDev );
1264  virtual CPLErr ComputeRasterMinMax( int, double* );
1265 
1266 // Only defined when Doxygen enabled
1267 #ifdef DOXYGEN_SKIP
1268  CPLErr SetMetadata( char ** papszMetadata,
1269  const char * pszDomain ) override;
1270  CPLErr SetMetadataItem( const char * pszName,
1271  const char * pszValue,
1272  const char * pszDomain ) override;
1273 #endif
1274 
1275  virtual int HasArbitraryOverviews();
1276  virtual int GetOverviewCount();
1277  virtual GDALRasterBand *GetOverview(int);
1278  virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig );
1279  virtual CPLErr BuildOverviews( const char * pszResampling,
1280  int nOverviews,
1281  int * panOverviewList,
1282  GDALProgressFunc pfnProgress,
1283  void * pProgressData );
1284 
1285  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
1286  int nBufXSize, int nBufYSize,
1287  GDALDataType eBufType, char **papszOptions );
1288 
1289  virtual CPLErr GetHistogram( double dfMin, double dfMax,
1290  int nBuckets, GUIntBig * panHistogram,
1291  int bIncludeOutOfRange, int bApproxOK,
1292  GDALProgressFunc, void *pProgressData );
1293 
1294  virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
1295  int *pnBuckets, GUIntBig ** ppanHistogram,
1296  int bForce,
1297  GDALProgressFunc, void *pProgressData);
1298  virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
1299  int nBuckets, GUIntBig *panHistogram );
1300 
1301  virtual GDALRasterAttributeTable *GetDefaultRAT();
1302  virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * poRAT );
1303 
1304  virtual GDALRasterBand *GetMaskBand();
1305  virtual int GetMaskFlags();
1306  virtual CPLErr CreateMaskBand( int nFlagsIn );
1307 
1308  virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
1309  int *pnPixelSpace,
1310  GIntBig *pnLineSpace,
1311  char **papszOptions ) CPL_WARN_UNUSED_RESULT;
1312 
1313  int GetDataCoverageStatus( int nXOff, int nYOff,
1314  int nXSize, int nYSize,
1315  int nMaskFlagStop = 0,
1316  double* pdfDataPct = nullptr );
1317 
1318  std::shared_ptr<GDALMDArray> AsMDArray() const;
1319 
1320 #ifndef DOXYGEN_XML
1321  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
1322 #endif
1323 
1327  static inline GDALRasterBandH ToHandle(GDALRasterBand* poBand)
1328  { return static_cast<GDALRasterBandH>(poBand); }
1329 
1334  { return static_cast<GDALRasterBand*>(hBand); }
1335 
1336 private:
1338 };
1339 
1341 /* ******************************************************************** */
1342 /* GDALAllValidMaskBand */
1343 /* ******************************************************************** */
1344 
1345 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
1346 {
1347  protected:
1348  CPLErr IReadBlock( int, int, void * ) override;
1349 
1350  CPL_DISALLOW_COPY_ASSIGN(GDALAllValidMaskBand)
1351 
1352  public:
1353  explicit GDALAllValidMaskBand( GDALRasterBand * );
1354  ~GDALAllValidMaskBand() override;
1355 
1356  GDALRasterBand *GetMaskBand() override;
1357  int GetMaskFlags() override;
1358 
1359  CPLErr ComputeStatistics( int bApproxOK,
1360  double *pdfMin, double *pdfMax,
1361  double *pdfMean, double *pdfStdDev,
1362  GDALProgressFunc, void *pProgressData ) override;
1363 
1364 };
1365 
1366 /* ******************************************************************** */
1367 /* GDALNoDataMaskBand */
1368 /* ******************************************************************** */
1369 
1370 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
1371 {
1372  double dfNoDataValue;
1373  GDALRasterBand *poParent;
1374 
1375  CPL_DISALLOW_COPY_ASSIGN(GDALNoDataMaskBand)
1376 
1377  protected:
1378  CPLErr IReadBlock( int, int, void * ) override;
1379  CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1380  void *, int, int, GDALDataType,
1381  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) override;
1382 
1383  public:
1384  explicit GDALNoDataMaskBand( GDALRasterBand * );
1385  ~GDALNoDataMaskBand() override;
1386 
1387  static bool IsNoDataInRange(double dfNoDataValue,
1388  GDALDataType eDataType);
1389 };
1390 
1391 /* ******************************************************************** */
1392 /* GDALNoDataValuesMaskBand */
1393 /* ******************************************************************** */
1394 
1395 class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
1396 {
1397  double *padfNodataValues;
1398 
1399  CPL_DISALLOW_COPY_ASSIGN(GDALNoDataValuesMaskBand)
1400 
1401  protected:
1402  CPLErr IReadBlock( int, int, void * ) override;
1403 
1404  public:
1405  explicit GDALNoDataValuesMaskBand( GDALDataset * );
1406  ~GDALNoDataValuesMaskBand() override;
1407 };
1408 
1409 /* ******************************************************************** */
1410 /* GDALRescaledAlphaBand */
1411 /* ******************************************************************** */
1412 
1413 class GDALRescaledAlphaBand : public GDALRasterBand
1414 {
1415  GDALRasterBand *poParent;
1416  void *pTemp;
1417 
1418  CPL_DISALLOW_COPY_ASSIGN(GDALRescaledAlphaBand)
1419 
1420  protected:
1421  CPLErr IReadBlock( int, int, void * ) override;
1422  CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1423  void *, int, int, GDALDataType,
1424  GSpacing, GSpacing,
1425  GDALRasterIOExtraArg* psExtraArg ) override;
1426 
1427  public:
1428  explicit GDALRescaledAlphaBand( GDALRasterBand * );
1429  ~GDALRescaledAlphaBand() override;
1430 };
1432 
1433 /* ******************************************************************** */
1434 /* GDALIdentifyEnum */
1435 /* ******************************************************************** */
1436 
1442 typedef enum
1443 {
1449  GDAL_IDENTIFY_TRUE = 1
1451 
1452 /* ******************************************************************** */
1453 /* GDALDriver */
1454 /* ******************************************************************** */
1455 
1467 class CPL_DLL GDALDriver : public GDALMajorObject
1468 {
1469  public:
1470  GDALDriver();
1471  ~GDALDriver() override;
1472 
1473  CPLErr SetMetadataItem( const char * pszName,
1474  const char * pszValue,
1475  const char * pszDomain = "" ) override;
1476 
1477 /* -------------------------------------------------------------------- */
1478 /* Public C++ methods. */
1479 /* -------------------------------------------------------------------- */
1480  GDALDataset *Create( const char * pszName,
1481  int nXSize, int nYSize, int nBands,
1482  GDALDataType eType, char ** papszOptions ) CPL_WARN_UNUSED_RESULT;
1483 
1484  GDALDataset *CreateMultiDimensional( const char * pszName,
1485  CSLConstList papszRootGroupOptions,
1486  CSLConstList papszOptions ) CPL_WARN_UNUSED_RESULT;
1487 
1488  CPLErr Delete( const char * pszName );
1489  CPLErr Rename( const char * pszNewName,
1490  const char * pszOldName );
1491  CPLErr CopyFiles( const char * pszNewName,
1492  const char * pszOldName );
1493 
1494  GDALDataset *CreateCopy( const char *, GDALDataset *,
1495  int, char **,
1496  GDALProgressFunc pfnProgress,
1497  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
1498 
1499 /* -------------------------------------------------------------------- */
1500 /* The following are semiprivate, not intended to be accessed */
1501 /* by anyone but the formats instantiating and populating the */
1502 /* drivers. */
1503 /* -------------------------------------------------------------------- */
1505  GDALDataset *(*pfnOpen)( GDALOpenInfo * );
1506 
1507  GDALDataset *(*pfnCreate)( const char * pszName,
1508  int nXSize, int nYSize, int nBands,
1509  GDALDataType eType,
1510  char ** papszOptions );
1511 
1512  GDALDataset *(*pfnCreateEx)( GDALDriver*, const char * pszName,
1513  int nXSize, int nYSize, int nBands,
1514  GDALDataType eType,
1515  char ** papszOptions );
1516 
1517  GDALDataset *(*pfnCreateMultiDimensional)( const char * pszName,
1518  CSLConstList papszRootGroupOptions,
1519  CSLConstList papszOptions );
1520 
1521  CPLErr (*pfnDelete)( const char * pszName );
1522 
1523  GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
1524  int, char **,
1525  GDALProgressFunc pfnProgress,
1526  void * pProgressData );
1527 
1528  void *pDriverData;
1529 
1530  void (*pfnUnloadDriver)(GDALDriver *);
1531 
1539  int (*pfnIdentify)( GDALOpenInfo * );
1540  int (*pfnIdentifyEx)( GDALDriver*, GDALOpenInfo * );
1541 
1542  CPLErr (*pfnRename)( const char * pszNewName,
1543  const char * pszOldName );
1544  CPLErr (*pfnCopyFiles)( const char * pszNewName,
1545  const char * pszOldName );
1546 
1547  // Used for legacy OGR drivers, and Python drivers
1548  GDALDataset *(*pfnOpenWithDriverArg)( GDALDriver*, GDALOpenInfo * );
1549 
1550  /* For legacy OGR drivers */
1551  GDALDataset *(*pfnCreateVectorOnly)( GDALDriver*,
1552  const char * pszName,
1553  char ** papszOptions );
1554  CPLErr (*pfnDeleteDataSource)( GDALDriver*,
1555  const char * pszName );
1557 
1558 /* -------------------------------------------------------------------- */
1559 /* Helper methods. */
1560 /* -------------------------------------------------------------------- */
1562  GDALDataset *DefaultCreateCopy( const char *, GDALDataset *,
1563  int, char **,
1564  GDALProgressFunc pfnProgress,
1565  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
1566 
1567  static CPLErr DefaultCreateCopyMultiDimensional(
1568  GDALDataset *poSrcDS,
1569  GDALDataset *poDstDS,
1570  bool bStrict,
1571  CSLConstList /*papszOptions*/,
1572  GDALProgressFunc pfnProgress,
1573  void * pProgressData );
1574 
1575  static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
1576  GDALDataset *poDstDS,
1577  int bStrict );
1578  static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
1579  GDALDataset *poDstDS,
1580  int bStrict,
1581  CSLConstList papszOptions,
1582  GDALProgressFunc pfnProgress,
1583  void * pProgressData );
1585  static CPLErr QuietDelete( const char * pszName,
1586  const char *const *papszAllowedDrivers = nullptr);
1587 
1589  static CPLErr DefaultRename( const char * pszNewName,
1590  const char * pszOldName );
1591  static CPLErr DefaultCopyFiles( const char * pszNewName,
1592  const char * pszOldName );
1594 
1598  static inline GDALDriverH ToHandle(GDALDriver* poDriver)
1599  { return static_cast<GDALDriverH>(poDriver); }
1600 
1604  static inline GDALDriver* FromHandle(GDALDriverH hDriver)
1605  { return static_cast<GDALDriver*>(hDriver); }
1606 
1607 private:
1609 };
1610 
1611 /* ******************************************************************** */
1612 /* GDALDriverManager */
1613 /* ******************************************************************** */
1614 
1622 class CPL_DLL GDALDriverManager : public GDALMajorObject
1623 {
1624  int nDrivers = 0;
1625  GDALDriver **papoDrivers = nullptr;
1626  std::map<CPLString, GDALDriver*> oMapNameToDrivers{};
1627 
1628  GDALDriver *GetDriver_unlocked( int iDriver )
1629  { return (iDriver >= 0 && iDriver < nDrivers) ?
1630  papoDrivers[iDriver] : nullptr; }
1631 
1632  GDALDriver *GetDriverByName_unlocked( const char * pszName )
1633  { return oMapNameToDrivers[CPLString(pszName).toupper()]; }
1634 
1635  static char** GetSearchPaths(const char* pszGDAL_DRIVER_PATH);
1636 
1637  static void CleanupPythonDrivers();
1638 
1640 
1641  public:
1643  ~GDALDriverManager();
1644 
1645  int GetDriverCount( void ) const;
1646  GDALDriver *GetDriver( int );
1647  GDALDriver *GetDriverByName( const char * );
1648 
1649  int RegisterDriver( GDALDriver * );
1650  void DeregisterDriver( GDALDriver * );
1651 
1652  // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
1653  static void AutoLoadDrivers();
1654  void AutoSkipDrivers();
1655 
1656  static void AutoLoadPythonDrivers();
1657 };
1658 
1660 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
1661 CPL_C_END
1662 
1663 /* ******************************************************************** */
1664 /* GDALAsyncReader */
1665 /* ******************************************************************** */
1666 
1672 class CPL_DLL GDALAsyncReader
1673 {
1674 
1676 
1677  protected:
1679  GDALDataset* poDS;
1680  int nXOff;
1681  int nYOff;
1682  int nXSize;
1683  int nYSize;
1684  void * pBuf;
1685  int nBufXSize;
1686  int nBufYSize;
1687  GDALDataType eBufType;
1688  int nBandCount;
1689  int* panBandMap;
1690  int nPixelSpace;
1691  int nLineSpace;
1692  int nBandSpace;
1694 
1695  public:
1696  GDALAsyncReader();
1697  virtual ~GDALAsyncReader();
1698 
1702  GDALDataset* GetGDALDataset() {return poDS;}
1706  int GetXOffset() const { return nXOff; }
1710  int GetYOffset() const { return nYOff; }
1714  int GetXSize() const { return nXSize; }
1718  int GetYSize() const { return nYSize; }
1722  void * GetBuffer() {return pBuf;}
1726  int GetBufferXSize() const { return nBufXSize; }
1730  int GetBufferYSize() const { return nBufYSize; }
1734  GDALDataType GetBufferType() const { return eBufType; }
1738  int GetBandCount() const { return nBandCount; }
1742  int* GetBandMap() { return panBandMap; }
1746  int GetPixelSpace() const { return nPixelSpace; }
1750  int GetLineSpace() const { return nLineSpace; }
1754  int GetBandSpace() const { return nBandSpace; }
1755 
1756  virtual GDALAsyncStatusType
1757  GetNextUpdatedRegion(double dfTimeout,
1758  int* pnBufXOff, int* pnBufYOff,
1759  int* pnBufXSize, int* pnBufYSize) = 0;
1760  virtual int LockBuffer( double dfTimeout = -1.0 );
1761  virtual void UnlockBuffer();
1762 };
1763 
1764 /* ******************************************************************** */
1765 /* Multidimensional array API */
1766 /* ******************************************************************** */
1767 
1768 class GDALMDArray;
1769 class GDALAttribute;
1770 class GDALDimension;
1771 class GDALEDTComponent;
1772 
1773 /* ******************************************************************** */
1774 /* GDALExtendedDataType */
1775 /* ******************************************************************** */
1776 
1785 {
1786 public:
1788 
1790 
1792 
1793  static GDALExtendedDataType Create(GDALDataType eType);
1794  static GDALExtendedDataType Create(const std::string& osName,
1795  size_t nTotalSize,
1796  std::vector<std::unique_ptr<GDALEDTComponent>>&& components);
1797  static GDALExtendedDataType CreateString(size_t nMaxStringLength = 0);
1798 
1799  bool operator== (const GDALExtendedDataType& ) const;
1801  bool operator!= (const GDALExtendedDataType& other) const { return !(operator==(other)); }
1802 
1807  const std::string& GetName() const { return m_osName; }
1808 
1813  GDALExtendedDataTypeClass GetClass() const { return m_eClass; }
1814 
1819  GDALDataType GetNumericDataType() const { return m_eNumericDT; }
1820 
1825  const std::vector<std::unique_ptr<GDALEDTComponent>>& GetComponents() const { return m_aoComponents; }
1826 
1833  size_t GetSize() const { return m_nSize; }
1834 
1839  size_t GetMaxStringLength() const { return m_nMaxStringLength; }
1840 
1841  bool CanConvertTo(const GDALExtendedDataType& other) const;
1842 
1843  bool NeedsFreeDynamicMemory() const;
1844 
1845  void FreeDynamicMemory(void* pBuffer) const;
1846 
1847  static
1848  bool CopyValue(const void* pSrc, const GDALExtendedDataType& srcType,
1849  void* pDst, const GDALExtendedDataType& dstType);
1850 
1851 private:
1852  explicit GDALExtendedDataType(size_t nMaxStringLength = 0);
1853  explicit GDALExtendedDataType(GDALDataType eType);
1854  GDALExtendedDataType(const std::string& osName,
1855  size_t nTotalSize,
1856  std::vector<std::unique_ptr<GDALEDTComponent>>&& components);
1857 
1858  std::string m_osName{};
1860  GDALDataType m_eNumericDT = GDT_Unknown;
1861  std::vector<std::unique_ptr<GDALEDTComponent>> m_aoComponents{};
1862  size_t m_nSize = 0;
1863  size_t m_nMaxStringLength = 0;
1864 };
1865 
1866 /* ******************************************************************** */
1867 /* GDALEDTComponent */
1868 /* ******************************************************************** */
1869 
1875 class CPL_DLL GDALEDTComponent
1876 {
1877 public:
1878  ~GDALEDTComponent();
1879  GDALEDTComponent(const std::string& name, size_t offset, const GDALExtendedDataType& type);
1881 
1882  bool operator== (const GDALEDTComponent& ) const;
1883 
1888  const std::string& GetName() const { return m_osName; }
1889 
1894  size_t GetOffset() const { return m_nOffset; }
1895 
1900  const GDALExtendedDataType& GetType() const { return m_oType; }
1901 
1902 private:
1903  std::string m_osName;
1904  size_t m_nOffset;
1905  GDALExtendedDataType m_oType;
1906 };
1907 
1908 /* ******************************************************************** */
1909 /* GDALIHasAttribute */
1910 /* ******************************************************************** */
1911 
1917 class CPL_DLL GDALIHasAttribute
1918 {
1919 protected:
1920  std::shared_ptr<GDALAttribute> GetAttributeFromAttributes(const std::string& osName) const;
1921 
1922 public:
1923  virtual ~GDALIHasAttribute();
1924 
1925  virtual std::shared_ptr<GDALAttribute> GetAttribute(const std::string& osName) const;
1926 
1927  virtual std::vector<std::shared_ptr<GDALAttribute>> GetAttributes(CSLConstList papszOptions = nullptr) const;
1928 
1929  virtual std::shared_ptr<GDALAttribute> CreateAttribute(
1930  const std::string& osName,
1931  const std::vector<GUInt64>& anDimensions,
1932  const GDALExtendedDataType& oDataType,
1933  CSLConstList papszOptions = nullptr);
1934 };
1935 
1936 /* ******************************************************************** */
1937 /* GDALGroup */
1938 /* ******************************************************************** */
1939 
1948 class CPL_DLL GDALGroup: public GDALIHasAttribute
1949 {
1950 protected:
1952  std::string m_osName{};
1953  std::string m_osFullName{};
1954 
1955  GDALGroup(const std::string& osParentName, const std::string& osName);
1956 
1957  const GDALGroup* GetInnerMostGroup(const std::string& osPathOrArrayOrDim,
1958  std::shared_ptr<GDALGroup>& curGroupHolder,
1959  std::string& osLastPart) const;
1961 
1962 public:
1963  virtual ~GDALGroup();
1964 
1969  const std::string& GetName() const { return m_osName; }
1970 
1975  const std::string& GetFullName() const { return m_osFullName; }
1976 
1977  virtual std::vector<std::string> GetMDArrayNames(CSLConstList papszOptions = nullptr) const;
1978  virtual std::shared_ptr<GDALMDArray> OpenMDArray(const std::string& osName,
1979  CSLConstList papszOptions = nullptr) const;
1980 
1981  virtual std::vector<std::string> GetGroupNames(CSLConstList papszOptions = nullptr) const;
1982  virtual std::shared_ptr<GDALGroup> OpenGroup(const std::string& osName,
1983  CSLConstList papszOptions = nullptr) const;
1984 
1985  virtual std::vector<std::shared_ptr<GDALDimension>> GetDimensions(CSLConstList papszOptions = nullptr) const;
1986 
1987  virtual std::shared_ptr<GDALGroup> CreateGroup(const std::string& osName,
1988  CSLConstList papszOptions = nullptr);
1989 
1990  virtual std::shared_ptr<GDALDimension> CreateDimension(const std::string& osName,
1991  const std::string& osType,
1992  const std::string& osDirection,
1993  GUInt64 nSize,
1994  CSLConstList papszOptions = nullptr);
1995 
1996  virtual std::shared_ptr<GDALMDArray> CreateMDArray(const std::string& osName,
1997  const std::vector<std::shared_ptr<GDALDimension>>& aoDimensions,
1998  const GDALExtendedDataType& oDataType,
1999  CSLConstList papszOptions = nullptr);
2000 
2001  GUInt64 GetTotalCopyCost() const;
2002 
2003  virtual bool CopyFrom(const std::shared_ptr<GDALGroup>& poDstRootGroup,
2004  GDALDataset* poSrcDS,
2005  const std::shared_ptr<GDALGroup>& poSrcGroup,
2006  bool bStrict,
2007  GUInt64& nCurCost,
2008  const GUInt64 nTotalCost,
2009  GDALProgressFunc pfnProgress,
2010  void * pProgressData);
2011 
2012  virtual CSLConstList GetStructuralInfo() const;
2013 
2014  std::shared_ptr<GDALMDArray> OpenMDArrayFromFullname(
2015  const std::string& osFullName,
2016  CSLConstList papszOptions = nullptr) const;
2017 
2018  std::shared_ptr<GDALMDArray> ResolveMDArray(const std::string& osName,
2019  const std::string& osStartingPath,
2020  CSLConstList papszOptions = nullptr) const;
2021 
2022  std::shared_ptr<GDALGroup> OpenGroupFromFullname(
2023  const std::string& osFullName,
2024  CSLConstList papszOptions = nullptr) const;
2025 
2026  std::shared_ptr<GDALDimension> OpenDimensionFromFullname(
2027  const std::string& osFullName) const;
2028 
2030  static constexpr GUInt64 COPY_COST = 1000;
2032 };
2033 
2034 /* ******************************************************************** */
2035 /* GDALAbstractMDArray */
2036 /* ******************************************************************** */
2037 
2043 class CPL_DLL GDALAbstractMDArray
2044 {
2045 protected:
2047  std::string m_osName{};
2048  std::string m_osFullName{};
2049  std::weak_ptr<GDALAbstractMDArray> m_pSelf{};
2050 
2051  GDALAbstractMDArray(const std::string& osParentName, const std::string& osName);
2052 
2053  void SetSelf(std::weak_ptr<GDALAbstractMDArray> self) { m_pSelf = self; }
2054 
2055  bool CheckReadWriteParams(const GUInt64* arrayStartIdx,
2056  const size_t* count,
2057  const GInt64*& arrayStep,
2058  const GPtrDiff_t*& bufferStride,
2059  const GDALExtendedDataType& bufferDataType,
2060  const void* buffer,
2061  const void* buffer_alloc_start,
2062  size_t buffer_alloc_size,
2063  std::vector<GInt64>& tmp_arrayStep,
2064  std::vector<GPtrDiff_t>& tmp_bufferStride) const;
2065 
2066  virtual bool IRead(const GUInt64* arrayStartIdx, // array of size GetDimensionCount()
2067  const size_t* count, // array of size GetDimensionCount()
2068  const GInt64* arrayStep, // step in elements
2069  const GPtrDiff_t* bufferStride, // stride in elements
2070  const GDALExtendedDataType& bufferDataType,
2071  void* pDstBuffer) const = 0;
2072 
2073  virtual bool IWrite(const GUInt64* arrayStartIdx, // array of size GetDimensionCount()
2074  const size_t* count, // array of size GetDimensionCount()
2075  const GInt64* arrayStep, // step in elements
2076  const GPtrDiff_t* bufferStride, // stride in elements
2077  const GDALExtendedDataType& bufferDataType,
2078  const void* pSrcBuffer);
2080 
2081 public:
2082  virtual ~GDALAbstractMDArray();
2083 
2088  const std::string& GetName() const{ return m_osName; }
2089 
2094  const std::string& GetFullName() const{ return m_osFullName; }
2095 
2096  GUInt64 GetTotalElementsCount() const;
2097 
2098  virtual size_t GetDimensionCount() const;
2099 
2100  virtual const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const = 0;
2101 
2102  virtual const GDALExtendedDataType &GetDataType() const = 0;
2103 
2104  virtual std::vector<GUInt64> GetBlockSize() const;
2105 
2106  virtual std::vector<size_t> GetProcessingChunkSize(size_t nMaxChunkMemory) const;
2107 
2123  typedef bool (*FuncProcessPerChunkType)(
2124  GDALAbstractMDArray* array,
2125  const GUInt64* chunkArrayStartIdx,
2126  const size_t* chunkCount,
2127  GUInt64 iCurChunk,
2128  GUInt64 nChunkCount,
2129  void* pUserData);
2130 
2131  virtual bool ProcessPerChunk(const GUInt64* arrayStartIdx,
2132  const GUInt64* count,
2133  const size_t* chunkSize,
2134  FuncProcessPerChunkType pfnFunc,
2135  void* pUserData);
2136 
2137  bool Read(const GUInt64* arrayStartIdx, // array of size GetDimensionCount()
2138  const size_t* count, // array of size GetDimensionCount()
2139  const GInt64* arrayStep, // step in elements
2140  const GPtrDiff_t* bufferStride, // stride in elements
2141  const GDALExtendedDataType& bufferDataType,
2142  void* pDstBuffer,
2143  const void* pDstBufferAllocStart = nullptr,
2144  size_t nDstBufferAllocSize = 0) const;
2145 
2146  bool Write(const GUInt64* arrayStartIdx, // array of size GetDimensionCount()
2147  const size_t* count, // array of size GetDimensionCount()
2148  const GInt64* arrayStep, // step in elements
2149  const GPtrDiff_t* bufferStride, // stride in elements
2150  const GDALExtendedDataType& bufferDataType,
2151  const void* pSrcBuffer,
2152  const void* pSrcBufferAllocStart = nullptr,
2153  size_t nSrcBufferAllocSize = 0);
2154 };
2155 
2156 /* ******************************************************************** */
2157 /* GDALRawResult */
2158 /* ******************************************************************** */
2159 
2166 class CPL_DLL GDALRawResult
2167 {
2168 private:
2169  GDALExtendedDataType m_dt;
2170  size_t m_nEltCount;
2171  size_t m_nSize;
2172  GByte* m_raw;
2173 
2174  void FreeMe();
2175 
2176  GDALRawResult(const GDALRawResult&) = delete;
2177  GDALRawResult& operator=(const GDALRawResult&) = delete;
2178 
2179 protected:
2180  friend class GDALAttribute;
2182  GDALRawResult(GByte* raw,
2183  const GDALExtendedDataType& dt,
2184  size_t nEltCount);
2186 
2187 public:
2188  ~GDALRawResult();
2190  GDALRawResult& operator=(GDALRawResult&&);
2191 
2193  const GByte& operator[](size_t idx) const { return m_raw[idx]; }
2195  const GByte* data() const { return m_raw; }
2197  size_t size() const { return m_nSize; }
2198 
2200  GByte* StealData();
2202 };
2203 
2204 
2205 /* ******************************************************************** */
2206 /* GDALAttribute */
2207 /* ******************************************************************** */
2208 
2219 class CPL_DLL GDALAttribute: virtual public GDALAbstractMDArray
2220 {
2221  mutable std::string m_osCachedVal{};
2222 
2223 protected:
2225  GDALAttribute(const std::string& osParentName, const std::string& osName);
2227 
2228 public:
2229 
2230  std::vector<GUInt64> GetDimensionsSize() const;
2231 
2232  GDALRawResult ReadAsRaw() const;
2233  const char* ReadAsString() const;
2234  int ReadAsInt() const;
2235  double ReadAsDouble() const;
2236  CPLStringList ReadAsStringArray() const;
2237  std::vector<int> ReadAsIntArray() const;
2238  std::vector<double> ReadAsDoubleArray() const;
2239 
2241  bool Write(const void* pabyValue, size_t nLen);
2242  bool Write(const char*);
2243  bool WriteInt(int);
2244  bool Write(double);
2245  bool Write(CSLConstList);
2246  bool Write(const double*, size_t);
2247 
2249  static constexpr GUInt64 COPY_COST = 100;
2251 
2252 };
2253 
2254 /************************************************************************/
2255 /* GDALAttributeString */
2256 /************************************************************************/
2257 
2259 class CPL_DLL GDALAttributeString final: public GDALAttribute
2260 {
2261  std::vector<std::shared_ptr<GDALDimension>> m_dims{};
2263  std::string m_osValue;
2264 
2265 protected:
2266 
2267  bool IRead(const GUInt64* ,
2268  const size_t* ,
2269  const GInt64* ,
2270  const GPtrDiff_t* ,
2271  const GDALExtendedDataType& bufferDataType,
2272  void* pDstBuffer) const override;
2273 
2274 public:
2275  GDALAttributeString(const std::string& osParentName,
2276  const std::string& osName,
2277  const std::string& osValue);
2278 
2279  const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const override;
2280 
2281  const GDALExtendedDataType &GetDataType() const override;
2282 };
2284 
2285 /************************************************************************/
2286 /* GDALAttributeNumeric */
2287 /************************************************************************/
2288 
2290 class CPL_DLL GDALAttributeNumeric final: public GDALAttribute
2291 {
2292  std::vector<std::shared_ptr<GDALDimension>> m_dims{};
2293  GDALExtendedDataType m_dt;
2294  int m_nValue = 0;
2295  double m_dfValue = 0;
2296  std::vector<GUInt32> m_anValuesUInt32{};
2297 
2298 protected:
2299 
2300  bool IRead(const GUInt64* ,
2301  const size_t* ,
2302  const GInt64* ,
2303  const GPtrDiff_t* ,
2304  const GDALExtendedDataType& bufferDataType,
2305  void* pDstBuffer) const override;
2306 
2307 public:
2308  GDALAttributeNumeric(const std::string& osParentName,
2309  const std::string& osName,
2310  double dfValue);
2311  GDALAttributeNumeric(const std::string& osParentName,
2312  const std::string& osName,
2313  int nValue);
2314  GDALAttributeNumeric(const std::string& osParentName,
2315  const std::string& osName,
2316  const std::vector<GUInt32>& anValues);
2317 
2318  const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const override;
2319 
2320  const GDALExtendedDataType &GetDataType() const override;
2321 };
2323 
2324 /* ******************************************************************** */
2325 /* GDALMDArray */
2326 /* ******************************************************************** */
2327 
2336 class CPL_DLL GDALMDArray: virtual public GDALAbstractMDArray, public GDALIHasAttribute
2337 {
2338  std::shared_ptr<GDALMDArray> GetView(const std::vector<GUInt64>& indices) const;
2339 
2340  inline std::shared_ptr<GDALMDArray> atInternal(std::vector<GUInt64>& indices) const
2341  {
2342  return GetView(indices);
2343  }
2344 
2345  template<typename... GUInt64VarArg>
2346  // cppcheck-suppress functionStatic
2347  inline std::shared_ptr<GDALMDArray> atInternal(std::vector<GUInt64>& indices,
2348  GUInt64 idx, GUInt64VarArg... tail) const
2349  {
2350  indices.push_back(idx);
2351  return atInternal(indices, tail...);
2352  }
2353 
2354  bool SetStatistics( GDALDataset* poDS,
2355  bool bApproxStats,
2356  double dfMin, double dfMax,
2357  double dfMean, double dfStdDev,
2358  GUInt64 nValidCount );
2359 
2360 protected:
2362  GDALMDArray(const std::string& osParentName, const std::string& osName);
2363 
2364  virtual bool IAdviseRead(const GUInt64* arrayStartIdx,
2365  const size_t* count) const;
2366 
2368 
2369 public:
2370 
2371  GUInt64 GetTotalCopyCost() const;
2372 
2373  virtual bool CopyFrom(GDALDataset* poSrcDS,
2374  const GDALMDArray* poSrcArray,
2375  bool bStrict,
2376  GUInt64& nCurCost,
2377  const GUInt64 nTotalCost,
2378  GDALProgressFunc pfnProgress,
2379  void * pProgressData);
2380 
2382  virtual bool IsWritable() const = 0;
2383 
2384  virtual CSLConstList GetStructuralInfo() const;
2385 
2386  virtual const std::string& GetUnit() const;
2387 
2388  virtual bool SetUnit(const std::string& osUnit);
2389 
2390  virtual bool SetSpatialRef(const OGRSpatialReference* poSRS);
2391 
2392  virtual std::shared_ptr<OGRSpatialReference> GetSpatialRef() const;
2393 
2394  virtual const void* GetRawNoDataValue() const;
2395 
2396  double GetNoDataValueAsDouble(bool* pbHasNoData = nullptr) const;
2397 
2398  virtual bool SetRawNoDataValue(const void* pRawNoData);
2399 
2400  bool SetNoDataValue(double dfNoData);
2401 
2402  virtual double GetOffset(bool* pbHasOffset = nullptr) const;
2403 
2404  virtual double GetScale(bool* pbHasScale = nullptr) const;
2405 
2406  virtual bool SetOffset(double dfOffset);
2407 
2408  virtual bool SetScale(double dfScale);
2409 
2410  std::shared_ptr<GDALMDArray> GetView(const std::string& viewExpr) const;
2411 
2412  std::shared_ptr<GDALMDArray> operator[](const std::string& fieldName) const;
2413 
2423  template<typename... GUInt64VarArg>
2424  // cppcheck-suppress functionStatic
2425  std::shared_ptr<GDALMDArray> at(GUInt64 idx, GUInt64VarArg... tail) const
2426  {
2427  std::vector<GUInt64> indices;
2428  indices.push_back(idx);
2429  return atInternal(indices, tail...);
2430  }
2431 
2432  virtual std::shared_ptr<GDALMDArray> Transpose(const std::vector<int>& anMapNewAxisToOldAxis) const;
2433 
2434  std::shared_ptr<GDALMDArray> GetUnscaled() const;
2435 
2436  virtual std::shared_ptr<GDALMDArray> GetMask(CSLConstList papszOptions) const;
2437 
2438  virtual GDALDataset* AsClassicDataset(size_t iXDim, size_t iYDim) const;
2439 
2440  virtual CPLErr GetStatistics( GDALDataset* poDS,
2441  bool bApproxOK, bool bForce,
2442  double *pdfMin, double *pdfMax,
2443  double *pdfMean, double *padfStdDev,
2444  GUInt64* pnValidCount,
2445  GDALProgressFunc pfnProgress, void *pProgressData );
2446 
2447  virtual bool ComputeStatistics( GDALDataset* poDS,
2448  bool bApproxOK,
2449  double *pdfMin, double *pdfMax,
2450  double *pdfMean, double *pdfStdDev,
2451  GUInt64* pnValidCount,
2452  GDALProgressFunc, void *pProgressData );
2453 
2454  bool AdviseRead(const GUInt64* arrayStartIdx,
2455  const size_t* count) const;
2456 
2458  static constexpr GUInt64 COPY_COST = 1000;
2459 
2460  bool CopyFromAllExceptValues(const GDALMDArray* poSrcArray,
2461  bool bStrict,
2462  GUInt64& nCurCost,
2463  const GUInt64 nTotalCost,
2464  GDALProgressFunc pfnProgress,
2465  void * pProgressData);
2466  struct Range
2467  {
2468  GUInt64 m_nStartIdx;
2469  GInt64 m_nIncr;
2470  Range(GUInt64 nStartIdx = 0, GInt64 nIncr = 0):
2471  m_nStartIdx(nStartIdx), m_nIncr(nIncr) {}
2472  };
2473 
2474  struct ViewSpec
2475  {
2476  std::string m_osFieldName{};
2477 
2478  // or
2479 
2480  std::vector<size_t> m_mapDimIdxToParentDimIdx{}; // of size m_dims.size()
2481  std::vector<Range> m_parentRanges{} ; // of size m_poParent->GetDimensionCount()
2482  };
2483 
2484  virtual std::shared_ptr<GDALMDArray> GetView(const std::string& viewExpr,
2485  bool bRenameDimensions,
2486  std::vector<ViewSpec>& viewSpecs) const;
2488 };
2489 
2490 
2491 /************************************************************************/
2492 /* GDALMDArrayRegularlySpaced */
2493 /************************************************************************/
2494 
2496 class CPL_DLL GDALMDArrayRegularlySpaced: public GDALMDArray
2497 {
2498  double m_dfStart;
2499  double m_dfIncrement;
2500  double m_dfOffsetInIncrement;
2502  std::vector<std::shared_ptr<GDALDimension>> m_dims;
2503  std::vector<std::shared_ptr<GDALAttribute>> m_attributes{};
2504 
2505 protected:
2506 
2507  bool IRead(const GUInt64* ,
2508  const size_t* ,
2509  const GInt64* ,
2510  const GPtrDiff_t* ,
2511  const GDALExtendedDataType& bufferDataType,
2512  void* pDstBuffer) const override;
2513 
2514 public:
2515  GDALMDArrayRegularlySpaced(
2516  const std::string& osParentName,
2517  const std::string& osName,
2518  const std::shared_ptr<GDALDimension>& poDim,
2519  double dfStart, double dfIncrement,
2520  double dfOffsetInIncrement);
2521 
2522  bool IsWritable() const override { return false; }
2523 
2524  const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const override;
2525 
2526  const GDALExtendedDataType &GetDataType() const override;
2527 
2528  std::vector<std::shared_ptr<GDALAttribute>> GetAttributes(CSLConstList) const override;
2529 
2530  void AddAttribute(const std::shared_ptr<GDALAttribute>& poAttr);
2531 };
2533 
2534 /* ******************************************************************** */
2535 /* GDALDimension */
2536 /* ******************************************************************** */
2537 
2549 class CPL_DLL GDALDimension
2550 {
2551 public:
2553  GDALDimension(const std::string& osParentName,
2554  const std::string& osName,
2555  const std::string& osType,
2556  const std::string& osDirection,
2557  GUInt64 nSize);
2559 
2560  virtual ~GDALDimension();
2561 
2566  const std::string& GetName() const { return m_osName; }
2567 
2572  const std::string& GetFullName() const { return m_osFullName; }
2573 
2582  const std::string& GetType() const { return m_osType; }
2583 
2592  const std::string& GetDirection() const { return m_osDirection; }
2593 
2598  GUInt64 GetSize() const { return m_nSize; }
2599 
2600  virtual std::shared_ptr<GDALMDArray> GetIndexingVariable() const;
2601 
2602  virtual bool SetIndexingVariable(std::shared_ptr<GDALMDArray> poIndexingVariable);
2603 
2604 protected:
2606  std::string m_osName;
2607  std::string m_osFullName;
2608  std::string m_osType;
2609  std::string m_osDirection;
2610  GUInt64 m_nSize;
2612 };
2613 
2614 
2615 /************************************************************************/
2616 /* GDALDimensionWeakIndexingVar() */
2617 /************************************************************************/
2618 
2620 class CPL_DLL GDALDimensionWeakIndexingVar: public GDALDimension
2621 {
2622  std::weak_ptr<GDALMDArray> m_poIndexingVariable{};
2623 
2624 public:
2625  GDALDimensionWeakIndexingVar(const std::string& osParentName,
2626  const std::string& osName,
2627  const std::string& osType,
2628  const std::string& osDirection,
2629  GUInt64 nSize);
2630 
2631  std::shared_ptr<GDALMDArray> GetIndexingVariable() const override;
2632 
2633  bool SetIndexingVariable(std::shared_ptr<GDALMDArray> poIndexingVariable) override;
2634 };
2636 
2637 /* ==================================================================== */
2638 /* An assortment of overview related stuff. */
2639 /* ==================================================================== */
2640 
2642 /* Only exported for drivers as plugin. Signature may change */
2643 CPLErr CPL_DLL
2644 GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands,
2645  int nOverviews,
2646  GDALRasterBand*** papapoOverviewBands,
2647  const char * pszResampling,
2648  GDALProgressFunc pfnProgress, void * pProgressData );
2649 
2650 typedef CPLErr (*GDALResampleFunction)
2651  ( double dfXRatioDstToSrc,
2652  double dfYRatioDstToSrc,
2653  double dfSrcXDelta,
2654  double dfSrcYDelta,
2655  GDALDataType eWrkDataType,
2656  const void * pChunk,
2657  const GByte * pabyChunkNodataMask,
2658  int nChunkXOff, int nChunkXSize,
2659  int nChunkYOff, int nChunkYSize,
2660  int nDstXOff, int nDstXOff2,
2661  int nDstYOff, int nDstYOff2,
2662  GDALRasterBand * poOverview,
2663  void** ppDstBuffer,
2664  GDALDataType* peDstBufferDataType,
2665  const char * pszResampling,
2666  int bHasNoData, float fNoDataValue,
2667  GDALColorTable* poColorTable,
2668  GDALDataType eSrcDataType,
2669  bool bPropagateNoData );
2670 
2671 GDALResampleFunction GDALGetResampleFunction(const char* pszResampling,
2672  int* pnRadius);
2673 
2674 GDALDataType GDALGetOvrWorkDataType(const char* pszResampling,
2675  GDALDataType eSrcDataType);
2676 
2678 
2679 CPLErr CPL_DLL
2680 HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
2681  GDALDataset **ppoDS,
2682  int nBands, int *panBandList,
2683  int nNewOverviews, int *panNewOverviewList,
2684  const char *pszResampling,
2685  GDALProgressFunc pfnProgress,
2686  void *pProgressData );
2687 
2688 CPLErr CPL_DLL
2689 GTIFFBuildOverviews( const char * pszFilename,
2690  int nBands, GDALRasterBand **papoBandList,
2691  int nOverviews, int * panOverviewList,
2692  const char * pszResampling,
2693  GDALProgressFunc pfnProgress, void * pProgressData );
2694 
2695 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
2696  int &nXOff, int &nYOff,
2697  int &nXSize, int &nYSize,
2698  int nBufXSize, int nBufYSize) CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead");
2699 int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand* poBand,
2700  int &nXOff, int &nYOff,
2701  int &nXSize, int &nYSize,
2702  int nBufXSize, int nBufYSize,
2703  GDALRasterIOExtraArg* psExtraArg);
2704 
2705 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize ) CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead");
2706 int CPL_DLL GDALOvLevelAdjust2( int nOvLevel, int nXSize, int nYSize );
2707 int CPL_DLL GDALComputeOvFactor( int nOvrXSize, int nRasterXSize,
2708  int nOvrYSize, int nRasterYSize );
2709 
2710 GDALDataset CPL_DLL *
2711 GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
2712  GDALDataset *poDependentDS );
2713 
2714 /* ==================================================================== */
2715 /* Infrastructure to check that dataset characteristics are valid */
2716 /* ==================================================================== */
2717 
2718 int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize );
2719 int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed );
2720 
2721 /* Internal use only */
2722 
2723 /* CPL_DLL exported, but only for in-tree drivers that can be built as plugins */
2724 int CPL_DLL GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension,
2725  double *padfGeoTransform, char** papszSiblingFiles,
2726  char** ppszWorldFileNameOut);
2727 int GDALReadTabFile2( const char * pszBaseFilename,
2728  double *padfGeoTransform, char **ppszWKT,
2729  int *pnGCPCount, GDAL_GCP **ppasGCPs,
2730  char** papszSiblingFiles, char** ppszTabFileNameOut );
2731 
2732 void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg* psDestArg,
2733  GDALRasterIOExtraArg* psSrcArg);
2734 
2735 CPL_C_END
2736 
2737 void GDALNullifyOpenDatasetsList();
2738 CPLMutex** GDALGetphDMMutex();
2739 CPLMutex** GDALGetphDLMutex();
2740 void GDALNullifyProxyPoolSingleton();
2741 void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
2742 GIntBig GDALGetResponsiblePIDForCurrentThread();
2743 
2744 CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt,
2745  CSLConstList papszSiblingFiles, int nFlags );
2746 
2747 CPLErr CPL_DLL EXIFExtractMetadata(char**& papszMetadata,
2748  void *fpL, int nOffset,
2749  int bSwabflag, int nTIFFHEADER,
2750  int& nExifOffset, int& nInterOffset, int& nGPSOffset);
2751 
2752 int GDALValidateOpenOptions( GDALDriverH hDriver,
2753  const char* const* papszOptionOptions);
2754 int GDALValidateOptions( const char* pszOptionList,
2755  const char* const* papszOptionsToValidate,
2756  const char* pszErrorMessageOptionType,
2757  const char* pszErrorMessageContainerName);
2758 
2759 GDALRIOResampleAlg GDALRasterIOGetResampleAlg(const char* pszResampling);
2760 const char* GDALRasterIOGetResampleAlg(GDALRIOResampleAlg eResampleAlg);
2761 
2762 void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg* psExtraArg,
2763  int nXSize, int nYSize,
2764  int nBufXSize, int nBufYSize);
2765 
2766 
2767 GDALDataset* GDALCreateOverviewDataset(GDALDataset* poDS, int nOvrLevel,
2768  int bThisLevelOnly);
2769 
2770 // Should cover particular cases of #3573, #4183, #4506, #6578
2771 // Behavior is undefined if fVal1 or fVal2 are NaN (should be tested before
2772 // calling this function)
2773 template<class T> inline bool ARE_REAL_EQUAL(T fVal1, T fVal2, int ulp = 2)
2774 {
2775  return fVal1 == fVal2 || /* Should cover infinity */
2776  std::abs(fVal1 - fVal2) < std::numeric_limits<float>::epsilon() * std::abs(fVal1+fVal2) * ulp;
2777 }
2778 
2779 double GDALAdjustNoDataCloseToFloatMax(double dfVal);
2780 
2781 #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) )
2782 
2783 // Number of data samples that will be used to compute approximate statistics
2784 // (minimum value, maximum value, etc.)
2785 #define GDALSTAT_APPROX_NUMSAMPLES 2500
2786 
2787 void GDALSerializeGCPListToXML( CPLXMLNode* psParentNode,
2788  GDAL_GCP* pasGCPList,
2789  int nGCPCount,
2790  const OGRSpatialReference* poGCP_SRS );
2791 void GDALDeserializeGCPListFromXML( CPLXMLNode* psGCPList,
2792  GDAL_GCP** ppasGCPList,
2793  int* pnGCPCount,
2794  OGRSpatialReference** ppoGCP_SRS );
2795 
2796 void GDALSerializeOpenOptionsToXML( CPLXMLNode* psParentNode, char** papszOpenOptions);
2797 char** GDALDeserializeOpenOptionsFromXML( CPLXMLNode* psParentNode );
2798 
2799 int GDALCanFileAcceptSidecarFile(const char* pszFilename);
2800 
2801 bool GDALCanReliablyUseSiblingFileList(const char* pszFilename);
2802 
2804 
2805 #endif /* ndef GDAL_PRIV_H_INCLUDED */
GDAL_IDENTIFY_UNKNOWN
@ GDAL_IDENTIFY_UNKNOWN
Identify could not determine if the file is recognized or not by the probed driver.
Definition: gdal_priv.h:1445
GDALDimension::GetFullName
const std::string & GetFullName() const
Return the full name.
Definition: gdal_priv.h:2572
CPL_PRINT_FUNC_FORMAT
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition: cpl_port.h:921
GDAL_IDENTIFY_FALSE
@ GDAL_IDENTIFY_FALSE
Identify determined the file is not recognized by the probed driver.
Definition: gdal_priv.h:1447
GDALOpenInfo::fpL
VSILFILE * fpL
Pointer to the file.
Definition: gdal_priv.h:295
GDALExtendedDataType::GetSize
size_t GetSize() const
Return data type size in bytes.
Definition: gdal_priv.h:1833
GDALDimension::SetIndexingVariable
virtual bool SetIndexingVariable(std::shared_ptr< GDALMDArray > poIndexingVariable)
Set the variable that is used to index the dimension.
Definition: gdalmultidim.cpp:6273
GDALGetDataTypeSizeBytes
int GDALGetDataTypeSizeBytes(GDALDataType)
Get data type size in bytes.
Definition: gdal_misc.cpp:305
GDALGroup::GetFullName
const std::string & GetFullName() const
Return the full name of the group.
Definition: gdal_priv.h:1975
GByte
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:215
GDALAsyncReader::GetYOffset
int GetYOffset() const
Return y offset.
Definition: gdal_priv.h:1710
GDALExtendedDataType
Class used to represent potentially complex data types.
Definition: gdal_priv.h:1785
GDALRasterBlock::GetYSize
int GetYSize() const
Return the height of the block.
Definition: gdal_priv.h:955
GDALDataset::Layers::Iterator::iterator_category
std::input_iterator_tag iterator_category
iterator_category
Definition: gdal_priv.h:714
GUInt64
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition: cpl_port.h:269
gdal.h
Public (C callable) GDAL entry points.
GDALOpenInfo
Class for dataset open functions.
Definition: gdal_priv.h:269
GDALDataset::Layers::Iterator
Layer iterator.
Definition: gdal_priv.h:705
GDALRasterBand::ComputeStatistics
virtual CPLErr ComputeStatistics(int bApproxOK, double *pdfMin, double *pdfMax, double *pdfMean, double *pdfStdDev, GDALProgressFunc, void *pProgressData)
Compute image statistics.
Definition: gdalrasterband.cpp:4894
GDALAsyncReader::GetPixelSpace
int GetPixelSpace() const
Return pixel spacing.
Definition: gdal_priv.h:1746
GDALAbstractMDArray::GetFullName
const std::string & GetFullName() const
Return the name of an array or attribute.
Definition: gdal_priv.h:2094
GDALRasterBlock::GetBlockSize
GPtrDiff_t GetBlockSize() const
Return the block size in bytes.
Definition: gdal_priv.h:967
GDALEDTComponent
Class for a component of a compound extended data type.
Definition: gdal_priv.h:1876
GDALAsyncReader::GetBandCount
int GetBandCount() const
Return band count.
Definition: gdal_priv.h:1738
begin
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:287
GDALOpenEx
GDALDatasetH GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags, const char *const *papszAllowedDrivers, const char *const *papszOpenOptions, const char *const *papszSiblingFiles)
Open a raster or vector file as a GDALDataset.
Definition: gdaldataset.cpp:3237
GDALDataset::Layers::Iterator::difference_type
void difference_type
difference_type
Definition: gdal_priv.h:712
GDALMDArray::IsWritable
virtual bool IsWritable() const =0
Return whether an array is writable;.
OGRStyleTable
This class represents a style table.
Definition: ogr_featurestyle.h:85
GEDTC_NUMERIC
@ GEDTC_NUMERIC
Numeric value.
Definition: gdal.h:283
CPLStringList
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:442
GDALAsyncReader
Class used as a session object for asynchronous requests.
Definition: gdal_priv.h:1673
GDT_Unknown
@ GDT_Unknown
Definition: gdal.h:61
GPtrDiff_t
GIntBig GPtrDiff_t
Integer type large enough to hold the difference between 2 addresses.
Definition: cpl_port.h:286
GDALExtendedDataType::GetClass
GDALExtendedDataTypeClass GetClass() const
Return type class.
Definition: gdal_priv.h:1813
GDALAsyncReader::GetBufferYSize
int GetBufferYSize() const
Return buffer height.
Definition: gdal_priv.h:1730
cpl_minixml.h
Definitions for CPL mini XML Parser/Serializer.
GDALDriver
Format specific driver.
Definition: gdal_priv.h:1468
cpl_vsi.h
Standard C Covers.
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:158
GDALAbstractMDArray
Abstract class, implemented by GDALAttribute and GDALMDArray.
Definition: gdal_priv.h:2044
GDALDataset::Bands
Class returned by GetBands() that act as a container for raster bands.
Definition: gdal_priv.h:471
GDALColorTableH
void * GDALColorTableH
Opaque type used for the C bindings of the C++ GDALColorTable class.
Definition: gdal.h:267
GDALAsyncReader::GetLineSpace
int GetLineSpace() const
Return line spacing.
Definition: gdal_priv.h:1750
GDALClose
void GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition: gdaldataset.cpp:3656
GDALRasterBlock::GetDataRef
void * GetDataRef(void)
Return the data buffer.
Definition: gdal_priv.h:963
GDALOpenInfo::nOpenFlags
int nOpenFlags
Open flags.
Definition: gdal_priv.h:287
GDALOpenInfo::papszOpenOptions
char ** papszOpenOptions
Open options.
Definition: gdal_priv.h:282
GDALMajorObject::SetMetadataItem
virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain="")
Set single metadata item.
Definition: gdalmajorobject.cpp:388
OGRGeometry
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:326
GDALColorEntry
Color tuple.
Definition: gdal.h:1181
GDALDimension::GetName
const std::string & GetName() const
Return the name.
Definition: gdal_priv.h:2566
GDALAbstractMDArray::GetDimensions
virtual const std::vector< std::shared_ptr< GDALDimension > > & GetDimensions() const =0
Return the dimensions of an attribute/array.
GDALColorInterp
GDALColorInterp
Definition: gdal.h:194
OGRLayer
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:71
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:333
GDALRasterBand
A single raster band (or channel).
Definition: gdal_priv.h:1112
GInt64
GIntBig GInt64
Signed 64 bit integer type.
Definition: cpl_port.h:267
GDALIdentifyEnum
GDALIdentifyEnum
Enumeration used by GDALDriver::pfnIdentify().
Definition: gdal_priv.h:1443
GDALAsyncReader::GetBandSpace
int GetBandSpace() const
Return band spacing.
Definition: gdal_priv.h:1754
GDALIHasAttribute::GetAttributes
virtual std::vector< std::shared_ptr< GDALAttribute > > GetAttributes(CSLConstList papszOptions=nullptr) const
Return the list of attributes contained in a GDALMDArray or GDALGroup.
Definition: gdalmultidim.cpp:116
GDALDimension::GetDirection
const std::string & GetDirection() const
Return the axis direction.
Definition: gdal_priv.h:2592
GDALAsyncReader::GetBufferType
GDALDataType GetBufferType() const
Return buffer data type.
Definition: gdal_priv.h:1734
GDALExtendedDataTypeClass
GDALExtendedDataTypeClass
Enumeration giving the class of a GDALExtendedDataType.
Definition: gdal.h:281
GDALRawResult::data
const GByte * data() const
Return pointer to the start of data.
Definition: gdal_priv.h:2195
GDALDataType
GDALDataType
Definition: gdal.h:60
CPLXMLNode
Document node structure.
Definition: cpl_minixml.h:70
OGRFeatureUniquePtr
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:790
GDALAbstractMDArray::GetName
const std::string & GetName() const
Return the name of an array or attribute.
Definition: gdal_priv.h:2088
GDALRasterBlock
A single raster block in the block cache.
Definition: gdal_priv.h:891
GDALMajorObjectH
void * GDALMajorObjectH
Opaque type used for the C bindings of the C++ GDALMajorObject class.
Definition: gdal.h:255
GDALRawResult
Store the raw result of an attribute value, which might contain dynamically allocated structures (lik...
Definition: gdal_priv.h:2167
GDALGroup
Class modeling a named container of GDALAttribute, GDALMDArray or other GDALGroup.
Definition: gdal_priv.h:1949
GDALDataset
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:340
GDALDataset::GetOpenOptions
char ** GetOpenOptions()
Return open options.
Definition: gdal_priv.h:606
GDALDataset::BuildOverviews
CPLErr BuildOverviews(const char *, int, int *, int, int *, GDALProgressFunc, void *)
Build raster overview(s)
Definition: gdaldataset.cpp:1929
GDALMajorObject::FromHandle
static GDALMajorObject * FromHandle(GDALMajorObjectH hMajorObject)
Convert a GDALMajorObjectH to a GDALMajorObject*.
Definition: gdal_priv.h:177
GDALRawResult::size
size_t size() const
Return the size in bytes of the raw result.
Definition: gdal_priv.h:2197
GDALIHasAttribute
Interface used to get a single GDALAttribute or a set of GDALAttribute.
Definition: gdal_priv.h:1918
GDALOpenInfo::bStatOK
int bStatOK
Whether stat()'ing the file was successful.
Definition: gdal_priv.h:290
CPL_C_START
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:337
GDALDriverManager
Class for managing the registration of file format drivers.
Definition: gdal_priv.h:1623
GDALMDArray
Class modeling a multi-dimensional array.
Definition: gdal_priv.h:2337
GDALOpenInfo::pabyHeader
GByte * pabyHeader
Buffer with first bytes of the file.
Definition: gdal_priv.h:300
GDALAsyncReader::GetYSize
int GetYSize() const
Return height.
Definition: gdal_priv.h:1718
GDALOpenInfo::eAccess
GDALAccess eAccess
Access flag.
Definition: gdal_priv.h:285
GDALRasterBand::GetMaskBand
virtual GDALRasterBand * GetMaskBand()
Return the mask band associated with the band.
Definition: gdalrasterband.cpp:5954
GDALMDArray::at
std::shared_ptr< GDALMDArray > at(GUInt64 idx, GUInt64VarArg... tail) const
Return a view of the array using integer indexing.
Definition: gdal_priv.h:2425
GDALExtendedDataType::GetNumericDataType
GDALDataType GetNumericDataType() const
Return numeric data type (only valid when GetClass() == GEDTC_NUMERIC)
Definition: gdal_priv.h:1819
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1216
GDALExtendedDataType::CreateString
static GDALExtendedDataType CreateString(size_t nMaxStringLength=0)
Return a new GDALExtendedDataType of class GEDTC_STRING.
Definition: gdalmultidim.cpp:6001
CPLErrorNum
int CPLErrorNum
Error number.
Definition: cpl_error.h:94
GUIntBig
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:251
GDALDataset::Open
static GDALDataset * Open(const char *pszFilename, unsigned int nOpenFlags=0, const char *const *papszAllowedDrivers=nullptr, const char *const *papszOpenOptions=nullptr, const char *const *papszSiblingFiles=nullptr)
Definition: gdal_priv.h:651
GDT_Float64
@ GDT_Float64
Definition: gdal.h:70
GDALRasterBlock::DropLock
int DropLock(void)
Decrement the lock count.
Definition: gdal_priv.h:931
GDALOpenInfo::bIsDirectory
int bIsDirectory
Whether the file is a directory.
Definition: gdal_priv.h:292
GDALDimension::GetType
const std::string & GetType() const
Return the axis type.
Definition: gdal_priv.h:2582
GDAL_GCP
Ground Control Point.
Definition: gdal.h:669
CPL_C_END
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:339
GDALRasterBand::IReadBlock
virtual CPLErr IReadBlock(int nBlockXOff, int nBlockYOff, void *pData)=0
Read a block of data.
GDALDimension
Class modeling a a dimension / axis used to index multidimensional arrays.
Definition: gdal_priv.h:2550
CPL_NULL_TERMINATED
#define CPL_NULL_TERMINATED
Null terminated variadic.
Definition: cpl_port.h:911
GDALExtendedDataType::GetComponents
const std::vector< std::unique_ptr< GDALEDTComponent > > & GetComponents() const
Return the components of the data type (only valid when GetClass() == GEDTC_COMPOUND)
Definition: gdal_priv.h:1825
GDALAsyncReader::GetNextUpdatedRegion
virtual GDALAsyncStatusType GetNextUpdatedRegion(double dfTimeout, int *pnBufXOff, int *pnBufYOff, int *pnBufXSize, int *pnBufYSize)=0
Get async IO update.
GDALAbstractMDArray::GetDataType
virtual const GDALExtendedDataType & GetDataType() const =0
Return the data type of an attribute/array.
ogr_feature.h
Simple feature classes.
GDALDataset::FeatureLayerPair
Object returned by GetFeatures() iterators.
Definition: gdal_priv.h:665
GDALAsyncReader::GetGDALDataset
GDALDataset * GetGDALDataset()
Return dataset.
Definition: gdal_priv.h:1702
CPLString::toupper
CPLString & toupper(void)
Convert to upper case in place.
Definition: cplstring.cpp:316
cpl_conv.h
Various convenience functions for CPL.
GDALDataset::ToHandle
static GDALDatasetH ToHandle(GDALDataset *poDS)
Convert a GDALDataset* to a GDALDatasetH.
Definition: gdal_priv.h:639
CPLVirtualMem
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition: cpl_virtualmem.h:62
cpl_string.h
Various convenience functions for working with strings and string lists.
GDALOpenInfo::papszAllowedDrivers
const char *const * papszAllowedDrivers
Allowed drivers (NULL for all)
Definition: gdal_priv.h:303
GDALDataset::CloseDependentDatasets
virtual int CloseDependentDatasets()
Drop references to any other datasets referenced by this dataset.
Definition: gdaldataset.cpp:4043
GDALColorTable::ToHandle
static GDALColorTableH ToHandle(GDALColorTable *poCT)
Convert a GDALColorTable* to a GDALRasterBandH.
Definition: gdal_priv.h:1030
GDALRasterBlock::AddLock
int AddLock(void)
Increment the lock count.
Definition: gdal_priv.h:929
GDALDataset::CreateMaskBand
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the dataset.
Definition: gdaldataset.cpp:3054
GSpacing
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:276
vsi_l_offset
GUIntBig vsi_l_offset
Type for a file offset.
Definition: cpl_vsi.h:140
GDALDimension::GetSize
GUInt64 GetSize() const
Return the size, that is the number of values along the dimension.
Definition: gdal_priv.h:2598
GDALAccess
GDALAccess
Definition: gdal.h:113
GDALDataset::MarkSuppressOnClose
void MarkSuppressOnClose()
Set that the dataset must be deleted on close.
Definition: gdal_priv.h:601
end
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:292
GDALAsyncStatusType
GDALAsyncStatusType
status of the asynchronous stream
Definition: gdal.h:101
GDALEDTComponent::GetOffset
size_t GetOffset() const
Return the offset (in bytes) of the component in the compound data type.
Definition: gdal_priv.h:1894
GDALDriver::FromHandle
static GDALDriver * FromHandle(GDALDriverH hDriver)
Convert a GDALDriverH to a GDALDriver*.
Definition: gdal_priv.h:1604
GDALRawResult::operator[]
const GByte & operator[](size_t idx) const
Return byte at specified index.
Definition: gdal_priv.h:2193
GDAL_IDENTIFY_TRUE
@ GDAL_IDENTIFY_TRUE
Identify determined the file is recognized by the probed driver.
Definition: gdal_priv.h:1449
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:318
GA_ReadOnly
@ GA_ReadOnly
Definition: gdal.h:114
GDALDimension::GetIndexingVariable
virtual std::shared_ptr< GDALMDArray > GetIndexingVariable() const
Return the variable that is used to index the dimension (if there is one).
Definition: gdalmultidim.cpp:6252
GDALAsyncReader::GetXSize
int GetXSize() const
Return width.
Definition: gdal_priv.h:1714
GDALRasterBlock::GetDirty
int GetDirty() const
Return the dirty flag.
Definition: gdal_priv.h:959
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:248
GDALDataset::Layers::Iterator::pointer
void pointer
pointer
Definition: gdal_priv.h:713
GDALAsyncReader::GetBufferXSize
int GetBufferXSize() const
Return buffer width.
Definition: gdal_priv.h:1726
GDALOpenInfo::nHeaderBytes
int nHeaderBytes
Number of bytes in pabyHeader.
Definition: gdal_priv.h:298
OGRwkbGeometryType
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:346
GDALDriver::ToHandle
static GDALDriverH ToHandle(GDALDriver *poDriver)
Convert a GDALDriver* to a GDALDriverH.
Definition: gdal_priv.h:1598
GDALRasterIOExtraArg
Structure to pass extra arguments to RasterIO() method.
Definition: gdal.h:151
GDALDataset::Layers::Iterator::~Iterator
~Iterator()
Destructor.
GDALRasterBand::ToHandle
void static GDALRasterBandH ToHandle(GDALRasterBand *poBand)
Convert a GDALRasterBand* to a GDALRasterBandH.
Definition: gdal_priv.h:1327
GDALRasterBlock::GetYOff
int GetYOff() const
Return the y offset of the top-left corner of the block.
Definition: gdal_priv.h:947
CPL_WARN_UNUSED_RESULT
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:946
GDALDataset::GetAccess
GDALAccess GetAccess() const
Return access mode.
Definition: gdal_priv.h:595
OGRFeature
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:365
GDALRWFlag
GDALRWFlag
Definition: gdal.h:119
GDALDataset::Features
Class returned by GetFeatures() that act as a container for vector features.
Definition: gdal_priv.h:755
GDALMajorObject
Object with metadata.
Definition: gdal_priv.h:136
GDALAbstractMDArray::Write
bool Write(const GUInt64 *arrayStartIdx, const size_t *count, const GInt64 *arrayStep, const GPtrDiff_t *bufferStride, const GDALExtendedDataType &bufferDataType, const void *pSrcBuffer, const void *pSrcBufferAllocStart=nullptr, size_t nSrcBufferAllocSize=0)
Write part or totality of a multidimensional array or attribute.
Definition: gdalmultidim.cpp:1454
GDALRasterBand::IRasterIO
virtual CPLErr IRasterIO(GDALRWFlag, int, int, int, int, void *, int, int, GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg *psExtraArg)
Read/write a region of image data for this band.
Definition: rasterio.cpp:68
GDALDataset::SetMetadataItem
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
CPLErr
CPLErr
Error category.
Definition: cpl_error.h:53
GDALAttribute
Class modeling an attribute that has a name, a value and a type, and is typically used to describe a ...
Definition: gdal_priv.h:2220
GDALDataset::SetMetadata
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
GDALEDTComponent::GetType
const GDALExtendedDataType & GetType() const
Return the data type of the component.
Definition: gdal_priv.h:1900
GDALColorTable::~GDALColorTable
~GDALColorTable()
Destructor.
GDALOpenInfo::pszFilename
char * pszFilename
Filename.
Definition: gdal_priv.h:280
GDALColorTable::FromHandle
static GDALColorTable * FromHandle(GDALColorTableH hCT)
Convert a GDALColorTableH to a GDALColorTable*.
Definition: gdal_priv.h:1036
GDT_Byte
@ GDT_Byte
Definition: gdal.h:62
GPI_RGB
@ GPI_RGB
Definition: gdal.h:222
GDALDatasetUniquePtr
std::unique_ptr< GDALDataset, GDALDatasetUniquePtrDeleter > GDALDatasetUniquePtr
Unique pointer type for GDALDataset.
Definition: gdal_priv.h:880
GDALRasterBand::GetMaskFlags
virtual int GetMaskFlags()
Return the status flags of the mask band associated with the band.
Definition: gdalrasterband.cpp:6219
GDALEDTComponent::GDALEDTComponent
GDALEDTComponent(const GDALEDTComponent &)
Copy constructor.
GDALRIOResampleAlg
GDALRIOResampleAlg
RasterIO() resampling method.
Definition: gdal.h:129
GetGDALDriverManager
GDALDriverManager * GetGDALDriverManager(void)
Fetch the global GDAL driver manager.
Definition: gdaldrivermanager.cpp:98
GDALRasterBand::SetMetadata
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
GDALRasterAttributeTable
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition: gdal_rat.h:48
GDALAsyncReader::GetXOffset
int GetXOffset() const
Return x offset.
Definition: gdal_priv.h:1706
GDALExtendedDataType::GetMaxStringLength
size_t GetMaxStringLength() const
Return the maximum length of a string in bytes.
Definition: gdal_priv.h:1839
GDALRasterBlock::GetBand
GDALRasterBand * GetBand()
Accessor to source GDALRasterBand object.
Definition: gdal_priv.h:975
GDALDataset::Layers
Class returned by GetLayers() that acts as a range of layers.
Definition: gdal_priv.h:692
GDALRasterBand::SetMetadataItem
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
GDALRasterBlock::GetXOff
int GetXOff() const
Return the x offset of the top-left corner of the block.
Definition: gdal_priv.h:943
GDALRasterBlock::GetDataType
GDALDataType GetDataType() const
Return the data type.
Definition: gdal_priv.h:939
GDALDataset::FromHandle
static GDALDataset * FromHandle(GDALDatasetH hDS)
Convert a GDALDatasetH to a GDALDataset*.
Definition: gdal_priv.h:645
ogr_core.h
Core portability services for cross-platform OGR code.
GDALPaletteInterp
GDALPaletteInterp
Definition: gdal.h:220
GDALExtendedDataType::Create
static GDALExtendedDataType Create(GDALDataType eType)
Return a new GDALExtendedDataType of class GEDTC_NUMERIC.
Definition: gdalmultidim.cpp:5938
GDALMajorObject::ToHandle
static GDALMajorObjectH ToHandle(GDALMajorObject *poMajorObject)
Convert a GDALMajorObject* to a GDALMajorObjectH.
Definition: gdal_priv.h:171
GDALRasterBandH
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:261
GDALGroup::GetName
const std::string & GetName() const
Return the name of the group.
Definition: gdal_priv.h:1969
wkbUnknown
@ wkbUnknown
unknown type, non-standard
Definition: ogr_core.h:347
GDALAsyncReader::GetBuffer
void * GetBuffer()
Return buffer.
Definition: gdal_priv.h:1722
GDALExtendedDataType::GetName
const std::string & GetName() const
Return type name.
Definition: gdal_priv.h:1807
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:1007
GDALEDTComponent::GetName
const std::string & GetName() const
Return the name.
Definition: gdal_priv.h:1888
GDALRasterBlock::GetXSize
int GetXSize() const
Return the width of the block.
Definition: gdal_priv.h:951
GDALDatasetH
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition: gdal.h:258
GDALRasterBand::FromHandle
static GDALRasterBand * FromHandle(GDALRasterBandH hBand)
Convert a GDALRasterBandH to a GDALRasterBand*.
Definition: gdal_priv.h:1333
GDALColorTable
A color table / palette.
Definition: gdal_priv.h:1006
VSILFILE
FILE VSILFILE
Opaque type for a FILE that implements the VSIVirtualHandle API.
Definition: cpl_vsi.h:156
GDALAsyncReader::GetBandMap
int * GetBandMap()
Return band map.
Definition: gdal_priv.h:1742
GDALDriverH
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition: gdal.h:264