forked from OSGeo/gdal
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgdal_priv.h
4731 lines (3831 loc) · 156 KB
/
gdal_priv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******************************************************************************
*
* Name: gdal_priv.h
* Project: GDAL Core
* Purpose: GDAL Core C++/Private declarations.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 1998, Frank Warmerdam
* Copyright (c) 2007-2014, Even Rouault <even dot rouault at spatialys.com>
*
* SPDX-License-Identifier: MIT
****************************************************************************/
#ifndef GDAL_PRIV_H_INCLUDED
#define GDAL_PRIV_H_INCLUDED
/**
* \file gdal_priv.h
*
* C++ GDAL entry points.
*/
/* -------------------------------------------------------------------- */
/* Predeclare various classes before pulling in gdal.h, the */
/* public declarations. */
/* -------------------------------------------------------------------- */
class GDALMajorObject;
class GDALDataset;
class GDALRasterBand;
class GDALDriver;
class GDALRasterAttributeTable;
class GDALProxyDataset;
class GDALProxyRasterBand;
class GDALAsyncReader;
class GDALRelationship;
class GDALAlgorithm;
/* -------------------------------------------------------------------- */
/* Pull in the public declarations. This gets the C apis, and */
/* also various constants. However, we will still get to */
/* provide the real class definitions for the GDAL classes. */
/* -------------------------------------------------------------------- */
#include "gdal.h"
#include "gdal_frmts.h"
#include "gdalsubdatasetinfo.h"
#include "cpl_vsi.h"
#include "cpl_conv.h"
#include "cpl_float.h"
#include "cpl_string.h"
#include "cpl_minixml.h"
#include "cpl_multiproc.h"
#include "cpl_atomic_ops.h"
#include <stdarg.h>
#include <cmath>
#include <complex>
#include <cstdint>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <set>
#if __cplusplus >= 202002L
#include <span>
#endif
#include <vector>
#include "ogr_core.h"
#include "ogr_feature.h"
//! @cond Doxygen_Suppress
#define GMO_VALID 0x0001
#define GMO_IGNORE_UNIMPLEMENTED 0x0002
#define GMO_SUPPORT_MD 0x0004
#define GMO_SUPPORT_MDMD 0x0008
#define GMO_MD_DIRTY 0x0010
#define GMO_PAM_CLASS 0x0020
//! @endcond
/************************************************************************/
/* GDALMultiDomainMetadata */
/************************************************************************/
//! @cond Doxygen_Suppress
class CPL_DLL GDALMultiDomainMetadata
{
private:
CPLStringList aosDomainList{};
struct Comparator
{
bool operator()(const char *a, const char *b) const
{
return STRCASECMP(a, b) < 0;
}
};
std::map<const char *, CPLStringList, Comparator> oMetadata{};
public:
GDALMultiDomainMetadata();
~GDALMultiDomainMetadata();
int XMLInit(const CPLXMLNode *psMetadata, int bMerge);
CPLXMLNode *Serialize() const;
CSLConstList GetDomainList() const
{
return aosDomainList.List();
}
char **GetMetadata(const char *pszDomain = "");
CPLErr SetMetadata(CSLConstList papszMetadata, const char *pszDomain = "");
const char *GetMetadataItem(const char *pszName,
const char *pszDomain = "");
CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
const char *pszDomain = "");
void Clear();
inline void clear()
{
Clear();
}
};
//! @endcond
/* ******************************************************************** */
/* GDALMajorObject */
/* */
/* Base class providing metadata, description and other */
/* services shared by major objects. */
/* ******************************************************************** */
/** Object with metadata. */
class CPL_DLL GDALMajorObject
{
protected:
//! @cond Doxygen_Suppress
int nFlags; // GMO_* flags.
CPLString sDescription{};
GDALMultiDomainMetadata oMDMD{};
//! @endcond
char **BuildMetadataDomainList(char **papszList, int bCheckNonEmpty,
...) CPL_NULL_TERMINATED;
public:
GDALMajorObject();
virtual ~GDALMajorObject();
int GetMOFlags() const;
void SetMOFlags(int nFlagsIn);
virtual const char *GetDescription() const;
virtual void SetDescription(const char *);
virtual char **GetMetadataDomainList();
virtual char **GetMetadata(const char *pszDomain = "");
virtual CPLErr SetMetadata(char **papszMetadata,
const char *pszDomain = "");
virtual const char *GetMetadataItem(const char *pszName,
const char *pszDomain = "");
virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
const char *pszDomain = "");
/** Convert a GDALMajorObject* to a GDALMajorObjectH.
* @since GDAL 2.3
*/
static inline GDALMajorObjectH ToHandle(GDALMajorObject *poMajorObject)
{
return static_cast<GDALMajorObjectH>(poMajorObject);
}
/** Convert a GDALMajorObjectH to a GDALMajorObject*.
* @since GDAL 2.3
*/
static inline GDALMajorObject *FromHandle(GDALMajorObjectH hMajorObject)
{
return static_cast<GDALMajorObject *>(hMajorObject);
}
};
/* ******************************************************************** */
/* GDALDefaultOverviews */
/* ******************************************************************** */
//! @cond Doxygen_Suppress
class GDALOpenInfo;
class CPL_DLL GDALDefaultOverviews
{
friend class GDALDataset;
GDALDataset *poDS;
GDALDataset *poODS;
CPLString osOvrFilename{};
bool bOvrIsAux;
bool bCheckedForMask;
bool bOwnMaskDS;
GDALDataset *poMaskDS;
// For "overview datasets" we record base level info so we can
// find our way back to get overview masks.
GDALDataset *poBaseDS;
// Stuff for deferred initialize/overviewscans.
bool bCheckedForOverviews;
void OverviewScan();
char *pszInitName;
bool bInitNameIsOVR;
char **papszInitSiblingFiles;
public:
GDALDefaultOverviews();
~GDALDefaultOverviews();
void Initialize(GDALDataset *poDSIn, const char *pszName = nullptr,
CSLConstList papszSiblingFiles = nullptr,
bool bNameIsOVR = false);
void Initialize(GDALDataset *poDSIn, GDALOpenInfo *poOpenInfo,
const char *pszName = nullptr,
bool bTransferSiblingFilesIfLoaded = true);
void TransferSiblingFiles(char **papszSiblingFiles);
int IsInitialized();
int CloseDependentDatasets();
// Overview Related
int GetOverviewCount(int nBand);
GDALRasterBand *GetOverview(int nBand, int iOverview);
CPLErr BuildOverviews(const char *pszBasename, const char *pszResampling,
int nOverviews, const int *panOverviewList,
int nBands, const int *panBandList,
GDALProgressFunc pfnProgress, void *pProgressData,
CSLConstList papszOptions);
CPLErr BuildOverviewsSubDataset(const char *pszPhysicalFile,
const char *pszResampling, int nOverviews,
const int *panOverviewList, int nBands,
const int *panBandList,
GDALProgressFunc pfnProgress,
void *pProgressData,
CSLConstList papszOptions);
CPLErr BuildOverviewsMask(const char *pszResampling, int nOverviews,
const int *panOverviewList,
GDALProgressFunc pfnProgress, void *pProgressData,
CSLConstList papszOptions);
CPLErr CleanOverviews();
// Mask Related
CPLErr CreateMaskBand(int nFlags, int nBand = -1);
GDALRasterBand *GetMaskBand(int nBand);
int GetMaskFlags(int nBand);
int HaveMaskFile(char **papszSiblings = nullptr,
const char *pszBasename = nullptr);
char **GetSiblingFiles()
{
return papszInitSiblingFiles;
}
private:
CPL_DISALLOW_COPY_ASSIGN(GDALDefaultOverviews)
};
//! @endcond
/* ******************************************************************** */
/* GDALOpenInfo */
/* ******************************************************************** */
/** Class for dataset open functions. */
class CPL_DLL GDALOpenInfo
{
bool bHasGotSiblingFiles = false;
char **papszSiblingFiles = nullptr;
int nHeaderBytesTried = 0;
public:
GDALOpenInfo(const char *pszFile, int nOpenFlagsIn,
const char *const *papszSiblingFiles = nullptr);
~GDALOpenInfo(void);
/** Filename */
char *pszFilename = nullptr;
/** Result of CPLGetExtension(pszFilename); */
std::string osExtension{};
/** Open options */
char **papszOpenOptions = nullptr;
/** Access flag */
GDALAccess eAccess = GA_ReadOnly;
/** Open flags */
int nOpenFlags = 0;
/** Whether stat()'ing the file was successful */
bool bStatOK = false;
/** Whether the file is a directory */
bool bIsDirectory = false;
/** Pointer to the file */
VSILFILE *fpL = nullptr;
/** Number of bytes in pabyHeader */
int nHeaderBytes = 0;
/** Buffer with first bytes of the file */
GByte *pabyHeader = nullptr;
/** Allowed drivers (NULL for all) */
const char *const *papszAllowedDrivers = nullptr;
int TryToIngest(int nBytes);
char **GetSiblingFiles();
char **StealSiblingFiles();
bool AreSiblingFilesLoaded() const;
bool IsSingleAllowedDriver(const char *pszDriverName) const;
/** Return whether the extension of the file is equal to pszExt, using
* case-insensitive comparison.
* @since 3.11 */
inline bool IsExtensionEqualToCI(const char *pszExt) const
{
return EQUAL(osExtension.c_str(), pszExt);
}
private:
CPL_DISALLOW_COPY_ASSIGN(GDALOpenInfo)
};
/* ******************************************************************** */
/* gdal::GCP */
/* ******************************************************************** */
namespace gdal
{
/** C++ wrapper over the C GDAL_GCP structure.
*
* It has the same binary layout, and thus a gdal::GCP pointer can be cast as a
* GDAL_GCP pointer.
*
* @since 3.9
*/
class CPL_DLL GCP
{
public:
explicit GCP(const char *pszId = "", const char *pszInfo = "",
double dfPixel = 0, double dfLine = 0, double dfX = 0,
double dfY = 0, double dfZ = 0);
~GCP();
GCP(const GCP &);
explicit GCP(const GDAL_GCP &other);
GCP &operator=(const GCP &);
GCP(GCP &&);
GCP &operator=(GCP &&);
/** Returns the "id" member. */
inline const char *Id() const
{
return gcp.pszId;
}
void SetId(const char *pszId);
/** Returns the "info" member. */
inline const char *Info() const
{
return gcp.pszInfo;
}
void SetInfo(const char *pszInfo);
/** Returns the "pixel" member. */
inline double Pixel() const
{
return gcp.dfGCPPixel;
}
/** Returns a reference to the "pixel" member. */
inline double &Pixel()
{
return gcp.dfGCPPixel;
}
/** Returns the "line" member. */
inline double Line() const
{
return gcp.dfGCPLine;
}
/** Returns a reference to the "line" member. */
inline double &Line()
{
return gcp.dfGCPLine;
}
/** Returns the "X" member. */
inline double X() const
{
return gcp.dfGCPX;
}
/** Returns a reference to the "X" member. */
inline double &X()
{
return gcp.dfGCPX;
}
/** Returns the "Y" member. */
inline double Y() const
{
return gcp.dfGCPY;
}
/** Returns a reference to the "Y" member. */
inline double &Y()
{
return gcp.dfGCPY;
}
/** Returns the "Z" member. */
inline double Z() const
{
return gcp.dfGCPZ;
}
/** Returns a reference to the "Z" member. */
inline double &Z()
{
return gcp.dfGCPZ;
}
/** Casts as a C GDAL_GCP pointer */
inline const GDAL_GCP *c_ptr() const
{
return &gcp;
}
static const GDAL_GCP *c_ptr(const std::vector<GCP> &asGCPs);
static std::vector<GCP> fromC(const GDAL_GCP *pasGCPList, int nGCPCount);
private:
GDAL_GCP gcp;
};
} /* namespace gdal */
/* ******************************************************************** */
/* GDALDataset */
/* ******************************************************************** */
class OGRLayer;
class OGRGeometry;
class OGRSpatialReference;
class OGRStyleTable;
class swq_select;
class swq_select_parse_options;
class GDALGroup;
//! @cond Doxygen_Suppress
typedef struct GDALSQLParseInfo GDALSQLParseInfo;
//! @endcond
//! @cond Doxygen_Suppress
#ifdef GDAL_COMPILATION
#define OPTIONAL_OUTSIDE_GDAL(val)
#else
#define OPTIONAL_OUTSIDE_GDAL(val) = val
#endif
//! @endcond
//! @cond Doxygen_Suppress
// This macro can be defined to check that GDALDataset::IRasterIO()
// implementations do not alter the passed panBandList. It is not defined
// by default (and should not!), hence int* is used.
#if defined(GDAL_BANDMAP_TYPE_CONST_SAFE)
#define BANDMAP_TYPE const int *
#else
#define BANDMAP_TYPE int *
#endif
//! @endcond
/** A set of associated raster bands, usually from one file. */
class CPL_DLL GDALDataset : public GDALMajorObject
{
friend GDALDatasetH CPL_STDCALL
GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags,
const char *const *papszAllowedDrivers,
const char *const *papszOpenOptions,
const char *const *papszSiblingFiles);
friend CPLErr CPL_STDCALL GDALClose(GDALDatasetH hDS);
friend class GDALDriver;
friend class GDALDefaultOverviews;
friend class GDALProxyDataset;
friend class GDALDriverManager;
CPL_INTERNAL void AddToDatasetOpenList();
CPL_INTERNAL void UnregisterFromSharedDataset();
CPL_INTERNAL static void ReportErrorV(const char *pszDSName,
CPLErr eErrClass, CPLErrorNum err_no,
const char *fmt, va_list args);
protected:
//! @cond Doxygen_Suppress
GDALDriver *poDriver = nullptr;
GDALAccess eAccess = GA_ReadOnly;
// Stored raster information.
int nRasterXSize = 512;
int nRasterYSize = 512;
int nBands = 0;
GDALRasterBand **papoBands = nullptr;
static constexpr int OPEN_FLAGS_CLOSED = -1;
int nOpenFlags =
0; // set to OPEN_FLAGS_CLOSED after Close() has been called
int nRefCount = 1;
bool bForceCachedIO = false;
bool bShared = false;
bool bIsInternal = true;
bool bSuppressOnClose = false;
mutable std::map<std::string, std::unique_ptr<OGRFieldDomain>>
m_oMapFieldDomains{};
GDALDataset(void);
explicit GDALDataset(int bForceCachedIO);
void RasterInitialize(int, int);
void SetBand(int nNewBand, GDALRasterBand *poBand);
void SetBand(int nNewBand, std::unique_ptr<GDALRasterBand> poBand);
GDALDefaultOverviews oOvManager{};
virtual CPLErr IBuildOverviews(const char *pszResampling, int nOverviews,
const int *panOverviewList, int nListBands,
const int *panBandList,
GDALProgressFunc pfnProgress,
void *pProgressData,
CSLConstList papszOptions);
virtual CPLErr
IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize,
void *pData, int nBufXSize, int nBufYSize, GDALDataType eBufType,
int nBandCount, BANDMAP_TYPE panBandMap, GSpacing nPixelSpace,
GSpacing nLineSpace, GSpacing nBandSpace,
GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
/* This method should only be be overloaded by GDALProxyDataset */
virtual CPLErr
BlockBasedRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
int nYSize, void *pData, int nBufXSize, int nBufYSize,
GDALDataType eBufType, int nBandCount,
const int *panBandMap, GSpacing nPixelSpace,
GSpacing nLineSpace, GSpacing nBandSpace,
GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
CPLErr BlockBasedFlushCache(bool bAtClosing);
CPLErr
BandBasedRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
int nYSize, void *pData, int nBufXSize, int nBufYSize,
GDALDataType eBufType, int nBandCount,
const int *panBandMap, GSpacing nPixelSpace,
GSpacing nLineSpace, GSpacing nBandSpace,
GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
CPLErr
RasterIOResampled(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
int nYSize, void *pData, int nBufXSize, int nBufYSize,
GDALDataType eBufType, int nBandCount,
const int *panBandMap, GSpacing nPixelSpace,
GSpacing nLineSpace, GSpacing nBandSpace,
GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
CPLErr ValidateRasterIOOrAdviseReadParameters(
const char *pszCallingFunc, int *pbStopProcessingOnCENone, int nXOff,
int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize,
int nBandCount, const int *panBandMap);
CPLErr TryOverviewRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
int nXSize, int nYSize, void *pData,
int nBufXSize, int nBufYSize,
GDALDataType eBufType, int nBandCount,
const int *panBandMap, GSpacing nPixelSpace,
GSpacing nLineSpace, GSpacing nBandSpace,
GDALRasterIOExtraArg *psExtraArg, int *pbTried);
void ShareLockWithParentDataset(GDALDataset *poParentDataset);
bool m_bCanBeReopened = false;
virtual bool CanBeCloned(int nScopeFlags, bool bCanShareState) const;
friend class GDALThreadSafeDataset;
friend class MEMDataset;
virtual std::unique_ptr<GDALDataset> Clone(int nScopeFlags,
bool bCanShareState) const;
//! @endcond
void CleanupPostFileClosing();
virtual int CloseDependentDatasets();
//! @cond Doxygen_Suppress
int ValidateLayerCreationOptions(const char *const *papszLCO);
char **papszOpenOptions = nullptr;
friend class GDALRasterBand;
// The below methods related to read write mutex are fragile logic, and
// should not be used by out-of-tree code if possible.
int EnterReadWrite(GDALRWFlag eRWFlag);
void LeaveReadWrite();
void InitRWLock();
void TemporarilyDropReadWriteLock();
void ReacquireReadWriteLock();
void DisableReadWriteMutex();
int AcquireMutex();
void ReleaseMutex();
bool IsAllBands(int nBandCount, const int *panBandList) const;
//! @endcond
public:
~GDALDataset() override;
virtual CPLErr Close();
int GetRasterXSize() const;
int GetRasterYSize() const;
int GetRasterCount() const;
GDALRasterBand *GetRasterBand(int);
const GDALRasterBand *GetRasterBand(int) const;
/**
* @brief SetQueryLoggerFunc
* @param pfnQueryLoggerFuncIn query logger function callback
* @param poQueryLoggerArgIn arguments passed to the query logger function
* @return true on success
*/
virtual bool SetQueryLoggerFunc(GDALQueryLoggerFunc pfnQueryLoggerFuncIn,
void *poQueryLoggerArgIn);
/** Class returned by GetBands() that act as a container for raster bands.
*/
class CPL_DLL Bands
{
private:
friend class GDALDataset;
GDALDataset *m_poSelf;
CPL_INTERNAL explicit Bands(GDALDataset *poSelf) : m_poSelf(poSelf)
{
}
class CPL_DLL Iterator
{
struct Private;
std::unique_ptr<Private> m_poPrivate;
public:
Iterator(GDALDataset *poDS, bool bStart);
Iterator(const Iterator &oOther); // declared but not defined.
// Needed for gcc 5.4 at least
Iterator(Iterator &&oOther) noexcept; // declared but not defined.
// Needed for gcc 5.4 at least
~Iterator();
GDALRasterBand *operator*();
Iterator &operator++();
bool operator!=(const Iterator &it) const;
};
public:
const Iterator begin() const;
const Iterator end() const;
size_t size() const;
GDALRasterBand *operator[](int iBand);
GDALRasterBand *operator[](size_t iBand);
};
Bands GetBands();
virtual CPLErr FlushCache(bool bAtClosing = false);
virtual CPLErr DropCache();
virtual GIntBig GetEstimatedRAMUsage();
virtual const OGRSpatialReference *GetSpatialRef() const;
virtual CPLErr SetSpatialRef(const OGRSpatialReference *poSRS);
// Compatibility layer
const char *GetProjectionRef(void) const;
CPLErr SetProjection(const char *pszProjection);
virtual CPLErr GetGeoTransform(double *padfTransform);
virtual CPLErr SetGeoTransform(double *padfTransform);
CPLErr GeolocationToPixelLine(
double dfGeolocX, double dfGeolocY, const OGRSpatialReference *poSRS,
double *pdfPixel, double *pdfLine,
CSLConstList papszTransformerOptions = nullptr) const;
virtual CPLErr AddBand(GDALDataType eType, char **papszOptions = nullptr);
virtual void *GetInternalHandle(const char *pszHandleName);
virtual GDALDriver *GetDriver(void);
virtual char **GetFileList(void);
virtual const char *GetDriverName();
virtual const OGRSpatialReference *GetGCPSpatialRef() const;
virtual int GetGCPCount();
virtual const GDAL_GCP *GetGCPs();
virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList,
const OGRSpatialReference *poGCP_SRS);
// Compatibility layer
const char *GetGCPProjection();
CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList,
const char *pszGCPProjection);
virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize,
int nBufXSize, int nBufYSize, GDALDataType eDT,
int nBandCount, int *panBandList,
char **papszOptions);
virtual CPLErr CreateMaskBand(int nFlagsIn);
virtual GDALAsyncReader *
BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize, void *pBuf,
int nBufXSize, int nBufYSize, GDALDataType eBufType,
int nBandCount, int *panBandMap, int nPixelSpace,
int nLineSpace, int nBandSpace, char **papszOptions);
virtual void EndAsyncReader(GDALAsyncReader *poARIO);
//! @cond Doxygen_Suppress
struct RawBinaryLayout
{
enum class Interleaving
{
UNKNOWN,
BIP,
BIL,
BSQ
};
std::string osRawFilename{};
Interleaving eInterleaving = Interleaving::UNKNOWN;
GDALDataType eDataType = GDT_Unknown;
bool bLittleEndianOrder = false;
vsi_l_offset nImageOffset = 0;
GIntBig nPixelOffset = 0;
GIntBig nLineOffset = 0;
GIntBig nBandOffset = 0;
};
virtual bool GetRawBinaryLayout(RawBinaryLayout &);
//! @endcond
#ifndef DOXYGEN_SKIP
CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
int nYSize, void *pData, int nBufXSize, int nBufYSize,
GDALDataType eBufType, int nBandCount,
const int *panBandMap, GSpacing nPixelSpace,
GSpacing nLineSpace, GSpacing nBandSpace,
GDALRasterIOExtraArg *psExtraArg
OPTIONAL_OUTSIDE_GDAL(nullptr)) CPL_WARN_UNUSED_RESULT;
#else
CPLErr RasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize,
int nYSize, void *pData, int nBufXSize, int nBufYSize,
GDALDataType eBufType, int nBandCount,
const int *panBandMap, GSpacing nPixelSpace,
GSpacing nLineSpace, GSpacing nBandSpace,
GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT;
#endif
virtual CPLStringList GetCompressionFormats(int nXOff, int nYOff,
int nXSize, int nYSize,
int nBandCount,
const int *panBandList);
virtual CPLErr ReadCompressedData(const char *pszFormat, int nXOff,
int nYOff, int nXSize, int nYSize,
int nBands, const int *panBandList,
void **ppBuffer, size_t *pnBufferSize,
char **ppszDetailedFormat);
int Reference();
int Dereference();
int ReleaseRef();
/** Return access mode.
* @return access mode.
*/
GDALAccess GetAccess() const
{
return eAccess;
}
int GetShared() const;
void MarkAsShared();
void MarkSuppressOnClose();
void UnMarkSuppressOnClose();
/** Return MarkSuppressOnClose flag.
* @return MarkSuppressOnClose flag.
*/
bool IsMarkedSuppressOnClose() const
{
return bSuppressOnClose;
}
/** Return open options.
* @return open options.
*/
char **GetOpenOptions()
{
return papszOpenOptions;
}
bool IsThreadSafe(int nScopeFlags) const;
#ifndef DOXYGEN_SKIP
/** Return open options.
* @return open options.
*/
CSLConstList GetOpenOptions() const
{
return papszOpenOptions;
}
#endif
static GDALDataset **GetOpenDatasets(int *pnDatasetCount);
#ifndef DOXYGEN_SKIP
CPLErr
BuildOverviews(const char *pszResampling, int nOverviews,
const int *panOverviewList, int nListBands,
const int *panBandList, GDALProgressFunc pfnProgress,
void *pProgressData,
CSLConstList papszOptions OPTIONAL_OUTSIDE_GDAL(nullptr));
#else
CPLErr BuildOverviews(const char *pszResampling, int nOverviews,
const int *panOverviewList, int nListBands,
const int *panBandList, GDALProgressFunc pfnProgress,
void *pProgressData, CSLConstList papszOptions);
#endif
#ifndef DOXYGEN_XML
void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,
...) const CPL_PRINT_FUNC_FORMAT(4, 5);
static void ReportError(const char *pszDSName, CPLErr eErrClass,
CPLErrorNum err_no, const char *fmt, ...)
CPL_PRINT_FUNC_FORMAT(4, 5);
#endif
char **GetMetadata(const char *pszDomain = "") override;
// Only defined when Doxygen enabled
#ifdef DOXYGEN_SKIP
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override;
CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
const char *pszDomain) override;
#endif
char **GetMetadataDomainList() override;
virtual void ClearStatistics();
/** Convert a GDALDataset* to a GDALDatasetH.
* @since GDAL 2.3
*/
static inline GDALDatasetH ToHandle(GDALDataset *poDS)
{
return static_cast<GDALDatasetH>(poDS);
}
/** Convert a GDALDatasetH to a GDALDataset*.
* @since GDAL 2.3
*/
static inline GDALDataset *FromHandle(GDALDatasetH hDS)
{
return static_cast<GDALDataset *>(hDS);
}
/** @see GDALOpenEx().
* @since GDAL 2.3
*/
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)
{
return FromHandle(GDALOpenEx(pszFilename, nOpenFlags,
papszAllowedDrivers, papszOpenOptions,
papszSiblingFiles));
}
/** Object returned by GetFeatures() iterators */
struct FeatureLayerPair
{
/** Unique pointer to a OGRFeature. */
OGRFeatureUniquePtr feature{};
/** Layer to which the feature belongs to. */
OGRLayer *layer = nullptr;
};
//! @cond Doxygen_Suppress
// SetEnableOverviews() only to be used by GDALOverviewDataset
void SetEnableOverviews(bool bEnable);
// Only to be used by driver's GetOverviewCount() method.
bool AreOverviewsEnabled() const;
static void ReportUpdateNotSupportedByDriver(const char *pszDriverName);
//! @endcond
private:
class Private;
Private *m_poPrivate;
CPL_INTERNAL OGRLayer *BuildLayerFromSelectInfo(
swq_select *psSelectInfo, OGRGeometry *poSpatialFilter,
const char *pszDialect, swq_select_parse_options *poSelectParseOptions);
CPLStringList oDerivedMetadataList{};
public:
virtual int GetLayerCount();
virtual OGRLayer *GetLayer(int iLayer);
virtual bool IsLayerPrivate(int iLayer) const;
/** Class returned by GetLayers() that acts as a range of layers.
* @since GDAL 2.3
*/
class CPL_DLL Layers
{
private:
friend class GDALDataset;
GDALDataset *m_poSelf;
CPL_INTERNAL explicit Layers(GDALDataset *poSelf) : m_poSelf(poSelf)
{
}
public:
/** Layer iterator.
* @since GDAL 2.3
*/
class CPL_DLL Iterator
{
struct Private;
std::unique_ptr<Private> m_poPrivate;
public:
using value_type = OGRLayer *; /**< value_type */
using reference = OGRLayer *; /**< reference */
using difference_type = void; /**< difference_type */
using pointer = void; /**< pointer */
using iterator_category =
std::input_iterator_tag; /**< iterator_category */
Iterator(); /**< Default constructor */