GDAL
gdal_priv.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id$
3  *
4  * Name: gdal_priv.h
5  * Project: GDAL Core
6  * Purpose: GDAL Core C++/Private declarations.
7  * Author: Frank Warmerdam, warmerdam@pobox.com
8  *
9  ******************************************************************************
10  * Copyright (c) 1998, Frank Warmerdam
11  * Copyright (c) 2007-2014, Even Rouault <even dot rouault at spatialys.com>
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a
14  * copy of this software and associated documentation files (the "Software"),
15  * to deal in the Software without restriction, including without limitation
16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  * and/or sell copies of the Software, and to permit persons to whom the
18  * Software is furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included
21  * in all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29  * DEALINGS IN THE SOFTWARE.
30  ****************************************************************************/
31 
32 #ifndef GDAL_PRIV_H_INCLUDED
33 #define GDAL_PRIV_H_INCLUDED
34 
41 /* -------------------------------------------------------------------- */
42 /* Predeclare various classes before pulling in gdal.h, the */
43 /* public declarations. */
44 /* -------------------------------------------------------------------- */
45 class GDALMajorObject;
46 class GDALDataset;
47 class GDALRasterBand;
48 class GDALDriver;
50 class GDALProxyDataset;
51 class GDALProxyRasterBand;
52 class GDALAsyncReader;
53 class GDALRelationship;
54 
55 /* -------------------------------------------------------------------- */
56 /* Pull in the public declarations. This gets the C apis, and */
57 /* also various constants. However, we will still get to */
58 /* provide the real class definitions for the GDAL classes. */
59 /* -------------------------------------------------------------------- */
60 
61 #include "gdal.h"
62 #include "gdal_frmts.h"
63 #include "cpl_vsi.h"
64 #include "cpl_conv.h"
65 #include "cpl_string.h"
66 #include "cpl_minixml.h"
67 #include "cpl_multiproc.h"
68 #include "cpl_atomic_ops.h"
69 
70 #include <stdarg.h>
71 
72 #include <cmath>
73 #include <cstdint>
74 #include <iterator>
75 #include <limits>
76 #include <map>
77 #include <memory>
78 #include <vector>
79 
80 #include "ogr_core.h"
81 #include "ogr_feature.h"
82 
84 #define GMO_VALID 0x0001
85 #define GMO_IGNORE_UNIMPLEMENTED 0x0002
86 #define GMO_SUPPORT_MD 0x0004
87 #define GMO_SUPPORT_MDMD 0x0008
88 #define GMO_MD_DIRTY 0x0010
89 #define GMO_PAM_CLASS 0x0020
90 
92 /************************************************************************/
93 /* GDALMultiDomainMetadata */
94 /************************************************************************/
95 
97 class CPL_DLL GDALMultiDomainMetadata
98 {
99 private:
100  char **papszDomainList;
101  CPLStringList **papoMetadataLists;
102 
103 public:
104  GDALMultiDomainMetadata();
105  ~GDALMultiDomainMetadata();
106 
107  int XMLInit( CPLXMLNode *psMetadata, int bMerge );
108  CPLXMLNode *Serialize();
109 
110  char **GetDomainList() { return papszDomainList; }
111 
112  char **GetMetadata( const char * pszDomain = "" );
113  CPLErr SetMetadata( char ** papszMetadata,
114  const char * pszDomain = "" );
115  const char *GetMetadataItem( const char * pszName,
116  const char * pszDomain = "" );
117  CPLErr SetMetadataItem( const char * pszName,
118  const char * pszValue,
119  const char * pszDomain = "" );
120 
121  void Clear();
122 
123  private:
124  CPL_DISALLOW_COPY_ASSIGN(GDALMultiDomainMetadata)
125 };
127 
128 /* ******************************************************************** */
129 /* GDALMajorObject */
130 /* */
131 /* Base class providing metadata, description and other */
132 /* services shared by major objects. */
133 /* ******************************************************************** */
134 
136 class CPL_DLL GDALMajorObject
137 {
138  protected:
140  int nFlags; // GMO_* flags.
141  CPLString sDescription{};
142  GDALMultiDomainMetadata oMDMD{};
143 
145 
146  char **BuildMetadataDomainList( char** papszList,
147  int bCheckNonEmpty, ... ) CPL_NULL_TERMINATED;
148  public:
149  GDALMajorObject();
150  virtual ~GDALMajorObject();
151 
152  int GetMOFlags() const;
153  void SetMOFlags( int nFlagsIn );
154 
155  virtual const char *GetDescription() const;
156  virtual void SetDescription( const char * );
157 
158  virtual char **GetMetadataDomainList();
159 
160  virtual char **GetMetadata( const char * pszDomain = "" );
161  virtual CPLErr SetMetadata( char ** papszMetadata,
162  const char * pszDomain = "" );
163  virtual const char *GetMetadataItem( const char * pszName,
164  const char * pszDomain = "" );
165  virtual CPLErr SetMetadataItem( const char * pszName,
166  const char * pszValue,
167  const char * pszDomain = "" );
168 
172  static inline GDALMajorObjectH ToHandle(GDALMajorObject* poMajorObject)
173  { return static_cast<GDALMajorObjectH>(poMajorObject); }
174 
178  static inline GDALMajorObject* FromHandle(GDALMajorObjectH hMajorObject)
179  { return static_cast<GDALMajorObject*>(hMajorObject); }
180 };
181 
182 /* ******************************************************************** */
183 /* GDALDefaultOverviews */
184 /* ******************************************************************** */
185 
187 class CPL_DLL GDALDefaultOverviews
188 {
189  friend class GDALDataset;
190 
191  GDALDataset *poDS;
192  GDALDataset *poODS;
193 
194  CPLString osOvrFilename{};
195 
196  bool bOvrIsAux;
197 
198  bool bCheckedForMask;
199  bool bOwnMaskDS;
200  GDALDataset *poMaskDS;
201 
202  // For "overview datasets" we record base level info so we can
203  // find our way back to get overview masks.
204  GDALDataset *poBaseDS;
205 
206  // Stuff for deferred initialize/overviewscans.
207  bool bCheckedForOverviews;
208  void OverviewScan();
209  char *pszInitName;
210  bool bInitNameIsOVR;
211  char **papszInitSiblingFiles;
212 
213  public:
214  GDALDefaultOverviews();
215  ~GDALDefaultOverviews();
216 
217  void Initialize( GDALDataset *poDSIn, const char *pszName = nullptr,
218  char **papszSiblingFiles = nullptr,
219  int bNameIsOVR = FALSE );
220 
221  void TransferSiblingFiles( char** papszSiblingFiles );
222 
223  int IsInitialized();
224 
226 
227  // Overview Related
228 
229  int GetOverviewCount( int nBand );
230  GDALRasterBand *GetOverview( int nBand, int iOverview );
231 
232  CPLErr BuildOverviews( const char * pszBasename,
233  const char * pszResampling,
234  int nOverviews, const int * panOverviewList,
235  int nBands, const int * panBandList,
236  GDALProgressFunc pfnProgress,
237  void *pProgressData,
238  CSLConstList papszOptions );
239 
240  CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile,
241  const char * pszResampling,
242  int nOverviews, const int * panOverviewList,
243  int nBands, const int * panBandList,
244  GDALProgressFunc pfnProgress,
245  void *pProgressData,
246  CSLConstList papszOptions );
247 
248  CPLErr CleanOverviews();
249 
250  // Mask Related
251 
252  CPLErr CreateMaskBand( int nFlags, int nBand = -1 );
253  GDALRasterBand *GetMaskBand( int nBand );
254  int GetMaskFlags( int nBand );
255 
256  int HaveMaskFile( char **papszSiblings = nullptr,
257  const char *pszBasename = nullptr );
258 
259  char** GetSiblingFiles() { return papszInitSiblingFiles; }
260 
261  private:
262  CPL_DISALLOW_COPY_ASSIGN(GDALDefaultOverviews)
263 };
265 
266 /* ******************************************************************** */
267 /* GDALOpenInfo */
268 /* ******************************************************************** */
269 
271 class CPL_DLL GDALOpenInfo
272 {
273  bool bHasGotSiblingFiles;
274  char **papszSiblingFiles;
275  int nHeaderBytesTried;
276 
277  public:
278  GDALOpenInfo( const char * pszFile, int nOpenFlagsIn,
279  const char * const * papszSiblingFiles = nullptr );
280  ~GDALOpenInfo( void );
281 
283  char *pszFilename;
286 
291 
293  int bStatOK;
296 
299 
304 
306  const char* const* papszAllowedDrivers;
307 
308  int TryToIngest(int nBytes);
309  char **GetSiblingFiles();
310  char **StealSiblingFiles();
311  bool AreSiblingFilesLoaded() const;
312 
313  private:
315 };
316 
317 /* ******************************************************************** */
318 /* GDALDataset */
319 /* ******************************************************************** */
320 
321 class OGRLayer;
322 class OGRGeometry;
323 class OGRSpatialReference;
324 class OGRStyleTable;
325 class swq_select;
326 class swq_select_parse_options;
327 class GDALGroup;
328 
330 typedef struct GDALSQLParseInfo GDALSQLParseInfo;
332 
334 #ifdef GDAL_COMPILATION
335 #define OPTIONAL_OUTSIDE_GDAL(val)
336 #else
337 #define OPTIONAL_OUTSIDE_GDAL(val) = val
338 #endif
339 
342 class CPL_DLL GDALDataset : public GDALMajorObject
343 {
344  friend GDALDatasetH CPL_STDCALL GDALOpenEx( const char* pszFilename,
345  unsigned int nOpenFlags,
346  const char* const* papszAllowedDrivers,
347  const char* const* papszOpenOptions,
348  const char* const* papszSiblingFiles );
349  friend void CPL_STDCALL GDALClose( GDALDatasetH hDS );
350 
351  friend class GDALDriver;
352  friend class GDALDefaultOverviews;
353  friend class GDALProxyDataset;
354  friend class GDALDriverManager;
355 
356  CPL_INTERNAL void AddToDatasetOpenList();
357 
358  CPL_INTERNAL static void ReportErrorV(
359  const char* pszDSName,
360  CPLErr eErrClass, CPLErrorNum err_no,
361  const char *fmt, va_list args);
362  protected:
364  GDALDriver *poDriver = nullptr;
365  GDALAccess eAccess = GA_ReadOnly;
366 
367  // Stored raster information.
368  int nRasterXSize = 512;
369  int nRasterYSize = 512;
370  int nBands = 0;
371  GDALRasterBand **papoBands = nullptr;
372 
373  int nOpenFlags = 0;
374 
375  int nRefCount = 1;
376  bool bForceCachedIO = false;
377  bool bShared = false;
378  bool bIsInternal = true;
379  bool bSuppressOnClose = false;
380 
381  mutable std::map<std::string, std::unique_ptr<OGRFieldDomain>> m_oMapFieldDomains{};
382 
383  GDALDataset(void);
384  explicit GDALDataset(int bForceCachedIO);
385 
386  void RasterInitialize( int, int );
387  void SetBand( int, GDALRasterBand * );
388 
389  GDALDefaultOverviews oOvManager{};
390 
391  virtual CPLErr IBuildOverviews( const char *,
392  int, const int *,
393  int, const int *,
394  GDALProgressFunc, void *,
395  CSLConstList papszOptions );
396 
397  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
398  void *, int, int, GDALDataType,
399  int, int *, GSpacing, GSpacing, GSpacing,
401 
402  CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
403  void *, int, int, GDALDataType,
404  int, int *, GSpacing, GSpacing, GSpacing,
406  void BlockBasedFlushCache(bool bAtClosing);
407 
408  CPLErr BandBasedRasterIO( GDALRWFlag eRWFlag,
409  int nXOff, int nYOff, int nXSize, int nYSize,
410  void * pData, int nBufXSize, int nBufYSize,
411  GDALDataType eBufType,
412  int nBandCount, int *panBandMap,
413  GSpacing nPixelSpace, GSpacing nLineSpace,
414  GSpacing nBandSpace,
416 
417  CPLErr RasterIOResampled( GDALRWFlag eRWFlag,
418  int nXOff, int nYOff, int nXSize, int nYSize,
419  void * pData, int nBufXSize, int nBufYSize,
420  GDALDataType eBufType,
421  int nBandCount, int *panBandMap,
422  GSpacing nPixelSpace, GSpacing nLineSpace,
423  GSpacing nBandSpace,
425 
426  CPLErr ValidateRasterIOOrAdviseReadParameters(
427  const char* pszCallingFunc,
428  int* pbStopProcessingOnCENone,
429  int nXOff, int nYOff, int nXSize, int nYSize,
430  int nBufXSize, int nBufYSize,
431  int nBandCount, int *panBandMap);
432 
433  CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
434  int nXOff, int nYOff, int nXSize, int nYSize,
435  void * pData, int nBufXSize, int nBufYSize,
436  GDALDataType eBufType,
437  int nBandCount, int *panBandMap,
438  GSpacing nPixelSpace, GSpacing nLineSpace,
439  GSpacing nBandSpace,
440  GDALRasterIOExtraArg* psExtraArg,
441  int* pbTried);
442 
443  void ShareLockWithParentDataset(GDALDataset* poParentDataset);
444 
446 
447  void CleanupPostFileClosing();
448 
449  virtual int CloseDependentDatasets();
451  int ValidateLayerCreationOptions( const char* const* papszLCO );
452 
453  char **papszOpenOptions = nullptr;
454 
455  friend class GDALRasterBand;
456 
457  // The below methods related to read write mutex are fragile logic, and
458  // should not be used by out-of-tree code if possible.
459  int EnterReadWrite(GDALRWFlag eRWFlag);
460  void LeaveReadWrite();
461  void InitRWLock();
462 
463  void TemporarilyDropReadWriteLock();
464  void ReacquireReadWriteLock();
465 
466  void DisableReadWriteMutex();
467 
468  int AcquireMutex();
469  void ReleaseMutex();
471 
472  public:
473  ~GDALDataset() override;
474 
475  int GetRasterXSize();
476  int GetRasterYSize();
477  int GetRasterCount();
478  GDALRasterBand *GetRasterBand( int );
479 
481  class CPL_DLL Bands
482  {
483  private:
484 
485  friend class GDALDataset;
486  GDALDataset* m_poSelf;
487  CPL_INTERNAL explicit Bands(GDALDataset* poSelf): m_poSelf(poSelf) {}
488 
489  class CPL_DLL Iterator
490  {
491  struct Private;
492  std::unique_ptr<Private> m_poPrivate;
493  public:
494  Iterator(GDALDataset* poDS, bool bStart);
495  Iterator(const Iterator& oOther); // declared but not defined. Needed for gcc 5.4 at least
496  Iterator(Iterator&& oOther) noexcept; // declared but not defined. Needed for gcc 5.4 at least
497  ~Iterator();
498  GDALRasterBand* operator*();
499  Iterator& operator++();
500  bool operator!=(const Iterator& it) const;
501  };
502 
503  public:
504 
505  const Iterator begin() const;
506 
507  const Iterator end() const;
508 
509  size_t size() const;
510 
511  GDALRasterBand* operator[](int iBand);
512  GDALRasterBand* operator[](size_t iBand);
513  };
514 
515  Bands GetBands();
516 
517  virtual void FlushCache(bool bAtClosing = false);
518 
519  virtual const OGRSpatialReference* GetSpatialRef() const;
520  virtual CPLErr SetSpatialRef(const OGRSpatialReference* poSRS);
521 
522  // Compatibility layer
523  const char *GetProjectionRef(void) const;
524  CPLErr SetProjection( const char * pszProjection );
525 
526  virtual CPLErr GetGeoTransform( double * padfTransform );
527  virtual CPLErr SetGeoTransform( double * padfTransform );
528 
529  virtual CPLErr AddBand( GDALDataType eType,
530  char **papszOptions=nullptr );
531 
532  virtual void *GetInternalHandle( const char * pszHandleName );
533  virtual GDALDriver *GetDriver(void);
534  virtual char **GetFileList(void);
535 
536  virtual const char* GetDriverName();
537 
538  virtual const OGRSpatialReference* GetGCPSpatialRef() const;
539  virtual int GetGCPCount();
540  virtual const GDAL_GCP *GetGCPs();
541  virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
542  const OGRSpatialReference * poGCP_SRS );
543 
544  // Compatibility layer
545  const char *GetGCPProjection();
546  CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
547  const char *pszGCPProjection );
548 
549  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
550  int nBufXSize, int nBufYSize,
551  GDALDataType eDT,
552  int nBandCount, int *panBandList,
553  char **papszOptions );
554 
555  virtual CPLErr CreateMaskBand( int nFlagsIn );
556 
557  virtual GDALAsyncReader*
558  BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize,
559  void *pBuf, int nBufXSize, int nBufYSize,
560  GDALDataType eBufType,
561  int nBandCount, int* panBandMap,
562  int nPixelSpace, int nLineSpace, int nBandSpace,
563  char **papszOptions);
564  virtual void EndAsyncReader(GDALAsyncReader *);
565 
567  struct RawBinaryLayout
568  {
569  enum class Interleaving
570  {
571  UNKNOWN,
572  BIP,
573  BIL,
574  BSQ
575  };
576  std::string osRawFilename{};
577  Interleaving eInterleaving = Interleaving::UNKNOWN;
578  GDALDataType eDataType = GDT_Unknown;
579  bool bLittleEndianOrder = false;
580 
581  vsi_l_offset nImageOffset = 0;
582  GIntBig nPixelOffset = 0;
583  GIntBig nLineOffset = 0;
584  GIntBig nBandOffset = 0;
585  };
586 
587  virtual bool GetRawBinaryLayout(RawBinaryLayout&);
589 
590  CPLErr RasterIO( GDALRWFlag, int, int, int, int,
591  void *, int, int, GDALDataType,
592  int, int *, GSpacing, GSpacing, GSpacing,
593  GDALRasterIOExtraArg* psExtraArg
594 #ifndef DOXYGEN_SKIP
595  OPTIONAL_OUTSIDE_GDAL(nullptr)
596 #endif
598 
599  int Reference();
600  int Dereference();
601  int ReleaseRef();
602 
606  GDALAccess GetAccess() const { return eAccess; }
607 
608  int GetShared() const;
609  void MarkAsShared();
610 
611  void MarkSuppressOnClose();
612 
616  char **GetOpenOptions() { return papszOpenOptions; }
617 
618  static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
619 
620  CPLErr BuildOverviews( const char *,
621  int, const int *,
622  int, const int *,
623  GDALProgressFunc, void *,
624  CSLConstList papszOptions
625 #ifndef DOXYGEN_SKIP
626  OPTIONAL_OUTSIDE_GDAL(nullptr)
627 #endif
628  );
629 
630 #ifndef DOXYGEN_XML
631  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
632 
633  static void ReportError(const char* pszDSName,
634  CPLErr eErrClass, CPLErrorNum err_no,
635  const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
636 #endif
637 
638  char ** GetMetadata(const char * pszDomain = "") override;
639 
640 // Only defined when Doxygen enabled
641 #ifdef DOXYGEN_SKIP
642  CPLErr SetMetadata( char ** papszMetadata,
643  const char * pszDomain ) override;
644  CPLErr SetMetadataItem( const char * pszName,
645  const char * pszValue,
646  const char * pszDomain ) override;
647 #endif
648 
649  char **GetMetadataDomainList() override;
650 
651  virtual void ClearStatistics();
652 
656  static inline GDALDatasetH ToHandle(GDALDataset* poDS)
657  { return static_cast<GDALDatasetH>(poDS); }
658 
662  static inline GDALDataset* FromHandle(GDALDatasetH hDS)
663  { return static_cast<GDALDataset*>(hDS); }
664 
668  static GDALDataset* Open( const char* pszFilename,
669  unsigned int nOpenFlags = 0,
670  const char* const* papszAllowedDrivers = nullptr,
671  const char* const* papszOpenOptions = nullptr,
672  const char* const* papszSiblingFiles = nullptr )
673  {
674  return FromHandle(GDALOpenEx(pszFilename, nOpenFlags,
675  papszAllowedDrivers,
676  papszOpenOptions,
677  papszSiblingFiles));
678  }
679 
682  {
685 
687  OGRLayer* layer = nullptr;
688  };
689 
691  // SetEnableOverviews() only to be used by GDALOverviewDataset
692  void SetEnableOverviews(bool bEnable);
693 
694  // Only to be used by driver's GetOverviewCount() method.
695  bool AreOverviewsEnabled() const;
697 
698 private:
699  class Private;
700  Private *m_poPrivate;
701 
702  CPL_INTERNAL OGRLayer* BuildLayerFromSelectInfo(swq_select* psSelectInfo,
703  OGRGeometry *poSpatialFilter,
704  const char *pszDialect,
705  swq_select_parse_options* poSelectParseOptions);
706  CPLStringList oDerivedMetadataList{};
707 
708  public:
709 
710  virtual int GetLayerCount();
711  virtual OGRLayer *GetLayer(int iLayer);
712 
713  virtual bool IsLayerPrivate(int iLayer) const;
714 
718  class CPL_DLL Layers
719  {
720  private:
721 
722  friend class GDALDataset;
723  GDALDataset* m_poSelf;
724  CPL_INTERNAL explicit Layers(GDALDataset* poSelf): m_poSelf(poSelf) {}
725 
726  public:
727 
731  class CPL_DLL Iterator
732  {
733  struct Private;
734  std::unique_ptr<Private> m_poPrivate;
735  public:
736 
737  using value_type = OGRLayer*;
738  using reference = OGRLayer*;
739  using difference_type = void;
740  using pointer = void;
741  using iterator_category = std::input_iterator_tag;
743  Iterator();
744  Iterator(GDALDataset* poDS, bool bStart);
745  Iterator(const Iterator& oOther);
746  Iterator(Iterator&& oOther) noexcept;
747  ~Iterator();
749  Iterator& operator=(const Iterator& oOther);
750  Iterator& operator=(Iterator&& oOther) noexcept;
752  OGRLayer* operator*() const;
753  Iterator& operator++();
754  Iterator operator++(int);
755  bool operator!=(const Iterator& it) const;
756  };
757 
758  Iterator begin() const;
759  Iterator end() const;
760 
761  size_t size() const;
762 
763  OGRLayer* operator[](int iLayer);
764  OGRLayer* operator[](size_t iLayer);
765  OGRLayer* operator[](const char* pszLayername);
766  };
767 
768  Layers GetLayers();
769 
770  virtual OGRLayer *GetLayerByName(const char *);
771  virtual OGRErr DeleteLayer(int iLayer);
772 
773  virtual void ResetReading();
774  virtual OGRFeature* GetNextFeature( OGRLayer** ppoBelongingLayer,
775  double* pdfProgressPct,
776  GDALProgressFunc pfnProgress,
777  void* pProgressData );
778 
779 
781  class CPL_DLL Features
782  {
783  private:
784 
785  friend class GDALDataset;
786  GDALDataset* m_poSelf;
787  CPL_INTERNAL explicit Features(GDALDataset* poSelf): m_poSelf(poSelf) {}
788 
789  class CPL_DLL Iterator
790  {
791  struct Private;
792  std::unique_ptr<Private> m_poPrivate;
793  public:
794  Iterator(GDALDataset* poDS, bool bStart);
795  Iterator(const Iterator& oOther); // declared but not defined. Needed for gcc 5.4 at least
796  Iterator(Iterator&& oOther) noexcept; // declared but not defined. Needed for gcc 5.4 at least
797  ~Iterator();
798  const FeatureLayerPair& operator*() const;
799  Iterator& operator++();
800  bool operator!=(const Iterator& it) const;
801  };
802 
803  public:
804 
805  const Iterator begin() const;
806 
807  const Iterator end() const;
808  };
809 
810  Features GetFeatures();
811 
812  virtual int TestCapability( const char * );
813 
814  virtual std::vector<std::string> GetFieldDomainNames(CSLConstList papszOptions = nullptr) const;
815 
816  virtual const OGRFieldDomain* GetFieldDomain(const std::string& name) const;
817 
818  virtual bool AddFieldDomain(std::unique_ptr<OGRFieldDomain>&& domain,
819  std::string& failureReason);
820 
821  virtual bool DeleteFieldDomain(const std::string& name,
822  std::string& failureReason);
823 
824  virtual bool UpdateFieldDomain(std::unique_ptr<OGRFieldDomain>&& domain,
825  std::string& failureReason);
826 
827  virtual std::vector<std::string> GetRelationshipNames(CSLConstList papszOptions = nullptr) const;
828 
829  virtual const GDALRelationship* GetRelationship(const std::string& name) const;
830 
831  virtual bool AddRelationship(std::unique_ptr<GDALRelationship>&& relationship,
832  std::string& failureReason);
833 
834  virtual bool DeleteRelationship(const std::string& name,
835  std::string& failureReason);
836 
837  virtual bool UpdateRelationship(std::unique_ptr<GDALRelationship>&& relationship,
838  std::string& failureReason);
839 
840  virtual OGRLayer *CreateLayer( const char *pszName,
841  OGRSpatialReference *poSpatialRef = nullptr,
843  char ** papszOptions = nullptr );
844  virtual OGRLayer *CopyLayer( OGRLayer *poSrcLayer,
845  const char *pszNewName,
846  char **papszOptions = nullptr );
847 
848  virtual OGRStyleTable *GetStyleTable();
849  virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
850 
851  virtual void SetStyleTable(OGRStyleTable *poStyleTable);
852 
853  virtual OGRLayer * ExecuteSQL( const char *pszStatement,
854  OGRGeometry *poSpatialFilter,
855  const char *pszDialect );
856  virtual void ReleaseResultSet( OGRLayer * poResultsSet );
857  virtual OGRErr AbortSQL( );
858 
859  int GetRefCount() const;
860  int GetSummaryRefCount() const;
861  OGRErr Release();
862 
863  virtual OGRErr StartTransaction(int bForce=FALSE);
864  virtual OGRErr CommitTransaction();
865  virtual OGRErr RollbackTransaction();
866 
867  virtual std::shared_ptr<GDALGroup> GetRootGroup() const;
868 
870  static int IsGenericSQLDialect(const char* pszDialect);
871 
872  // Semi-public methods. Only to be used by in-tree drivers.
873  GDALSQLParseInfo* BuildParseInfo(swq_select* psSelectInfo,
874  swq_select_parse_options* poSelectParseOptions);
875  static void DestroyParseInfo(GDALSQLParseInfo* psParseInfo );
876  OGRLayer * ExecuteSQL( const char *pszStatement,
877  OGRGeometry *poSpatialFilter,
878  const char *pszDialect,
879  swq_select_parse_options* poSelectParseOptions);
881 
882  protected:
883  virtual OGRLayer *ICreateLayer( const char *pszName,
884  OGRSpatialReference *poSpatialRef = nullptr,
886  char ** papszOptions = nullptr );
887 
889  OGRErr ProcessSQLCreateIndex( const char * );
890  OGRErr ProcessSQLDropIndex( const char * );
891  OGRErr ProcessSQLDropTable( const char * );
892  OGRErr ProcessSQLAlterTableAddColumn( const char * );
893  OGRErr ProcessSQLAlterTableDropColumn( const char * );
894  OGRErr ProcessSQLAlterTableAlterColumn( const char * );
895  OGRErr ProcessSQLAlterTableRenameColumn( const char * );
896 
897  OGRStyleTable *m_poStyleTable = nullptr;
898 
899  friend class GDALProxyPoolDataset;
901 
902  private:
904 };
905 
907 struct CPL_DLL GDALDatasetUniquePtrDeleter
908 {
909  void operator()(GDALDataset* poDataset) const
910  { GDALClose(poDataset); }
911 };
913 
919 using GDALDatasetUniquePtr = std::unique_ptr<GDALDataset, GDALDatasetUniquePtrDeleter>;
920 
921 /* ******************************************************************** */
922 /* GDALRasterBlock */
923 /* ******************************************************************** */
924 
929 class CPL_DLL GDALRasterBlock
930 {
931  friend class GDALAbstractBandBlockCache;
932 
933  GDALDataType eType;
934 
935  bool bDirty;
936  volatile int nLockCount;
937 
938  int nXOff;
939  int nYOff;
940 
941  int nXSize;
942  int nYSize;
943 
944  void *pData;
945 
946  GDALRasterBand *poBand;
947 
948  GDALRasterBlock *poNext;
949  GDALRasterBlock *poPrevious;
950 
951  bool bMustDetach;
952 
953  CPL_INTERNAL void Detach_unlocked( void );
954  CPL_INTERNAL void Touch_unlocked( void );
955 
956  CPL_INTERNAL void RecycleFor( int nXOffIn, int nYOffIn );
957 
958  public:
959  GDALRasterBlock( GDALRasterBand *, int, int );
960  GDALRasterBlock( int nXOffIn, int nYOffIn ); /* only for lookup purpose */
961  virtual ~GDALRasterBlock();
962 
963  CPLErr Internalize( void );
964  void Touch( void );
965  void MarkDirty( void );
966  void MarkClean( void );
968  int AddLock( void ) { return CPLAtomicInc(&nLockCount); }
970  int DropLock( void ) { return CPLAtomicDec(&nLockCount); }
971  void Detach();
972 
973  CPLErr Write();
974 
978  GDALDataType GetDataType() const { return eType; }
982  int GetXOff() const { return nXOff; }
986  int GetYOff() const { return nYOff; }
990  int GetXSize() const { return nXSize; }
994  int GetYSize() const { return nYSize; }
998  int GetDirty() const { return bDirty; }
1002  void *GetDataRef( void ) { return pData; }
1007  return static_cast<GPtrDiff_t>(nXSize) * nYSize * GDALGetDataTypeSizeBytes(eType); }
1008 
1009  int TakeLock();
1010  int DropLockForRemovalFromStorage();
1011 
1014  GDALRasterBand *GetBand() { return poBand; }
1015 
1016  static void FlushDirtyBlocks();
1017  static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE);
1018  static void Verify();
1019 
1020  static void EnterDisableDirtyBlockFlush();
1021  static void LeaveDisableDirtyBlockFlush();
1022 
1023 #ifdef notdef
1024  static void CheckNonOrphanedBlocks(GDALRasterBand* poBand);
1025  void DumpBlock();
1026  static void DumpAll();
1027 #endif
1028 
1029  /* Should only be called by GDALDestroyDriverManager() */
1031  CPL_INTERNAL static void DestroyRBMutex();
1033 
1034  private:
1036 };
1037 
1038 /* ******************************************************************** */
1039 /* GDALColorTable */
1040 /* ******************************************************************** */
1041 
1044 class CPL_DLL GDALColorTable
1045 {
1046  GDALPaletteInterp eInterp;
1047 
1048  std::vector<GDALColorEntry> aoEntries{};
1049 
1050 public:
1052  ~GDALColorTable();
1053 
1054  GDALColorTable *Clone() const;
1055  int IsSame(const GDALColorTable* poOtherCT) const;
1056 
1057  GDALPaletteInterp GetPaletteInterpretation() const;
1058 
1059  int GetColorEntryCount() const;
1060  const GDALColorEntry *GetColorEntry( int ) const;
1061  int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
1062  void SetColorEntry( int, const GDALColorEntry * );
1063  int CreateColorRamp( int, const GDALColorEntry * ,
1064  int, const GDALColorEntry * );
1065  bool IsIdentity() const;
1066 
1071  { return static_cast<GDALColorTableH>(poCT); }
1072 
1077  { return static_cast<GDALColorTable*>(hCT); }
1078 
1079 };
1080 
1081 /* ******************************************************************** */
1082 /* GDALAbstractBandBlockCache */
1083 /* ******************************************************************** */
1084 
1086 
1088 // only used by GDALRasterBand implementation.
1089 
1090 class GDALAbstractBandBlockCache
1091 {
1092  // List of blocks that can be freed or recycled, and its lock
1093  CPLLock *hSpinLock = nullptr;
1094  GDALRasterBlock *psListBlocksToFree = nullptr;
1095 
1096  // Band keep alive counter, and its lock & condition
1097  CPLCond *hCond = nullptr;
1098  CPLMutex *hCondMutex = nullptr;
1099  volatile int nKeepAliveCounter = 0;
1100 
1101  volatile int m_nDirtyBlocks = 0;
1102 
1103  CPL_DISALLOW_COPY_ASSIGN(GDALAbstractBandBlockCache)
1104 
1105  protected:
1106  GDALRasterBand *poBand;
1107 
1108  int m_nInitialDirtyBlocksInFlushCache = 0;
1109  int m_nLastTick = -1;
1110  bool m_bWriteDirtyBlocks = true;
1111 
1112  void FreeDanglingBlocks();
1113  void UnreferenceBlockBase();
1114 
1115  void StartDirtyBlockFlushingLog();
1116  void UpdateDirtyBlockFlushingLog();
1117  void EndDirtyBlockFlushingLog();
1118 
1119  public:
1120  explicit GDALAbstractBandBlockCache(GDALRasterBand* poBand);
1121  virtual ~GDALAbstractBandBlockCache();
1122 
1123  GDALRasterBlock* CreateBlock(int nXBlockOff, int nYBlockOff);
1124  void AddBlockToFreeList( GDALRasterBlock * );
1125  void IncDirtyBlocks(int nInc);
1126  void WaitCompletionPendingTasks();
1127  void DisableDirtyBlockWriting() { m_bWriteDirtyBlocks = false; }
1128 
1129  virtual bool Init() = 0;
1130  virtual bool IsInitOK() = 0;
1131  virtual CPLErr FlushCache() = 0;
1132  virtual CPLErr AdoptBlock( GDALRasterBlock* poBlock ) = 0;
1133  virtual GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff,
1134  int nYBlockYOff ) = 0;
1135  virtual CPLErr UnreferenceBlock( GDALRasterBlock* poBlock ) = 0;
1136  virtual CPLErr FlushBlock( int nXBlockOff, int nYBlockOff,
1137  int bWriteDirtyBlock ) = 0;
1138 };
1139 
1140 GDALAbstractBandBlockCache* GDALArrayBandBlockCacheCreate(GDALRasterBand* poBand);
1141 GDALAbstractBandBlockCache* GDALHashSetBandBlockCacheCreate(GDALRasterBand* poBand);
1142 
1144 
1145 /* ******************************************************************** */
1146 /* GDALRasterBand */
1147 /* ******************************************************************** */
1148 
1149 class GDALMDArray;
1150 
1152 typedef enum
1153 {
1154  GMVR_UNKNOWN,
1158 
1161 
1164 
1167 
1170 
1173 
1176 
1179 class CPL_DLL GDALRasterBand : public GDALMajorObject
1180 {
1181  private:
1182  friend class GDALArrayBandBlockCache;
1183  friend class GDALHashSetBandBlockCache;
1184  friend class GDALRasterBlock;
1185  friend class GDALDataset;
1186 
1187  CPLErr eFlushBlockErr = CE_None;
1188  GDALAbstractBandBlockCache* poBandBlockCache = nullptr;
1189 
1190  CPL_INTERNAL void SetFlushBlockErr( CPLErr eErr );
1191  CPL_INTERNAL CPLErr UnreferenceBlock( GDALRasterBlock* poBlock );
1192  CPL_INTERNAL void IncDirtyBlocks(int nInc);
1193 
1194  protected:
1196  GDALDataset *poDS = nullptr;
1197  int nBand = 0; /* 1 based */
1198 
1199  int nRasterXSize = 0;
1200  int nRasterYSize = 0;
1201 
1202  GDALDataType eDataType = GDT_Byte;
1203  GDALAccess eAccess = GA_ReadOnly;
1204 
1205  /* stuff related to blocking, and raster cache */
1206  int nBlockXSize = -1;
1207  int nBlockYSize = -1;
1208  int nBlocksPerRow = 0;
1209  int nBlocksPerColumn = 0;
1210 
1211  int nBlockReads = 0;
1212  int bForceCachedIO = 0;
1213 
1214  GDALRasterBand *poMask = nullptr;
1215  bool bOwnMask = false;
1216  int nMaskFlags = 0;
1217 
1218  void InvalidateMaskBand();
1219 
1220  friend class GDALProxyRasterBand;
1221  friend class GDALDefaultOverviews;
1222 
1223  CPLErr RasterIOResampled( GDALRWFlag, int, int, int, int,
1224  void *, int, int, GDALDataType,
1226 
1227  int EnterReadWrite(GDALRWFlag eRWFlag);
1228  void LeaveReadWrite();
1229  void InitRWLock();
1230  void SetValidPercent( GUIntBig nSampleCount, GUIntBig nValidCount );
1232 
1233  protected:
1234  virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void * pData ) = 0;
1235  virtual CPLErr IWriteBlock( int nBlockXOff, int nBlockYOff, void * pData );
1236 
1237  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1238  void *, int, int, GDALDataType,
1240 
1241  virtual int IGetDataCoverageStatus( int nXOff, int nYOff,
1242  int nXSize, int nYSize,
1243  int nMaskFlagStop,
1244  double* pdfDataPct);
1246  CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
1247  void *, int, int, GDALDataType,
1249 
1250  CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
1251  int nXOff, int nYOff, int nXSize, int nYSize,
1252  void * pData, int nBufXSize, int nBufYSize,
1253  GDALDataType eBufType,
1254  GSpacing nPixelSpace, GSpacing nLineSpace,
1255  GDALRasterIOExtraArg* psExtraArg,
1256  int* pbTried );
1257 
1258  int InitBlockInfo();
1259 
1260  void AddBlockToFreeList( GDALRasterBlock * );
1262 
1263  public:
1264  GDALRasterBand();
1265  explicit GDALRasterBand(int bForceCachedIO);
1266 
1267  ~GDALRasterBand() override;
1268 
1269  int GetXSize();
1270  int GetYSize();
1271  int GetBand();
1272  GDALDataset*GetDataset();
1273 
1274  GDALDataType GetRasterDataType( void );
1275  void GetBlockSize( int *, int * );
1276  CPLErr GetActualBlockSize ( int, int, int *, int * );
1277 
1278  virtual GDALSuggestedBlockAccessPattern GetSuggestedBlockAccessPattern() const;
1279 
1280  GDALAccess GetAccess();
1281 
1282  CPLErr RasterIO( GDALRWFlag, int, int, int, int,
1283  void *, int, int, GDALDataType,
1284  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg
1285 #ifndef DOXYGEN_SKIP
1286  OPTIONAL_OUTSIDE_GDAL(nullptr)
1287 #endif
1289  CPLErr ReadBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
1290 
1291  CPLErr WriteBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
1292 
1293  GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
1294  int bJustInitialize = FALSE ) CPL_WARN_UNUSED_RESULT;
1295  GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff ) CPL_WARN_UNUSED_RESULT;
1296  CPLErr FlushBlock( int, int, int bWriteDirtyBlock = TRUE );
1297 
1298  unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand,
1299  unsigned char* pTranslationTable = nullptr,
1300  int* pApproximateMatching = nullptr);
1301 
1302  // New OpengIS CV_SampleDimension stuff.
1303 
1304  virtual CPLErr FlushCache(bool bAtClosing = false);
1305  virtual char **GetCategoryNames();
1306  virtual double GetNoDataValue( int *pbSuccess = nullptr );
1307  virtual int64_t GetNoDataValueAsInt64( int *pbSuccess = nullptr );
1308  virtual uint64_t GetNoDataValueAsUInt64( int *pbSuccess = nullptr );
1309  virtual double GetMinimum( int *pbSuccess = nullptr );
1310  virtual double GetMaximum(int *pbSuccess = nullptr );
1311  virtual double GetOffset( int *pbSuccess = nullptr );
1312  virtual double GetScale( int *pbSuccess = nullptr );
1313  virtual const char *GetUnitType();
1314  virtual GDALColorInterp GetColorInterpretation();
1315  virtual GDALColorTable *GetColorTable();
1316  virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
1317 
1318  virtual CPLErr SetCategoryNames( char ** papszNames );
1319  virtual CPLErr SetNoDataValue( double dfNoData );
1320  virtual CPLErr SetNoDataValueAsInt64( int64_t nNoData );
1321  virtual CPLErr SetNoDataValueAsUInt64( uint64_t nNoData );
1322  virtual CPLErr DeleteNoDataValue();
1323  virtual CPLErr SetColorTable( GDALColorTable * poCT );
1324  virtual CPLErr SetColorInterpretation( GDALColorInterp eColorInterp );
1325  virtual CPLErr SetOffset( double dfNewOffset );
1326  virtual CPLErr SetScale( double dfNewScale );
1327  virtual CPLErr SetUnitType( const char * pszNewValue );
1328 
1329  virtual CPLErr GetStatistics( int bApproxOK, int bForce,
1330  double *pdfMin, double *pdfMax,
1331  double *pdfMean, double *padfStdDev );
1332  virtual CPLErr ComputeStatistics( int bApproxOK,
1333  double *pdfMin, double *pdfMax,
1334  double *pdfMean, double *pdfStdDev,
1335  GDALProgressFunc, void *pProgressData );
1336  virtual CPLErr SetStatistics( double dfMin, double dfMax,
1337  double dfMean, double dfStdDev );
1338  virtual CPLErr ComputeRasterMinMax( int, double* );
1339 
1340 // Only defined when Doxygen enabled
1341 #ifdef DOXYGEN_SKIP
1342  CPLErr SetMetadata( char ** papszMetadata,
1343  const char * pszDomain ) override;
1344  CPLErr SetMetadataItem( const char * pszName,
1345  const char * pszValue,
1346  const char * pszDomain ) override;
1347 #endif
1348 
1349  virtual int HasArbitraryOverviews();
1350  virtual int GetOverviewCount();
1351  virtual GDALRasterBand *GetOverview(int);
1352  virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig );
1353  virtual CPLErr BuildOverviews( const char * pszResampling,
1354  int nOverviews,
1355  const int * panOverviewList,
1356  GDALProgressFunc pfnProgress,
1357  void * pProgressData,
1358  CSLConstList papszOptions );
1359 
1360  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
1361  int nBufXSize, int nBufYSize,
1362  GDALDataType eBufType, char **papszOptions );
1363 
1364  virtual CPLErr GetHistogram( double dfMin, double dfMax,
1365  int nBuckets, GUIntBig * panHistogram,
1366  int bIncludeOutOfRange, int bApproxOK,
1367  GDALProgressFunc, void *pProgressData );
1368 
1369  virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
1370  int *pnBuckets, GUIntBig ** ppanHistogram,
1371  int bForce,
1372  GDALProgressFunc, void *pProgressData);
1373  virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
1374  int nBuckets, GUIntBig *panHistogram );
1375 
1376  virtual GDALRasterAttributeTable *GetDefaultRAT();
1377  virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * poRAT );
1378 
1379  virtual GDALRasterBand *GetMaskBand();
1380  virtual int GetMaskFlags();
1381  virtual CPLErr CreateMaskBand( int nFlagsIn );
1382  virtual bool IsMaskBand() const;
1383  virtual GDALMaskValueRange GetMaskValueRange() const;
1384 
1385  virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
1386  int *pnPixelSpace,
1387  GIntBig *pnLineSpace,
1388  char **papszOptions ) CPL_WARN_UNUSED_RESULT;
1389 
1390  int GetDataCoverageStatus( int nXOff, int nYOff,
1391  int nXSize, int nYSize,
1392  int nMaskFlagStop = 0,
1393  double* pdfDataPct = nullptr );
1394 
1395  std::shared_ptr<GDALMDArray> AsMDArray() const;
1396 
1397 #ifndef DOXYGEN_XML
1398  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
1399 #endif
1400 
1404  static inline GDALRasterBandH ToHandle(GDALRasterBand* poBand)
1405  { return static_cast<GDALRasterBandH>(poBand); }
1406 
1411  { return static_cast<GDALRasterBand*>(hBand); }
1412 
1413 private:
1415 };
1416 
1418 /* ******************************************************************** */
1419 /* GDALAllValidMaskBand */
1420 /* ******************************************************************** */
1421 
1422 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
1423 {
1424  protected:
1425  CPLErr IReadBlock( int, int, void * ) override;
1426 
1427  CPL_DISALLOW_COPY_ASSIGN(GDALAllValidMaskBand)
1428 
1429  public:
1430  explicit GDALAllValidMaskBand( GDALRasterBand * );
1431  ~GDALAllValidMaskBand() override;
1432 
1433  GDALRasterBand *GetMaskBand() override;
1434  int GetMaskFlags() override;
1435 
1436  bool IsMaskBand() const override { return true; }
1437  GDALMaskValueRange GetMaskValueRange() const override { return GMVR_0_AND_255_ONLY; }
1438 
1439  CPLErr ComputeStatistics( int bApproxOK,
1440  double *pdfMin, double *pdfMax,
1441  double *pdfMean, double *pdfStdDev,
1442  GDALProgressFunc, void *pProgressData ) override;
1443 
1444 };
1445 
1446 /* ******************************************************************** */
1447 /* GDALNoDataMaskBand */
1448 /* ******************************************************************** */
1449 
1450 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
1451 {
1452  friend class GDALRasterBand;
1453  double dfNoDataValue = 0;
1454  int64_t nNoDataValueInt64 = 0;
1455  uint64_t nNoDataValueUInt64 = 0;
1456  GDALRasterBand *poParent;
1457 
1458  CPL_DISALLOW_COPY_ASSIGN(GDALNoDataMaskBand)
1459 
1460  protected:
1461  CPLErr IReadBlock( int, int, void * ) override;
1462  CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1463  void *, int, int, GDALDataType,
1464  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) override;
1465 
1466  public:
1467  explicit GDALNoDataMaskBand( GDALRasterBand * );
1468  ~GDALNoDataMaskBand() override;
1469 
1470  bool IsMaskBand() const override { return true; }
1471  GDALMaskValueRange GetMaskValueRange() const override { return GMVR_0_AND_255_ONLY; }
1472 
1473  static bool IsNoDataInRange(double dfNoDataValue,
1474  GDALDataType eDataType);
1475 };
1476 
1477 /* ******************************************************************** */
1478 /* GDALNoDataValuesMaskBand */
1479 /* ******************************************************************** */
1480 
1481 class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
1482 {
1483  double *padfNodataValues;
1484 
1485  CPL_DISALLOW_COPY_ASSIGN(GDALNoDataValuesMaskBand)
1486 
1487  protected:
1488  CPLErr IReadBlock( int, int, void * ) override;
1489 
1490  public:
1491  explicit GDALNoDataValuesMaskBand( GDALDataset * );
1492  ~GDALNoDataValuesMaskBand() override;
1493 
1494  bool IsMaskBand() const override { return true; }
1495  GDALMaskValueRange GetMaskValueRange() const override { return GMVR_0_AND_255_ONLY; }
1496 };
1497 
1498 /* ******************************************************************** */
1499 /* GDALRescaledAlphaBand */
1500 /* ******************************************************************** */
1501 
1502 class GDALRescaledAlphaBand : public GDALRasterBand
1503 {
1504  GDALRasterBand *poParent;
1505  void *pTemp;
1506 
1507  CPL_DISALLOW_COPY_ASSIGN(GDALRescaledAlphaBand)
1508 
1509  protected:
1510  CPLErr IReadBlock( int, int, void * ) override;
1511  CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1512  void *, int, int, GDALDataType,
1513  GSpacing, GSpacing,
1514  GDALRasterIOExtraArg* psExtraArg ) override;
1515 
1516  public:
1517  explicit GDALRescaledAlphaBand( GDALRasterBand * );
1518  ~GDALRescaledAlphaBand() override;
1519 
1520  bool IsMaskBand() const override { return true; }
1521 };
1523 
1524 /* ******************************************************************** */
1525 /* GDALIdentifyEnum */
1526 /* ******************************************************************** */
1527 
1533 typedef enum
1534 {
1542 
1543 /* ******************************************************************** */
1544 /* GDALDriver */
1545 /* ******************************************************************** */
1546 
1558 class CPL_DLL GDALDriver : public GDALMajorObject
1559 {
1560  public:
1561  GDALDriver();
1562  ~GDALDriver() override;
1563 
1564  CPLErr SetMetadataItem( const char * pszName,
1565  const char * pszValue,
1566  const char * pszDomain = "" ) override;
1567 
1568 /* -------------------------------------------------------------------- */
1569 /* Public C++ methods. */
1570 /* -------------------------------------------------------------------- */
1571  GDALDataset *Create( const char * pszName,
1572  int nXSize, int nYSize, int nBands,
1573  GDALDataType eType, CSLConstList papszOptions ) CPL_WARN_UNUSED_RESULT;
1574 
1575  GDALDataset *CreateMultiDimensional( const char * pszName,
1576  CSLConstList papszRootGroupOptions,
1577  CSLConstList papszOptions ) CPL_WARN_UNUSED_RESULT;
1578 
1579  CPLErr Delete( const char * pszName );
1580  CPLErr Rename( const char * pszNewName,
1581  const char * pszOldName );
1582  CPLErr CopyFiles( const char * pszNewName,
1583  const char * pszOldName );
1584 
1585  GDALDataset *CreateCopy( const char *, GDALDataset *,
1586  int, CSLConstList papszOptions,
1587  GDALProgressFunc pfnProgress,
1588  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
1589 
1590 /* -------------------------------------------------------------------- */
1591 /* The following are semiprivate, not intended to be accessed */
1592 /* by anyone but the formats instantiating and populating the */
1593 /* drivers. */
1594 /* -------------------------------------------------------------------- */
1596  GDALDataset *(*pfnOpen)( GDALOpenInfo * );
1597 
1598  GDALDataset *(*pfnCreate)( const char * pszName,
1599  int nXSize, int nYSize, int nBands,
1600  GDALDataType eType,
1601  char ** papszOptions );
1602 
1603  GDALDataset *(*pfnCreateEx)( GDALDriver*, const char * pszName,
1604  int nXSize, int nYSize, int nBands,
1605  GDALDataType eType,
1606  char ** papszOptions );
1607 
1608  GDALDataset *(*pfnCreateMultiDimensional)( const char * pszName,
1609  CSLConstList papszRootGroupOptions,
1610  CSLConstList papszOptions );
1611 
1612  CPLErr (*pfnDelete)( const char * pszName );
1613 
1614  GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
1615  int, char **,
1616  GDALProgressFunc pfnProgress,
1617  void * pProgressData );
1618 
1619  void *pDriverData;
1620 
1621  void (*pfnUnloadDriver)(GDALDriver *);
1622 
1630  int (*pfnIdentify)( GDALOpenInfo * );
1631  int (*pfnIdentifyEx)( GDALDriver*, GDALOpenInfo * );
1632 
1633  CPLErr (*pfnRename)( const char * pszNewName,
1634  const char * pszOldName );
1635  CPLErr (*pfnCopyFiles)( const char * pszNewName,
1636  const char * pszOldName );
1637 
1638  // Used for legacy OGR drivers, and Python drivers
1639  GDALDataset *(*pfnOpenWithDriverArg)( GDALDriver*, GDALOpenInfo * );
1640 
1641  /* For legacy OGR drivers */
1642  GDALDataset *(*pfnCreateVectorOnly)( GDALDriver*,
1643  const char * pszName,
1644  char ** papszOptions );
1645  CPLErr (*pfnDeleteDataSource)( GDALDriver*,
1646  const char * pszName );
1648 
1649 /* -------------------------------------------------------------------- */
1650 /* Helper methods. */
1651 /* -------------------------------------------------------------------- */
1653  GDALDataset *DefaultCreateCopy( const char *, GDALDataset *,
1654  int, CSLConstList papszOptions,
1655  GDALProgressFunc pfnProgress,
1656  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
1657 
1658  static CPLErr DefaultCreateCopyMultiDimensional(
1659  GDALDataset *poSrcDS,
1660  GDALDataset *poDstDS,
1661  bool bStrict,
1662  CSLConstList /*papszOptions*/,
1663  GDALProgressFunc pfnProgress,
1664  void * pProgressData );
1665 
1666  static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
1667  GDALDataset *poDstDS,
1668  int bStrict );
1669  static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
1670  GDALDataset *poDstDS,
1671  int bStrict,
1672  CSLConstList papszOptions,
1673  GDALProgressFunc pfnProgress,
1674  void * pProgressData );
1676  static CPLErr QuietDelete( const char * pszName,
1677  CSLConstList papszAllowedDrivers = nullptr);
1678 
1680  static CPLErr DefaultRename( const char * pszNewName,
1681  const char * pszOldName );
1682  static CPLErr DefaultCopyFiles( const char * pszNewName,
1683  const char * pszOldName );
1685 
1689  static inline GDALDriverH ToHandle(GDALDriver* poDriver)
1690  { return static_cast<GDALDriverH>(poDriver); }
1691 
1695  static inline GDALDriver* FromHandle(GDALDriverH hDriver)
1696  { return static_cast<GDALDriver*>(hDriver); }
1697 
1698 private:
1700 };
1701 
1702 /* ******************************************************************** */
1703 /* GDALDriverManager */
1704 /* ******************************************************************** */
1705 
1713 class CPL_DLL GDALDriverManager : public GDALMajorObject
1714 {
1715  int nDrivers = 0;
1716  GDALDriver **papoDrivers = nullptr;
1717  std::map<CPLString, GDALDriver*> oMapNameToDrivers{};
1718  std::string m_osDriversIniPath{};
1719 
1720  GDALDriver *GetDriver_unlocked( int iDriver )
1721  { return (iDriver >= 0 && iDriver < nDrivers) ?
1722  papoDrivers[iDriver] : nullptr; }
1723 
1724  GDALDriver *GetDriverByName_unlocked( const char * pszName ) const
1725  { auto oIter = oMapNameToDrivers.find(CPLString(pszName).toupper());
1726  return oIter == oMapNameToDrivers.end() ? nullptr : oIter->second;
1727  }
1728 
1729  static char** GetSearchPaths(const char* pszGDAL_DRIVER_PATH);
1730 
1731  static void CleanupPythonDrivers();
1732 
1734 
1735  public:
1737  ~GDALDriverManager();
1738 
1739  int GetDriverCount( void ) const;
1740  GDALDriver *GetDriver( int );
1741  GDALDriver *GetDriverByName( const char * );
1742 
1743  int RegisterDriver( GDALDriver * );
1744  void DeregisterDriver( GDALDriver * );
1745 
1746  // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
1747  void AutoLoadDrivers();
1748  void AutoSkipDrivers();
1749  void ReorderDrivers();
1750 
1751  static void AutoLoadPythonDrivers();
1752 };
1753 
1755 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
1756 CPL_C_END
1757 
1758 /* ******************************************************************** */
1759 /* GDALAsyncReader */
1760 /* ******************************************************************** */
1761 
1767 class CPL_DLL GDALAsyncReader
1768 {
1769 
1771 
1772  protected:
1774  GDALDataset* poDS;
1775  int nXOff;
1776  int nYOff;
1777  int nXSize;
1778  int nYSize;
1779  void * pBuf;
1780  int nBufXSize;
1781  int nBufYSize;
1782  GDALDataType eBufType;
1783  int nBandCount;
1784  int* panBandMap;
1785  int nPixelSpace;
1786  int nLineSpace;
1787  int nBandSpace;
1789 
1790  public:
1791  GDALAsyncReader();
1792  virtual ~GDALAsyncReader();
1793 
1797  GDALDataset* GetGDALDataset() {return poDS;}
1801  int GetXOffset() const { return nXOff; }
1805  int GetYOffset() const { return nYOff; }
1809  int GetXSize() const { return nXSize; }
1813  int GetYSize() const { return nYSize; }
1817  void * GetBuffer() {return pBuf;}
1821  int GetBufferXSize() const { return nBufXSize; }
1825  int GetBufferYSize() const { return nBufYSize; }
1829  GDALDataType GetBufferType() const { return eBufType; }
1833  int GetBandCount() const { return nBandCount; }
1837  int* GetBandMap() { return panBandMap; }
1841  int GetPixelSpace() const { return nPixelSpace; }
1845  int GetLineSpace() const { return nLineSpace; }
1849  int GetBandSpace() const { return nBandSpace; }
1850 
1851  virtual GDALAsyncStatusType
1852  GetNextUpdatedRegion(double dfTimeout,
1853  int* pnBufXOff, int* pnBufYOff,
1854  int* pnBufXSize, int* pnBufYSize) = 0;
1855  virtual int LockBuffer( double dfTimeout = -1.0 );
1856  virtual void UnlockBuffer();
1857 };
1858 
1859 /* ******************************************************************** */
1860 /* Multidimensional array API */
1861 /* ******************************************************************** */
1862 
1863 class GDALMDArray;
1864 class GDALAttribute;
1865 class GDALDimension;
1866 class GDALEDTComponent;
1867 
1868 /* ******************************************************************** */
1869 /* GDALExtendedDataType */
1870 /* ******************************************************************** */
1871 
1880 {
1881 public:
1883 
1885 
1887 
1888  static GDALExtendedDataType Create(GDALDataType eType);
1889  static GDALExtendedDataType Create(const std::string& osName,
1890  size_t nTotalSize,
1891  std::vector<std::unique_ptr<GDALEDTComponent>>&& components);
1892  static GDALExtendedDataType CreateString(size_t nMaxStringLength = 0,
1894 
1895  bool operator== (const GDALExtendedDataType& ) const;
1897  bool operator!= (const GDALExtendedDataType& other) const { return !(operator==(other)); }
1898 
1903  const std::string& GetName() const { return m_osName; }
1904 
1909  GDALExtendedDataTypeClass GetClass() const { return m_eClass; }
1910 
1915  GDALDataType GetNumericDataType() const { return m_eNumericDT; }
1916 
1923  GDALExtendedDataTypeSubType GetSubType() const { return m_eSubType; }
1924 
1929  const std::vector<std::unique_ptr<GDALEDTComponent>>& GetComponents() const { return m_aoComponents; }
1930 
1937  size_t GetSize() const { return m_nSize; }
1938 
1943  size_t GetMaxStringLength() const { return m_nMaxStringLength; }
1944 
1945  bool CanConvertTo(const GDALExtendedDataType& other) const;
1946 
1947  bool NeedsFreeDynamicMemory() const;
1948 
1949  void FreeDynamicMemory(void* pBuffer) const;
1950 
1951  static
1952  bool CopyValue(const void* pSrc, const GDALExtendedDataType& srcType,
1953  void* pDst, const GDALExtendedDataType& dstType);
1954 
1955  static
1956  bool CopyValues(const void* pSrc, const GDALExtendedDataType& srcType,
1957  GPtrDiff_t nSrcStrideInElts,
1958  void* pDst, const GDALExtendedDataType& dstType,
1959  GPtrDiff_t nDstStrideInElts,
1960  size_t nValues);
1961 
1962 private:
1963  GDALExtendedDataType(size_t nMaxStringLength, GDALExtendedDataTypeSubType eSubType);
1964  explicit GDALExtendedDataType(GDALDataType eType);
1965  GDALExtendedDataType(const std::string& osName,
1966  size_t nTotalSize,
1967  std::vector<std::unique_ptr<GDALEDTComponent>>&& components);
1968 
1969  std::string m_osName{};
1972  GDALDataType m_eNumericDT = GDT_Unknown;
1973  std::vector<std::unique_ptr<GDALEDTComponent>> m_aoComponents{};
1974  size_t m_nSize = 0;
1975  size_t m_nMaxStringLength = 0;
1976 };
1977 
1978 /* ******************************************************************** */
1979 /* GDALEDTComponent */
1980 /* ******************************************************************** */
1981 
1987 class CPL_DLL GDALEDTComponent
1988 {
1989 public:
1990  ~GDALEDTComponent();
1991  GDALEDTComponent(const std::string& name, size_t offset, const GDALExtendedDataType& type);
1993 
1994  bool operator== (const GDALEDTComponent& ) const;
1995 
2000  const std::string& GetName() const { return m_osName; }
2001 
2006  size_t GetOffset() const { return m_nOffset; }
2007 
2012  const GDALExtendedDataType& GetType() const { return m_oType; }
2013 
2014 private:
2015  std::string m_osName;
2016  size_t m_nOffset;
2017  GDALExtendedDataType m_oType;
2018 };
2019 
2020 /* ******************************************************************** */
2021 /* GDALIHasAttribute */
2022 /* ******************************************************************** */
2023 
2029 class CPL_DLL GDALIHasAttribute
2030 {
2031 protected:
2032  std::shared_ptr<GDALAttribute> GetAttributeFromAttributes(const std::string& osName) const;
2033 
2034 public:
2035  virtual ~GDALIHasAttribute();
2036 
2037  virtual std::shared_ptr<GDALAttribute> GetAttribute(const std::string& osName) const;
2038 
2039  virtual std::vector<std::shared_ptr<GDALAttribute>> GetAttributes(CSLConstList papszOptions = nullptr) const;
2040 
2041  virtual std::shared_ptr<GDALAttribute> CreateAttribute(
2042  const std::string& osName,
2043  const std::vector<GUInt64>& anDimensions,
2044  const GDALExtendedDataType& oDataType,
2045  CSLConstList papszOptions = nullptr);
2046 };
2047 
2048 /* ******************************************************************** */
2049 /* GDALGroup */
2050 /* ******************************************************************** */
2051 
2060 class CPL_DLL GDALGroup: public GDALIHasAttribute
2061 {
2062 protected:
2064  std::string m_osName{};
2065  std::string m_osFullName{};
2066 
2067  GDALGroup(const std::string& osParentName, const std::string& osName);
2068 
2069  const GDALGroup* GetInnerMostGroup(const std::string& osPathOrArrayOrDim,
2070  std::shared_ptr<GDALGroup>& curGroupHolder,
2071  std::string& osLastPart) const;
2073 
2074 public:
2075  virtual ~GDALGroup();
2076 
2081  const std::string& GetName() const { return m_osName; }
2082 
2087  const std::string& GetFullName() const { return m_osFullName; }
2088 
2089  virtual std::vector<std::string> GetMDArrayNames(CSLConstList papszOptions = nullptr) const;
2090  virtual std::shared_ptr<GDALMDArray> OpenMDArray(const std::string& osName,
2091  CSLConstList papszOptions = nullptr) const;
2092 
2093  virtual std::vector<std::string> GetGroupNames(CSLConstList papszOptions = nullptr) const;
2094  virtual std::shared_ptr<GDALGroup> OpenGroup(const std::string& osName,
2095  CSLConstList papszOptions = nullptr) const;
2096 
2097  virtual std::vector<std::string> GetVectorLayerNames(CSLConstList papszOptions = nullptr) const;
2098  virtual OGRLayer* OpenVectorLayer(const std::string& osName,
2099  CSLConstList papszOptions = nullptr) const;
2100 
2101  virtual std::vector<std::shared_ptr<GDALDimension>> GetDimensions(CSLConstList papszOptions = nullptr) const;
2102 
2103  virtual std::shared_ptr<GDALGroup> CreateGroup(const std::string& osName,
2104  CSLConstList papszOptions = nullptr);
2105 
2106  virtual std::shared_ptr<GDALDimension> CreateDimension(const std::string& osName,
2107  const std::string& osType,
2108  const std::string& osDirection,
2109  GUInt64 nSize,
2110  CSLConstList papszOptions = nullptr);
2111 
2112  virtual std::shared_ptr<GDALMDArray> CreateMDArray(const std::string& osName,
2113  const std::vector<std::shared_ptr<GDALDimension>>& aoDimensions,
2114  const GDALExtendedDataType& oDataType,
2115  CSLConstList papszOptions = nullptr);
2116 
2117  GUInt64 GetTotalCopyCost() const;
2118 
2119  virtual bool CopyFrom(const std::shared_ptr<GDALGroup>& poDstRootGroup,
2120  GDALDataset* poSrcDS,
2121  const std::shared_ptr<GDALGroup>& poSrcGroup,
2122  bool bStrict,
2123  GUInt64& nCurCost,
2124  const GUInt64 nTotalCost,
2125  GDALProgressFunc pfnProgress,
2126  void * pProgressData,
2127  CSLConstList papszOptions = nullptr);
2128 
2129  virtual CSLConstList GetStructuralInfo() const;
2130 
2131  std::shared_ptr<GDALMDArray> OpenMDArrayFromFullname(
2132  const std::string& osFullName,
2133  CSLConstList papszOptions = nullptr) const;
2134 
2135  std::shared_ptr<GDALMDArray> ResolveMDArray(const std::string& osName,
2136  const std::string& osStartingPath,
2137  CSLConstList papszOptions = nullptr) const;
2138 
2139  std::shared_ptr<GDALGroup> OpenGroupFromFullname(
2140  const std::string& osFullName,
2141  CSLConstList papszOptions = nullptr) const;
2142 
2143  std::shared_ptr<GDALDimension> OpenDimensionFromFullname(
2144  const std::string& osFullName) const;
2145 
2146  virtual void ClearStatistics();
2147 
2149  static constexpr GUInt64 COPY_COST = 1000;
2151 };
2152 
2153 /* ******************************************************************** */
2154 /* GDALAbstractMDArray */
2155 /* ******************************************************************** */
2156 
2162 class CPL_DLL GDALAbstractMDArray
2163 {
2164 protected:
2166  std::string m_osName{};
2167  std::string m_osFullName{};
2168  std::weak_ptr<GDALAbstractMDArray> m_pSelf{};
2169 
2170  GDALAbstractMDArray(const std::string& osParentName, const std::string& osName);
2171 
2172  void SetSelf(std::weak_ptr<GDALAbstractMDArray> self) { m_pSelf = self; }
2173 
2174  bool CheckReadWriteParams(const GUInt64* arrayStartIdx,
2175  const size_t* count,
2176  const GInt64*& arrayStep,
2177  const GPtrDiff_t*& bufferStride,
2178  const GDALExtendedDataType& bufferDataType,
2179  const void* buffer,
2180  const void* buffer_alloc_start,
2181  size_t buffer_alloc_size,
2182  std::vector<GInt64>& tmp_arrayStep,
2183  std::vector<GPtrDiff_t>& tmp_bufferStride) const;
2184 
2185  virtual bool IRead(const GUInt64* arrayStartIdx, // array of size GetDimensionCount()
2186  const size_t* count, // array of size GetDimensionCount()
2187  const GInt64* arrayStep, // step in elements
2188  const GPtrDiff_t* bufferStride, // stride in elements
2189  const GDALExtendedDataType& bufferDataType,
2190  void* pDstBuffer) const = 0;
2191 
2192  virtual bool IWrite(const GUInt64* arrayStartIdx, // array of size GetDimensionCount()
2193  const size_t* count, // array of size GetDimensionCount()
2194  const GInt64* arrayStep, // step in elements
2195  const GPtrDiff_t* bufferStride, // stride in elements
2196  const GDALExtendedDataType& bufferDataType,
2197  const void* pSrcBuffer);
2199 
2200 public:
2201  virtual ~GDALAbstractMDArray();
2202 
2207  const std::string& GetName() const{ return m_osName; }
2208 
2213  const std::string& GetFullName() const{ return m_osFullName; }
2214 
2215  GUInt64 GetTotalElementsCount() const;
2216 
2217  virtual size_t GetDimensionCount() const;
2218 
2219  virtual const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const = 0;
2220 
2221  virtual const GDALExtendedDataType &GetDataType() const = 0;
2222 
2223  virtual std::vector<GUInt64> GetBlockSize() const;
2224 
2225  virtual std::vector<size_t> GetProcessingChunkSize(size_t nMaxChunkMemory) const;
2226 
2242  typedef bool (*FuncProcessPerChunkType)(
2243  GDALAbstractMDArray* array,
2244  const GUInt64* chunkArrayStartIdx,
2245  const size_t* chunkCount,
2246  GUInt64 iCurChunk,
2247  GUInt64 nChunkCount,
2248  void* pUserData);
2249 
2250  virtual bool ProcessPerChunk(const GUInt64* arrayStartIdx,
2251  const GUInt64* count,
2252  const size_t* chunkSize,
2253  FuncProcessPerChunkType pfnFunc,
2254  void* pUserData);
2255 
2256  virtual bool Read(const GUInt64* arrayStartIdx, // array of size GetDimensionCount()
2257  const size_t* count, // array of size GetDimensionCount()
2258  const GInt64* arrayStep, // step in elements
2259  const GPtrDiff_t* bufferStride, // stride in elements
2260  const GDALExtendedDataType& bufferDataType,
2261  void* pDstBuffer,
2262  const void* pDstBufferAllocStart = nullptr,
2263  size_t nDstBufferAllocSize = 0) const;
2264 
2265  bool Write(const GUInt64* arrayStartIdx, // array of size GetDimensionCount()
2266  const size_t* count, // array of size GetDimensionCount()
2267  const GInt64* arrayStep, // step in elements
2268  const GPtrDiff_t* bufferStride, // stride in elements
2269  const GDALExtendedDataType& bufferDataType,
2270  const void* pSrcBuffer,
2271  const void* pSrcBufferAllocStart = nullptr,
2272  size_t nSrcBufferAllocSize = 0);
2273 };
2274 
2275 /* ******************************************************************** */
2276 /* GDALRawResult */
2277 /* ******************************************************************** */
2278 
2285 class CPL_DLL GDALRawResult
2286 {
2287 private:
2288  GDALExtendedDataType m_dt;
2289  size_t m_nEltCount;
2290  size_t m_nSize;
2291  GByte* m_raw;
2292 
2293  void FreeMe();
2294 
2295  GDALRawResult(const GDALRawResult&) = delete;
2296  GDALRawResult& operator=(const GDALRawResult&) = delete;
2297 
2298 protected:
2299  friend class GDALAttribute;
2301  GDALRawResult(GByte* raw,
2302  const GDALExtendedDataType& dt,
2303  size_t nEltCount);
2305 
2306 public:
2307  ~GDALRawResult();
2309  GDALRawResult& operator=(GDALRawResult&&);
2310 
2312  const GByte& operator[](size_t idx) const { return m_raw[idx]; }
2314  const GByte* data() const { return m_raw; }
2316  size_t size() const { return m_nSize; }
2317 
2319  GByte* StealData();
2321 };
2322 
2323 
2324 /* ******************************************************************** */
2325 /* GDALAttribute */
2326 /* ******************************************************************** */
2327 
2338 class CPL_DLL GDALAttribute: virtual public GDALAbstractMDArray
2339 {
2340  mutable std::string m_osCachedVal{};
2341 
2342 protected:
2344  GDALAttribute(const std::string& osParentName, const std::string& osName);
2346 
2347 public:
2348 
2349  std::vector<GUInt64> GetDimensionsSize() const;
2350 
2351  GDALRawResult ReadAsRaw() const;
2352  const char* ReadAsString() const;
2353  int ReadAsInt() const;
2354  double ReadAsDouble() const;
2355  CPLStringList ReadAsStringArray() const;
2356  std::vector<int> ReadAsIntArray() const;
2357  std::vector<double> ReadAsDoubleArray() const;
2358 
2360  bool Write(const void* pabyValue, size_t nLen);
2361  bool Write(const char*);
2362  bool WriteInt(int);
2363  bool Write(double);
2364  bool Write(CSLConstList);
2365  bool Write(const double*, size_t);
2366 
2368  static constexpr GUInt64 COPY_COST = 100;
2370 
2371 };
2372 
2373 /************************************************************************/
2374 /* GDALAttributeString */
2375 /************************************************************************/
2376 
2378 class CPL_DLL GDALAttributeString final: public GDALAttribute
2379 {
2380  std::vector<std::shared_ptr<GDALDimension>> m_dims{};
2382  std::string m_osValue;
2383 
2384 protected:
2385 
2386  bool IRead(const GUInt64* ,
2387  const size_t* ,
2388  const GInt64* ,
2389  const GPtrDiff_t* ,
2390  const GDALExtendedDataType& bufferDataType,
2391  void* pDstBuffer) const override;
2392 
2393 public:
2394  GDALAttributeString(const std::string& osParentName,
2395  const std::string& osName,
2396  const std::string& osValue,
2398 
2399  const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const override;
2400 
2401  const GDALExtendedDataType &GetDataType() const override;
2402 };
2404 
2405 /************************************************************************/
2406 /* GDALAttributeNumeric */
2407 /************************************************************************/
2408 
2410 class CPL_DLL GDALAttributeNumeric final: public GDALAttribute
2411 {
2412  std::vector<std::shared_ptr<GDALDimension>> m_dims{};
2413  GDALExtendedDataType m_dt;
2414  int m_nValue = 0;
2415  double m_dfValue = 0;
2416  std::vector<GUInt32> m_anValuesUInt32{};
2417 
2418 protected:
2419 
2420  bool IRead(const GUInt64* ,
2421  const size_t* ,
2422  const GInt64* ,
2423  const GPtrDiff_t* ,
2424  const GDALExtendedDataType& bufferDataType,
2425  void* pDstBuffer) const override;
2426 
2427 public:
2428  GDALAttributeNumeric(const std::string& osParentName,
2429  const std::string& osName,
2430  double dfValue);
2431  GDALAttributeNumeric(const std::string& osParentName,
2432  const std::string& osName,
2433  int nValue);
2434  GDALAttributeNumeric(const std::string& osParentName,
2435  const std::string& osName,
2436  const std::vector<GUInt32>& anValues);
2437 
2438  const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const override;
2439 
2440  const GDALExtendedDataType &GetDataType() const override;
2441 };
2443 
2444 /* ******************************************************************** */
2445 /* GDALMDArray */
2446 /* ******************************************************************** */
2447 
2456 class CPL_DLL GDALMDArray: virtual public GDALAbstractMDArray, public GDALIHasAttribute
2457 {
2458  friend class GDALMDArrayResampled;
2459  std::shared_ptr<GDALMDArray> GetView(const std::vector<GUInt64>& indices) const;
2460 
2461  inline std::shared_ptr<GDALMDArray> atInternal(std::vector<GUInt64>& indices) const
2462  {
2463  return GetView(indices);
2464  }
2465 
2466  template<typename... GUInt64VarArg>
2467  // cppcheck-suppress functionStatic
2468  inline std::shared_ptr<GDALMDArray> atInternal(std::vector<GUInt64>& indices,
2469  GUInt64 idx, GUInt64VarArg... tail) const
2470  {
2471  indices.push_back(idx);
2472  return atInternal(indices, tail...);
2473  }
2474 
2475  mutable bool m_bHasTriedCachedArray = false;
2476  mutable std::shared_ptr<GDALMDArray> m_poCachedArray{};
2477 
2478 protected:
2480  GDALMDArray(const std::string& osParentName, const std::string& osName);
2481 
2482  virtual bool IAdviseRead(const GUInt64* arrayStartIdx,
2483  const size_t* count,
2484  CSLConstList papszOptions) const;
2485 
2486  virtual bool IsCacheable() const { return true; }
2487 
2488  virtual bool SetStatistics( bool bApproxStats,
2489  double dfMin, double dfMax,
2490  double dfMean, double dfStdDev,
2491  GUInt64 nValidCount );
2492 
2493  static std::string MassageName(const std::string& inputName);
2494 
2495  std::shared_ptr<GDALGroup> GetCacheRootGroup(bool bCanCreate,
2496  std::string& osCacheFilenameOut) const;
2497 
2498  // Returns if bufferStride values express a transposed view of the array
2499  bool IsTransposedRequest(const size_t* count,
2500  const GPtrDiff_t* bufferStride) const;
2501 
2502  // Should only be called if IsTransposedRequest() returns true
2503  bool ReadForTransposedRequest(const GUInt64* arrayStartIdx,
2504  const size_t* count,
2505  const GInt64* arrayStep,
2506  const GPtrDiff_t* bufferStride,
2507  const GDALExtendedDataType& bufferDataType,
2508  void* pDstBuffer) const;
2510 
2511 public:
2512 
2513  GUInt64 GetTotalCopyCost() const;
2514 
2515  virtual bool CopyFrom(GDALDataset* poSrcDS,
2516  const GDALMDArray* poSrcArray,
2517  bool bStrict,
2518  GUInt64& nCurCost,
2519  const GUInt64 nTotalCost,
2520  GDALProgressFunc pfnProgress,
2521  void * pProgressData);
2522 
2524  virtual bool IsWritable() const = 0;
2525 
2534  virtual const std::string& GetFilename() const = 0;
2535 
2536  virtual CSLConstList GetStructuralInfo() const;
2537 
2538  virtual const std::string& GetUnit() const;
2539 
2540  virtual bool SetUnit(const std::string& osUnit);
2541 
2542  virtual bool SetSpatialRef(const OGRSpatialReference* poSRS);
2543 
2544  virtual std::shared_ptr<OGRSpatialReference> GetSpatialRef() const;
2545 
2546  virtual const void* GetRawNoDataValue() const;
2547 
2548  double GetNoDataValueAsDouble(bool* pbHasNoData = nullptr) const;
2549 
2550  int64_t GetNoDataValueAsInt64(bool* pbHasNoData = nullptr) const;
2551 
2552  uint64_t GetNoDataValueAsUInt64(bool* pbHasNoData = nullptr) const;
2553 
2554  virtual bool SetRawNoDataValue(const void* pRawNoData);
2555 
2557  bool SetNoDataValue(int nNoData) { return SetNoDataValue(static_cast<int64_t>(nNoData)); }
2559 
2560  bool SetNoDataValue(double dfNoData);
2561 
2562  bool SetNoDataValue(int64_t nNoData);
2563 
2564  bool SetNoDataValue(uint64_t nNoData);
2565 
2566  virtual double GetOffset(bool* pbHasOffset = nullptr, GDALDataType* peStorageType = nullptr) const;
2567 
2568  virtual double GetScale(bool* pbHasScale = nullptr, GDALDataType* peStorageType = nullptr) const;
2569 
2570  virtual bool SetOffset(double dfOffset, GDALDataType eStorageType = GDT_Unknown);
2571 
2572  virtual bool SetScale(double dfScale, GDALDataType eStorageType = GDT_Unknown);
2573 
2574  std::shared_ptr<GDALMDArray> GetView(const std::string& viewExpr) const;
2575 
2576  std::shared_ptr<GDALMDArray> operator[](const std::string& fieldName) const;
2577 
2587  // sphinx 4.1.0 / breathe 4.30.0 don't like typename...
2589  template<typename... GUInt64VarArg>
2591  // cppcheck-suppress functionStatic
2592  std::shared_ptr<GDALMDArray> at(GUInt64 idx, GUInt64VarArg... tail) const
2593  {
2594  std::vector<GUInt64> indices;
2595  indices.push_back(idx);
2596  return atInternal(indices, tail...);
2597  }
2598 
2599  virtual std::shared_ptr<GDALMDArray> Transpose(const std::vector<int>& anMapNewAxisToOldAxis) const;
2600 
2601  std::shared_ptr<GDALMDArray> GetUnscaled() const;
2602 
2603  virtual std::shared_ptr<GDALMDArray> GetMask(CSLConstList papszOptions) const;
2604 
2605  std::shared_ptr<GDALMDArray>
2606  GetResampled( const std::vector<std::shared_ptr<GDALDimension>>& apoNewDims,
2607  GDALRIOResampleAlg resampleAlg,
2608  const OGRSpatialReference* poTargetSRS,
2609  CSLConstList papszOptions ) const;
2610 
2611  virtual GDALDataset* AsClassicDataset(size_t iXDim, size_t iYDim) const;
2612 
2613  virtual CPLErr GetStatistics( bool bApproxOK, bool bForce,
2614  double *pdfMin, double *pdfMax,
2615  double *pdfMean, double *padfStdDev,
2616  GUInt64* pnValidCount,
2617  GDALProgressFunc pfnProgress, void *pProgressData );
2618 
2619  virtual bool ComputeStatistics( bool bApproxOK,
2620  double *pdfMin, double *pdfMax,
2621  double *pdfMean, double *pdfStdDev,
2622  GUInt64* pnValidCount,
2623  GDALProgressFunc, void *pProgressData );
2624 
2625  virtual void ClearStatistics();
2626 
2627  virtual std::vector<std::shared_ptr<GDALMDArray>> GetCoordinateVariables() const;
2628 
2629  bool AdviseRead(const GUInt64* arrayStartIdx,
2630  const size_t* count,
2631  CSLConstList papszOptions = nullptr) const;
2632 
2633  bool IsRegularlySpaced(double& dfStart, double& dfIncrement) const;
2634 
2635  bool GuessGeoTransform(size_t nDimX, size_t nDimY, bool bPixelIsPoint,
2636  double adfGeoTransform[6]) const;
2637 
2638  bool Cache( CSLConstList papszOptions = nullptr ) const;
2639 
2640  bool Read(const GUInt64* arrayStartIdx, // array of size GetDimensionCount()
2641  const size_t* count, // array of size GetDimensionCount()
2642  const GInt64* arrayStep, // step in elements
2643  const GPtrDiff_t* bufferStride, // stride in elements
2644  const GDALExtendedDataType& bufferDataType,
2645  void* pDstBuffer,
2646  const void* pDstBufferAllocStart = nullptr,
2647  size_t nDstBufferAllocSize = 0) const override final;
2648 
2650  static constexpr GUInt64 COPY_COST = 1000;
2651 
2652  bool CopyFromAllExceptValues(const GDALMDArray* poSrcArray,
2653  bool bStrict,
2654  GUInt64& nCurCost,
2655  const GUInt64 nTotalCost,
2656  GDALProgressFunc pfnProgress,
2657  void * pProgressData);
2658  struct Range
2659  {
2660  GUInt64 m_nStartIdx;
2661  GInt64 m_nIncr;
2662  explicit Range(GUInt64 nStartIdx = 0, GInt64 nIncr = 0):
2663  m_nStartIdx(nStartIdx), m_nIncr(nIncr) {}
2664  };
2665 
2666  struct ViewSpec
2667  {
2668  std::string m_osFieldName{};
2669 
2670  // or
2671 
2672  std::vector<size_t> m_mapDimIdxToParentDimIdx{}; // of size m_dims.size()
2673  std::vector<Range> m_parentRanges{} ; // of size m_poParent->GetDimensionCount()
2674  };
2675 
2676  virtual std::shared_ptr<GDALMDArray> GetView(const std::string& viewExpr,
2677  bool bRenameDimensions,
2678  std::vector<ViewSpec>& viewSpecs) const;
2680 };
2681 
2683 bool GDALMDRasterIOFromBand(GDALRasterBand* poBand,
2684  GDALRWFlag eRWFlag,
2685  size_t iDimX,
2686  size_t iDimY,
2687  const GUInt64* arrayStartIdx,
2688  const size_t* count,
2689  const GInt64* arrayStep,
2690  const GPtrDiff_t* bufferStride,
2691  const GDALExtendedDataType& bufferDataType,
2692  void* pBuffer);
2694 
2695 /************************************************************************/
2696 /* GDALMDArrayRegularlySpaced */
2697 /************************************************************************/
2698 
2700 class CPL_DLL GDALMDArrayRegularlySpaced: public GDALMDArray
2701 {
2702  double m_dfStart;
2703  double m_dfIncrement;
2704  double m_dfOffsetInIncrement;
2706  std::vector<std::shared_ptr<GDALDimension>> m_dims;
2707  std::vector<std::shared_ptr<GDALAttribute>> m_attributes{};
2708  std::string m_osEmptyFilename{};
2709 
2710 protected:
2711 
2712  bool IRead(const GUInt64* ,
2713  const size_t* ,
2714  const GInt64* ,
2715  const GPtrDiff_t* ,
2716  const GDALExtendedDataType& bufferDataType,
2717  void* pDstBuffer) const override;
2718 
2719 public:
2720  GDALMDArrayRegularlySpaced(
2721  const std::string& osParentName,
2722  const std::string& osName,
2723  const std::shared_ptr<GDALDimension>& poDim,
2724  double dfStart, double dfIncrement,
2725  double dfOffsetInIncrement);
2726 
2727  static std::shared_ptr<GDALMDArrayRegularlySpaced> Create(
2728  const std::string& osParentName,
2729  const std::string& osName,
2730  const std::shared_ptr<GDALDimension>& poDim,
2731  double dfStart, double dfIncrement,
2732  double dfOffsetInIncrement);
2733 
2734  bool IsWritable() const override { return false; }
2735 
2736  const std::string& GetFilename() const override { return m_osEmptyFilename; }
2737 
2738  const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const override;
2739 
2740  const GDALExtendedDataType &GetDataType() const override;
2741 
2742  std::vector<std::shared_ptr<GDALAttribute>> GetAttributes(CSLConstList) const override;
2743 
2744  void AddAttribute(const std::shared_ptr<GDALAttribute>& poAttr);
2745 };
2747 
2748 /* ******************************************************************** */
2749 /* GDALDimension */
2750 /* ******************************************************************** */
2751 
2763 class CPL_DLL GDALDimension
2764 {
2765 public:
2767  GDALDimension(const std::string& osParentName,
2768  const std::string& osName,
2769  const std::string& osType,
2770  const std::string& osDirection,
2771  GUInt64 nSize);
2773 
2774  virtual ~GDALDimension();
2775 
2780  const std::string& GetName() const { return m_osName; }
2781 
2786  const std::string& GetFullName() const { return m_osFullName; }
2787 
2796  const std::string& GetType() const { return m_osType; }
2797 
2806  const std::string& GetDirection() const { return m_osDirection; }
2807 
2812  GUInt64 GetSize() const { return m_nSize; }
2813 
2814  virtual std::shared_ptr<GDALMDArray> GetIndexingVariable() const;
2815 
2816  virtual bool SetIndexingVariable(std::shared_ptr<GDALMDArray> poIndexingVariable);
2817 
2818 protected:
2820  std::string m_osName;
2821  std::string m_osFullName;
2822  std::string m_osType;
2823  std::string m_osDirection;
2824  GUInt64 m_nSize;
2826 };
2827 
2828 
2829 /************************************************************************/
2830 /* GDALDimensionWeakIndexingVar() */
2831 /************************************************************************/
2832 
2834 class CPL_DLL GDALDimensionWeakIndexingVar: public GDALDimension
2835 {
2836  std::weak_ptr<GDALMDArray> m_poIndexingVariable{};
2837 
2838 public:
2839  GDALDimensionWeakIndexingVar(const std::string& osParentName,
2840  const std::string& osName,
2841  const std::string& osType,
2842  const std::string& osDirection,
2843  GUInt64 nSize);
2844 
2845  std::shared_ptr<GDALMDArray> GetIndexingVariable() const override;
2846 
2847  bool SetIndexingVariable(std::shared_ptr<GDALMDArray> poIndexingVariable) override;
2848 };
2850 
2851 /************************************************************************/
2852 /* GDALAntiRecursionGuard */
2853 /************************************************************************/
2854 
2856 struct GDALAntiRecursionStruct;
2857 class GDALAntiRecursionGuard
2858 {
2859  GDALAntiRecursionStruct* m_psAntiRecursionStruct;
2860  std::string m_osIdentifier;
2861  int m_nDepth;
2862 
2863  GDALAntiRecursionGuard(const GDALAntiRecursionGuard&) = delete;
2864  GDALAntiRecursionGuard& operator= (const GDALAntiRecursionGuard&) = delete;
2865 
2866 public:
2867  explicit GDALAntiRecursionGuard(const std::string& osIdentifier);
2868  GDALAntiRecursionGuard(const GDALAntiRecursionGuard& other, const std::string& osIdentifier);
2869  ~GDALAntiRecursionGuard();
2870  int GetCallDepth() const { return m_nDepth; }
2871 };
2873 
2874 /************************************************************************/
2875 /* Relationships */
2876 /************************************************************************/
2877 
2889 class CPL_DLL GDALRelationship
2890 {
2891 protected:
2893  std::string m_osName{};
2894  std::string m_osLeftTableName{};
2895  std::string m_osRightTableName{};
2897  std::string m_osMappingTableName{};
2898  std::vector<std::string> m_osListLeftTableFields{};
2899  std::vector<std::string> m_osListRightTableFields{};
2900  std::vector<std::string> m_osListLeftMappingTableFields{};
2901  std::vector<std::string> m_osListRightMappingTableFields{};
2903  std::string m_osForwardPathLabel{};
2904  std::string m_osBackwardPathLabel{};
2905  std::string m_osRelatedTableType{};
2906 
2909 public:
2917  GDALRelationship(const std::string& osName,
2918  const std::string& osLeftTableName,
2919  const std::string& osRightTableName,
2921  : m_osName(osName), m_osLeftTableName(osLeftTableName), m_osRightTableName(osRightTableName), m_eCardinality(eCardinality)
2922  {}
2923 
2925  const std::string& GetName() const { return m_osName; }
2926 
2928  GDALRelationshipCardinality GetCardinality() const { return m_eCardinality; }
2929 
2934  const std::string& GetLeftTableName() const { return m_osLeftTableName; }
2935 
2937  const std::string& GetRightTableName() const { return m_osRightTableName; }
2938 
2943  const std::string& GetMappingTableName() const { return m_osMappingTableName; }
2944 
2949  void SetMappingTableName( const std::string& osName ) { m_osMappingTableName = osName; }
2950 
2956  const std::vector<std::string>& GetLeftTableFields() const { return m_osListLeftTableFields; }
2957 
2963  const std::vector<std::string>& GetRightTableFields() const { return m_osListRightTableFields; }
2964 
2970  void SetLeftTableFields( const std::vector<std::string>& osListFields ) { m_osListLeftTableFields = osListFields; }
2971 
2977  void SetRightTableFields( const std::vector<std::string>& osListFields ) { m_osListRightTableFields = osListFields; }
2978 
2984  const std::vector<std::string>& GetLeftMappingTableFields() const { return m_osListLeftMappingTableFields; }
2985 
2991  const std::vector<std::string>& GetRightMappingTableFields() const { return m_osListRightMappingTableFields; }
2992 
2998  void SetLeftMappingTableFields( const std::vector<std::string>& osListFields ) { m_osListLeftMappingTableFields = osListFields; }
2999 
3005  void SetRightMappingTableFields( const std::vector<std::string>& osListFields ) { m_osListRightMappingTableFields = osListFields; }
3006 
3011  GDALRelationshipType GetType() const { return m_eType; }
3012 
3017  void SetType( GDALRelationshipType eType ) { m_eType = eType; }
3018 
3033  const std::string& GetForwardPathLabel() const { return m_osForwardPathLabel; }
3034 
3049  void SetForwardPathLabel( const std::string& osLabel ) { m_osForwardPathLabel = osLabel; }
3050 
3065  const std::string& GetBackwardPathLabel() const { return m_osBackwardPathLabel; }
3066 
3081  void SetBackwardPathLabel( const std::string& osLabel ) { m_osBackwardPathLabel = osLabel; }
3082 
3092  const std::string& GetRelatedTableType() const { return m_osRelatedTableType; }
3093 
3103  void SetRelatedTableType( const std::string& osType ) { m_osRelatedTableType = osType; }
3104 
3107  static inline GDALRelationshipH ToHandle(GDALRelationship* poRelationship)
3108  { return static_cast<GDALRelationshipH>(poRelationship); }
3109 
3112  static inline GDALRelationship* FromHandle(GDALRelationshipH hRelationship)
3113  { return static_cast<GDALRelationship*>(hRelationship); }
3114 };
3115 
3116 /* ==================================================================== */
3117 /* An assortment of overview related stuff. */
3118 /* ==================================================================== */
3119 
3121 /* Only exported for drivers as plugin. Signature may change */
3122 CPLErr CPL_DLL
3123 GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand* const * papoSrcBands,
3124  int nOverviews,
3125  GDALRasterBand* const* const * papapoOverviewBands,
3126  const char * pszResampling,
3127  GDALProgressFunc pfnProgress, void * pProgressData,
3128  CSLConstList papszOptions );
3129 
3130 typedef CPLErr (*GDALResampleFunction)
3131  ( double dfXRatioDstToSrc,
3132  double dfYRatioDstToSrc,
3133  double dfSrcXDelta,
3134  double dfSrcYDelta,
3135  GDALDataType eWrkDataType,
3136  const void * pChunk,
3137  const GByte * pabyChunkNodataMask,
3138  int nChunkXOff, int nChunkXSize,
3139  int nChunkYOff, int nChunkYSize,
3140  int nDstXOff, int nDstXOff2,
3141  int nDstYOff, int nDstYOff2,
3142  GDALRasterBand * poOverview,
3143  void** ppDstBuffer,
3144  GDALDataType* peDstBufferDataType,
3145  const char * pszResampling,
3146  int bHasNoData, float fNoDataValue,
3147  GDALColorTable* poColorTable,
3148  GDALDataType eSrcDataType,
3149  bool bPropagateNoData );
3150 
3151 GDALResampleFunction GDALGetResampleFunction(const char* pszResampling,
3152  int* pnRadius);
3153 
3154 GDALDataType GDALGetOvrWorkDataType(const char* pszResampling,
3155  GDALDataType eSrcDataType);
3156 
3158 
3159 CPLErr CPL_DLL
3160 HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
3161  GDALDataset **ppoDS,
3162  int nBands, const int *panBandList,
3163  int nNewOverviews, const int *panNewOverviewList,
3164  const char *pszResampling,
3165  GDALProgressFunc pfnProgress,
3166  void *pProgressData,
3167  CSLConstList papszOptions );
3168 
3169 CPLErr CPL_DLL
3170 GTIFFBuildOverviews( const char * pszFilename,
3171  int nBands, GDALRasterBand * const* papoBandList,
3172  int nOverviews, const int * panOverviewList,
3173  const char * pszResampling,
3174  GDALProgressFunc pfnProgress, void * pProgressData,
3175  CSLConstList papszOptions );
3176 
3177 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
3178  int &nXOff, int &nYOff,
3179  int &nXSize, int &nYSize,
3180  int nBufXSize, int nBufYSize) CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead");
3181 int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand* poBand,
3182  int &nXOff, int &nYOff,
3183  int &nXSize, int &nYSize,
3184  int nBufXSize, int nBufYSize,
3185  GDALRasterIOExtraArg* psExtraArg);
3186 
3187 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize ) CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead");
3188 int CPL_DLL GDALOvLevelAdjust2( int nOvLevel, int nXSize, int nYSize );
3189 int CPL_DLL GDALComputeOvFactor( int nOvrXSize, int nRasterXSize,
3190  int nOvrYSize, int nRasterYSize );
3191 
3192 GDALDataset CPL_DLL *
3193 GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
3194  GDALDataset *poDependentDS );
3195 
3196 /* ==================================================================== */
3197 /* Infrastructure to check that dataset characteristics are valid */
3198 /* ==================================================================== */
3199 
3200 int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize );
3201 int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed );
3202 
3203 /* Internal use only */
3204 
3205 /* CPL_DLL exported, but only for in-tree drivers that can be built as plugins */
3206 int CPL_DLL GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension,
3207  double *padfGeoTransform, char** papszSiblingFiles,
3208  char** ppszWorldFileNameOut);
3209 int GDALReadTabFile2( const char * pszBaseFilename,
3210  double *padfGeoTransform, char **ppszWKT,
3211  int *pnGCPCount, GDAL_GCP **ppasGCPs,
3212  char** papszSiblingFiles, char** ppszTabFileNameOut );
3213 
3214 void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg* psDestArg,
3215  GDALRasterIOExtraArg* psSrcArg);
3216 
3217 CPL_C_END
3218 
3219 void GDALNullifyOpenDatasetsList();
3220 CPLMutex** GDALGetphDMMutex();
3221 CPLMutex** GDALGetphDLMutex();
3222 void GDALNullifyProxyPoolSingleton();
3223 void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
3224 GIntBig GDALGetResponsiblePIDForCurrentThread();
3225 
3226 CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt,
3227  CSLConstList papszSiblingFiles, int nFlags );
3228 
3229 CPLErr CPL_DLL EXIFExtractMetadata(char**& papszMetadata,
3230  void *fpL, int nOffset,
3231  int bSwabflag, int nTIFFHEADER,
3232  int& nExifOffset, int& nInterOffset, int& nGPSOffset);
3233 
3234 int GDALValidateOpenOptions( GDALDriverH hDriver,
3235  const char* const* papszOptionOptions);
3236 int GDALValidateOptions( const char* pszOptionList,
3237  const char* const* papszOptionsToValidate,
3238  const char* pszErrorMessageOptionType,
3239  const char* pszErrorMessageContainerName);
3240 
3241 GDALRIOResampleAlg GDALRasterIOGetResampleAlg(const char* pszResampling);
3242 const char* GDALRasterIOGetResampleAlg(GDALRIOResampleAlg eResampleAlg);
3243 
3244 void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg* psExtraArg,
3245  int nXSize, int nYSize,
3246  int nBufXSize, int nBufYSize);
3247 
3248 
3249 GDALDataset* GDALCreateOverviewDataset(GDALDataset* poDS, int nOvrLevel,
3250  bool bThisLevelOnly);
3251 
3252 // Should cover particular cases of #3573, #4183, #4506, #6578
3253 // Behavior is undefined if fVal1 or fVal2 are NaN (should be tested before
3254 // calling this function)
3255 template<class T> inline bool ARE_REAL_EQUAL(T fVal1, T fVal2, int ulp = 2)
3256 {
3257  return fVal1 == fVal2 || /* Should cover infinity */
3258  std::abs(fVal1 - fVal2) < std::numeric_limits<float>::epsilon() * std::abs(fVal1+fVal2) * ulp;
3259 }
3260 
3261 double GDALAdjustNoDataCloseToFloatMax(double dfVal);
3262 
3263 #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) )
3264 
3265 // Number of data samples that will be used to compute approximate statistics
3266 // (minimum value, maximum value, etc.)
3267 #define GDALSTAT_APPROX_NUMSAMPLES 2500
3268 
3269 void GDALSerializeGCPListToXML( CPLXMLNode* psParentNode,
3270  GDAL_GCP* pasGCPList,
3271  int nGCPCount,
3272  const OGRSpatialReference* poGCP_SRS );
3273 void GDALDeserializeGCPListFromXML( CPLXMLNode* psGCPList,
3274  GDAL_GCP** ppasGCPList,
3275  int* pnGCPCount,
3276  OGRSpatialReference** ppoGCP_SRS );
3277 
3278 void GDALSerializeOpenOptionsToXML( CPLXMLNode* psParentNode, char** papszOpenOptions);
3279 char** GDALDeserializeOpenOptionsFromXML( CPLXMLNode* psParentNode );
3280 
3281 int GDALCanFileAcceptSidecarFile(const char* pszFilename);
3282 
3283 bool GDALCanReliablyUseSiblingFileList(const char* pszFilename);
3284 
3285 bool CPL_DLL GDALIsDriverDeprecatedForGDAL35StillEnabled(const char* pszDriverName, const char* pszExtraMsg = "");
3286 
3287 typedef enum
3288 {
3289  GSF_UNSIGNED_INT,
3290  GSF_SIGNED_INT,
3291  GSF_FLOATING_POINT,
3292 } GDALBufferSampleFormat;
3293 
3294 bool CPL_DLL GDALBufferHasOnlyNoData(const void* pBuffer,
3295  double dfNoDataValue,
3296  size_t nWidth, size_t nHeight,
3297  size_t nLineStride,
3298  size_t nComponents,
3299  int nBitsPerSample,
3300  GDALBufferSampleFormat nSampleFormat);
3301 
3302 void CPL_DLL GDALCopyNoDataValue(GDALRasterBand* poDstBand,
3303  GDALRasterBand* poSrcBand);
3304 
3305 double CPL_DLL GDALGetNoDataValueCastToDouble(int64_t nVal);
3306 double CPL_DLL GDALGetNoDataValueCastToDouble(uint64_t nVal);
3307 
3309 
3310 #endif /* ndef GDAL_PRIV_H_INCLUDED */
GDAL_IDENTIFY_UNKNOWN
@ GDAL_IDENTIFY_UNKNOWN
Identify could not determine if the file is recognized or not by the probed driver.
Definition: gdal_priv.h:1536
GDALRelationship::SetRelatedTableType
void SetRelatedTableType(const std::string &osType)
Sets the type string of the related table.
Definition: gdal_priv.h:3103
GDALDimension::GetFullName
const std::string & GetFullName() const
Return the full name.
Definition: gdal_priv.h:2786
CPL_PRINT_FUNC_FORMAT
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition: cpl_port.h:844
GDAL_IDENTIFY_FALSE
@ GDAL_IDENTIFY_FALSE
Identify determined the file is not recognized by the probed driver.
Definition: gdal_priv.h:1538
GDALOpenInfo::fpL
VSILFILE * fpL
Pointer to the file.
Definition: gdal_priv.h:298
GDALExtendedDataType::GetSize
size_t GetSize() const
Return data type size in bytes.
Definition: gdal_priv.h:1937
GDALDimension::SetIndexingVariable
virtual bool SetIndexingVariable(std::shared_ptr< GDALMDArray > poIndexingVariable)
Set the variable that is used to index the dimension.
Definition: gdalmultidim.cpp:8648
GDALGetDataTypeSizeBytes
int GDALGetDataTypeSizeBytes(GDALDataType)
Get data type size in bytes.
Definition: gdal_misc.cpp:318
GDALGroup::GetFullName
const std::string & GetFullName() const
Return the full name of the group.
Definition: gdal_priv.h:2087
GDALRasterBand::GetMaskValueRange
virtual GDALMaskValueRange GetMaskValueRange() const
Returns the range of values that a mask band can take.
Definition: gdalrasterband.cpp:7232
GByte
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:203
GDALAsyncReader::GetYOffset
int GetYOffset() const
Return y offset.
Definition: gdal_priv.h:1805
GDALExtendedDataType
Class used to represent potentially complex data types.
Definition: gdal_priv.h:1879
GDALRasterBlock::GetYSize
int GetYSize() const
Return the height of the block.
Definition: gdal_priv.h:994
GDALDataset::Layers::Iterator::iterator_category
std::input_iterator_tag iterator_category
iterator_category
Definition: gdal_priv.h:741
GUInt64
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition: cpl_port.h:251
gdal.h
GDALOpenInfo
Class for dataset open functions.
Definition: gdal_priv.h:271
GDALDataset::Layers::Iterator
Layer iterator.
Definition: gdal_priv.h:731
GDALRasterBand::ComputeStatistics
virtual CPLErr ComputeStatistics(int bApproxOK, double *pdfMin, double *pdfMax, double *pdfMean, double *pdfStdDev, GDALProgressFunc, void *pProgressData)
Compute image statistics.
Definition: gdalrasterband.cpp:5390
GDALAsyncReader::GetPixelSpace
int GetPixelSpace() const
Return pixel spacing.
Definition: gdal_priv.h:1841
GDALAbstractMDArray::GetFullName
const std::string & GetFullName() const
Return the name of an array or attribute.
Definition: gdal_priv.h:2213
GDALRasterBlock::GetBlockSize
GPtrDiff_t GetBlockSize() const
Return the block size in bytes.
Definition: gdal_priv.h:1006
GDALEDTComponent
Class for a component of a compound extended data type.
Definition: gdal_priv.h:1987
GSBAP_RANDOM
constexpr GDALSuggestedBlockAccessPattern GSBAP_RANDOM
Random access to blocks is efficient.
Definition: gdal_priv.h:1166
GDALAsyncReader::GetBandCount
int GetBandCount() const
Return band count.
Definition: gdal_priv.h:1833
GDALRasterBand::IsMaskBand
virtual bool IsMaskBand() const
Returns whether a band is a mask band.
Definition: gdalrasterband.cpp:7182
GSBAP_UNKNOWN
constexpr GDALSuggestedBlockAccessPattern GSBAP_UNKNOWN
Unknown, or no particular read order is suggested.
Definition: gdal_priv.h:1163
GDALRelationship::GetLeftTableName
const std::string & GetLeftTableName() const
Get the name of the left (or base/origin) table in the relationship.
Definition: gdal_priv.h:2934
begin
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:325
GDALOpenEx
GDALDatasetH GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags, const char *const *papszAllowedDrivers, const char *const *papszOpenOptions, const char *const *papszSiblingFiles)
Open a raster or vector file as a GDALDataset.
Definition: gdaldataset.cpp:3219
GDALDataset::Layers::Iterator::difference_type
void difference_type
difference_type
Definition: gdal_priv.h:739
GDALMDArray::IsWritable
virtual bool IsWritable() const =0
Return whether an array is writable.
OGRStyleTable
This class represents a style table.
Definition: ogr_featurestyle.h:84
GDALRelationship::SetForwardPathLabel
void SetForwardPathLabel(const std::string &osLabel)
Sets the label of the forward path for the relationship.
Definition: gdal_priv.h:3049
GEDTC_NUMERIC
@ GEDTC_NUMERIC
Numeric value.
Definition: gdal.h:299
CPLStringList
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:429
GDALAsyncReader
Class used as a session object for asynchronous requests.
Definition: gdal_priv.h:1767
GDT_Unknown
@ GDT_Unknown
Definition: gdal.h:64
GDALRelationship::GDALRelationship
GDALRelationship(const std::string &osName, const std::string &osLeftTableName, const std::string &osRightTableName, GDALRelationshipCardinality eCardinality=GDALRelationshipCardinality::GRC_ONE_TO_MANY)
Constructor for a relationship between two tables.
Definition: gdal_priv.h:2917
GMVR_0_AND_255_ONLY
@ GMVR_0_AND_255_ONLY
Definition: gdal_priv.h:1156
GDALExtendedDataType::GetClass
GDALExtendedDataTypeClass GetClass() const
Return type class.
Definition: gdal_priv.h:1909
GRT_ASSOCIATION
@ GRT_ASSOCIATION
Association relationship.
Definition: gdal.h:1685
GDALRelationship::GetRightTableName
const std::string & GetRightTableName() const
Get the name of the right (or related/destination) table in the relationship.
Definition: gdal_priv.h:2937
GDALAsyncReader::GetBufferYSize
int GetBufferYSize() const
Return buffer height.
Definition: gdal_priv.h:1825
cpl_minixml.h
GDALDriver
Format specific driver.
Definition: gdal_priv.h:1558
cpl_vsi.h
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:157
GDALAbstractMDArray
Abstract class, implemented by GDALAttribute and GDALMDArray.
Definition: gdal_priv.h:2162
GDALDataset::Bands
Class returned by GetBands() that act as a container for raster bands.
Definition: gdal_priv.h:481
GDALMDArray::at
std::shared_ptr< GDALMDArray > at(GUInt64 idx, GUInt64VarArg... tail) const
Return a view of the array using integer indexing.
Definition: gdal_priv.h:2592
GDALColorTableH
void * GDALColorTableH
Opaque type used for the C bindings of the C++ GDALColorTable class.
Definition: gdal.h:278
GDALAsyncReader::GetLineSpace
int GetLineSpace() const
Return line spacing.
Definition: gdal_priv.h:1845
GDALClose
void GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition: gdaldataset.cpp:3641
GDALRasterBlock::GetDataRef
void * GetDataRef(void)
Return the data buffer.
Definition: gdal_priv.h:1002
GDALOpenInfo::nOpenFlags
int nOpenFlags
Open flags.
Definition: gdal_priv.h:290
GDALOpenInfo::papszOpenOptions
char ** papszOpenOptions
Open options.
Definition: gdal_priv.h:285
GDALMajorObject::SetMetadataItem
virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain="")
Set single metadata item.
Definition: gdalmajorobject.cpp:387
OGRGeometry
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:326
GDALColorEntry
Color tuple.
Definition: gdal.h:1517
GDALDimension::GetName
const std::string & GetName() const
Return the name.
Definition: gdal_priv.h:2780
GDALAbstractMDArray::GetDimensions
virtual const std::vector< std::shared_ptr< GDALDimension > > & GetDimensions() const =0
Return the dimensions of an attribute/array.
GDALColorInterp
GDALColorInterp
Definition: gdal.h:204
OGRLayer
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:72
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:320
GDALRasterBand
A single raster band (or channel).
Definition: gdal_priv.h:1179
GInt64
GIntBig GInt64
Signed 64 bit integer type.
Definition: cpl_port.h:249
GDALRelationship::GetRightTableFields
const std::vector< std::string > & GetRightTableFields() const
Get the names of the participating fields from the right table in the relationship.
Definition: gdal_priv.h:2963
GDALIdentifyEnum
GDALIdentifyEnum
Enumeration used by GDALDriver::pfnIdentify().
Definition: gdal_priv.h:1533
GDALAsyncReader::GetBandSpace
int GetBandSpace() const
Return band spacing.
Definition: gdal_priv.h:1849
GMVR_0_AND_1_ONLY
@ GMVR_0_AND_1_ONLY
Definition: gdal_priv.h:1155
GDALIHasAttribute::GetAttributes
virtual std::vector< std::shared_ptr< GDALAttribute > > GetAttributes(CSLConstList papszOptions=nullptr) const
Return the list of attributes contained in a GDALMDArray or GDALGroup.
Definition: gdalmultidim.cpp:223
GPtrDiff_t
int GPtrDiff_t
Integer type large enough to hold the difference between 2 addresses.
Definition: cpl_port.h:269
GDALDimension::GetDirection
const std::string & GetDirection() const
Return the axis direction.
Definition: gdal_priv.h:2806
GDALRelationship::SetType
void SetType(GDALRelationshipType eType)
Sets the type of the relationship.
Definition: gdal_priv.h:3017
GDALAsyncReader::GetBufferType
GDALDataType GetBufferType() const
Return buffer data type.
Definition: gdal_priv.h:1829
GDALExtendedDataTypeClass
GDALExtendedDataTypeClass
Enumeration giving the class of a GDALExtendedDataType.
Definition: gdal.h:297
GDALMaskValueRange
GDALMaskValueRange
Range of values found in a mask band.
Definition: gdal_priv.h:1152
GDALRawResult::data
const GByte * data() const
Return pointer to the start of data.
Definition: gdal_priv.h:2314
GDALDataType
GDALDataType
Definition: gdal.h:63
CPLXMLNode
Document node structure.
Definition: cpl_minixml.h:69
OGRFeatureUniquePtr
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:842
GDALRelationship::FromHandle
static GDALRelationship * FromHandle(GDALRelationshipH hRelationship)
Convert a GDALRelationshipH to a GDALRelationship*.
Definition: gdal_priv.h:3112
GDALAbstractMDArray::GetName
const std::string & GetName() const
Return the name of an array or attribute.
Definition: gdal_priv.h:2207
GDALRasterBlock
A single raster block in the block cache.
Definition: gdal_priv.h:929
GDALMajorObjectH
void * GDALMajorObjectH
Opaque type used for the C bindings of the C++ GDALMajorObject class.
Definition: gdal.h:266
GDALRawResult
Store the raw result of an attribute value, which might contain dynamically allocated structures (lik...
Definition: gdal_priv.h:2285
GDALGroup
Class modeling a named container of GDALAttribute, GDALMDArray, OGRLayer or other GDALGroup.
Definition: gdal_priv.h:2060
GDALDataset
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:342
GDALDataset::GetOpenOptions
char ** GetOpenOptions()
Return open options.
Definition: gdal_priv.h:616
GDALMajorObject::FromHandle
static GDALMajorObject * FromHandle(GDALMajorObjectH hMajorObject)
Convert a GDALMajorObjectH to a GDALMajorObject*.
Definition: gdal_priv.h:178
GDALRawResult::size
size_t size() const
Return the size in bytes of the raw result.
Definition: gdal_priv.h:2316
GDALIHasAttribute
Interface used to get a single GDALAttribute or a set of GDALAttribute.
Definition: gdal_priv.h:2029
GDALRelationship
Definition of a table relationship.
Definition: gdal_priv.h:2889
GDALOpenInfo::bStatOK
int bStatOK
Whether stat()'ing the file was successful.
Definition: gdal_priv.h:293
GDALRelationship::GetType
GDALRelationshipType GetType() const
Get the type of the relationship.
Definition: gdal_priv.h:3011
CPL_C_START
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:304
GDALDriverManager
Class for managing the registration of file format drivers.
Definition: gdal_priv.h:1713
GDALRelationshipH
void * GDALRelationshipH
Opaque type used for the C bindings of the C++ GDALRelationship class.
Definition: gdal.h:289
GDALRelationship::GetForwardPathLabel
const std::string & GetForwardPathLabel() const
Get the label of the forward path for the relationship.
Definition: gdal_priv.h:3033
GDALMDArray
Class modeling a multi-dimensional array.
Definition: gdal_priv.h:2456
GDALOpenInfo::pabyHeader
GByte * pabyHeader
Buffer with first bytes of the file.
Definition: gdal_priv.h:303
GDALAsyncReader::GetYSize
int GetYSize() const
Return height.
Definition: gdal_priv.h:1813
GDALOpenInfo::eAccess
GDALAccess eAccess
Access flag.
Definition: gdal_priv.h:288
GDALRasterBand::GetMaskBand
virtual GDALRasterBand * GetMaskBand()
Return the mask band associated with the band.
Definition: gdalrasterband.cpp:6720
GDALExtendedDataType::GetNumericDataType
GDALDataType GetNumericDataType() const
Return numeric data type (only valid when GetClass() == GEDTC_NUMERIC)
Definition: gdal_priv.h:1915
GDALExtendedDataType::CreateString
static GDALExtendedDataType CreateString(size_t nMaxStringLength=0, GDALExtendedDataTypeSubType eSubType=GEDTST_NONE)
Return a new GDALExtendedDataType of class GEDTC_STRING.
Definition: gdalmultidim.cpp:8374
GRC_ONE_TO_MANY
@ GRC_ONE_TO_MANY
One-to-many.
Definition: gdal.h:1669
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1056
CPLErrorNum
int CPLErrorNum
Error number.
Definition: cpl_error.h:94
GUIntBig
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:233
GDALDataset::Open
static GDALDataset * Open(const char *pszFilename, unsigned int nOpenFlags=0, const char *const *papszAllowedDrivers=nullptr, const char *const *papszOpenOptions=nullptr, const char *const *papszSiblingFiles=nullptr)
Definition: gdal_priv.h:668
GDT_Float64
@ GDT_Float64
Definition: gdal.h:73
GDALExtendedDataType::GetSubType
GDALExtendedDataTypeSubType GetSubType() const
Return subtype.
Definition: gdal_priv.h:1923
GDALRasterBlock::DropLock
int DropLock(void)
Decrement the lock count.
Definition: gdal_priv.h:970
GDALRelationship::GetBackwardPathLabel
const std::string & GetBackwardPathLabel() const
Get the label of the backward path for the relationship.
Definition: gdal_priv.h:3065
GDALRelationship::GetLeftTableFields
const std::vector< std::string > & GetLeftTableFields() const
Get the names of the participating fields from the left table in the relationship.
Definition: gdal_priv.h:2956
GDALOpenInfo::bIsDirectory
int bIsDirectory
Whether the file is a directory.
Definition: gdal_priv.h:295
GDALDimension::GetType
const std::string & GetType() const
Return the axis type.
Definition: gdal_priv.h:2796
GDAL_GCP
Ground Control Point.
Definition: gdal.h:892
CPL_C_END
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:306
GDALRasterBand::IReadBlock
virtual CPLErr IReadBlock(int nBlockXOff, int nBlockYOff, void *pData)=0
Read a block of data.
GDALDimension
Class modeling a a dimension / axis used to index multidimensional arrays.
Definition: gdal_priv.h:2763
GEDTST_NONE
@ GEDTST_NONE
None.
Definition: gdal.h:311
GDALRelationship::SetBackwardPathLabel
void SetBackwardPathLabel(const std::string &osLabel)
Sets the label of the backward path for the relationship.
Definition: gdal_priv.h:3081
GDALRelationship::GetCardinality
GDALRelationshipCardinality GetCardinality() const
Get the cardinality of the relationship.
Definition: gdal_priv.h:2928
CPL_NULL_TERMINATED
#define CPL_NULL_TERMINATED
Null terminated variadic.
Definition: cpl_port.h:834
GSBAP_BOTTOM_TO_TOP
constexpr GDALSuggestedBlockAccessPattern GSBAP_BOTTOM_TO_TOP
Reading by strips from bottom to top is the most efficient.
Definition: gdal_priv.h:1172
GDALExtendedDataType::GetComponents
const std::vector< std::unique_ptr< GDALEDTComponent > > & GetComponents() const
Return the components of the data type (only valid when GetClass() == GEDTC_COMPOUND)
Definition: gdal_priv.h:1929
GDALAbstractMDArray::GetDataType
virtual const GDALExtendedDataType & GetDataType() const =0
Return the data type of an attribute/array.
GSBAP_LARGEST_CHUNK_POSSIBLE
constexpr GDALSuggestedBlockAccessPattern GSBAP_LARGEST_CHUNK_POSSIBLE
Reading the largest chunk from the raster is the most efficient (can be combined with above values).
Definition: gdal_priv.h:1175
ogr_feature.h
GDALDataset::FeatureLayerPair
Object returned by GetFeatures() iterators.
Definition: gdal_priv.h:681
GDALAsyncReader::GetGDALDataset
GDALDataset * GetGDALDataset()
Return dataset.
Definition: gdal_priv.h:1797
cpl_conv.h
GDALDataset::ToHandle
static GDALDatasetH ToHandle(GDALDataset *poDS)
Convert a GDALDataset* to a GDALDatasetH.
Definition: gdal_priv.h:656
GDALRelationship::SetRightTableFields
void SetRightTableFields(const std::vector< std::string > &osListFields)
Sets the names of the participating fields from the right table in the relationship.
Definition: gdal_priv.h:2977
CPLVirtualMem
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition: cpl_virtualmem.h:62
cpl_string.h
GDALAbstractMDArray::Read
virtual bool Read(const GUInt64 *arrayStartIdx, const size_t *count, const GInt64 *arrayStep, const GPtrDiff_t *bufferStride, const GDALExtendedDataType &bufferDataType, void *pDstBuffer, const void *pDstBufferAllocStart=nullptr, size_t nDstBufferAllocSize=0) const
Read part or totality of a multidimensional array or attribute.
Definition: gdalmultidim.cpp:1793
GDALOpenInfo::papszAllowedDrivers
const char *const * papszAllowedDrivers
Allowed drivers (NULL for all)
Definition: gdal_priv.h:306
GDALMajorObject::SetMetadata
virtual CPLErr SetMetadata(char **papszMetadata, const char *pszDomain="")
Set metadata.
Definition: gdalmajorobject.cpp:291
GDALDataset::CloseDependentDatasets
virtual int CloseDependentDatasets()
Drop references to any other datasets referenced by this dataset.
Definition: gdaldataset.cpp:4028
GDALColorTable::ToHandle
static GDALColorTableH ToHandle(GDALColorTable *poCT)
Convert a GDALColorTable* to a GDALRasterBandH.
Definition: gdal_priv.h:1070
GDALRasterBlock::AddLock
int AddLock(void)
Increment the lock count.
Definition: gdal_priv.h:968
GDALDataset::CreateMaskBand
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the dataset.
Definition: gdaldataset.cpp:3028
GDALRelationship::SetLeftTableFields
void SetLeftTableFields(const std::vector< std::string > &osListFields)
Sets the names of the participating fields from the left table in the relationship.
Definition: gdal_priv.h:2970
OGRFieldDomain
Definition of a field domain.
Definition: ogr_feature.h:881
GSpacing
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:292
vsi_l_offset
GUIntBig vsi_l_offset
Type for a file offset.
Definition: cpl_vsi.h:142
GDALDimension::GetSize
GUInt64 GetSize() const
Return the size, that is the number of values along the dimension.
Definition: gdal_priv.h:2812
GDALAccess
GDALAccess
Definition: gdal.h:116
end
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:330
GDALAsyncStatusType
GDALAsyncStatusType
status of the asynchronous stream
Definition: gdal.h:103
GDALEDTComponent::GetOffset
size_t GetOffset() const
Return the offset (in bytes) of the component in the compound data type.
Definition: gdal_priv.h:2006
GDALDriver::FromHandle
static GDALDriver * FromHandle(GDALDriverH hDriver)
Convert a GDALDriverH to a GDALDriver*.
Definition: gdal_priv.h:1695
GDALRawResult::operator[]
const GByte & operator[](size_t idx) const
Return byte at specified index.
Definition: gdal_priv.h:2312
GDAL_IDENTIFY_TRUE
@ GDAL_IDENTIFY_TRUE
Identify determined the file is recognized by the probed driver.
Definition: gdal_priv.h:1540
OGRErr
int OGRErr
Type for a OGR error.
Definition: ogr_core.h:341
GDALRelationship::GetMappingTableName
const std::string & GetMappingTableName() const
Get the name of the mapping table for many-to-many relationships.
Definition: gdal_priv.h:2943
GA_ReadOnly
@ GA_ReadOnly
Definition: gdal.h:117
GDALDimension::GetIndexingVariable
virtual std::shared_ptr< GDALMDArray > GetIndexingVariable() const
Return the variable that is used to index the dimension (if there is one).
Definition: gdalmultidim.cpp:8627
GDALAsyncReader::GetXSize
int GetXSize() const
Return width.
Definition: gdal_priv.h:1809
GDALRasterBlock::GetDirty
int GetDirty() const
Return the dirty flag.
Definition: gdal_priv.h:998
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:230
GDALRelationship::GetLeftMappingTableFields
const std::vector< std::string > & GetLeftMappingTableFields() const
Get the names of the mapping table fields which correspond to the participating fields from the left ...
Definition: gdal_priv.h:2984
GDALRelationship::GetRightMappingTableFields
const std::vector< std::string > & GetRightMappingTableFields() const
Get the names of the mapping table fields which correspond to the participating fields from the right...
Definition: gdal_priv.h:2991
GDALDataset::Layers::Iterator::pointer
void pointer
pointer
Definition: gdal_priv.h:740
GDALAsyncReader::GetBufferXSize
int GetBufferXSize() const
Return buffer width.
Definition: gdal_priv.h:1821
GDALOpenInfo::nHeaderBytes
int nHeaderBytes
Number of bytes in pabyHeader.
Definition: gdal_priv.h:301
OGRwkbGeometryType
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:368
GDALDriver::ToHandle
static GDALDriverH ToHandle(GDALDriver *poDriver)
Convert a GDALDriver* to a GDALDriverH.
Definition: gdal_priv.h:1689
GDALRasterIOExtraArg
Structure to pass extra arguments to RasterIO() method, must be initialized with INIT_RASTERIO_EXTRA_...
Definition: gdal.h:161
GDALRasterBand::ToHandle
void static GDALRasterBandH ToHandle(GDALRasterBand *poBand)
Convert a GDALRasterBand* to a GDALRasterBandH.
Definition: gdal_priv.h:1404
GDALRasterBlock::GetYOff
int GetYOff() const
Return the y offset of the top-left corner of the block.
Definition: gdal_priv.h:986
CPL_WARN_UNUSED_RESULT
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:869
GDALDataset::GetAccess
GDALAccess GetAccess() const
Return access mode.
Definition: gdal_priv.h:606
GDALRelationship::SetMappingTableName
void SetMappingTableName(const std::string &osName)
Sets the name of the mapping table for many-to-many relationships.
Definition: gdal_priv.h:2949
OGRFeature
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:381
GDALMDArray::GetFilename
virtual const std::string & GetFilename() const =0
Return the filename that contains that array.
GDALRWFlag
GDALRWFlag
Definition: gdal.h:122
GDALRelationship::GetName
const std::string & GetName() const
Get the name of the relationship.
Definition: gdal_priv.h:2925
GDALRelationship::SetLeftMappingTableFields
void SetLeftMappingTableFields(const std::vector< std::string > &osListFields)
Sets the names of the mapping table fields which correspond to the participating fields from the left...
Definition: gdal_priv.h:2998
GDALDataset::Features
Class returned by GetFeatures() that act as a container for vector features.
Definition: gdal_priv.h:781
GDALRelationship::ToHandle
static GDALRelationshipH ToHandle(GDALRelationship *poRelationship)
Convert a GDALRelationship* to a GDALRelationshipH.
Definition: gdal_priv.h:3107
GDALSuggestedBlockAccessPattern
int GDALSuggestedBlockAccessPattern
Suggested/most efficient access pattern to blocks.
Definition: gdal_priv.h:1160
GDALDataset::BuildOverviews
CPLErr BuildOverviews(const char *, int, const int *, int, const int *, GDALProgressFunc, void *, CSLConstList papszOptions)
Build raster overview(s)
Definition: gdaldataset.cpp:1818
GDALMajorObject
Object with metadata.
Definition: gdal_priv.h:136
GDALAbstractMDArray::Write
bool Write(const GUInt64 *arrayStartIdx, const size_t *count, const GInt64 *arrayStep, const GPtrDiff_t *bufferStride, const GDALExtendedDataType &bufferDataType, const void *pSrcBuffer, const void *pSrcBufferAllocStart=nullptr, size_t nSrcBufferAllocSize=0)
Write part or totality of a multidimensional array or attribute.
Definition: gdalmultidim.cpp:1910
GDALRasterBand::IRasterIO
virtual CPLErr IRasterIO(GDALRWFlag, int, int, int, int, void *, int, int, GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg *psExtraArg)
Read/write a region of image data for this band.
Definition: rasterio.cpp:208
CPLErr
CPLErr
Error category.
Definition: cpl_error.h:52
GDALAttribute
Class modeling an attribute that has a name, a value and a type, and is typically used to describe a ...
Definition: gdal_priv.h:2338
GDALEDTComponent::GetType
const GDALExtendedDataType & GetType() const
Return the data type of the component.
Definition: gdal_priv.h:2012
GDALOpenInfo::pszFilename
char * pszFilename
Filename.
Definition: gdal_priv.h:283
GDALColorTable::FromHandle
static GDALColorTable * FromHandle(GDALColorTableH hCT)
Convert a GDALColorTableH to a GDALColorTable*.
Definition: gdal_priv.h:1076
GDT_Byte
@ GDT_Byte
Definition: gdal.h:65
GPI_RGB
@ GPI_RGB
Definition: gdal.h:233
GDALExtendedDataTypeSubType
GDALExtendedDataTypeSubType
Enumeration giving the subtype of a GDALExtendedDataType.
Definition: gdal.h:309
GDALDatasetUniquePtr
std::unique_ptr< GDALDataset, GDALDatasetUniquePtrDeleter > GDALDatasetUniquePtr
Unique pointer type for GDALDataset.
Definition: gdal_priv.h:919
GDALRasterBand::GetMaskFlags
virtual int GetMaskFlags()
Return the status flags of the mask band associated with the band.
Definition: gdalrasterband.cpp:7041
GDALRIOResampleAlg
GDALRIOResampleAlg
RasterIO() resampling method.
Definition: gdal.h:131
GetGDALDriverManager
GDALDriverManager * GetGDALDriverManager(void)
Fetch the global GDAL driver manager.
Definition: gdaldrivermanager.cpp:100
GDALRasterAttributeTable
Definition: gdal_rat.h:47
GDALAsyncReader::GetXOffset
int GetXOffset() const
Return x offset.
Definition: gdal_priv.h:1801
GDALExtendedDataType::GetMaxStringLength
size_t GetMaxStringLength() const
Return the maximum length of a string in bytes.
Definition: gdal_priv.h:1943
GDALRelationshipCardinality
GDALRelationshipCardinality
Cardinality of relationship.
Definition: gdal.h:1664
GDALRasterBlock::GetBand
GDALRasterBand * GetBand()
Accessor to source GDALRasterBand object.
Definition: gdal_priv.h:1014
GDALDataset::Layers
Class returned by GetLayers() that acts as a range of layers.
Definition: gdal_priv.h:718
GDALRasterBlock::GetXOff
int GetXOff() const
Return the x offset of the top-left corner of the block.
Definition: gdal_priv.h:982
GDALRasterBlock::GetDataType
GDALDataType GetDataType() const
Return the data type.
Definition: gdal_priv.h:978
GDALDataset::FromHandle
static GDALDataset * FromHandle(GDALDatasetH hDS)
Convert a GDALDatasetH to a GDALDataset*.
Definition: gdal_priv.h:662
ogr_core.h
GDALPaletteInterp
GDALPaletteInterp
Definition: gdal.h:230
GDALExtendedDataType::Create
static GDALExtendedDataType Create(GDALDataType eType)
Return a new GDALExtendedDataType of class GEDTC_NUMERIC.
Definition: gdalmultidim.cpp:8310
GDALMajorObject::ToHandle
static GDALMajorObjectH ToHandle(GDALMajorObject *poMajorObject)
Convert a GDALMajorObject* to a GDALMajorObjectH.
Definition: gdal_priv.h:172
GDALRasterBandH
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:272
GDALGroup::GetName
const std::string & GetName() const
Return the name of the group.
Definition: gdal_priv.h:2081
GDALRelationship::SetRightMappingTableFields
void SetRightMappingTableFields(const std::vector< std::string > &osListFields)
Sets the names of the mapping table fields which correspond to the participating fields from the righ...
Definition: gdal_priv.h:3005
wkbUnknown
@ wkbUnknown
unknown type, non-standard
Definition: ogr_core.h:370
GDALAsyncReader::GetBuffer
void * GetBuffer()
Return buffer.
Definition: gdal_priv.h:1817
GDALExtendedDataType::GetName
const std::string & GetName() const
Return type name.
Definition: gdal_priv.h:1903
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:930
GDALEDTComponent::GetName
const std::string & GetName() const
Return the name.
Definition: gdal_priv.h:2000
GDALRasterBlock::GetXSize
int GetXSize() const
Return the width of the block.
Definition: gdal_priv.h:990
GDALDatasetH
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition: gdal.h:269
GDALRasterBand::FromHandle
static GDALRasterBand * FromHandle(GDALRasterBandH hBand)
Convert a GDALRasterBandH to a GDALRasterBand*.
Definition: gdal_priv.h:1410
GDALColorTable
A color table / palette.
Definition: gdal_priv.h:1044
VSILFILE
FILE VSILFILE
Opaque type for a FILE that implements the VSIVirtualHandle API.
Definition: cpl_vsi.h:158
GDALAsyncReader::GetBandMap
int * GetBandMap()
Return band map.
Definition: gdal_priv.h:1837
GSBAP_TOP_TO_BOTTOM
constexpr GDALSuggestedBlockAccessPattern GSBAP_TOP_TO_BOTTOM
Reading by strips from top to bottom is the most efficient.
Definition: gdal_priv.h:1169
GDALDriverH
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition: gdal.h:275
GDALRelationship::GetRelatedTableType
const std::string & GetRelatedTableType() const
Get the type string of the related table.
Definition: gdal_priv.h:3092
GDALRelationshipType
GDALRelationshipType
Type of relationship.
Definition: gdal.h:1680