GDAL
gdal_priv.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: gdal_priv.h 8f0ebfd5b6f153a63b6e2186b68577937cedc02c 2020-06-14 00:21:08 +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 <cmath>
70 #include <cstdint>
71 #include <iterator>
72 #include <limits>
73 #include <map>
74 #include <memory>
75 #include <vector>
76 
77 #include "ogr_core.h"
78 #include "ogr_feature.h"
79 
81 #define GMO_VALID 0x0001
82 #define GMO_IGNORE_UNIMPLEMENTED 0x0002
83 #define GMO_SUPPORT_MD 0x0004
84 #define GMO_SUPPORT_MDMD 0x0008
85 #define GMO_MD_DIRTY 0x0010
86 #define GMO_PAM_CLASS 0x0020
88 
89 /************************************************************************/
90 /* GDALMultiDomainMetadata */
91 /************************************************************************/
92 
94 class CPL_DLL GDALMultiDomainMetadata
95 {
96 private:
97  char **papszDomainList;
98  CPLStringList **papoMetadataLists;
99 
100 public:
101  GDALMultiDomainMetadata();
102  ~GDALMultiDomainMetadata();
103 
104  int XMLInit( CPLXMLNode *psMetadata, int bMerge );
105  CPLXMLNode *Serialize();
106 
107  char **GetDomainList() { return papszDomainList; }
108 
109  char **GetMetadata( const char * pszDomain = "" );
110  CPLErr SetMetadata( char ** papszMetadata,
111  const char * pszDomain = "" );
112  const char *GetMetadataItem( const char * pszName,
113  const char * pszDomain = "" );
114  CPLErr SetMetadataItem( const char * pszName,
115  const char * pszValue,
116  const char * pszDomain = "" );
117 
118  void Clear();
119 
120  private:
121  CPL_DISALLOW_COPY_ASSIGN(GDALMultiDomainMetadata)
122 };
124 
125 /* ******************************************************************** */
126 /* GDALMajorObject */
127 /* */
128 /* Base class providing metadata, description and other */
129 /* services shared by major objects. */
130 /* ******************************************************************** */
131 
133 class CPL_DLL GDALMajorObject
134 {
135  protected:
137  int nFlags; // GMO_* flags.
138  CPLString sDescription{};
139  GDALMultiDomainMetadata oMDMD{};
140 
142 
143  char **BuildMetadataDomainList( char** papszList,
144  int bCheckNonEmpty, ... ) CPL_NULL_TERMINATED;
145  public:
146  GDALMajorObject();
147  virtual ~GDALMajorObject();
148 
149  int GetMOFlags() const;
150  void SetMOFlags( int nFlagsIn );
151 
152  virtual const char *GetDescription() const;
153  virtual void SetDescription( const char * );
154 
155  virtual char **GetMetadataDomainList();
156 
157  virtual char **GetMetadata( const char * pszDomain = "" );
158  virtual CPLErr SetMetadata( char ** papszMetadata,
159  const char * pszDomain = "" );
160  virtual const char *GetMetadataItem( const char * pszName,
161  const char * pszDomain = "" );
162  virtual CPLErr SetMetadataItem( const char * pszName,
163  const char * pszValue,
164  const char * pszDomain = "" );
165 
169  static inline GDALMajorObjectH ToHandle(GDALMajorObject* poMajorObject)
170  { return static_cast<GDALMajorObjectH>(poMajorObject); }
171 
175  static inline GDALMajorObject* FromHandle(GDALMajorObjectH hMajorObject)
176  { return static_cast<GDALMajorObject*>(hMajorObject); }
177 };
178 
179 /* ******************************************************************** */
180 /* GDALDefaultOverviews */
181 /* ******************************************************************** */
182 
184 class CPL_DLL GDALDefaultOverviews
185 {
186  friend class GDALDataset;
187 
188  GDALDataset *poDS;
189  GDALDataset *poODS;
190 
191  CPLString osOvrFilename{};
192 
193  bool bOvrIsAux;
194 
195  bool bCheckedForMask;
196  bool bOwnMaskDS;
197  GDALDataset *poMaskDS;
198 
199  // For "overview datasets" we record base level info so we can
200  // find our way back to get overview masks.
201  GDALDataset *poBaseDS;
202 
203  // Stuff for deferred initialize/overviewscans.
204  bool bCheckedForOverviews;
205  void OverviewScan();
206  char *pszInitName;
207  bool bInitNameIsOVR;
208  char **papszInitSiblingFiles;
209 
210  public:
211  GDALDefaultOverviews();
212  ~GDALDefaultOverviews();
213 
214  void Initialize( GDALDataset *poDSIn, const char *pszName = nullptr,
215  char **papszSiblingFiles = nullptr,
216  int bNameIsOVR = FALSE );
217 
218  void TransferSiblingFiles( char** papszSiblingFiles );
219 
220  int IsInitialized();
221 
223 
224  // Overview Related
225 
226  int GetOverviewCount( int nBand );
227  GDALRasterBand *GetOverview( int nBand, int iOverview );
228 
229  CPLErr BuildOverviews( const char * pszBasename,
230  const char * pszResampling,
231  int nOverviews, int * panOverviewList,
232  int nBands, int * panBandList,
233  GDALProgressFunc pfnProgress,
234  void *pProgressData );
235 
236  CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile,
237  const char * pszResampling,
238  int nOverviews, int * panOverviewList,
239  int nBands, int * panBandList,
240  GDALProgressFunc pfnProgress,
241  void *pProgressData );
242 
243  CPLErr CleanOverviews();
244 
245  // Mask Related
246 
247  CPLErr CreateMaskBand( int nFlags, int nBand = -1 );
248  GDALRasterBand *GetMaskBand( int nBand );
249  int GetMaskFlags( int nBand );
250 
251  int HaveMaskFile( char **papszSiblings = nullptr,
252  const char *pszBasename = nullptr );
253 
254  char** GetSiblingFiles() { return papszInitSiblingFiles; }
255 
256  private:
257  CPL_DISALLOW_COPY_ASSIGN(GDALDefaultOverviews)
258 };
260 
261 /* ******************************************************************** */
262 /* GDALOpenInfo */
263 /* ******************************************************************** */
264 
266 class CPL_DLL GDALOpenInfo
267 {
268  bool bHasGotSiblingFiles;
269  char **papszSiblingFiles;
270  int nHeaderBytesTried;
271 
272  public:
273  GDALOpenInfo( const char * pszFile, int nOpenFlagsIn,
274  const char * const * papszSiblingFiles = nullptr );
275  ~GDALOpenInfo( void );
276 
278  char *pszFilename;
281 
286 
288  int bStatOK;
291 
294 
299 
301  const char* const* papszAllowedDrivers;
302 
303  int TryToIngest(int nBytes);
304  char **GetSiblingFiles();
305  char **StealSiblingFiles();
306  bool AreSiblingFilesLoaded() const;
307 
308  private:
310 };
311 
312 /* ******************************************************************** */
313 /* GDALDataset */
314 /* ******************************************************************** */
315 
316 class OGRLayer;
317 class OGRGeometry;
318 class OGRSpatialReference;
319 class OGRStyleTable;
320 class swq_select;
321 class swq_select_parse_options;
322 class GDALGroup;
323 
325 typedef struct GDALSQLParseInfo GDALSQLParseInfo;
327 
329 #ifdef GDAL_COMPILATION
330 #define OPTIONAL_OUTSIDE_GDAL(val)
331 #else
332 #define OPTIONAL_OUTSIDE_GDAL(val) = val
333 #endif
335 
337 class CPL_DLL GDALDataset : public GDALMajorObject
338 {
339  friend GDALDatasetH CPL_STDCALL GDALOpenEx( const char* pszFilename,
340  unsigned int nOpenFlags,
341  const char* const* papszAllowedDrivers,
342  const char* const* papszOpenOptions,
343  const char* const* papszSiblingFiles );
344  friend void CPL_STDCALL GDALClose( GDALDatasetH hDS );
345 
346  friend class GDALDriver;
347  friend class GDALDefaultOverviews;
348  friend class GDALProxyDataset;
349  friend class GDALDriverManager;
350 
351  CPL_INTERNAL void AddToDatasetOpenList();
352 
353  protected:
355  GDALDriver *poDriver = nullptr;
356  GDALAccess eAccess = GA_ReadOnly;
357 
358  // Stored raster information.
359  int nRasterXSize = 512;
360  int nRasterYSize = 512;
361  int nBands = 0;
362  GDALRasterBand **papoBands = nullptr;
363 
364  int nOpenFlags = 0;
365 
366  int nRefCount = 1;
367  bool bForceCachedIO = false;
368  bool bShared = false;
369  bool bIsInternal = true;
370  bool bSuppressOnClose = false;
371 
372  GDALDataset(void);
373  explicit GDALDataset(int bForceCachedIO);
374 
375  void RasterInitialize( int, int );
376  void SetBand( int, GDALRasterBand * );
377 
378  GDALDefaultOverviews oOvManager{};
379 
380  virtual CPLErr IBuildOverviews( const char *, int, int *,
381  int, int *, GDALProgressFunc, void * );
382 
383  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
384  void *, int, int, GDALDataType,
385  int, int *, GSpacing, GSpacing, GSpacing,
387 
388  CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
389  void *, int, int, GDALDataType,
390  int, int *, GSpacing, GSpacing, GSpacing,
392  void BlockBasedFlushCache();
393 
394  CPLErr BandBasedRasterIO( GDALRWFlag eRWFlag,
395  int nXOff, int nYOff, int nXSize, int nYSize,
396  void * pData, int nBufXSize, int nBufYSize,
397  GDALDataType eBufType,
398  int nBandCount, int *panBandMap,
399  GSpacing nPixelSpace, GSpacing nLineSpace,
400  GSpacing nBandSpace,
402 
403  CPLErr RasterIOResampled( GDALRWFlag eRWFlag,
404  int nXOff, int nYOff, int nXSize, int nYSize,
405  void * pData, int nBufXSize, int nBufYSize,
406  GDALDataType eBufType,
407  int nBandCount, int *panBandMap,
408  GSpacing nPixelSpace, GSpacing nLineSpace,
409  GSpacing nBandSpace,
411 
412  CPLErr ValidateRasterIOOrAdviseReadParameters(
413  const char* pszCallingFunc,
414  int* pbStopProcessingOnCENone,
415  int nXOff, int nYOff, int nXSize, int nYSize,
416  int nBufXSize, int nBufYSize,
417  int nBandCount, int *panBandMap);
418 
419  CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
420  int nXOff, int nYOff, int nXSize, int nYSize,
421  void * pData, int nBufXSize, int nBufYSize,
422  GDALDataType eBufType,
423  int nBandCount, int *panBandMap,
424  GSpacing nPixelSpace, GSpacing nLineSpace,
425  GSpacing nBandSpace,
426  GDALRasterIOExtraArg* psExtraArg,
427  int* pbTried);
428 
429  void ShareLockWithParentDataset(GDALDataset* poParentDataset);
430 
432  virtual int CloseDependentDatasets();
434  int ValidateLayerCreationOptions( const char* const* papszLCO );
435 
436  char **papszOpenOptions = nullptr;
437 
438  friend class GDALRasterBand;
439 
440  // The below methods related to read write mutex are fragile logic, and
441  // should not be used by out-of-tree code if possible.
442  int EnterReadWrite(GDALRWFlag eRWFlag);
443  void LeaveReadWrite();
444  void InitRWLock();
445 
446  void TemporarilyDropReadWriteLock();
447  void ReacquireReadWriteLock();
448 
449  void DisableReadWriteMutex();
450 
451  int AcquireMutex();
452  void ReleaseMutex();
454 
455  public:
456  ~GDALDataset() override;
457 
458  int GetRasterXSize();
459  int GetRasterYSize();
460  int GetRasterCount();
461  GDALRasterBand *GetRasterBand( int );
462 
464  class CPL_DLL Bands
465  {
466  private:
467 
468  friend class GDALDataset;
469  GDALDataset* m_poSelf;
470  CPL_INTERNAL explicit Bands(GDALDataset* poSelf): m_poSelf(poSelf) {}
471 
472  class CPL_DLL Iterator
473  {
474  struct Private;
475  std::unique_ptr<Private> m_poPrivate;
476  public:
477  Iterator(GDALDataset* poDS, bool bStart);
478  Iterator(const Iterator& oOther); // declared but not defined. Needed for gcc 5.4 at least
479  Iterator(Iterator&& oOther) noexcept; // declared but not defined. Needed for gcc 5.4 at least
480  ~Iterator();
481  GDALRasterBand* operator*();
482  Iterator& operator++();
483  bool operator!=(const Iterator& it) const;
484  };
485 
486  public:
487 
488  const Iterator begin() const;
489 
490  const Iterator end() const;
491 
492  size_t size() const;
493 
494  GDALRasterBand* operator[](int iBand);
495  GDALRasterBand* operator[](size_t iBand);
496  };
497 
498  Bands GetBands();
499 
500  virtual void FlushCache(void);
501 
502  virtual const OGRSpatialReference* GetSpatialRef() const;
503  virtual CPLErr SetSpatialRef(const OGRSpatialReference* poSRS);
504 
505  // Compatibility layer
506  const char *GetProjectionRef(void) const;
507  CPLErr SetProjection( const char * pszProjection );
508 
509  virtual CPLErr GetGeoTransform( double * padfTransform );
510  virtual CPLErr SetGeoTransform( double * padfTransform );
511 
512  virtual CPLErr AddBand( GDALDataType eType,
513  char **papszOptions=nullptr );
514 
515  virtual void *GetInternalHandle( const char * pszHandleName );
516  virtual GDALDriver *GetDriver(void);
517  virtual char **GetFileList(void);
518 
519  virtual const char* GetDriverName();
520 
521  virtual const OGRSpatialReference* GetGCPSpatialRef() const;
522  virtual int GetGCPCount();
523  virtual const GDAL_GCP *GetGCPs();
524  virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
525  const OGRSpatialReference * poGCP_SRS );
526 
527  // Compatibility layer
528  const char *GetGCPProjection();
529  CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
530  const char *pszGCPProjection );
531 
532  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
533  int nBufXSize, int nBufYSize,
534  GDALDataType eDT,
535  int nBandCount, int *panBandList,
536  char **papszOptions );
537 
538  virtual CPLErr CreateMaskBand( int nFlagsIn );
539 
540  virtual GDALAsyncReader*
541  BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize,
542  void *pBuf, int nBufXSize, int nBufYSize,
543  GDALDataType eBufType,
544  int nBandCount, int* panBandMap,
545  int nPixelSpace, int nLineSpace, int nBandSpace,
546  char **papszOptions);
547  virtual void EndAsyncReader(GDALAsyncReader *);
548 
550  struct RawBinaryLayout
551  {
552  enum class Interleaving
553  {
554  UNKNOWN,
555  BIP,
556  BIL,
557  BSQ
558  };
559  std::string osRawFilename{};
560  Interleaving eInterleaving = Interleaving::UNKNOWN;
561  GDALDataType eDataType = GDT_Unknown;
562  bool bLittleEndianOrder = false;
563 
564  vsi_l_offset nImageOffset = 0;
565  GIntBig nPixelOffset = 0;
566  GIntBig nLineOffset = 0;
567  GIntBig nBandOffset = 0;
568  };
569 
570  virtual bool GetRawBinaryLayout(RawBinaryLayout&);
572 
573  CPLErr RasterIO( GDALRWFlag, int, int, int, int,
574  void *, int, int, GDALDataType,
575  int, int *, GSpacing, GSpacing, GSpacing,
576  GDALRasterIOExtraArg* psExtraArg
577 #ifndef DOXYGEN_SKIP
578  OPTIONAL_OUTSIDE_GDAL(nullptr)
579 #endif
581 
582  int Reference();
583  int Dereference();
584  int ReleaseRef();
585 
589  GDALAccess GetAccess() const { return eAccess; }
590 
591  int GetShared() const;
592  void MarkAsShared();
593 
595  void MarkSuppressOnClose() { bSuppressOnClose = true; }
596 
600  char **GetOpenOptions() { return papszOpenOptions; }
601 
602  static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
603 
604  CPLErr BuildOverviews( const char *, int, int *,
605  int, int *, GDALProgressFunc, void * );
606 
607 #ifndef DOXYGEN_XML
608  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
609 #endif
610 
611  char ** GetMetadata(const char * pszDomain = "") override;
612 
613 // Only defined when Doxygen enabled
614 #ifdef DOXYGEN_SKIP
615  CPLErr SetMetadata( char ** papszMetadata,
616  const char * pszDomain ) override;
617  CPLErr SetMetadataItem( const char * pszName,
618  const char * pszValue,
619  const char * pszDomain ) override;
620 #endif
621 
622  char **GetMetadataDomainList() override;
623 
627  static inline GDALDatasetH ToHandle(GDALDataset* poDS)
628  { return static_cast<GDALDatasetH>(poDS); }
629 
633  static inline GDALDataset* FromHandle(GDALDatasetH hDS)
634  { return static_cast<GDALDataset*>(hDS); }
635 
639  static GDALDataset* Open( const char* pszFilename,
640  unsigned int nOpenFlags = 0,
641  const char* const* papszAllowedDrivers = nullptr,
642  const char* const* papszOpenOptions = nullptr,
643  const char* const* papszSiblingFiles = nullptr )
644  {
645  return FromHandle(GDALOpenEx(pszFilename, nOpenFlags,
646  papszAllowedDrivers,
647  papszOpenOptions,
648  papszSiblingFiles));
649  }
650 
653  {
656 
658  OGRLayer* layer = nullptr;
659  };
660 
661 private:
662  class Private;
663  Private *m_poPrivate;
664 
665  CPL_INTERNAL OGRLayer* BuildLayerFromSelectInfo(swq_select* psSelectInfo,
666  OGRGeometry *poSpatialFilter,
667  const char *pszDialect,
668  swq_select_parse_options* poSelectParseOptions);
669  CPLStringList oDerivedMetadataList{};
670 
671  public:
672 
673  virtual int GetLayerCount();
674  virtual OGRLayer *GetLayer(int iLayer);
675 
679  class CPL_DLL Layers
680  {
681  private:
682 
683  friend class GDALDataset;
684  GDALDataset* m_poSelf;
685  CPL_INTERNAL explicit Layers(GDALDataset* poSelf): m_poSelf(poSelf) {}
686 
687  public:
688 
692  class CPL_DLL Iterator
693  {
694  struct Private;
695  std::unique_ptr<Private> m_poPrivate;
696  public:
697 
698  using value_type = OGRLayer*;
699  using reference = OGRLayer*;
700  using difference_type = void;
701  using pointer = void;
702  using iterator_category = std::input_iterator_tag;
704  Iterator();
705  Iterator(GDALDataset* poDS, bool bStart);
706  Iterator(const Iterator& oOther);
707  Iterator(Iterator&& oOther) noexcept;
710  Iterator& operator=(const Iterator& oOther);
711  Iterator& operator=(Iterator&& oOther) noexcept;
713  OGRLayer* operator*() const;
714  Iterator& operator++();
715  Iterator operator++(int);
716  bool operator!=(const Iterator& it) const;
717  };
718 
719  Iterator begin() const;
720  Iterator end() const;
721 
722  size_t size() const;
723 
724  OGRLayer* operator[](int iLayer);
725  OGRLayer* operator[](size_t iLayer);
726  OGRLayer* operator[](const char* pszLayername);
727  };
728 
729  Layers GetLayers();
730 
731  virtual OGRLayer *GetLayerByName(const char *);
732  virtual OGRErr DeleteLayer(int iLayer);
733 
734  virtual void ResetReading();
735  virtual OGRFeature* GetNextFeature( OGRLayer** ppoBelongingLayer,
736  double* pdfProgressPct,
737  GDALProgressFunc pfnProgress,
738  void* pProgressData );
739 
740 
742  class CPL_DLL Features
743  {
744  private:
745 
746  friend class GDALDataset;
747  GDALDataset* m_poSelf;
748  CPL_INTERNAL explicit Features(GDALDataset* poSelf): m_poSelf(poSelf) {}
749 
750  class CPL_DLL Iterator
751  {
752  struct Private;
753  std::unique_ptr<Private> m_poPrivate;
754  public:
755  Iterator(GDALDataset* poDS, bool bStart);
756  Iterator(const Iterator& oOther); // declared but not defined. Needed for gcc 5.4 at least
757  Iterator(Iterator&& oOther) noexcept; // declared but not defined. Needed for gcc 5.4 at least
758  ~Iterator();
759  const FeatureLayerPair& operator*() const;
760  Iterator& operator++();
761  bool operator!=(const Iterator& it) const;
762  };
763 
764  public:
765 
766  const Iterator begin() const;
767 
768  const Iterator end() const;
769  };
770 
771  Features GetFeatures();
772 
773  virtual int TestCapability( const char * );
774 
775  virtual OGRLayer *CreateLayer( const char *pszName,
776  OGRSpatialReference *poSpatialRef = nullptr,
778  char ** papszOptions = nullptr );
779  virtual OGRLayer *CopyLayer( OGRLayer *poSrcLayer,
780  const char *pszNewName,
781  char **papszOptions = nullptr );
782 
783  virtual OGRStyleTable *GetStyleTable();
784  virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
785 
786  virtual void SetStyleTable(OGRStyleTable *poStyleTable);
787 
788  virtual OGRLayer * ExecuteSQL( const char *pszStatement,
789  OGRGeometry *poSpatialFilter,
790  const char *pszDialect );
791  virtual void ReleaseResultSet( OGRLayer * poResultsSet );
792 
793  int GetRefCount() const;
794  int GetSummaryRefCount() const;
795  OGRErr Release();
796 
797  virtual OGRErr StartTransaction(int bForce=FALSE);
798  virtual OGRErr CommitTransaction();
799  virtual OGRErr RollbackTransaction();
800 
801  virtual std::shared_ptr<GDALGroup> GetRootGroup() const;
802 
804  static int IsGenericSQLDialect(const char* pszDialect);
805 
806  // Semi-public methods. Only to be used by in-tree drivers.
807  GDALSQLParseInfo* BuildParseInfo(swq_select* psSelectInfo,
808  swq_select_parse_options* poSelectParseOptions);
809  static void DestroyParseInfo(GDALSQLParseInfo* psParseInfo );
810  OGRLayer * ExecuteSQL( const char *pszStatement,
811  OGRGeometry *poSpatialFilter,
812  const char *pszDialect,
813  swq_select_parse_options* poSelectParseOptions);
815 
816  protected:
817  virtual OGRLayer *ICreateLayer( const char *pszName,
818  OGRSpatialReference *poSpatialRef = nullptr,
820  char ** papszOptions = nullptr );
821 
823  OGRErr ProcessSQLCreateIndex( const char * );
824  OGRErr ProcessSQLDropIndex( const char * );
825  OGRErr ProcessSQLDropTable( const char * );
826  OGRErr ProcessSQLAlterTableAddColumn( const char * );
827  OGRErr ProcessSQLAlterTableDropColumn( const char * );
828  OGRErr ProcessSQLAlterTableAlterColumn( const char * );
829  OGRErr ProcessSQLAlterTableRenameColumn( const char * );
830 
831  OGRStyleTable *m_poStyleTable = nullptr;
832 
833  // Compatibility layers
834  const OGRSpatialReference* GetSpatialRefFromOldGetProjectionRef() const;
835  CPLErr OldSetProjectionFromSetSpatialRef(const OGRSpatialReference* poSRS);
836  const OGRSpatialReference* GetGCPSpatialRefFromOldGetGCPProjection() const;
837  CPLErr OldSetGCPsFromNew( int nGCPCount, const GDAL_GCP *pasGCPList,
838  const OGRSpatialReference * poGCP_SRS );
839 
840  friend class GDALProxyPoolDataset;
841  virtual const char *_GetProjectionRef();
842  const char *GetProjectionRefFromSpatialRef(const OGRSpatialReference*) const;
843  virtual const char *_GetGCPProjection();
844  const char *GetGCPProjectionFromSpatialRef(const OGRSpatialReference* poSRS) const;
845  virtual CPLErr _SetProjection( const char * pszProjection );
846  virtual CPLErr _SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
847  const char *pszGCPProjection );
849 
850  private:
852 };
853 
855 struct CPL_DLL GDALDatasetUniquePtrDeleter
856 {
857  void operator()(GDALDataset* poDataset) const
858  { GDALClose(poDataset); }
859 };
861 
867 typedef std::unique_ptr<GDALDataset, GDALDatasetUniquePtrDeleter> GDALDatasetUniquePtr;
868 
869 /* ******************************************************************** */
870 /* GDALRasterBlock */
871 /* ******************************************************************** */
872 
877 class CPL_DLL GDALRasterBlock
878 {
879  friend class GDALAbstractBandBlockCache;
880 
881  GDALDataType eType;
882 
883  bool bDirty;
884  volatile int nLockCount;
885 
886  int nXOff;
887  int nYOff;
888 
889  int nXSize;
890  int nYSize;
891 
892  void *pData;
893 
894  GDALRasterBand *poBand;
895 
896  GDALRasterBlock *poNext;
897  GDALRasterBlock *poPrevious;
898 
899  bool bMustDetach;
900 
901  CPL_INTERNAL void Detach_unlocked( void );
902  CPL_INTERNAL void Touch_unlocked( void );
903 
904  CPL_INTERNAL void RecycleFor( int nXOffIn, int nYOffIn );
905 
906  public:
907  GDALRasterBlock( GDALRasterBand *, int, int );
908  GDALRasterBlock( int nXOffIn, int nYOffIn ); /* only for lookup purpose */
909  virtual ~GDALRasterBlock();
910 
911  CPLErr Internalize( void );
912  void Touch( void );
913  void MarkDirty( void );
914  void MarkClean( void );
916  int AddLock( void ) { return CPLAtomicInc(&nLockCount); }
918  int DropLock( void ) { return CPLAtomicDec(&nLockCount); }
919  void Detach();
920 
921  CPLErr Write();
922 
926  GDALDataType GetDataType() const { return eType; }
930  int GetXOff() const { return nXOff; }
934  int GetYOff() const { return nYOff; }
938  int GetXSize() const { return nXSize; }
942  int GetYSize() const { return nYSize; }
946  int GetDirty() const { return bDirty; }
950  void *GetDataRef( void ) { return pData; }
955  return static_cast<GPtrDiff_t>(nXSize) * nYSize * GDALGetDataTypeSizeBytes(eType); }
956 
957  int TakeLock();
958  int DropLockForRemovalFromStorage();
959 
962  GDALRasterBand *GetBand() { return poBand; }
963 
964  static void FlushDirtyBlocks();
965  static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE);
966  static void Verify();
967 
968  static void EnterDisableDirtyBlockFlush();
969  static void LeaveDisableDirtyBlockFlush();
970 
971 #ifdef notdef
972  static void CheckNonOrphanedBlocks(GDALRasterBand* poBand);
973  void DumpBlock();
974  static void DumpAll();
975 #endif
976 
977  /* Should only be called by GDALDestroyDriverManager() */
979  CPL_INTERNAL static void DestroyRBMutex();
981 
982  private:
984 };
985 
986 /* ******************************************************************** */
987 /* GDALColorTable */
988 /* ******************************************************************** */
989 
992 class CPL_DLL GDALColorTable
993 {
994  GDALPaletteInterp eInterp;
995 
996  std::vector<GDALColorEntry> aoEntries{};
997 
998 public:
1001 
1002  GDALColorTable *Clone() const;
1003  int IsSame(const GDALColorTable* poOtherCT) const;
1004 
1005  GDALPaletteInterp GetPaletteInterpretation() const;
1006 
1007  int GetColorEntryCount() const;
1008  const GDALColorEntry *GetColorEntry( int ) const;
1009  int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
1010  void SetColorEntry( int, const GDALColorEntry * );
1011  int CreateColorRamp( int, const GDALColorEntry * ,
1012  int, const GDALColorEntry * );
1013 
1018  { return static_cast<GDALColorTableH>(poCT); }
1019 
1024  { return static_cast<GDALColorTable*>(hCT); }
1025 
1026 };
1027 
1028 /* ******************************************************************** */
1029 /* GDALAbstractBandBlockCache */
1030 /* ******************************************************************** */
1031 
1033 
1035 // only used by GDALRasterBand implementation.
1036 
1037 class GDALAbstractBandBlockCache
1038 {
1039  // List of blocks that can be freed or recycled, and its lock
1040  CPLLock *hSpinLock = nullptr;
1041  GDALRasterBlock *psListBlocksToFree = nullptr;
1042 
1043  // Band keep alive counter, and its lock & condition
1044  CPLCond *hCond = nullptr;
1045  CPLMutex *hCondMutex = nullptr;
1046  volatile int nKeepAliveCounter = 0;
1047 
1048  volatile int m_nDirtyBlocks = 0;
1049 
1050  CPL_DISALLOW_COPY_ASSIGN(GDALAbstractBandBlockCache)
1051 
1052  protected:
1053  GDALRasterBand *poBand;
1054 
1055  int m_nInitialDirtyBlocksInFlushCache = 0;
1056  int m_nLastTick = -1;
1057 
1058  void FreeDanglingBlocks();
1059  void UnreferenceBlockBase();
1060 
1061  void StartDirtyBlockFlushingLog();
1062  void UpdateDirtyBlockFlushingLog();
1063  void EndDirtyBlockFlushingLog();
1064 
1065  public:
1066  explicit GDALAbstractBandBlockCache(GDALRasterBand* poBand);
1067  virtual ~GDALAbstractBandBlockCache();
1068 
1069  GDALRasterBlock* CreateBlock(int nXBlockOff, int nYBlockOff);
1070  void AddBlockToFreeList( GDALRasterBlock * );
1071  void IncDirtyBlocks(int nInc);
1072  void WaitCompletionPendingTasks();
1073 
1074  virtual bool Init() = 0;
1075  virtual bool IsInitOK() = 0;
1076  virtual CPLErr FlushCache() = 0;
1077  virtual CPLErr AdoptBlock( GDALRasterBlock* poBlock ) = 0;
1078  virtual GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff,
1079  int nYBlockYOff ) = 0;
1080  virtual CPLErr UnreferenceBlock( GDALRasterBlock* poBlock ) = 0;
1081  virtual CPLErr FlushBlock( int nXBlockOff, int nYBlockOff,
1082  int bWriteDirtyBlock ) = 0;
1083 };
1084 
1085 GDALAbstractBandBlockCache* GDALArrayBandBlockCacheCreate(GDALRasterBand* poBand);
1086 GDALAbstractBandBlockCache* GDALHashSetBandBlockCacheCreate(GDALRasterBand* poBand);
1087 
1089 
1090 /* ******************************************************************** */
1091 /* GDALRasterBand */
1092 /* ******************************************************************** */
1093 
1094 class GDALMDArray;
1095 
1098 class CPL_DLL GDALRasterBand : public GDALMajorObject
1099 {
1100  private:
1101  friend class GDALArrayBandBlockCache;
1102  friend class GDALHashSetBandBlockCache;
1103  friend class GDALRasterBlock;
1104  friend class GDALDataset;
1105 
1106  CPLErr eFlushBlockErr = CE_None;
1107  GDALAbstractBandBlockCache* poBandBlockCache = nullptr;
1108 
1109  CPL_INTERNAL void SetFlushBlockErr( CPLErr eErr );
1110  CPL_INTERNAL CPLErr UnreferenceBlock( GDALRasterBlock* poBlock );
1111  CPL_INTERNAL void SetValidPercent( GUIntBig nSampleCount, GUIntBig nValidCount );
1112  CPL_INTERNAL void IncDirtyBlocks(int nInc);
1113 
1114  protected:
1116  GDALDataset *poDS = nullptr;
1117  int nBand = 0; /* 1 based */
1118 
1119  int nRasterXSize = 0;
1120  int nRasterYSize = 0;
1121 
1122  GDALDataType eDataType = GDT_Byte;
1123  GDALAccess eAccess = GA_ReadOnly;
1124 
1125  /* stuff related to blocking, and raster cache */
1126  int nBlockXSize = -1;
1127  int nBlockYSize = -1;
1128  int nBlocksPerRow = 0;
1129  int nBlocksPerColumn = 0;
1130 
1131  int nBlockReads = 0;
1132  int bForceCachedIO = 0;
1133 
1134  GDALRasterBand *poMask = nullptr;
1135  bool bOwnMask = false;
1136  int nMaskFlags = 0;
1137 
1138  void InvalidateMaskBand();
1139 
1140  friend class GDALProxyRasterBand;
1141  friend class GDALDefaultOverviews;
1142 
1143  CPLErr RasterIOResampled( GDALRWFlag, int, int, int, int,
1144  void *, int, int, GDALDataType,
1146 
1147  int EnterReadWrite(GDALRWFlag eRWFlag);
1148  void LeaveReadWrite();
1149  void InitRWLock();
1151 
1152  protected:
1153  virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void * pData ) = 0;
1154  virtual CPLErr IWriteBlock( int nBlockXOff, int nBlockYOff, void * pData );
1155 
1156  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1157  void *, int, int, GDALDataType,
1159 
1160  virtual int IGetDataCoverageStatus( int nXOff, int nYOff,
1161  int nXSize, int nYSize,
1162  int nMaskFlagStop,
1163  double* pdfDataPct);
1165  CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
1166  void *, int, int, GDALDataType,
1168 
1169  CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
1170  int nXOff, int nYOff, int nXSize, int nYSize,
1171  void * pData, int nBufXSize, int nBufYSize,
1172  GDALDataType eBufType,
1173  GSpacing nPixelSpace, GSpacing nLineSpace,
1174  GDALRasterIOExtraArg* psExtraArg,
1175  int* pbTried );
1176 
1177  int InitBlockInfo();
1178 
1179  void AddBlockToFreeList( GDALRasterBlock * );
1181 
1182  GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
1183 
1184  public:
1185  GDALRasterBand();
1186  explicit GDALRasterBand(int bForceCachedIO);
1187 
1188  ~GDALRasterBand() override;
1189 
1190  int GetXSize();
1191  int GetYSize();
1192  int GetBand();
1193  GDALDataset*GetDataset();
1194 
1195  GDALDataType GetRasterDataType( void );
1196  void GetBlockSize( int *, int * );
1197  CPLErr GetActualBlockSize ( int, int, int *, int * );
1198  GDALAccess GetAccess();
1199 
1200  CPLErr RasterIO( GDALRWFlag, int, int, int, int,
1201  void *, int, int, GDALDataType,
1202  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg
1203 #ifndef DOXYGEN_SKIP
1204  OPTIONAL_OUTSIDE_GDAL(nullptr)
1205 #endif
1207  CPLErr ReadBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
1208 
1209  CPLErr WriteBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
1210 
1211  GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
1212  int bJustInitialize = FALSE ) CPL_WARN_UNUSED_RESULT;
1213  CPLErr FlushBlock( int, int, int bWriteDirtyBlock = TRUE );
1214 
1215  unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand,
1216  unsigned char* pTranslationTable = nullptr,
1217  int* pApproximateMatching = nullptr);
1218 
1219  // New OpengIS CV_SampleDimension stuff.
1220 
1221  virtual CPLErr FlushCache();
1222  virtual char **GetCategoryNames();
1223  virtual double GetNoDataValue( int *pbSuccess = nullptr );
1224  virtual double GetMinimum( int *pbSuccess = nullptr );
1225  virtual double GetMaximum(int *pbSuccess = nullptr );
1226  virtual double GetOffset( int *pbSuccess = nullptr );
1227  virtual double GetScale( int *pbSuccess = nullptr );
1228  virtual const char *GetUnitType();
1229  virtual GDALColorInterp GetColorInterpretation();
1230  virtual GDALColorTable *GetColorTable();
1231  virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
1232 
1233  virtual CPLErr SetCategoryNames( char ** papszNames );
1234  virtual CPLErr SetNoDataValue( double dfNoData );
1235  virtual CPLErr DeleteNoDataValue();
1236  virtual CPLErr SetColorTable( GDALColorTable * poCT );
1237  virtual CPLErr SetColorInterpretation( GDALColorInterp eColorInterp );
1238  virtual CPLErr SetOffset( double dfNewOffset );
1239  virtual CPLErr SetScale( double dfNewScale );
1240  virtual CPLErr SetUnitType( const char * pszNewValue );
1241 
1242  virtual CPLErr GetStatistics( int bApproxOK, int bForce,
1243  double *pdfMin, double *pdfMax,
1244  double *pdfMean, double *padfStdDev );
1245  virtual CPLErr ComputeStatistics( int bApproxOK,
1246  double *pdfMin, double *pdfMax,
1247  double *pdfMean, double *pdfStdDev,
1248  GDALProgressFunc, void *pProgressData );
1249  virtual CPLErr SetStatistics( double dfMin, double dfMax,
1250  double dfMean, double dfStdDev );
1251  virtual CPLErr ComputeRasterMinMax( int, double* );
1252 
1253 // Only defined when Doxygen enabled
1254 #ifdef DOXYGEN_SKIP
1255  CPLErr SetMetadata( char ** papszMetadata,
1256  const char * pszDomain ) override;
1257  CPLErr SetMetadataItem( const char * pszName,
1258  const char * pszValue,
1259  const char * pszDomain ) override;
1260 #endif
1261 
1262  virtual int HasArbitraryOverviews();
1263  virtual int GetOverviewCount();
1264  virtual GDALRasterBand *GetOverview(int);
1265  virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig );
1266  virtual CPLErr BuildOverviews( const char * pszResampling,
1267  int nOverviews,
1268  int * panOverviewList,
1269  GDALProgressFunc pfnProgress,
1270  void * pProgressData );
1271 
1272  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
1273  int nBufXSize, int nBufYSize,
1274  GDALDataType eBufType, char **papszOptions );
1275 
1276  virtual CPLErr GetHistogram( double dfMin, double dfMax,
1277  int nBuckets, GUIntBig * panHistogram,
1278  int bIncludeOutOfRange, int bApproxOK,
1279  GDALProgressFunc, void *pProgressData );
1280 
1281  virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
1282  int *pnBuckets, GUIntBig ** ppanHistogram,
1283  int bForce,
1284  GDALProgressFunc, void *pProgressData);
1285  virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
1286  int nBuckets, GUIntBig *panHistogram );
1287 
1288  virtual GDALRasterAttributeTable *GetDefaultRAT();
1289  virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * poRAT );
1290 
1291  virtual GDALRasterBand *GetMaskBand();
1292  virtual int GetMaskFlags();
1293  virtual CPLErr CreateMaskBand( int nFlagsIn );
1294 
1295  virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
1296  int *pnPixelSpace,
1297  GIntBig *pnLineSpace,
1298  char **papszOptions ) CPL_WARN_UNUSED_RESULT;
1299 
1300  int GetDataCoverageStatus( int nXOff, int nYOff,
1301  int nXSize, int nYSize,
1302  int nMaskFlagStop = 0,
1303  double* pdfDataPct = nullptr );
1304 
1305  std::shared_ptr<GDALMDArray> AsMDArray() const;
1306 
1307 #ifndef DOXYGEN_XML
1308  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
1309 #endif
1310 
1314  static inline GDALRasterBandH ToHandle(GDALRasterBand* poBand)
1315  { return static_cast<GDALRasterBandH>(poBand); }
1316 
1321  { return static_cast<GDALRasterBand*>(hBand); }
1322 
1323 private:
1325 };
1326 
1328 /* ******************************************************************** */
1329 /* GDALAllValidMaskBand */
1330 /* ******************************************************************** */
1331 
1332 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
1333 {
1334  protected:
1335  CPLErr IReadBlock( int, int, void * ) override;
1336 
1337  CPL_DISALLOW_COPY_ASSIGN(GDALAllValidMaskBand)
1338 
1339  public:
1340  explicit GDALAllValidMaskBand( GDALRasterBand * );
1341  ~GDALAllValidMaskBand() override;
1342 
1343  GDALRasterBand *GetMaskBand() override;
1344  int GetMaskFlags() override;
1345 
1346  CPLErr ComputeStatistics( int bApproxOK,
1347  double *pdfMin, double *pdfMax,
1348  double *pdfMean, double *pdfStdDev,
1349  GDALProgressFunc, void *pProgressData ) override;
1350 
1351 };
1352 
1353 /* ******************************************************************** */
1354 /* GDALNoDataMaskBand */
1355 /* ******************************************************************** */
1356 
1357 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
1358 {
1359  double dfNoDataValue;
1360  GDALRasterBand *poParent;
1361 
1362  CPL_DISALLOW_COPY_ASSIGN(GDALNoDataMaskBand)
1363 
1364  protected:
1365  CPLErr IReadBlock( int, int, void * ) override;
1366  CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1367  void *, int, int, GDALDataType,
1368  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) override;
1369 
1370  public:
1371  explicit GDALNoDataMaskBand( GDALRasterBand * );
1372  ~GDALNoDataMaskBand() override;
1373 
1374  static bool IsNoDataInRange(double dfNoDataValue,
1375  GDALDataType eDataType);
1376 };
1377 
1378 /* ******************************************************************** */
1379 /* GDALNoDataValuesMaskBand */
1380 /* ******************************************************************** */
1381 
1382 class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
1383 {
1384  double *padfNodataValues;
1385 
1386  CPL_DISALLOW_COPY_ASSIGN(GDALNoDataValuesMaskBand)
1387 
1388  protected:
1389  CPLErr IReadBlock( int, int, void * ) override;
1390 
1391  public:
1392  explicit GDALNoDataValuesMaskBand( GDALDataset * );
1393  ~GDALNoDataValuesMaskBand() override;
1394 };
1395 
1396 /* ******************************************************************** */
1397 /* GDALRescaledAlphaBand */
1398 /* ******************************************************************** */
1399 
1400 class GDALRescaledAlphaBand : public GDALRasterBand
1401 {
1402  GDALRasterBand *poParent;
1403  void *pTemp;
1404 
1405  CPL_DISALLOW_COPY_ASSIGN(GDALRescaledAlphaBand)
1406 
1407  protected:
1408  CPLErr IReadBlock( int, int, void * ) override;
1409  CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1410  void *, int, int, GDALDataType,
1411  GSpacing, GSpacing,
1412  GDALRasterIOExtraArg* psExtraArg ) override;
1413 
1414  public:
1415  explicit GDALRescaledAlphaBand( GDALRasterBand * );
1416  ~GDALRescaledAlphaBand() override;
1417 };
1419 
1420 /* ******************************************************************** */
1421 /* GDALIdentifyEnum */
1422 /* ******************************************************************** */
1423 
1429 typedef enum
1430 {
1436  GDAL_IDENTIFY_TRUE = 1
1438 
1439 /* ******************************************************************** */
1440 /* GDALDriver */
1441 /* ******************************************************************** */
1442 
1454 class CPL_DLL GDALDriver : public GDALMajorObject
1455 {
1456  public:
1457  GDALDriver();
1458  ~GDALDriver() override;
1459 
1460  CPLErr SetMetadataItem( const char * pszName,
1461  const char * pszValue,
1462  const char * pszDomain = "" ) override;
1463 
1464 /* -------------------------------------------------------------------- */
1465 /* Public C++ methods. */
1466 /* -------------------------------------------------------------------- */
1467  GDALDataset *Create( const char * pszName,
1468  int nXSize, int nYSize, int nBands,
1469  GDALDataType eType, char ** papszOptions ) CPL_WARN_UNUSED_RESULT;
1470 
1471  GDALDataset *CreateMultiDimensional( const char * pszName,
1472  CSLConstList papszRootGroupOptions,
1473  CSLConstList papszOptions ) CPL_WARN_UNUSED_RESULT;
1474 
1475  CPLErr Delete( const char * pszName );
1476  CPLErr Rename( const char * pszNewName,
1477  const char * pszOldName );
1478  CPLErr CopyFiles( const char * pszNewName,
1479  const char * pszOldName );
1480 
1481  GDALDataset *CreateCopy( const char *, GDALDataset *,
1482  int, char **,
1483  GDALProgressFunc pfnProgress,
1484  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
1485 
1486 /* -------------------------------------------------------------------- */
1487 /* The following are semiprivate, not intended to be accessed */
1488 /* by anyone but the formats instantiating and populating the */
1489 /* drivers. */
1490 /* -------------------------------------------------------------------- */
1492  GDALDataset *(*pfnOpen)( GDALOpenInfo * );
1493 
1494  GDALDataset *(*pfnCreate)( const char * pszName,
1495  int nXSize, int nYSize, int nBands,
1496  GDALDataType eType,
1497  char ** papszOptions );
1498 
1499  GDALDataset *(*pfnCreateEx)( GDALDriver*, const char * pszName,
1500  int nXSize, int nYSize, int nBands,
1501  GDALDataType eType,
1502  char ** papszOptions );
1503 
1504  GDALDataset *(*pfnCreateMultiDimensional)( const char * pszName,
1505  CSLConstList papszRootGroupOptions,
1506  CSLConstList papszOptions );
1507 
1508  CPLErr (*pfnDelete)( const char * pszName );
1509 
1510  GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
1511  int, char **,
1512  GDALProgressFunc pfnProgress,
1513  void * pProgressData );
1514 
1515  void *pDriverData;
1516 
1517  void (*pfnUnloadDriver)(GDALDriver *);
1518 
1526  int (*pfnIdentify)( GDALOpenInfo * );
1527  int (*pfnIdentifyEx)( GDALDriver*, GDALOpenInfo * );
1528 
1529  CPLErr (*pfnRename)( const char * pszNewName,
1530  const char * pszOldName );
1531  CPLErr (*pfnCopyFiles)( const char * pszNewName,
1532  const char * pszOldName );
1533 
1534  // Used for legacy OGR drivers, and Python drivers
1535  GDALDataset *(*pfnOpenWithDriverArg)( GDALDriver*, GDALOpenInfo * );
1536 
1537  /* For legacy OGR drivers */
1538  GDALDataset *(*pfnCreateVectorOnly)( GDALDriver*,
1539  const char * pszName,
1540  char ** papszOptions );
1541  CPLErr (*pfnDeleteDataSource)( GDALDriver*,
1542  const char * pszName );
1544 
1545 /* -------------------------------------------------------------------- */
1546 /* Helper methods. */
1547 /* -------------------------------------------------------------------- */
1549  GDALDataset *DefaultCreateCopy( const char *, GDALDataset *,
1550  int, char **,
1551  GDALProgressFunc pfnProgress,
1552  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
1553 
1554  static CPLErr DefaultCreateCopyMultiDimensional(
1555  GDALDataset *poSrcDS,
1556  GDALDataset *poDstDS,
1557  bool bStrict,
1558  CSLConstList /*papszOptions*/,
1559  GDALProgressFunc pfnProgress,
1560  void * pProgressData );
1561 
1562  static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
1563  GDALDataset *poDstDS,
1564  int bStrict );
1565  static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
1566  GDALDataset *poDstDS,
1567  int bStrict,
1568  CSLConstList papszOptions,
1569  GDALProgressFunc pfnProgress,
1570  void * pProgressData );
1572  static CPLErr QuietDelete( const char * pszName,
1573  const char *const *papszAllowedDrivers = nullptr);
1574 
1576  static CPLErr DefaultRename( const char * pszNewName,
1577  const char * pszOldName );
1578  static CPLErr DefaultCopyFiles( const char * pszNewName,
1579  const char * pszOldName );
1581 
1585  static inline GDALDriverH ToHandle(GDALDriver* poDriver)
1586  { return static_cast<GDALDriverH>(poDriver); }
1587 
1591  static inline GDALDriver* FromHandle(GDALDriverH hDriver)
1592  { return static_cast<GDALDriver*>(hDriver); }
1593 
1594 private:
1596 };
1597 
1598 /* ******************************************************************** */
1599 /* GDALDriverManager */
1600 /* ******************************************************************** */
1601 
1609 class CPL_DLL GDALDriverManager : public GDALMajorObject
1610 {
1611  int nDrivers = 0;
1612  GDALDriver **papoDrivers = nullptr;
1613  std::map<CPLString, GDALDriver*> oMapNameToDrivers{};
1614 
1615  GDALDriver *GetDriver_unlocked( int iDriver )
1616  { return (iDriver >= 0 && iDriver < nDrivers) ?
1617  papoDrivers[iDriver] : nullptr; }
1618 
1619  GDALDriver *GetDriverByName_unlocked( const char * pszName )
1620  { return oMapNameToDrivers[CPLString(pszName).toupper()]; }
1621 
1622  static char** GetSearchPaths(const char* pszGDAL_DRIVER_PATH);
1623 
1624  static void CleanupPythonDrivers();
1625 
1627 
1628  public:
1630  ~GDALDriverManager();
1631 
1632  int GetDriverCount( void ) const;
1633  GDALDriver *GetDriver( int );
1634  GDALDriver *GetDriverByName( const char * );
1635 
1636  int RegisterDriver( GDALDriver * );
1637  void DeregisterDriver( GDALDriver * );
1638 
1639  // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
1640  static void AutoLoadDrivers();
1641  void AutoSkipDrivers();
1642 
1643  static void AutoLoadPythonDrivers();
1644 };
1645 
1647 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
1648 CPL_C_END
1649 
1650 /* ******************************************************************** */
1651 /* GDALAsyncReader */
1652 /* ******************************************************************** */
1653 
1659 class CPL_DLL GDALAsyncReader
1660 {
1661 
1663 
1664  protected:
1666  GDALDataset* poDS;
1667  int nXOff;
1668  int nYOff;
1669  int nXSize;
1670  int nYSize;
1671  void * pBuf;
1672  int nBufXSize;
1673  int nBufYSize;
1674  GDALDataType eBufType;
1675  int nBandCount;
1676  int* panBandMap;
1677  int nPixelSpace;
1678  int nLineSpace;
1679  int nBandSpace;
1681 
1682  public:
1683  GDALAsyncReader();
1684  virtual ~GDALAsyncReader();
1685 
1689  GDALDataset* GetGDALDataset() {return poDS;}
1693  int GetXOffset() const { return nXOff; }
1697  int GetYOffset() const { return nYOff; }
1701  int GetXSize() const { return nXSize; }
1705  int GetYSize() const { return nYSize; }
1709  void * GetBuffer() {return pBuf;}
1713  int GetBufferXSize() const { return nBufXSize; }
1717  int GetBufferYSize() const { return nBufYSize; }
1721  GDALDataType GetBufferType() const { return eBufType; }
1725  int GetBandCount() const { return nBandCount; }
1729  int* GetBandMap() { return panBandMap; }
1733  int GetPixelSpace() const { return nPixelSpace; }
1737  int GetLineSpace() const { return nLineSpace; }
1741  int GetBandSpace() const { return nBandSpace; }
1742 
1743  virtual GDALAsyncStatusType
1744  GetNextUpdatedRegion(double dfTimeout,
1745  int* pnBufXOff, int* pnBufYOff,
1746  int* pnBufXSize, int* pnBufYSize) = 0;
1747  virtual int LockBuffer( double dfTimeout = -1.0 );
1748  virtual void UnlockBuffer();
1749 };
1750 
1751 /* ******************************************************************** */
1752 /* Multidimensional array API */
1753 /* ******************************************************************** */
1754 
1755 class GDALMDArray;
1756 class GDALAttribute;
1757 class GDALDimension;
1758 class GDALEDTComponent;
1759 
1760 /* ******************************************************************** */
1761 /* GDALExtendedDataType */
1762 /* ******************************************************************** */
1763 
1772 {
1773 public:
1775 
1777 
1779 
1780  static GDALExtendedDataType Create(GDALDataType eType);
1781  static GDALExtendedDataType Create(const std::string& osName,
1782  size_t nTotalSize,
1783  std::vector<std::unique_ptr<GDALEDTComponent>>&& components);
1784  static GDALExtendedDataType CreateString(size_t nMaxStringLength = 0);
1785 
1786  bool operator== (const GDALExtendedDataType& ) const;
1788  bool operator!= (const GDALExtendedDataType& other) const { return !(operator==(other)); }
1789 
1794  const std::string& GetName() const { return m_osName; }
1795 
1800  GDALExtendedDataTypeClass GetClass() const { return m_eClass; }
1801 
1806  GDALDataType GetNumericDataType() const { return m_eNumericDT; }
1807 
1812  const std::vector<std::unique_ptr<GDALEDTComponent>>& GetComponents() const { return m_aoComponents; }
1813 
1820  size_t GetSize() const { return m_nSize; }
1821 
1826  size_t GetMaxStringLength() const { return m_nMaxStringLength; }
1827 
1828  bool CanConvertTo(const GDALExtendedDataType& other) const;
1829 
1830  bool NeedsFreeDynamicMemory() const;
1831 
1832  void FreeDynamicMemory(void* pBuffer) const;
1833 
1834  static
1835  bool CopyValue(const void* pSrc, const GDALExtendedDataType& srcType,
1836  void* pDst, const GDALExtendedDataType& dstType);
1837 
1838 private:
1839  explicit GDALExtendedDataType(size_t nMaxStringLength = 0);
1840  explicit GDALExtendedDataType(GDALDataType eType);
1841  GDALExtendedDataType(const std::string& osName,
1842  size_t nTotalSize,
1843  std::vector<std::unique_ptr<GDALEDTComponent>>&& components);
1844 
1845  std::string m_osName{};
1847  GDALDataType m_eNumericDT = GDT_Unknown;
1848  std::vector<std::unique_ptr<GDALEDTComponent>> m_aoComponents{};
1849  size_t m_nSize = 0;
1850  size_t m_nMaxStringLength = 0;
1851 };
1852 
1853 /* ******************************************************************** */
1854 /* GDALEDTComponent */
1855 /* ******************************************************************** */
1856 
1862 class CPL_DLL GDALEDTComponent
1863 {
1864 public:
1865  ~GDALEDTComponent();
1866  GDALEDTComponent(const std::string& name, size_t offset, const GDALExtendedDataType& type);
1868 
1869  bool operator== (const GDALEDTComponent& ) const;
1870 
1875  const std::string& GetName() const { return m_osName; }
1876 
1881  size_t GetOffset() const { return m_nOffset; }
1882 
1887  const GDALExtendedDataType& GetType() const { return m_oType; }
1888 
1889 private:
1890  std::string m_osName;
1891  size_t m_nOffset;
1892  GDALExtendedDataType m_oType;
1893 };
1894 
1895 /* ******************************************************************** */
1896 /* GDALIHasAttribute */
1897 /* ******************************************************************** */
1898 
1904 class CPL_DLL GDALIHasAttribute
1905 {
1906 protected:
1907  std::shared_ptr<GDALAttribute> GetAttributeFromAttributes(const std::string& osName) const;
1908 
1909 public:
1910  virtual ~GDALIHasAttribute();
1911 
1912  virtual std::shared_ptr<GDALAttribute> GetAttribute(const std::string& osName) const;
1913 
1914  virtual std::vector<std::shared_ptr<GDALAttribute>> GetAttributes(CSLConstList papszOptions = nullptr) const;
1915 
1916  virtual std::shared_ptr<GDALAttribute> CreateAttribute(
1917  const std::string& osName,
1918  const std::vector<GUInt64>& anDimensions,
1919  const GDALExtendedDataType& oDataType,
1920  CSLConstList papszOptions = nullptr);
1921 };
1922 
1923 /* ******************************************************************** */
1924 /* GDALGroup */
1925 /* ******************************************************************** */
1926 
1935 class CPL_DLL GDALGroup: public GDALIHasAttribute
1936 {
1937 protected:
1939  std::string m_osName{};
1940  std::string m_osFullName{};
1941 
1942  GDALGroup(const std::string& osParentName, const std::string& osName);
1943 
1944  const GDALGroup* GetInnerMostGroup(const std::string& osPathOrArrayOrDim,
1945  std::shared_ptr<GDALGroup>& curGroupHolder,
1946  std::string& osLastPart) const;
1948 
1949 public:
1950  virtual ~GDALGroup();
1951 
1956  const std::string& GetName() const { return m_osName; }
1957 
1962  const std::string& GetFullName() const { return m_osFullName; }
1963 
1964  virtual std::vector<std::string> GetMDArrayNames(CSLConstList papszOptions = nullptr) const;
1965  virtual std::shared_ptr<GDALMDArray> OpenMDArray(const std::string& osName,
1966  CSLConstList papszOptions = nullptr) const;
1967 
1968  virtual std::vector<std::string> GetGroupNames(CSLConstList papszOptions = nullptr) const;
1969  virtual std::shared_ptr<GDALGroup> OpenGroup(const std::string& osName,
1970  CSLConstList papszOptions = nullptr) const;
1971 
1972  virtual std::vector<std::shared_ptr<GDALDimension>> GetDimensions(CSLConstList papszOptions = nullptr) const;
1973 
1974  virtual std::shared_ptr<GDALGroup> CreateGroup(const std::string& osName,
1975  CSLConstList papszOptions = nullptr);
1976 
1977  virtual std::shared_ptr<GDALDimension> CreateDimension(const std::string& osName,
1978  const std::string& osType,
1979  const std::string& osDirection,
1980  GUInt64 nSize,
1981  CSLConstList papszOptions = nullptr);
1982 
1983  virtual std::shared_ptr<GDALMDArray> CreateMDArray(const std::string& osName,
1984  const std::vector<std::shared_ptr<GDALDimension>>& aoDimensions,
1985  const GDALExtendedDataType& oDataType,
1986  CSLConstList papszOptions = nullptr);
1987 
1988  GUInt64 GetTotalCopyCost() const;
1989 
1990  virtual bool CopyFrom(const std::shared_ptr<GDALGroup>& poDstRootGroup,
1991  GDALDataset* poSrcDS,
1992  const std::shared_ptr<GDALGroup>& poSrcGroup,
1993  bool bStrict,
1994  GUInt64& nCurCost,
1995  const GUInt64 nTotalCost,
1996  GDALProgressFunc pfnProgress,
1997  void * pProgressData);
1998 
1999  virtual CSLConstList GetStructuralInfo() const;
2000 
2001  std::shared_ptr<GDALMDArray> OpenMDArrayFromFullname(
2002  const std::string& osFullName,
2003  CSLConstList papszOptions = nullptr) const;
2004 
2005  std::shared_ptr<GDALDimension> OpenDimensionFromFullname(
2006  const std::string& osFullName) const;
2007 
2009  static constexpr GUInt64 COPY_COST = 1000;
2011 };
2012 
2013 /* ******************************************************************** */
2014 /* GDALAbstractMDArray */
2015 /* ******************************************************************** */
2016 
2022 class CPL_DLL GDALAbstractMDArray
2023 {
2024 protected:
2026  std::string m_osName{};
2027  std::string m_osFullName{};
2028  std::weak_ptr<GDALAbstractMDArray> m_pSelf{};
2029 
2030  GDALAbstractMDArray(const std::string& osParentName, const std::string& osName);
2031 
2032  void SetSelf(std::weak_ptr<GDALAbstractMDArray> self) { m_pSelf = self; }
2033 
2034  bool CheckReadWriteParams(const GUInt64* arrayStartIdx,
2035  const size_t* count,
2036  const GInt64*& arrayStep,
2037  const GPtrDiff_t*& bufferStride,
2038  const GDALExtendedDataType& bufferDataType,
2039  const void* buffer,
2040  const void* buffer_alloc_start,
2041  size_t buffer_alloc_size,
2042  std::vector<GInt64>& tmp_arrayStep,
2043  std::vector<GPtrDiff_t>& tmp_bufferStride) const;
2044 
2045  virtual bool IRead(const GUInt64* arrayStartIdx, // array of size GetDimensionCount()
2046  const size_t* count, // array of size GetDimensionCount()
2047  const GInt64* arrayStep, // step in elements
2048  const GPtrDiff_t* bufferStride, // stride in elements
2049  const GDALExtendedDataType& bufferDataType,
2050  void* pDstBuffer) const = 0;
2051 
2052  virtual bool IWrite(const GUInt64* arrayStartIdx, // array of size GetDimensionCount()
2053  const size_t* count, // array of size GetDimensionCount()
2054  const GInt64* arrayStep, // step in elements
2055  const GPtrDiff_t* bufferStride, // stride in elements
2056  const GDALExtendedDataType& bufferDataType,
2057  const void* pSrcBuffer);
2059 
2060 public:
2061  virtual ~GDALAbstractMDArray();
2062 
2067  const std::string& GetName() const{ return m_osName; }
2068 
2073  const std::string& GetFullName() const{ return m_osFullName; }
2074 
2075  GUInt64 GetTotalElementsCount() const;
2076 
2077  virtual size_t GetDimensionCount() const;
2078 
2079  virtual const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const = 0;
2080 
2081  virtual const GDALExtendedDataType &GetDataType() const = 0;
2082 
2083  virtual std::vector<GUInt64> GetBlockSize() const;
2084 
2085  virtual std::vector<size_t> GetProcessingChunkSize(size_t nMaxChunkMemory) const;
2086 
2102  typedef bool (*FuncProcessPerChunkType)(
2103  GDALAbstractMDArray* array,
2104  const GUInt64* chunkArrayStartIdx,
2105  const size_t* chunkCount,
2106  GUInt64 iCurChunk,
2107  GUInt64 nChunkCount,
2108  void* pUserData);
2109 
2110  virtual bool ProcessPerChunk(const GUInt64* arrayStartIdx,
2111  const GUInt64* count,
2112  const size_t* chunkSize,
2113  FuncProcessPerChunkType pfnFunc,
2114  void* pUserData);
2115 
2116  bool Read(const GUInt64* arrayStartIdx, // array of size GetDimensionCount()
2117  const size_t* count, // array of size GetDimensionCount()
2118  const GInt64* arrayStep, // step in elements
2119  const GPtrDiff_t* bufferStride, // stride in elements
2120  const GDALExtendedDataType& bufferDataType,
2121  void* pDstBuffer,
2122  const void* pDstBufferAllocStart = nullptr,
2123  size_t nDstBufferAllocSize = 0) const;
2124 
2125  bool Write(const GUInt64* arrayStartIdx, // array of size GetDimensionCount()
2126  const size_t* count, // array of size GetDimensionCount()
2127  const GInt64* arrayStep, // step in elements
2128  const GPtrDiff_t* bufferStride, // stride in elements
2129  const GDALExtendedDataType& bufferDataType,
2130  const void* pSrcBuffer,
2131  const void* pSrcBufferAllocStart = nullptr,
2132  size_t nSrcBufferAllocSize = 0);
2133 };
2134 
2135 /* ******************************************************************** */
2136 /* GDALRawResult */
2137 /* ******************************************************************** */
2138 
2145 class CPL_DLL GDALRawResult
2146 {
2147 private:
2148  GDALExtendedDataType m_dt;
2149  size_t m_nEltCount;
2150  size_t m_nSize;
2151  GByte* m_raw;
2152 
2153  void FreeMe();
2154 
2155  GDALRawResult(const GDALRawResult&) = delete;
2156  GDALRawResult& operator=(const GDALRawResult&) = delete;
2157 
2158 protected:
2159  friend class GDALAttribute;
2161  GDALRawResult(GByte* raw,
2162  const GDALExtendedDataType& dt,
2163  size_t nEltCount);
2165 
2166 public:
2167  ~GDALRawResult();
2169  GDALRawResult& operator=(GDALRawResult&&);
2170 
2172  const GByte& operator[](size_t idx) const { return m_raw[idx]; }
2174  const GByte* data() const { return m_raw; }
2176  size_t size() const { return m_nSize; }
2177 
2179  GByte* StealData();
2181 };
2182 
2183 
2184 /* ******************************************************************** */
2185 /* GDALAttribute */
2186 /* ******************************************************************** */
2187 
2198 class CPL_DLL GDALAttribute: virtual public GDALAbstractMDArray
2199 {
2200  mutable std::string m_osCachedVal{};
2201 
2202 protected:
2204  GDALAttribute(const std::string& osParentName, const std::string& osName);
2206 
2207 public:
2208 
2209  std::vector<GUInt64> GetDimensionsSize() const;
2210 
2211  GDALRawResult ReadAsRaw() const;
2212  const char* ReadAsString() const;
2213  int ReadAsInt() const;
2214  double ReadAsDouble() const;
2215  CPLStringList ReadAsStringArray() const;
2216  std::vector<int> ReadAsIntArray() const;
2217  std::vector<double> ReadAsDoubleArray() const;
2218 
2220  bool Write(const void* pabyValue, size_t nLen);
2221  bool Write(const char*);
2222  bool WriteInt(int);
2223  bool Write(double);
2224  bool Write(CSLConstList);
2225  bool Write(const double*, size_t);
2226 
2228  static constexpr GUInt64 COPY_COST = 100;
2230 
2231 };
2232 
2233 /************************************************************************/
2234 /* GDALAttributeString */
2235 /************************************************************************/
2236 
2238 class CPL_DLL GDALAttributeString final: public GDALAttribute
2239 {
2240  std::vector<std::shared_ptr<GDALDimension>> m_dims{};
2242  std::string m_osValue;
2243 
2244 protected:
2245 
2246  bool IRead(const GUInt64* ,
2247  const size_t* ,
2248  const GInt64* ,
2249  const GPtrDiff_t* ,
2250  const GDALExtendedDataType& bufferDataType,
2251  void* pDstBuffer) const override;
2252 
2253 public:
2254  GDALAttributeString(const std::string& osParentName,
2255  const std::string& osName,
2256  const std::string& osValue);
2257 
2258  const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const override;
2259 
2260  const GDALExtendedDataType &GetDataType() const override;
2261 };
2263 
2264 /************************************************************************/
2265 /* GDALAttributeNumeric */
2266 /************************************************************************/
2267 
2269 class CPL_DLL GDALAttributeNumeric final: public GDALAttribute
2270 {
2271  std::vector<std::shared_ptr<GDALDimension>> m_dims{};
2272  GDALExtendedDataType m_dt;
2273  int m_nValue = 0;
2274  double m_dfValue = 0;
2275  std::vector<GUInt32> m_anValuesUInt32{};
2276 
2277 protected:
2278 
2279  bool IRead(const GUInt64* ,
2280  const size_t* ,
2281  const GInt64* ,
2282  const GPtrDiff_t* ,
2283  const GDALExtendedDataType& bufferDataType,
2284  void* pDstBuffer) const override;
2285 
2286 public:
2287  GDALAttributeNumeric(const std::string& osParentName,
2288  const std::string& osName,
2289  double dfValue);
2290  GDALAttributeNumeric(const std::string& osParentName,
2291  const std::string& osName,
2292  int nValue);
2293  GDALAttributeNumeric(const std::string& osParentName,
2294  const std::string& osName,
2295  const std::vector<GUInt32>& anValues);
2296 
2297  const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const override;
2298 
2299  const GDALExtendedDataType &GetDataType() const override;
2300 };
2302 
2303 /* ******************************************************************** */
2304 /* GDALMDArray */
2305 /* ******************************************************************** */
2306 
2315 class CPL_DLL GDALMDArray: virtual public GDALAbstractMDArray, public GDALIHasAttribute
2316 {
2317  std::shared_ptr<GDALMDArray> GetView(const std::vector<GUInt64>& indices) const;
2318 
2319  inline std::shared_ptr<GDALMDArray> atInternal(std::vector<GUInt64>& indices) const
2320  {
2321  return GetView(indices);
2322  }
2323 
2324  template<typename... GUInt64VarArg>
2325  // cppcheck-suppress functionStatic
2326  inline std::shared_ptr<GDALMDArray> atInternal(std::vector<GUInt64>& indices,
2327  GUInt64 idx, GUInt64VarArg... tail) const
2328  {
2329  indices.push_back(idx);
2330  return atInternal(indices, tail...);
2331  }
2332 
2333 protected:
2335  GDALMDArray(const std::string& osParentName, const std::string& osName);
2337 
2338 public:
2339 
2340  GUInt64 GetTotalCopyCost() const;
2341 
2342  virtual bool CopyFrom(GDALDataset* poSrcDS,
2343  const GDALMDArray* poSrcArray,
2344  bool bStrict,
2345  GUInt64& nCurCost,
2346  const GUInt64 nTotalCost,
2347  GDALProgressFunc pfnProgress,
2348  void * pProgressData);
2349 
2351  virtual bool IsWritable() const = 0;
2352 
2353  virtual CSLConstList GetStructuralInfo() const;
2354 
2355  virtual const std::string& GetUnit() const;
2356 
2357  virtual bool SetUnit(const std::string& osUnit);
2358 
2359  virtual bool SetSpatialRef(const OGRSpatialReference* poSRS);
2360 
2361  virtual std::shared_ptr<OGRSpatialReference> GetSpatialRef() const;
2362 
2363  virtual const void* GetRawNoDataValue() const;
2364 
2365  double GetNoDataValueAsDouble(bool* pbHasNoData = nullptr) const;
2366 
2367  virtual bool SetRawNoDataValue(const void* pRawNoData);
2368 
2369  bool SetNoDataValue(double dfNoData);
2370 
2371  virtual double GetOffset(bool* pbHasOffset = nullptr) const;
2372 
2373  virtual double GetScale(bool* pbHasScale = nullptr) const;
2374 
2375  virtual bool SetOffset(double dfOffset);
2376 
2377  virtual bool SetScale(double dfScale);
2378 
2379  std::shared_ptr<GDALMDArray> GetView(const std::string& viewExpr) const;
2380 
2381  std::shared_ptr<GDALMDArray> operator[](const std::string& fieldName) const;
2382 
2392  template<typename... GUInt64VarArg>
2393  // cppcheck-suppress functionStatic
2394  std::shared_ptr<GDALMDArray> at(GUInt64 idx, GUInt64VarArg... tail) const
2395  {
2396  std::vector<GUInt64> indices;
2397  indices.push_back(idx);
2398  return atInternal(indices, tail...);
2399  }
2400 
2401  virtual std::shared_ptr<GDALMDArray> Transpose(const std::vector<int>& anMapNewAxisToOldAxis) const;
2402 
2403  std::shared_ptr<GDALMDArray> GetUnscaled() const;
2404 
2405  virtual std::shared_ptr<GDALMDArray> GetMask(CSLConstList papszOptions) const;
2406 
2407  virtual GDALDataset* AsClassicDataset(size_t iXDim, size_t iYDim) const;
2408 
2410  static constexpr GUInt64 COPY_COST = 1000;
2411 
2412  bool CopyFromAllExceptValues(const GDALMDArray* poSrcArray,
2413  bool bStrict,
2414  GUInt64& nCurCost,
2415  const GUInt64 nTotalCost,
2416  GDALProgressFunc pfnProgress,
2417  void * pProgressData);
2418  struct Range
2419  {
2420  GUInt64 m_nStartIdx;
2421  GInt64 m_nIncr;
2422  Range(GUInt64 nStartIdx = 0, GInt64 nIncr = 0):
2423  m_nStartIdx(nStartIdx), m_nIncr(nIncr) {}
2424  };
2425 
2426  struct ViewSpec
2427  {
2428  std::string m_osFieldName{};
2429 
2430  // or
2431 
2432  std::vector<size_t> m_mapDimIdxToParentDimIdx{}; // of size m_dims.size()
2433  std::vector<Range> m_parentRanges{} ; // of size m_poParent->GetDimensionCount()
2434  };
2435 
2436  virtual std::shared_ptr<GDALMDArray> GetView(const std::string& viewExpr,
2437  bool bRenameDimensions,
2438  std::vector<ViewSpec>& viewSpecs) const;
2440 };
2441 
2442 
2443 /************************************************************************/
2444 /* GDALMDArrayRegularlySpaced */
2445 /************************************************************************/
2446 
2448 class CPL_DLL GDALMDArrayRegularlySpaced: public GDALMDArray
2449 {
2450  double m_dfStart;
2451  double m_dfIncrement;
2452  double m_dfOffsetInIncrement;
2454  std::vector<std::shared_ptr<GDALDimension>> m_dims;
2455  std::vector<std::shared_ptr<GDALAttribute>> m_attributes{};
2456 
2457 protected:
2458 
2459  bool IRead(const GUInt64* ,
2460  const size_t* ,
2461  const GInt64* ,
2462  const GPtrDiff_t* ,
2463  const GDALExtendedDataType& bufferDataType,
2464  void* pDstBuffer) const override;
2465 
2466 public:
2467  GDALMDArrayRegularlySpaced(
2468  const std::string& osParentName,
2469  const std::string& osName,
2470  const std::shared_ptr<GDALDimension>& poDim,
2471  double dfStart, double dfIncrement,
2472  double dfOffsetInIncrement);
2473 
2474  bool IsWritable() const override { return false; }
2475 
2476  const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const override;
2477 
2478  const GDALExtendedDataType &GetDataType() const override;
2479 
2480  std::vector<std::shared_ptr<GDALAttribute>> GetAttributes(CSLConstList) const override;
2481 
2482  void AddAttribute(const std::shared_ptr<GDALAttribute>& poAttr);
2483 };
2485 
2486 /* ******************************************************************** */
2487 /* GDALDimension */
2488 /* ******************************************************************** */
2489 
2501 class CPL_DLL GDALDimension
2502 {
2503 public:
2505  GDALDimension(const std::string& osParentName,
2506  const std::string& osName,
2507  const std::string& osType,
2508  const std::string& osDirection,
2509  GUInt64 nSize);
2511 
2512  virtual ~GDALDimension();
2513 
2518  const std::string& GetName() const { return m_osName; }
2519 
2524  const std::string& GetFullName() const { return m_osFullName; }
2525 
2534  const std::string& GetType() const { return m_osType; }
2535 
2544  const std::string& GetDirection() const { return m_osDirection; }
2545 
2550  GUInt64 GetSize() const { return m_nSize; }
2551 
2552  virtual std::shared_ptr<GDALMDArray> GetIndexingVariable() const;
2553 
2554  virtual bool SetIndexingVariable(std::shared_ptr<GDALMDArray> poIndexingVariable);
2555 
2556 protected:
2558  std::string m_osName;
2559  std::string m_osFullName;
2560  std::string m_osType;
2561  std::string m_osDirection;
2562  GUInt64 m_nSize;
2564 };
2565 
2566 
2567 /************************************************************************/
2568 /* GDALDimensionWeakIndexingVar() */
2569 /************************************************************************/
2570 
2572 class CPL_DLL GDALDimensionWeakIndexingVar: public GDALDimension
2573 {
2574  std::weak_ptr<GDALMDArray> m_poIndexingVariable{};
2575 
2576 public:
2577  GDALDimensionWeakIndexingVar(const std::string& osParentName,
2578  const std::string& osName,
2579  const std::string& osType,
2580  const std::string& osDirection,
2581  GUInt64 nSize);
2582 
2583  std::shared_ptr<GDALMDArray> GetIndexingVariable() const override;
2584 
2585  bool SetIndexingVariable(std::shared_ptr<GDALMDArray> poIndexingVariable) override;
2586 };
2588 
2589 /* ==================================================================== */
2590 /* An assortment of overview related stuff. */
2591 /* ==================================================================== */
2592 
2594 /* Only exported for drivers as plugin. Signature may change */
2595 CPLErr CPL_DLL
2596 GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands,
2597  int nOverviews,
2598  GDALRasterBand*** papapoOverviewBands,
2599  const char * pszResampling,
2600  GDALProgressFunc pfnProgress, void * pProgressData );
2601 
2602 typedef CPLErr (*GDALResampleFunction)
2603  ( double dfXRatioDstToSrc,
2604  double dfYRatioDstToSrc,
2605  double dfSrcXDelta,
2606  double dfSrcYDelta,
2607  GDALDataType eWrkDataType,
2608  void * pChunk,
2609  GByte * pabyChunkNodataMask,
2610  int nChunkXOff, int nChunkXSize,
2611  int nChunkYOff, int nChunkYSize,
2612  int nDstXOff, int nDstXOff2,
2613  int nDstYOff, int nDstYOff2,
2614  GDALRasterBand * poOverview,
2615  const char * pszResampling,
2616  int bHasNoData, float fNoDataValue,
2617  GDALColorTable* poColorTable,
2618  GDALDataType eSrcDataType,
2619  bool bPropagateNoData );
2620 
2621 GDALResampleFunction GDALGetResampleFunction(const char* pszResampling,
2622  int* pnRadius);
2623 
2624 #ifdef GDAL_ENABLE_RESAMPLING_MULTIBAND
2625 typedef CPLErr (*GDALResampleFunctionMultiBands)
2626  ( double dfXRatioDstToSrc,
2627  double dfYRatioDstToSrc,
2628  double dfSrcXDelta,
2629  double dfSrcYDelta,
2630  GDALDataType eWrkDataType,
2631  void * pChunk, int nBands,
2632  GByte * pabyChunkNodataMask,
2633  int nChunkXOff, int nChunkXSize,
2634  int nChunkYOff, int nChunkYSize,
2635  int nDstXOff, int nDstXOff2,
2636  int nDstYOff, int nDstYOff2,
2637  GDALRasterBand ** papoDstBands,
2638  const char * pszResampling,
2639  int bHasNoData, float fNoDataValue,
2640  GDALColorTable* poColorTable,
2641  GDALDataType eSrcDataType);
2642 
2643 GDALResampleFunctionMultiBands GDALGetResampleFunctionMultiBands(const char* pszResampling,
2644  int* pnRadius);
2645 #endif
2646 
2647 GDALDataType GDALGetOvrWorkDataType(const char* pszResampling,
2648  GDALDataType eSrcDataType);
2649 
2651 
2652 CPLErr CPL_DLL
2653 HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
2654  GDALDataset **ppoDS,
2655  int nBands, int *panBandList,
2656  int nNewOverviews, int *panNewOverviewList,
2657  const char *pszResampling,
2658  GDALProgressFunc pfnProgress,
2659  void *pProgressData );
2660 
2661 CPLErr CPL_DLL
2662 GTIFFBuildOverviews( const char * pszFilename,
2663  int nBands, GDALRasterBand **papoBandList,
2664  int nOverviews, int * panOverviewList,
2665  const char * pszResampling,
2666  GDALProgressFunc pfnProgress, void * pProgressData );
2667 
2668 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
2669  int &nXOff, int &nYOff,
2670  int &nXSize, int &nYSize,
2671  int nBufXSize, int nBufYSize) CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead");
2672 int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand* poBand,
2673  int &nXOff, int &nYOff,
2674  int &nXSize, int &nYSize,
2675  int nBufXSize, int nBufYSize,
2676  GDALRasterIOExtraArg* psExtraArg);
2677 
2678 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize ) CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead");
2679 int CPL_DLL GDALOvLevelAdjust2( int nOvLevel, int nXSize, int nYSize );
2680 int CPL_DLL GDALComputeOvFactor( int nOvrXSize, int nRasterXSize,
2681  int nOvrYSize, int nRasterYSize );
2682 
2683 GDALDataset CPL_DLL *
2684 GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
2685  GDALDataset *poDependentDS );
2686 
2687 /* ==================================================================== */
2688 /* Infrastructure to check that dataset characteristics are valid */
2689 /* ==================================================================== */
2690 
2691 int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize );
2692 int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed );
2693 
2694 /* Internal use only */
2695 
2696 /* CPL_DLL exported, but only for in-tree drivers that can be built as plugins */
2697 int CPL_DLL GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension,
2698  double *padfGeoTransform, char** papszSiblingFiles,
2699  char** ppszWorldFileNameOut);
2700 int GDALReadTabFile2( const char * pszBaseFilename,
2701  double *padfGeoTransform, char **ppszWKT,
2702  int *pnGCPCount, GDAL_GCP **ppasGCPs,
2703  char** papszSiblingFiles, char** ppszTabFileNameOut );
2704 
2705 void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg* psDestArg,
2706  GDALRasterIOExtraArg* psSrcArg);
2707 
2708 CPL_C_END
2709 
2710 void GDALNullifyOpenDatasetsList();
2711 CPLMutex** GDALGetphDMMutex();
2712 CPLMutex** GDALGetphDLMutex();
2713 void GDALNullifyProxyPoolSingleton();
2714 GDALDriver* GDALGetAPIPROXYDriver();
2715 void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
2716 GIntBig GDALGetResponsiblePIDForCurrentThread();
2717 
2718 CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt,
2719  CSLConstList papszSiblingFiles, int nFlags );
2720 
2721 CPLErr EXIFExtractMetadata(char**& papszMetadata,
2722  void *fpL, int nOffset,
2723  int bSwabflag, int nTIFFHEADER,
2724  int& nExifOffset, int& nInterOffset, int& nGPSOffset);
2725 
2726 int GDALValidateOpenOptions( GDALDriverH hDriver,
2727  const char* const* papszOptionOptions);
2728 int GDALValidateOptions( const char* pszOptionList,
2729  const char* const* papszOptionsToValidate,
2730  const char* pszErrorMessageOptionType,
2731  const char* pszErrorMessageContainerName);
2732 
2733 GDALRIOResampleAlg GDALRasterIOGetResampleAlg(const char* pszResampling);
2734 const char* GDALRasterIOGetResampleAlg(GDALRIOResampleAlg eResampleAlg);
2735 
2736 void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg* psExtraArg,
2737  int nXSize, int nYSize,
2738  int nBufXSize, int nBufYSize);
2739 
2740 
2741 GDALDataset* GDALCreateOverviewDataset(GDALDataset* poDS, int nOvrLevel,
2742  int bThisLevelOnly);
2743 
2744 // Should cover particular cases of #3573, #4183, #4506, #6578
2745 // Behaviour is undefined if fVal1 or fVal2 are NaN (should be tested before
2746 // calling this function)
2747 template<class T> inline bool ARE_REAL_EQUAL(T fVal1, T fVal2, int ulp = 2)
2748 {
2749  return fVal1 == fVal2 || /* Should cover infinity */
2750  std::abs(fVal1 - fVal2) < std::numeric_limits<float>::epsilon() * std::abs(fVal1+fVal2) * ulp;
2751 }
2752 
2753 double GDALAdjustNoDataCloseToFloatMax(double dfVal);
2754 
2755 #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) )
2756 
2757 // Number of data samples that will be used to compute approximate statistics
2758 // (minimum value, maximum value, etc.)
2759 #define GDALSTAT_APPROX_NUMSAMPLES 2500
2760 
2761 void GDALSerializeGCPListToXML( CPLXMLNode* psParentNode,
2762  GDAL_GCP* pasGCPList,
2763  int nGCPCount,
2764  const OGRSpatialReference* poGCP_SRS );
2765 void GDALDeserializeGCPListFromXML( CPLXMLNode* psGCPList,
2766  GDAL_GCP** ppasGCPList,
2767  int* pnGCPCount,
2768  OGRSpatialReference** ppoGCP_SRS );
2769 
2770 void GDALSerializeOpenOptionsToXML( CPLXMLNode* psParentNode, char** papszOpenOptions);
2771 char** GDALDeserializeOpenOptionsFromXML( CPLXMLNode* psParentNode );
2772 
2773 int GDALCanFileAcceptSidecarFile(const char* pszFilename);
2775 
2776 #endif /* ndef GDAL_PRIV_H_INCLUDED */
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:442
Convenient string class based on std::string.
Definition: cpl_string.h:333
CPLString & toupper(void)
Convert to upper case in place.
Definition: cplstring.cpp:316
Abstract class, implemented by GDALAttribute and GDALMDArray.
Definition: gdal_priv.h:2023
virtual const std::vector< std::shared_ptr< GDALDimension > > & GetDimensions() const =0
Return the dimensions of an attribute/array.
virtual const GDALExtendedDataType & GetDataType() const =0
Return the data type of an attribute/array.
const std::string & GetFullName() const
Return the name of an array or attribute.
Definition: gdal_priv.h:2073
const std::string & GetName() const
Return the name of an array or attribute.
Definition: gdal_priv.h:2067
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:1310
Class used as a session object for asynchronous requests.
Definition: gdal_priv.h:1660
void * GetBuffer()
Return buffer.
Definition: gdal_priv.h:1709
int GetXOffset() const
Return x offset.
Definition: gdal_priv.h:1693
int GetYOffset() const
Return y offset.
Definition: gdal_priv.h:1697
int GetYSize() const
Return height.
Definition: gdal_priv.h:1705
int GetBandCount() const
Return band count.
Definition: gdal_priv.h:1725
GDALDataType GetBufferType() const
Return buffer data type.
Definition: gdal_priv.h:1721
int GetBandSpace() const
Return band spacing.
Definition: gdal_priv.h:1741
int GetBufferYSize() const
Return buffer height.
Definition: gdal_priv.h:1717
int GetXSize() const
Return width.
Definition: gdal_priv.h:1701
GDALDataset * GetGDALDataset()
Return dataset.
Definition: gdal_priv.h:1689
virtual GDALAsyncStatusType GetNextUpdatedRegion(double dfTimeout, int *pnBufXOff, int *pnBufYOff, int *pnBufXSize, int *pnBufYSize)=0
Get async IO update.
int GetPixelSpace() const
Return pixel spacing.
Definition: gdal_priv.h:1733
int * GetBandMap()
Return band map.
Definition: gdal_priv.h:1729
int GetLineSpace() const
Return line spacing.
Definition: gdal_priv.h:1737
int GetBufferXSize() const
Return buffer width.
Definition: gdal_priv.h:1713
Class modeling an attribute that has a name, a value and a type, and is typically used to describe a ...
Definition: gdal_priv.h:2199
A color table / palette.
Definition: gdal_priv.h:993
static GDALColorTableH ToHandle(GDALColorTable *poCT)
Convert a GDALColorTable* to a GDALRasterBandH.
Definition: gdal_priv.h:1017
static GDALColorTable * FromHandle(GDALColorTableH hCT)
Convert a GDALColorTableH to a GDALColorTable*.
Definition: gdal_priv.h:1023
~GDALColorTable()
Destructor.
Class returned by GetBands() that act as a container for raster bands.
Definition: gdal_priv.h:465
Class returned by GetFeatures() that act as a container for vector features.
Definition: gdal_priv.h:743
Layer iterator.
Definition: gdal_priv.h:693
void pointer
pointer
Definition: gdal_priv.h:701
void difference_type
difference_type
Definition: gdal_priv.h:700
std::input_iterator_tag iterator_category
iterator_category
Definition: gdal_priv.h:702
Class returned by GetLayers() that acts as a range of layers.
Definition: gdal_priv.h:680
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:338
virtual int CloseDependentDatasets()
Drop references to any other datasets referenced by this dataset.
Definition: gdaldataset.cpp:3995
static GDALDataset * FromHandle(GDALDatasetH hDS)
Convert a GDALDatasetH to a GDALDataset*.
Definition: gdal_priv.h:633
CPLErr BuildOverviews(const char *, int, int *, int, int *, GDALProgressFunc, void *)
Build raster overview(s)
Definition: gdaldataset.cpp:1925
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the dataset.
Definition: gdaldataset.cpp:3034
void MarkSuppressOnClose()
Set that the dataset must be deleted on close.
Definition: gdal_priv.h:595
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:639
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
char ** GetOpenOptions()
Return open options.
Definition: gdal_priv.h:600
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
static GDALDatasetH ToHandle(GDALDataset *poDS)
Convert a GDALDataset* to a GDALDatasetH.
Definition: gdal_priv.h:627
GDALAccess GetAccess() const
Return access mode.
Definition: gdal_priv.h:589
Class modeling a a dimension / axis used to index multidimensional arrays.
Definition: gdal_priv.h:2502
const std::string & GetName() const
Return the name.
Definition: gdal_priv.h:2518
const std::string & GetType() const
Return the axis type.
Definition: gdal_priv.h:2534
const std::string & GetDirection() const
Return the axis direction.
Definition: gdal_priv.h:2544
GUInt64 GetSize() const
Return the size, that is the number of values along the dimension.
Definition: gdal_priv.h:2550
const std::string & GetFullName() const
Return the full name.
Definition: gdal_priv.h:2524
Class for managing the registration of file format drivers.
Definition: gdal_priv.h:1610
Format specific driver.
Definition: gdal_priv.h:1455
static GDALDriver * FromHandle(GDALDriverH hDriver)
Convert a GDALDriverH to a GDALDriver*.
Definition: gdal_priv.h:1591
static GDALDriverH ToHandle(GDALDriver *poDriver)
Convert a GDALDriver* to a GDALDriverH.
Definition: gdal_priv.h:1585
Class for a component of a compound extended data type.
Definition: gdal_priv.h:1863
const std::string & GetName() const
Return the name.
Definition: gdal_priv.h:1875
size_t GetOffset() const
Return the offset (in bytes) of the component in the compound data type.
Definition: gdal_priv.h:1881
const GDALExtendedDataType & GetType() const
Return the data type of the component.
Definition: gdal_priv.h:1887
GDALEDTComponent(const GDALEDTComponent &)
Copy constructor.
Class used to represent potentially complex data types.
Definition: gdal_priv.h:1772
size_t GetSize() const
Return data type size in bytes.
Definition: gdal_priv.h:1820
size_t GetMaxStringLength() const
Return the maximum length of a string in bytes.
Definition: gdal_priv.h:1826
static GDALExtendedDataType Create(GDALDataType eType)
Return a new GDALExtendedDataType of class GEDTC_NUMERIC.
Definition: gdalmultidim.cpp:5024
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:1812
GDALDataType GetNumericDataType() const
Return numeric data type (only valid when GetClass() == GEDTC_NUMERIC)
Definition: gdal_priv.h:1806
GDALExtendedDataTypeClass GetClass() const
Return type class.
Definition: gdal_priv.h:1800
const std::string & GetName() const
Return type name.
Definition: gdal_priv.h:1794
static GDALExtendedDataType CreateString(size_t nMaxStringLength=0)
Return a new GDALExtendedDataType of class GEDTC_STRING.
Definition: gdalmultidim.cpp:5087
Class modeling a named container of GDALAttribute, GDALMDArray or other GDALGroup.
Definition: gdal_priv.h:1936
const std::string & GetName() const
Return the name of the group.
Definition: gdal_priv.h:1956
const std::string & GetFullName() const
Return the full name of the group.
Definition: gdal_priv.h:1962
Interface used to get a single GDALAttribute or a set of GDALAttribute.
Definition: gdal_priv.h:1905
Class modeling a multi-dimensional array.
Definition: gdal_priv.h:2316
virtual bool IsWritable() const =0
Return whether an array is writable;.
std::shared_ptr< GDALMDArray > at(GUInt64 idx, GUInt64VarArg... tail) const
Return a view of the array using integer indexing.
Definition: gdal_priv.h:2394
Object with metadata.
Definition: gdal_priv.h:134
static GDALMajorObjectH ToHandle(GDALMajorObject *poMajorObject)
Convert a GDALMajorObject* to a GDALMajorObjectH.
Definition: gdal_priv.h:169
static GDALMajorObject * FromHandle(GDALMajorObjectH hMajorObject)
Convert a GDALMajorObjectH to a GDALMajorObject*.
Definition: gdal_priv.h:175
Class for dataset open functions.
Definition: gdal_priv.h:267
int bStatOK
Whether stat()'ing the file was successful.
Definition: gdal_priv.h:288
GByte * pabyHeader
Buffer with first bytes of the file.
Definition: gdal_priv.h:298
int bIsDirectory
Whether the file is a directory.
Definition: gdal_priv.h:290
char ** papszOpenOptions
Open options.
Definition: gdal_priv.h:280
GDALAccess eAccess
Access flag.
Definition: gdal_priv.h:283
int nOpenFlags
Open flags.
Definition: gdal_priv.h:285
VSILFILE * fpL
Pointer to the file.
Definition: gdal_priv.h:293
char * pszFilename
Filename.
Definition: gdal_priv.h:278
int nHeaderBytes
Number of bytes in pabyHeader.
Definition: gdal_priv.h:296
const char *const * papszAllowedDrivers
Allowed drivers (NULL for all)
Definition: gdal_priv.h:301
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition: gdal_rat.h:48
A single raster band (or channel).
Definition: gdal_priv.h:1099
void static GDALRasterBandH ToHandle(GDALRasterBand *poBand)
Convert a GDALRasterBand* to a GDALRasterBandH.
Definition: gdal_priv.h:1314
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
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
virtual CPLErr IReadBlock(int nBlockXOff, int nBlockYOff, void *pData)=0
Read a block of data.
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
static GDALRasterBand * FromHandle(GDALRasterBandH hBand)
Convert a GDALRasterBandH to a GDALRasterBand*.
Definition: gdal_priv.h:1320
A single raster block in the block cache.
Definition: gdal_priv.h:878
int GetDirty() const
Return the dirty flag.
Definition: gdal_priv.h:946
int GetXSize() const
Return the width of the block.
Definition: gdal_priv.h:938
GPtrDiff_t GetBlockSize() const
Return the block size in bytes.
Definition: gdal_priv.h:954
int GetYSize() const
Return the height of the block.
Definition: gdal_priv.h:942
GDALDataType GetDataType() const
Return the data type.
Definition: gdal_priv.h:926
int GetXOff() const
Return the x offset of the top-left corner of the block.
Definition: gdal_priv.h:930
int AddLock(void)
Increment the lock count.
Definition: gdal_priv.h:916
GDALRasterBand * GetBand()
Accessor to source GDALRasterBand object.
Definition: gdal_priv.h:962
int GetYOff() const
Return the y offset of the top-left corner of the block.
Definition: gdal_priv.h:934
int DropLock(void)
Decrement the lock count.
Definition: gdal_priv.h:918
void * GetDataRef(void)
Return the data buffer.
Definition: gdal_priv.h:950
Store the raw result of an attribute value, which might contain dynamically allocated structures (lik...
Definition: gdal_priv.h:2146
size_t size() const
Return the size in bytes of the raw result.
Definition: gdal_priv.h:2176
const GByte * data() const
Return pointer to the start of data.
Definition: gdal_priv.h:2174
const GByte & operator[](size_t idx) const
Return byte at specified index.
Definition: gdal_priv.h:2172
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:355
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:326
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:71
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:158
This class represents a style table.
Definition: ogr_featurestyle.h:85
Various convenience functions for CPL.
CPLErr
Error category.
Definition: cpl_error.h:53
int CPLErrorNum
Error number.
Definition: cpl_error.h:94
Definitions for CPL mini XML Parser/Serializer.
#define CPL_NULL_TERMINATED
Null terminated variadic.
Definition: cpl_port.h:907
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:251
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:339
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:337
GIntBig GInt64
Signed 64 bit integer type.
Definition: cpl_port.h:267
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition: cpl_port.h:917
GIntBig GPtrDiff_t
Integer type large enough to hold the difference between 2 addresses.
Definition: cpl_port.h:286
#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:1003
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1212
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition: cpl_port.h:269
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:942
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:215
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:248
Various convenience functions for working with strings and string lists.
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition: cpl_virtualmem.h:62
Standard C Covers.
FILE VSILFILE
Opaque type for a FILE that implements the VSIVirtualHandle API.
Definition: cpl_vsi.h:156
GUIntBig vsi_l_offset
Type for a file offset.
Definition: cpl_vsi.h:140
Public (C callable) GDAL entry points.
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:276
GDALAccess
Definition: gdal.h:113
@ GA_ReadOnly
Definition: gdal.h:114
void GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition: gdaldataset.cpp:3624
GDALPaletteInterp
Definition: gdal.h:220
@ GPI_RGB
Definition: gdal.h:222
GDALDataType
Definition: gdal.h:60
@ GDT_Byte
Definition: gdal.h:62
@ GDT_Float64
Definition: gdal.h:70
@ GDT_Unknown
Definition: gdal.h:61
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition: gdal.h:258
GDALExtendedDataTypeClass
Enumeration giving the class of a GDALExtendedDataType.
Definition: gdal.h:281
@ GEDTC_NUMERIC
Numeric value.
Definition: gdal.h:283
GDALRIOResampleAlg
RasterIO() resampling method.
Definition: gdal.h:129
int GDALGetDataTypeSizeBytes(GDALDataType)
Get data type size in bytes.
Definition: gdal_misc.cpp:305
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:3223
void * GDALMajorObjectH
Opaque type used for the C bindings of the C++ GDALMajorObject class.
Definition: gdal.h:255
GDALColorInterp
Definition: gdal.h:194
GDALAsyncStatusType
status of the asynchronous stream
Definition: gdal.h:101
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition: gdal.h:264
GDALRWFlag
Definition: gdal.h:119
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:261
void * GDALColorTableH
Opaque type used for the C bindings of the C++ GDALColorTable class.
Definition: gdal.h:267
GDALDriverManager * GetGDALDriverManager(void)
Fetch the global GDAL driver manager.
Definition: gdaldrivermanager.cpp:97
GDALIdentifyEnum
Enumeration used by GDALDriver::pfnIdentify().
Definition: gdal_priv.h:1430
@ GDAL_IDENTIFY_TRUE
Identify determined the file is recognized by the probed driver.
Definition: gdal_priv.h:1436
@ GDAL_IDENTIFY_FALSE
Identify determined the file is not recognized by the probed driver.
Definition: gdal_priv.h:1434
@ GDAL_IDENTIFY_UNKNOWN
Identify could not determine if the file is recognized or not by the probed driver.
Definition: gdal_priv.h:1432
std::unique_ptr< GDALDataset, GDALDatasetUniquePtrDeleter > GDALDatasetUniquePtr
Unique pointer type for GDALDataset.
Definition: gdal_priv.h:867
Core portability services for cross-platform OGR code.
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:346
@ wkbUnknown
unknown type, non-standard
Definition: ogr_core.h:347
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:318
Simple feature classes.
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:780
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:287
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:292
Document node structure.
Definition: cpl_minixml.h:70
Color tuple.
Definition: gdal.h:1174
Object returned by GetFeatures() iterators.
Definition: gdal_priv.h:653
Structure to pass extra arguments to RasterIO() method.
Definition: gdal.h:151
Ground Control Point.
Definition: gdal.h:664