32 #ifndef GDAL_PRIV_H_INCLUDED
33 #define GDAL_PRIV_H_INCLUDED
50 class GDALProxyDataset;
51 class GDALProxyRasterBand;
61 #include "gdal_frmts.h"
66 #include "cpl_multiproc.h"
67 #include "cpl_atomic_ops.h"
80 #define GMO_VALID 0x0001
81 #define GMO_IGNORE_UNIMPLEMENTED 0x0002
82 #define GMO_SUPPORT_MD 0x0004
83 #define GMO_SUPPORT_MDMD 0x0008
84 #define GMO_MD_DIRTY 0x0010
85 #define GMO_PAM_CLASS 0x0020
93 class CPL_DLL GDALMultiDomainMetadata
96 char **papszDomainList;
100 GDALMultiDomainMetadata();
101 ~GDALMultiDomainMetadata();
103 int XMLInit(
CPLXMLNode *psMetadata,
int bMerge );
106 char **GetDomainList() {
return papszDomainList; }
108 char **GetMetadata(
const char * pszDomain =
"" );
109 CPLErr SetMetadata(
char ** papszMetadata,
110 const char * pszDomain =
"" );
111 const char *GetMetadataItem(
const char * pszName,
112 const char * pszDomain =
"" );
113 CPLErr SetMetadataItem(
const char * pszName,
114 const char * pszValue,
115 const char * pszDomain =
"" );
138 GDALMultiDomainMetadata oMDMD{};
142 char **BuildMetadataDomainList(
char** papszList,
148 int GetMOFlags()
const;
149 void SetMOFlags(
int nFlagsIn );
151 virtual const char *GetDescription()
const;
152 virtual void SetDescription(
const char * );
154 virtual char **GetMetadataDomainList();
156 virtual char **GetMetadata(
const char * pszDomain =
"" );
157 virtual CPLErr SetMetadata(
char ** papszMetadata,
158 const char * pszDomain =
"" );
159 virtual const char *GetMetadataItem(
const char * pszName,
160 const char * pszDomain =
"" );
161 virtual CPLErr SetMetadataItem(
const char * pszName,
162 const char * pszValue,
163 const char * pszDomain =
"" );
183 class CPL_DLL GDALDefaultOverviews
194 bool bCheckedForMask;
203 bool bCheckedForOverviews;
207 char **papszInitSiblingFiles;
210 GDALDefaultOverviews();
211 ~GDALDefaultOverviews();
213 void Initialize(
GDALDataset *poDSIn,
const char *pszName =
nullptr,
214 char **papszSiblingFiles =
nullptr,
215 int bNameIsOVR = FALSE );
217 void TransferSiblingFiles(
char** papszSiblingFiles );
225 int GetOverviewCount(
int nBand );
229 const char * pszResampling,
230 int nOverviews,
int * panOverviewList,
231 int nBands,
int * panBandList,
232 GDALProgressFunc pfnProgress,
233 void *pProgressData );
235 CPLErr BuildOverviewsSubDataset(
const char * pszPhysicalFile,
236 const char * pszResampling,
237 int nOverviews,
int * panOverviewList,
238 int nBands,
int * panBandList,
239 GDALProgressFunc pfnProgress,
240 void *pProgressData );
248 int GetMaskFlags(
int nBand );
250 int HaveMaskFile(
char **papszSiblings =
nullptr,
251 const char *pszBasename =
nullptr );
253 char** GetSiblingFiles() {
return papszInitSiblingFiles; }
267 bool bHasGotSiblingFiles;
268 char **papszSiblingFiles;
269 int nHeaderBytesTried;
273 const char *
const * papszSiblingFiles =
nullptr );
302 int TryToIngest(
int nBytes);
303 char **GetSiblingFiles();
304 char **StealSiblingFiles();
305 bool AreSiblingFilesLoaded()
const;
320 class swq_select_parse_options;
323 typedef struct GDALSQLParseInfo GDALSQLParseInfo;
327 #ifdef GDAL_COMPILATION
328 #define OPTIONAL_OUTSIDE_GDAL(val)
330 #define OPTIONAL_OUTSIDE_GDAL(val) = val
338 unsigned int nOpenFlags,
339 const char*
const* papszAllowedDrivers,
340 const char*
const* papszOpenOptions,
341 const char*
const* papszSiblingFiles );
345 friend class GDALDefaultOverviews;
346 friend class GDALProxyDataset;
349 CPL_INTERNAL
void AddToDatasetOpenList();
357 int nRasterXSize = 512;
358 int nRasterYSize = 512;
365 bool bForceCachedIO =
false;
366 bool bShared =
false;
367 bool bIsInternal =
true;
368 bool bSuppressOnClose =
false;
373 void RasterInitialize(
int,
int );
376 GDALDefaultOverviews oOvManager{};
378 virtual CPLErr IBuildOverviews(
const char *,
int,
int *,
379 int,
int *, GDALProgressFunc,
void * );
390 void BlockBasedFlushCache();
393 int nXOff,
int nYOff,
int nXSize,
int nYSize,
394 void * pData,
int nBufXSize,
int nBufYSize,
396 int nBandCount,
int *panBandMap,
402 int nXOff,
int nYOff,
int nXSize,
int nYSize,
403 void * pData,
int nBufXSize,
int nBufYSize,
405 int nBandCount,
int *panBandMap,
410 CPLErr ValidateRasterIOOrAdviseReadParameters(
411 const char* pszCallingFunc,
412 int* pbStopProcessingOnCENone,
413 int nXOff,
int nYOff,
int nXSize,
int nYSize,
414 int nBufXSize,
int nBufYSize,
415 int nBandCount,
int *panBandMap);
418 int nXOff,
int nYOff,
int nXSize,
int nYSize,
419 void * pData,
int nBufXSize,
int nBufYSize,
421 int nBandCount,
int *panBandMap,
428 virtual int CloseDependentDatasets();
430 int ValidateLayerCreationOptions(
const char*
const* papszLCO );
432 char **papszOpenOptions =
nullptr;
439 void LeaveReadWrite();
442 void TemporarilyDropReadWriteLock();
443 void ReacquireReadWriteLock();
445 void DisableReadWriteMutex();
454 int GetRasterXSize();
455 int GetRasterYSize();
456 int GetRasterCount();
468 class CPL_DLL Iterator
471 std::unique_ptr<Private> m_poPrivate;
474 Iterator(
const Iterator& oOther);
475 Iterator(Iterator&& oOther) noexcept;
478 Iterator& operator++();
479 bool operator!=(
const Iterator& it)
const;
484 const Iterator
begin()
const;
486 const Iterator
end()
const;
496 virtual void FlushCache(
void);
502 const char *GetProjectionRef(
void)
const;
503 CPLErr SetProjection(
const char * pszProjection );
505 virtual CPLErr GetGeoTransform(
double * padfTransform );
506 virtual CPLErr SetGeoTransform(
double * padfTransform );
509 char **papszOptions=
nullptr );
511 virtual void *GetInternalHandle(
const char * pszHandleName );
513 virtual char **GetFileList(
void);
515 virtual const char* GetDriverName();
518 virtual int GetGCPCount();
520 virtual CPLErr SetGCPs(
int nGCPCount,
const GDAL_GCP *pasGCPList,
524 const char *GetGCPProjection();
526 const char *pszGCPProjection );
528 virtual CPLErr AdviseRead(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
529 int nBufXSize,
int nBufYSize,
531 int nBandCount,
int *panBandList,
532 char **papszOptions );
534 virtual CPLErr CreateMaskBand(
int nFlagsIn );
537 BeginAsyncReader(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
538 void *pBuf,
int nBufXSize,
int nBufYSize,
540 int nBandCount,
int* panBandMap,
541 int nPixelSpace,
int nLineSpace,
int nBandSpace,
542 char **papszOptions);
550 OPTIONAL_OUTSIDE_GDAL(
nullptr)
552 ) CPL_WARN_UNUSED_RESULT;
563 int GetShared()
const;
574 static GDALDataset **GetOpenDatasets(
int *pnDatasetCount );
576 CPLErr BuildOverviews(
const char *,
int,
int *,
577 int,
int *, GDALProgressFunc,
void * );
581 char ** GetMetadata(const
char * pszDomain = "") override;
585 CPLErr SetMetadata(
char ** papszMetadata,
586 const char * pszDomain )
override;
587 const char *GetMetadataItem(
const char * pszName,
588 const char * pszDomain )
override;
589 CPLErr SetMetadataItem(
const char * pszName,
590 const char * pszValue,
591 const char * pszDomain )
override;
594 char **GetMetadataDomainList()
override;
612 unsigned int nOpenFlags = 0,
613 const char*
const* papszAllowedDrivers =
nullptr,
614 const char*
const* papszOpenOptions =
nullptr,
615 const char*
const* papszSiblingFiles =
nullptr )
617 return FromHandle(
GDALOpenEx(pszFilename, nOpenFlags,
635 Private *m_poPrivate;
637 CPL_INTERNAL
OGRLayer* BuildLayerFromSelectInfo(swq_select* psSelectInfo,
639 const char *pszDialect,
640 swq_select_parse_options* poSelectParseOptions);
645 virtual int GetLayerCount();
646 virtual OGRLayer *GetLayer(
int iLayer);
667 std::unique_ptr<Private> m_poPrivate;
688 bool operator!=(const
Iterator& it) const;
697 OGRLayer* operator[](
size_t iLayer);
698 OGRLayer* operator[](const
char* pszLayername);
703 virtual
OGRLayer *GetLayerByName(const
char *);
704 virtual
OGRErr DeleteLayer(
int iLayer);
706 virtual
void ResetReading();
708 double* pdfProgressPct,
709 GDALProgressFunc pfnProgress,
710 void* pProgressData );
720 CPL_INTERNAL
explicit Features(
GDALDataset* poSelf): m_poSelf(poSelf) {}
722 class CPL_DLL Iterator
725 std::unique_ptr<Private> m_poPrivate;
728 Iterator(
const Iterator& oOther);
729 Iterator(Iterator&& oOther) noexcept;
732 Iterator& operator++();
733 bool operator!=(
const Iterator& it)
const;
738 const Iterator
begin()
const;
740 const Iterator
end()
const;
745 virtual int TestCapability(
const char * );
747 virtual OGRLayer *CreateLayer(
const char *pszName,
750 char ** papszOptions =
nullptr );
752 const char *pszNewName,
753 char **papszOptions =
nullptr );
756 virtual void SetStyleTableDirectly(
OGRStyleTable *poStyleTable );
760 virtual OGRLayer * ExecuteSQL(
const char *pszStatement,
762 const char *pszDialect );
763 virtual void ReleaseResultSet(
OGRLayer * poResultsSet );
765 int GetRefCount()
const;
766 int GetSummaryRefCount()
const;
769 virtual OGRErr StartTransaction(
int bForce=FALSE);
770 virtual OGRErr CommitTransaction();
771 virtual OGRErr RollbackTransaction();
774 static int IsGenericSQLDialect(
const char* pszDialect);
777 GDALSQLParseInfo* BuildParseInfo(swq_select* psSelectInfo,
778 swq_select_parse_options* poSelectParseOptions);
779 static void DestroyParseInfo(GDALSQLParseInfo* psParseInfo );
780 OGRLayer * ExecuteSQL(
const char *pszStatement,
782 const char *pszDialect,
783 swq_select_parse_options* poSelectParseOptions);
787 virtual OGRLayer *ICreateLayer(
const char *pszName,
790 char ** papszOptions =
nullptr );
793 OGRErr ProcessSQLCreateIndex(
const char * );
794 OGRErr ProcessSQLDropIndex(
const char * );
795 OGRErr ProcessSQLDropTable(
const char * );
796 OGRErr ProcessSQLAlterTableAddColumn(
const char * );
797 OGRErr ProcessSQLAlterTableDropColumn(
const char * );
798 OGRErr ProcessSQLAlterTableAlterColumn(
const char * );
799 OGRErr ProcessSQLAlterTableRenameColumn(
const char * );
807 CPLErr OldSetGCPsFromNew(
int nGCPCount,
const GDAL_GCP *pasGCPList,
810 friend class GDALProxyPoolDataset;
811 virtual const char *_GetProjectionRef();
813 virtual const char *_GetGCPProjection();
815 virtual CPLErr _SetProjection(
const char * pszProjection );
816 virtual CPLErr _SetGCPs(
int nGCPCount,
const GDAL_GCP *pasGCPList,
817 const char *pszGCPProjection );
825 struct CPL_DLL GDALDatasetUniquePtrDeleter
849 friend class GDALAbstractBandBlockCache;
854 volatile int nLockCount;
871 CPL_INTERNAL
void Detach_unlocked(
void );
872 CPL_INTERNAL
void Touch_unlocked(
void );
874 CPL_INTERNAL
void RecycleFor(
int nXOffIn,
int nYOffIn );
881 CPLErr Internalize(
void );
883 void MarkDirty(
void );
884 void MarkClean(
void );
886 int AddLock(
void ) {
return CPLAtomicInc(&nLockCount); }
888 int DropLock(
void ) {
return CPLAtomicDec(&nLockCount); }
928 int DropLockForRemovalFromStorage();
934 static void FlushDirtyBlocks();
935 static int FlushCacheBlock(
int bDirtyBlocksOnly = FALSE);
936 static void Verify();
938 static void EnterDisableDirtyBlockFlush();
939 static void LeaveDisableDirtyBlockFlush();
944 static void DumpAll();
949 CPL_INTERNAL
static void DestroyRBMutex();
966 std::vector<GDALColorEntry> aoEntries{};
977 int GetColorEntryCount()
const;
1007 class GDALAbstractBandBlockCache
1010 CPLLock *hSpinLock =
nullptr;
1014 CPLCond *hCond =
nullptr;
1015 CPLMutex *hCondMutex =
nullptr;
1016 volatile int nKeepAliveCounter = 0;
1018 volatile int m_nDirtyBlocks = 0;
1025 int m_nInitialDirtyBlocksInFlushCache = 0;
1026 int m_nLastTick = -1;
1028 void FreeDanglingBlocks();
1029 void UnreferenceBlockBase();
1030 void WaitKeepAliveCounter();
1032 void StartDirtyBlockFlushingLog();
1033 void UpdateDirtyBlockFlushingLog();
1034 void EndDirtyBlockFlushingLog();
1038 virtual ~GDALAbstractBandBlockCache();
1042 void IncDirtyBlocks(
int nInc);
1044 virtual
bool Init() = 0;
1045 virtual
bool IsInitOK() = 0;
1046 virtual
CPLErr FlushCache() = 0;
1047 virtual
CPLErr AdoptBlock( GDALRasterBlock* poBlock ) = 0;
1048 virtual GDALRasterBlock *TryGetLockedBlockRef(
int nXBlockOff,
1049 int nYBlockYOff ) = 0;
1050 virtual
CPLErr UnreferenceBlock( GDALRasterBlock* poBlock ) = 0;
1051 virtual
CPLErr FlushBlock(
int nXBlockOff,
int nYBlockOff,
1052 int bWriteDirtyBlock ) = 0;
1055 GDALAbstractBandBlockCache* GDALArrayBandBlockCacheCreate(
GDALRasterBand* poBand);
1056 GDALAbstractBandBlockCache* GDALHashSetBandBlockCacheCreate(
GDALRasterBand* poBand);
1069 friend class GDALArrayBandBlockCache;
1070 friend class GDALHashSetBandBlockCache;
1071 friend class GDALRasterBlock;
1073 CPLErr eFlushBlockErr = CE_None;
1074 GDALAbstractBandBlockCache* poBandBlockCache =
nullptr;
1076 CPL_INTERNAL
void SetFlushBlockErr(
CPLErr eErr );
1077 CPL_INTERNAL
CPLErr UnreferenceBlock( GDALRasterBlock* poBlock );
1078 CPL_INTERNAL
void SetValidPercent(
GUIntBig nSampleCount,
GUIntBig nValidCount );
1079 CPL_INTERNAL
void IncDirtyBlocks(
int nInc);
1086 int nRasterXSize = 0;
1087 int nRasterYSize = 0;
1093 int nBlockXSize = -1;
1094 int nBlockYSize = -1;
1095 int nBlocksPerRow = 0;
1096 int nBlocksPerColumn = 0;
1098 int nBlockReads = 0;
1099 int bForceCachedIO = 0;
1102 bool bOwnMask =
false;
1105 void InvalidateMaskBand();
1108 friend class GDALProxyRasterBand;
1109 friend class GDALDefaultOverviews;
1116 void LeaveReadWrite();
1121 virtual CPLErr IReadBlock(
int nBlockXOff,
int nBlockYOff,
void * pData ) = 0;
1122 virtual CPLErr IWriteBlock(
int nBlockXOff,
int nBlockYOff,
void * pData );
1128 virtual int IGetDataCoverageStatus(
int nXOff,
int nYOff,
1129 int nXSize,
int nYSize,
1131 double* pdfDataPct);
1138 int nXOff,
int nYOff,
int nXSize,
int nYSize,
1139 void * pData,
int nBufXSize,
int nBufYSize,
1145 int InitBlockInfo();
1147 void AddBlockToFreeList( GDALRasterBlock * );
1150 GDALRasterBlock *TryGetLockedBlockRef(
int nXBlockOff,
int nYBlockYOff );
1164 void GetBlockSize(
int *,
int * );
1165 CPLErr GetActualBlockSize (
int,
int,
int *,
int * );
1171 #ifndef DOXYGEN_SKIP
1172 OPTIONAL_OUTSIDE_GDAL(
nullptr)
1179 GDALRasterBlock *GetLockedBlockRef(
int nXBlockOff,
int nYBlockOff,
1181 CPLErr FlushBlock(
int,
int,
int bWriteDirtyBlock = TRUE );
1183 unsigned char* GetIndexColorTranslationTo(
GDALRasterBand* poReferenceBand,
1184 unsigned char* pTranslationTable =
nullptr,
1185 int* pApproximateMatching =
nullptr);
1189 virtual CPLErr FlushCache();
1190 virtual char **GetCategoryNames();
1191 virtual double GetNoDataValue(
int *pbSuccess =
nullptr );
1192 virtual double GetMinimum(
int *pbSuccess =
nullptr );
1193 virtual double GetMaximum(
int *pbSuccess =
nullptr );
1194 virtual double GetOffset(
int *pbSuccess =
nullptr );
1195 virtual double GetScale(
int *pbSuccess =
nullptr );
1196 virtual const char *GetUnitType();
1199 virtual CPLErr Fill(
double dfRealValue,
double dfImaginaryValue = 0);
1201 virtual CPLErr SetCategoryNames(
char ** papszNames );
1202 virtual CPLErr SetNoDataValue(
double dfNoData );
1203 virtual CPLErr DeleteNoDataValue();
1206 virtual CPLErr SetOffset(
double dfNewOffset );
1207 virtual CPLErr SetScale(
double dfNewScale );
1208 virtual CPLErr SetUnitType(
const char * pszNewValue );
1210 virtual CPLErr GetStatistics(
int bApproxOK,
int bForce,
1211 double *pdfMin,
double *pdfMax,
1212 double *pdfMean,
double *padfStdDev );
1213 virtual CPLErr ComputeStatistics(
int bApproxOK,
1214 double *pdfMin,
double *pdfMax,
1215 double *pdfMean,
double *pdfStdDev,
1216 GDALProgressFunc,
void *pProgressData );
1217 virtual CPLErr SetStatistics(
double dfMin,
double dfMax,
1218 double dfMean,
double dfStdDev );
1219 virtual CPLErr ComputeRasterMinMax(
int,
double* );
1223 char **GetMetadata(
const char * pszDomain =
"" )
override;
1224 CPLErr SetMetadata(
char ** papszMetadata,
1225 const char * pszDomain )
override;
1226 const char *GetMetadataItem(
const char * pszName,
1227 const char * pszDomain )
override;
1228 CPLErr SetMetadataItem(
const char * pszName,
1229 const char * pszValue,
1230 const char * pszDomain )
override;
1233 virtual int HasArbitraryOverviews();
1234 virtual int GetOverviewCount();
1237 virtual CPLErr BuildOverviews(
const char * pszResampling,
1239 int * panOverviewList,
1240 GDALProgressFunc pfnProgress,
1241 void * pProgressData );
1243 virtual CPLErr AdviseRead(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
1244 int nBufXSize,
int nBufYSize,
1247 virtual CPLErr GetHistogram(
double dfMin,
double dfMax,
1248 int nBuckets,
GUIntBig * panHistogram,
1249 int bIncludeOutOfRange,
int bApproxOK,
1250 GDALProgressFunc,
void *pProgressData );
1252 virtual CPLErr GetDefaultHistogram(
double *pdfMin,
double *pdfMax,
1253 int *pnBuckets,
GUIntBig ** ppanHistogram,
1255 GDALProgressFunc,
void *pProgressData);
1256 virtual CPLErr SetDefaultHistogram(
double dfMin,
double dfMax,
1257 int nBuckets,
GUIntBig *panHistogram );
1263 virtual int GetMaskFlags();
1264 virtual CPLErr CreateMaskBand(
int nFlagsIn );
1271 int GetDataCoverageStatus(
int nXOff,
int nYOff,
1272 int nXSize,
int nYSize,
1273 int nMaskFlagStop = 0,
1274 double* pdfDataPct =
nullptr );
1302 CPLErr IReadBlock(
int,
int,
void * )
override;
1308 ~GDALAllValidMaskBand() override;
1310 GDALRasterBand *GetMaskBand() override;
1311 int GetMaskFlags() override;
1313 CPLErr ComputeStatistics(
int bApproxOK,
1314 double *pdfMin,
double *pdfMax,
1315 double *pdfMean,
double *pdfStdDev,
1316 GDALProgressFunc,
void *pProgressData ) override;
1324 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
1326 double dfNoDataValue;
1327 GDALRasterBand *poParent;
1332 CPLErr IReadBlock(
int,
int,
void * ) override;
1338 explicit GDALNoDataMaskBand( GDALRasterBand * );
1339 ~GDALNoDataMaskBand() override;
1341 static
bool IsNoDataInRange(
double dfNoDataValue,
1342 GDALDataType eDataType);
1349 class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
1351 double *padfNodataValues;
1356 CPLErr IReadBlock(
int,
int,
void * ) override;
1359 explicit GDALNoDataValuesMaskBand(
GDALDataset * );
1360 ~GDALNoDataValuesMaskBand() override;
1367 class GDALRescaledAlphaBand : public GDALRasterBand
1369 GDALRasterBand *poParent;
1375 CPLErr IReadBlock(
int,
int,
void * ) override;
1376 CPLErr IRasterIO( GDALRWFlag,
int,
int,
int,
int,
1377 void *,
int,
int, GDALDataType,
1382 explicit GDALRescaledAlphaBand( GDALRasterBand * );
1383 ~GDALRescaledAlphaBand() override;
1427 CPLErr SetMetadataItem(
const char * pszName,
1428 const char * pszValue,
1429 const char * pszDomain =
"" )
override;
1434 GDALDataset *Create(
const char * pszName,
1435 int nXSize,
int nYSize,
int nBands,
1438 CPLErr Delete(
const char * pszName );
1439 CPLErr Rename(
const char * pszNewName,
1440 const char * pszOldName );
1441 CPLErr CopyFiles(
const char * pszNewName,
1442 const char * pszOldName );
1444 GDALDataset *CreateCopy(
const char *, GDALDataset *,
1446 GDALProgressFunc pfnProgress,
1457 GDALDataset *(*pfnCreate)(
const char * pszName,
1458 int nXSize,
int nYSize,
int nBands,
1460 char ** papszOptions );
1462 CPLErr (*pfnDelete)(
const char * pszName );
1464 GDALDataset *(*pfnCreateCopy)(
const char *, GDALDataset *,
1466 GDALProgressFunc pfnProgress,
1467 void * pProgressData );
1482 CPLErr (*pfnRename)(
const char * pszNewName,
1483 const char * pszOldName );
1484 CPLErr (*pfnCopyFiles)(
const char * pszNewName,
1485 const char * pszOldName );
1489 GDALDataset *(*pfnCreateVectorOnly)( GDALDriver*,
1490 const char * pszName,
1491 char ** papszOptions );
1492 CPLErr (*pfnDeleteDataSource)( GDALDriver*,
1493 const char * pszName );
1500 GDALDataset *DefaultCreateCopy(
const char *, GDALDataset *,
1502 GDALProgressFunc pfnProgress,
1504 static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
1505 GDALDataset *poDstDS,
1507 static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
1508 GDALDataset *poDstDS,
1511 GDALProgressFunc pfnProgress,
1512 void * pProgressData );
1514 static CPLErr QuietDelete(
const char * pszName );
1517 static CPLErr DefaultRename(
const char * pszNewName,
1518 const char * pszOldName );
1519 static CPLErr DefaultCopyFiles(
const char * pszNewName,
1520 const char * pszOldName );
1533 {
return static_cast<GDALDriver*
>(hDriver); }
1554 std::map<CPLString, GDALDriver*> oMapNameToDrivers{};
1556 GDALDriver *GetDriver_unlocked(
int iDriver )
1557 {
return (iDriver >= 0 && iDriver < nDrivers) ?
1558 papoDrivers[iDriver] :
nullptr; }
1560 GDALDriver *GetDriverByName_unlocked(
const char * pszName )
1569 int GetDriverCount(
void )
const;
1577 static void AutoLoadDrivers();
1578 void AutoSkipDrivers();
1609 GDALDataType eBufType;
1679 GetNextUpdatedRegion(
double dfTimeout,
1680 int* pnBufXOff,
int* pnBufYOff,
1681 int* pnBufXSize,
int* pnBufYSize) = 0;
1682 virtual int LockBuffer(
double dfTimeout = -1.0 );
1683 virtual void UnlockBuffer();
1693 GDALRegenerateOverviewsMultiBand(
int nBands, GDALRasterBand** papoSrcBands,
1695 GDALRasterBand*** papapoOverviewBands,
1696 const char * pszResampling,
1697 GDALProgressFunc pfnProgress,
void * pProgressData );
1699 typedef CPLErr (*GDALResampleFunction)
1700 (
double dfXRatioDstToSrc,
1701 double dfYRatioDstToSrc,
1704 GDALDataType eWrkDataType,
1706 GByte * pabyChunkNodataMask,
1707 int nChunkXOff,
int nChunkXSize,
1708 int nChunkYOff,
int nChunkYSize,
1709 int nDstXOff,
int nDstXOff2,
1710 int nDstYOff,
int nDstYOff2,
1711 GDALRasterBand * poOverview,
1712 const char * pszResampling,
1713 int bHasNoData,
float fNoDataValue,
1715 GDALDataType eSrcDataType,
1716 bool bPropagateNoData );
1718 GDALResampleFunction GDALGetResampleFunction(
const char* pszResampling,
1721 #ifdef GDAL_ENABLE_RESAMPLING_MULTIBAND
1722 typedef CPLErr (*GDALResampleFunctionMultiBands)
1723 (
double dfXRatioDstToSrc,
1724 double dfYRatioDstToSrc,
1727 GDALDataType eWrkDataType,
1728 void * pChunk,
int nBands,
1729 GByte * pabyChunkNodataMask,
1730 int nChunkXOff,
int nChunkXSize,
1731 int nChunkYOff,
int nChunkYSize,
1732 int nDstXOff,
int nDstXOff2,
1733 int nDstYOff,
int nDstYOff2,
1734 GDALRasterBand ** papoDstBands,
1735 const char * pszResampling,
1736 int bHasNoData,
float fNoDataValue,
1738 GDALDataType eSrcDataType);
1740 GDALResampleFunctionMultiBands GDALGetResampleFunctionMultiBands(
const char* pszResampling,
1744 GDALDataType GDALGetOvrWorkDataType(
const char* pszResampling,
1745 GDALDataType eSrcDataType);
1750 HFAAuxBuildOverviews(
const char *pszOvrFilename, GDALDataset *poParentDS,
1751 GDALDataset **ppoDS,
1752 int nBands,
int *panBandList,
1753 int nNewOverviews,
int *panNewOverviewList,
1754 const char *pszResampling,
1755 GDALProgressFunc pfnProgress,
1756 void *pProgressData );
1759 GTIFFBuildOverviews(
const char * pszFilename,
1760 int nBands, GDALRasterBand **papoBandList,
1761 int nOverviews,
int * panOverviewList,
1762 const char * pszResampling,
1763 GDALProgressFunc pfnProgress,
void * pProgressData );
1766 GDALDefaultBuildOverviews( GDALDataset *hSrcDS,
const char * pszBasename,
1767 const char * pszResampling,
1768 int nOverviews,
int * panOverviewList,
1769 int nBands,
int * panBandList,
1770 GDALProgressFunc pfnProgress,
void * pProgressData);
1772 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
1773 int &nXOff,
int &nYOff,
1774 int &nXSize,
int &nYSize,
1775 int nBufXSize,
int nBufYSize) CPL_WARN_DEPRECATED(
"Use GDALBandGetBestOverviewLevel2 instead");
1776 int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand* poBand,
1777 int &nXOff,
int &nYOff,
1778 int &nXSize,
int &nYSize,
1779 int nBufXSize,
int nBufYSize,
1782 int CPL_DLL GDALOvLevelAdjust(
int nOvLevel,
int nXSize ) CPL_WARN_DEPRECATED(
"Use GDALOvLevelAdjust2 instead");
1783 int CPL_DLL GDALOvLevelAdjust2(
int nOvLevel,
int nXSize,
int nYSize );
1784 int CPL_DLL GDALComputeOvFactor(
int nOvrXSize,
int nRasterXSize,
1785 int nOvrYSize,
int nRasterYSize );
1787 GDALDataset CPL_DLL *
1788 GDALFindAssociatedAuxFile(
const char *pszBasefile,
GDALAccess eAccess,
1789 GDALDataset *poDependentDS );
1795 int CPL_DLL GDALCheckDatasetDimensions(
int nXSize,
int nYSize );
1796 int CPL_DLL GDALCheckBandCount(
int nBands,
int bIsZeroAllowed );
1801 int CPL_DLL GDALReadWorldFile2(
const char *pszBaseFilename,
const char *pszExtension,
1802 double *padfGeoTransform,
char** papszSiblingFiles,
1803 char** ppszWorldFileNameOut);
1804 int GDALReadTabFile2(
const char * pszBaseFilename,
1805 double *padfGeoTransform,
char **ppszWKT,
1806 int *pnGCPCount,
GDAL_GCP **ppasGCPs,
1807 char** papszSiblingFiles,
char** ppszTabFileNameOut );
1814 void GDALNullifyOpenDatasetsList();
1815 CPLMutex** GDALGetphDMMutex();
1816 CPLMutex** GDALGetphDLMutex();
1817 void GDALNullifyProxyPoolSingleton();
1819 void GDALSetResponsiblePIDForCurrentThread(
GIntBig responsiblePID);
1820 GIntBig GDALGetResponsiblePIDForCurrentThread();
1822 CPLString GDALFindAssociatedFile(
const char *pszBasename,
const char *pszExt,
1825 CPLErr EXIFExtractMetadata(
char**& papszMetadata,
1826 void *fpL,
int nOffset,
1827 int bSwabflag,
int nTIFFHEADER,
1828 int& nExifOffset,
int& nInterOffset,
int& nGPSOffset);
1831 const char*
const* papszOptionOptions);
1832 int GDALValidateOptions(
const char* pszOptionList,
1833 const char*
const* papszOptionsToValidate,
1834 const char* pszErrorMessageOptionType,
1835 const char* pszErrorMessageContainerName);
1841 int nXSize,
int nYSize,
1842 int nBufXSize,
int nBufYSize);
1845 GDALDataset* GDALCreateOverviewDataset(GDALDataset* poDS,
int nOvrLevel,
1846 int bThisLevelOnly);
1851 template<
class T>
inline bool ARE_REAL_EQUAL(T fVal1, T fVal2,
int ulp = 2)
1853 return fVal1 == fVal2 ||
1854 std::abs(fVal1 - fVal2) < std::numeric_limits<float>::epsilon() * std::abs(fVal1+fVal2) * ulp;
1857 double GDALAdjustNoDataCloseToFloatMax(
double dfVal);
1859 #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) )
1863 #define GDALSTAT_APPROX_NUMSAMPLES 2500
1865 void GDALSerializeGCPListToXML(
CPLXMLNode* psParentNode,
1869 void GDALDeserializeGCPListFromXML(
CPLXMLNode* psGCPList,
1874 void GDALSerializeOpenOptionsToXML(
CPLXMLNode* psParentNode,
char** papszOpenOptions);
1875 char** GDALDeserializeOpenOptionsFromXML(
CPLXMLNode* psParentNode );
1877 int GDALCanFileAcceptSidecarFile(
const char* pszFilename);
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition: gdal_rat.h:47
Layer iterator.
Definition: gdal_priv.h:664
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:3128
std::unique_ptr< OGRFeature, OGRFeatureUniquePtrDeleter > OGRFeatureUniquePtr
Unique pointer type for OGRFeature.
Definition: ogr_feature.h:780
GDALDataType
Definition: gdal.h:60
GDALDataType GetBufferType() const
Return buffer data type.
Definition: gdal_priv.h:1656
Identify could not determine if the file is recognized or not by the probed driver.
Definition: gdal_priv.h:1399
std::unique_ptr< GDALDataset, GDALDatasetUniquePtrDeleter > GDALDatasetUniquePtr
Unique pointer type for GDALDataset.
Definition: gdal_priv.h:837
Document node structure.
Definition: cpl_minixml.h:66
Definitions for CPL mini XML Parser/Serializer.
int GetYOff() const
Return the y offset of the top-left corner of the block.
Definition: gdal_priv.h:904
void static GDALRasterBandH ToHandle(GDALRasterBand *poBand)
Convert a GDALRasterBand* to a GDALRasterBandH.
Definition: gdal_priv.h:1281
GDALDataset * GetGDALDataset()
Return dataset.
Definition: gdal_priv.h:1624
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:337
Object returned by GetFeatures() iterators.
Definition: gdal_priv.h:624
const char *const * papszAllowedDrivers
Allowed drivers (NULL for all)
Definition: gdal_priv.h:300
int * GetBandMap()
Return band map.
Definition: gdal_priv.h:1664
int DropLock(void)
Decrement the lock count.
Definition: gdal_priv.h:888
FILE VSILFILE
Opaque type for a FILE that implements the VSIVirtualHandle API.
Definition: cpl_vsi.h:156
char ** GetOpenOptions()
Return open options.
Definition: gdal_priv.h:572
void pointer
pointer
Definition: gdal_priv.h:673
GByte * pabyHeader
Buffer with first bytes of the file.
Definition: gdal_priv.h:297
int GetXOff() const
Return the x offset of the top-left corner of the block.
Definition: gdal_priv.h:900
GDALAccess eAccess
Access flag.
Definition: gdal_priv.h:282
GDALRIOResampleAlg
RasterIO() resampling method.
Definition: gdal.h:128
VSILFILE * fpL
Pointer to the file.
Definition: gdal_priv.h:292
int GetXSize() const
Return width.
Definition: gdal_priv.h:1636
static GDALRasterBand * FromHandle(GDALRasterBandH hBand)
Convert a GDALRasterBandH to a GDALRasterBand*.
Definition: gdal_priv.h:1287
GDALRWFlag
Definition: gdal.h:119
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition: gdal.h:255
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:215
char * pszFilename
Filename.
Definition: gdal_priv.h:277
Color tuple.
Definition: gdal.h:1059
int nOpenFlags
Open flags.
Definition: gdal_priv.h:284
A single raster block in the block cache.
Definition: gdal_priv.h:847
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:258
int AddLock(void)
Increment the lock count.
Definition: gdal_priv.h:886
Convenient string class based on std::string.
Definition: cpl_string.h:329
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition: cpl_port.h:914
unknown type, non-standard
Definition: ogr_core.h:319
int GetLineSpace() const
Return line spacing.
Definition: gdal_priv.h:1672
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition: cpl_virtualmem.h:62
CPLErr BuildOverviews(const char *, int, int *, int, int *, GDALProgressFunc, void *)
Build raster overview(s)
Definition: gdaldataset.cpp:1923
Various convenience functions for working with strings and string lists.
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:273
int bIsDirectory
Whether the file is a directory.
Definition: gdal_priv.h:289
static GDALColorTableH ToHandle(GDALColorTable *poCT)
Convert a GDALColorTable* to a GDALRasterBandH.
Definition: gdal_priv.h:987
GIntBig GPtrDiff_t
Integer type large enough to hold the difference between 2 addresses.
Definition: cpl_port.h:286
int GetYSize() const
Return the height of the block.
Definition: gdal_priv.h:912
int GetXSize() const
Return the width of the block.
Definition: gdal_priv.h:908
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:317
static GDALDriverH ToHandle(GDALDriver *poDriver)
Convert a GDALDriver* to a GDALDriverH.
Definition: gdal_priv.h:1526
Public (C callable) GDAL entry points.
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:611
GDALAsyncStatusType
status of the asynchronous stream
Definition: gdal.h:100
GPtrDiff_t GetBlockSize() const
Return the block size in bytes.
Definition: gdal_priv.h:924
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:286
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1194
void * GetBuffer()
Return buffer.
Definition: gdal_priv.h:1644
GDALRasterBand * GetBand()
Accessor to source GDALRasterBand object.
Definition: gdal_priv.h:932
Class for dataset open functions.
Definition: gdal_priv.h:265
int GetYOffset() const
Return y offset.
Definition: gdal_priv.h:1632
void MarkSuppressOnClose()
Set that the dataset must be deleted on close.
Definition: gdal_priv.h:567
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:438
static GDALDriver * FromHandle(GDALDriverH hDriver)
Convert a GDALDriverH to a GDALDriver*.
Definition: gdal_priv.h:1532
Identify determined the file is recognized by the probed driver.
Definition: gdal_priv.h:1403
static GDALMajorObjectH ToHandle(GDALMajorObject *poMajorObject)
Convert a GDALMajorObject* to a GDALMajorObjectH.
Definition: gdal_priv.h:168
GDALPaletteInterp
Definition: gdal.h:216
Core portability services for cross-platform OGR code.
int bStatOK
Whether stat()'ing the file was successful.
Definition: gdal_priv.h:287
int nHeaderBytes
Number of bytes in pabyHeader.
Definition: gdal_priv.h:295
Class returned by GetBands() that act as a container for raster bands.
Definition: gdal_priv.h:460
virtual int CloseDependentDatasets()
Drop references to any other datasets referenced by this dataset.
Definition: gdaldataset.cpp:3911
void * GetDataRef(void)
Return the data buffer.
Definition: gdal_priv.h:920
int GetYSize() const
Return height.
Definition: gdal_priv.h:1640
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the dataset.
Definition: gdaldataset.cpp:2939
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:251
int CPLErrorNum
Error number.
Definition: cpl_error.h:94
Various convenience functions for CPL.
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:156
int GetBufferXSize() const
Return buffer width.
Definition: gdal_priv.h:1648
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition: gdal.h:261
void GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition: gdaldataset.cpp:3540
static GDALDatasetH ToHandle(GDALDataset *poDS)
Convert a GDALDataset* to a GDALDatasetH.
Definition: gdal_priv.h:599
void * GDALMajorObjectH
Opaque type used for the C bindings of the C++ GDALMajorObject class.
Definition: gdal.h:252
char ** papszOpenOptions
Open options.
Definition: gdal_priv.h:279
Object with metadata.
Definition: gdal_priv.h:132
int GetBufferYSize() const
Return buffer height.
Definition: gdal_priv.h:1652
Class returned by GetLayers() that acts as a range of layers.
Definition: gdal_priv.h:651
static GDALDataset * FromHandle(GDALDatasetH hDS)
Convert a GDALDatasetH to a GDALDataset*.
Definition: gdal_priv.h:605
std::input_iterator_tag iterator_category
iterator_category
Definition: gdal_priv.h:674
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:70
int GetDirty() const
Return the dirty flag.
Definition: gdal_priv.h:916
A single raster band (or channel).
Definition: gdal_priv.h:1066
GDALAccess
Definition: gdal.h:113
int GetPixelSpace() const
Return pixel spacing.
Definition: gdal_priv.h:1668
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:354
int GetBandSpace() const
Return band spacing.
Definition: gdal_priv.h:1676
This class represents a style table.
Definition: ogr_featurestyle.h:84
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:335
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:339
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:248
void * GDALColorTableH
Opaque type used for the C bindings of the C++ GDALColorTable class.
Definition: gdal.h:264
int GetXOffset() const
Return x offset.
Definition: gdal_priv.h:1628
Class for managing the registration of file format drivers.
Definition: gdal_priv.h:1550
OGRLayer::FeatureIterator begin(OGRLayer *poLayer)
Return begin of feature iterator.
Definition: ogrsf_frmts.h:287
#define CPL_NULL_TERMINATED
Null terminated variadic.
Definition: cpl_port.h:904
CPLSTRING_METHOD_DLL CPLString & toupper(void)
Convert to upper case in place.
Definition: cplstring.cpp:316
GDALIdentifyEnum
Enumeration used by GDALDriver::pfnIdentify().
Definition: gdal_priv.h:1396
int OGRErr
Simple container for a bounding region.
Definition: ogr_core.h:290
GDALColorInterp
Definition: gdal.h:190
int GDALGetDataTypeSizeBytes(GDALDataType)
Get data type size in bytes.
Definition: gdal_misc.cpp:305
Class returned by GetFeatures() that act as a container for vector features.
Definition: gdal_priv.h:714
static GDALMajorObject * FromHandle(GDALMajorObjectH hMajorObject)
Convert a GDALMajorObjectH to a GDALMajorObject*.
Definition: gdal_priv.h:174
GDALDataType GetDataType() const
Return the data type.
Definition: gdal_priv.h:896
Identify determined the file is not recognized by the probed driver.
Definition: gdal_priv.h:1401
OGRLayer::FeatureIterator end(OGRLayer *poLayer)
Return end of feature iterator.
Definition: ogrsf_frmts.h:292
int GetBandCount() const
Return band count.
Definition: gdal_priv.h:1660
void difference_type
difference_type
Definition: gdal_priv.h:672
Format specific driver.
Definition: gdal_priv.h:1421
A color table / palette.
Definition: gdal_priv.h:962
Ground Control Point.
Definition: gdal.h:563
CPLErr
Error category.
Definition: cpl_error.h:52
GDALDriverManager * GetGDALDriverManager(void)
Fetch the global GDAL driver manager.
Definition: gdaldrivermanager.cpp:97
#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:997
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:939
Class used as a session object for asynchronous requests.
Definition: gdal_priv.h:1594
static GDALColorTable * FromHandle(GDALColorTableH hCT)
Convert a GDALColorTableH to a GDALColorTable*.
Definition: gdal_priv.h:993