GDAL

- Main Page
- Related Pages
- Classes
- Files
- Download
- Issue Tracker

- File List
- File Members

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