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