15#ifndef GDAL_CPP_FUNCTIONS_H_INCLUDED
16#define GDAL_CPP_FUNCTIONS_H_INCLUDED
20#include "cpl_progress.h"
25#include "gdal_geotransform.h"
33typedef struct _CPLMutex CPLMutex;
49CPLErr CPL_DLL GDALRegenerateOverviewsMultiBand(
52 const char *pszResampling, GDALProgressFunc pfnProgress,
55CPLErr CPL_DLL GDALRegenerateOverviewsMultiBand(
56 const std::vector<GDALRasterBand *> &apoSrcBands,
59 const std::vector<std::vector<GDALRasterBand *>> &aapoOverviewBands,
60 const char *pszResampling, GDALProgressFunc pfnProgress,
70struct GDALOverviewResampleArgs
84 double dfXRatioDstToSrc = 0;
87 double dfYRatioDstToSrc = 0;
89 double dfSrcXDelta = 0;
91 double dfSrcYDelta = 0;
95 const GByte *pabyChunkNodataMask =
nullptr;
113 const char *pszResampling =
nullptr;
115 bool bHasNoData =
false;
117 double dfNoDataValue = 0;
119 const GDALColorTable *poColorTable =
nullptr;
123 bool bPropagateNoData =
false;
126typedef CPLErr (*GDALResampleFunction)(
const GDALOverviewResampleArgs &args,
127 const void *pChunk,
void **ppDstBuffer,
130GDALResampleFunction GDALGetResampleFunction(
const char *pszResampling,
133std::string CPL_DLL GDALGetNormalizedOvrResampling(
const char *pszResampling);
135GDALDataType GDALGetOvrWorkDataType(
const char *pszResampling,
141HFAAuxBuildOverviews(
const char *pszOvrFilename,
GDALDataset *poParentDS,
142 GDALDataset **ppoDS,
int nBands,
const int *panBandList,
143 int nNewOverviews,
const int *panNewOverviewList,
144 const char *pszResampling, GDALProgressFunc pfnProgress,
147CPLErr CPL_DLL GTIFFBuildOverviews(
const char *pszFilename,
int nBands,
149 int nOverviews,
const int *panOverviewList,
150 const char *pszResampling,
151 GDALProgressFunc pfnProgress,
155CPLErr CPL_DLL GTIFFBuildOverviewsEx(
const char *pszFilename,
int nBands,
157 int nOverviews,
const int *panOverviewList,
158 const std::pair<int, int> *pasOverviewSize,
159 const char *pszResampling,
160 const char *
const *papszOptions,
161 GDALProgressFunc pfnProgress,
162 void *pProgressData);
164int CPL_DLL GDALBandGetBestOverviewLevel(
GDALRasterBand *poBand,
int &nXOff,
165 int &nYOff,
int &nXSize,
int &nYSize,
166 int nBufXSize,
int nBufYSize)
167 CPL_WARN_DEPRECATED(
"Use GDALBandGetBestOverviewLevel2 instead");
168int CPL_DLL GDALBandGetBestOverviewLevel2(
GDALRasterBand *poBand,
int &nXOff,
169 int &nYOff,
int &nXSize,
int &nYSize,
170 int nBufXSize,
int nBufYSize,
173int CPL_DLL GDALOvLevelAdjust(
int nOvLevel,
int nXSize)
174 CPL_WARN_DEPRECATED(
"Use GDALOvLevelAdjust2 instead");
175int CPL_DLL GDALOvLevelAdjust2(
int nOvLevel,
int nXSize,
int nYSize);
176int CPL_DLL GDALComputeOvFactor(
int nOvrXSize,
int nRasterXSize,
int nOvrYSize,
179GDALDataset CPL_DLL *GDALFindAssociatedAuxFile(
const char *pszBasefile,
187int CPL_DLL GDALCheckDatasetDimensions(
int nXSize,
int nYSize);
188int CPL_DLL GDALCheckBandCount(
int nBands,
int bIsZeroAllowed);
194int CPL_DLL GDALReadWorldFile2(
const char *pszBaseFilename,
195 const char *pszExtension,
196 double *padfGeoTransform,
198 char **ppszWorldFileNameOut);
199int CPL_DLL GDALReadTabFile2(
const char *pszBaseFilename,
200 double *padfGeoTransform,
char **ppszWKT,
201 int *pnGCPCount,
GDAL_GCP **ppasGCPs,
203 char **ppszTabFileNameOut);
208void CPL_DLL GDALExpandPackedBitsToByteAt0Or1(
212void CPL_DLL GDALExpandPackedBitsToByteAt0Or255(
218int CPL_DLL GDALReadWorldFile2(
const char *pszBaseFilename,
221 char **ppszWorldFileNameOut);
223std::unique_ptr<GDALDataset> CPL_DLL
229void GDALNullifyOpenDatasetsList();
230CPLMutex **GDALGetphDMMutex();
231CPLMutex **GDALGetphDLMutex();
232void GDALNullifyProxyPoolSingleton();
233void GDALSetResponsiblePIDForCurrentThread(
GIntBig responsiblePID);
234GIntBig GDALGetResponsiblePIDForCurrentThread();
236CPLString GDALFindAssociatedFile(
const char *pszBasename,
const char *pszExt,
239CPLErr CPL_DLL EXIFExtractMetadata(
char **&papszMetadata,
void *fpL,
240 int nOffset,
int bSwabflag,
int nTIFFHEADER,
241 int &nExifOffset,
int &nInterOffset,
245 const char *
const *papszOptionOptions);
246int GDALValidateOptions(
const char *pszOptionList,
247 const char *
const *papszOptionsToValidate,
248 const char *pszErrorMessageOptionType,
249 const char *pszErrorMessageContainerName);
252GDALRasterIOGetResampleAlg(
const char *pszResampling);
256 int nXSize,
int nYSize,
int nBufXSize,
260 bool bThisLevelOnly);
269inline bool ARE_REAL_EQUAL(
float fVal1,
float fVal2,
int ulp = 2)
272 return fVal1 == fVal2 ||
274 std::numeric_limits<float>::epsilon() * abs(fVal1 + fVal2) * ulp;
279inline bool ARE_REAL_EQUAL(
double dfVal1,
double dfVal2,
int ulp = 2)
282 return dfVal1 == dfVal2 ||
283 abs(dfVal1 - dfVal2) <
284 static_cast<double>(std::numeric_limits<float>::epsilon()) *
285 abs(dfVal1 + dfVal2) * ulp;
288double GDALAdjustNoDataCloseToFloatMax(
double dfVal);
290#define DIV_ROUND_UP(a, b) (((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1))
294#define GDALSTAT_APPROX_NUMSAMPLES 2500
296void GDALSerializeGCPListToXML(
CPLXMLNode *psParentNode,
297 const std::vector<gdal::GCP> &asGCPs,
299void GDALDeserializeGCPListFromXML(
const CPLXMLNode *psGCPList,
300 std::vector<gdal::GCP> &asGCPs,
303void GDALSerializeOpenOptionsToXML(
CPLXMLNode *psParentNode,
306GDALDeserializeOpenOptionsFromXML(
const CPLXMLNode *psParentNode);
308int GDALCanFileAcceptSidecarFile(
const char *pszFilename);
310bool GDALCanReliablyUseSiblingFileList(
const char *pszFilename);
317} GDALBufferSampleFormat;
319bool CPL_DLL GDALBufferHasOnlyNoData(
const void *pBuffer,
double dfNoDataValue,
320 size_t nWidth,
size_t nHeight,
321 size_t nLineStride,
size_t nComponents,
323 GDALBufferSampleFormat nSampleFormat);
327 bool *pbCannotBeExactlyRepresented =
nullptr);
329double CPL_DLL GDALGetNoDataValueCastToDouble(int64_t nVal);
330double CPL_DLL GDALGetNoDataValueCastToDouble(uint64_t nVal);
335void CPL_DLL GDALEnablePixelTypeSignedByteWarning(
GDALRasterBandH hBand,
338std::string CPL_DLL GDALGetCompressionFormatForJPEG(
VSILFILE *fp);
339std::string CPL_DLL GDALGetCompressionFormatForJPEG(
const void *pBuffer,
344 const std::vector<std::shared_ptr<GDALMDArray>> &apoArrays,
345 const std::vector<GDALRATFieldUsage> &aeUsages);
348GDALGetColorInterpFromSTACCommonName(
const char *pszName);
352std::string CPL_DLL GDALGetCacheDirectory();
354bool GDALDoesFileOrDatasetExist(
const char *pszName,
355 const char **ppszType =
nullptr,
359GDALGetMessageAboutMissingPluginDriver(
GDALDriver *poMissingPluginDriver);
361std::string GDALPrintDriverList(
int nOptions,
bool bJSON);
363struct GDALColorAssociation
372std::vector<GDALColorAssociation> GDALLoadTextColorMap(
const char *pszFilename,
379 return eErr1 == CE_None ? eErr2 : eErr1;
386 return eErr1 == CE_None ? (b ? CE_None : CE_Failure) : eErr1;
Convenient string class based on std::string.
Definition cpl_string.h:320
A color table / palette.
Definition gdal_colortable.h:32
A set of associated raster bands, usually from one file.
Definition gdal_dataset.h:76
Format specific driver.
Definition gdal_driver.h:63
Class modeling a multi-dimensional array.
Definition gdal_multidim.h:852
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition gdal_rat.h:48
A single raster band (or channel).
Definition gdal_rasterband.h:105
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:152
CPL error handling services.
CPLErr
Error category.
Definition cpl_error.h:37
Core portability definitions for CPL.
#define CPL_RESTRICT
restrict keyword to declare that pointers do not alias
Definition cpl_port.h:916
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:289
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:285
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:175
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:205
Various convenience functions for working with strings and string lists.
struct VSIVirtualHandle VSILFILE
Opaque type for a FILE that implements the VSIVirtualHandle API.
Definition cpl_vsi.h:141
Public (C callable) GDAL entry points.
GDALRATTableType
RAT table type (thematic or athematic).
Definition gdal.h:2263
GDALAccess
Definition gdal.h:118
GDALDataType
Definition gdal.h:48
@ GDT_Unknown
Definition gdal.h:49
GDALRasterAttributeTableH GDALCreateRasterAttributeTableFromMDArrays(GDALRATTableType eTableType, int nArrays, const GDALMDArrayH *ahArrays, const GDALRATFieldUsage *paeUsages)
Return a virtual Raster Attribute Table from several GDALMDArray's.
Definition gdalmultidim_rat.cpp:511
GDALRIOResampleAlg
RasterIO() resampling method.
Definition gdal.h:135
GDALDatasetH GDALGetThreadSafeDataset(GDALDatasetH, int nScopeFlags, CSLConstList papszOptions)
Return a thread-safe dataset.
Definition gdalthreadsafedataset.cpp:1285
GDALColorInterp
Types of color interpretation for raster bands.
Definition gdal.h:270
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition gdal_fwd.h:51
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition gdal_fwd.h:45
Document node structure.
Definition cpl_minixml.h:54
Ground Control Point.
Definition gdal.h:1221