30#ifndef GDAL_PAM_H_INCLUDED
31#define GDAL_PAM_H_INCLUDED
45#define GCIF_GEOTRANSFORM 0x01
46#define GCIF_PROJECTION 0x02
47#define GCIF_METADATA 0x04
50#define GCIF_NODATA 0x001000
51#define GCIF_CATEGORYNAMES 0x002000
52#define GCIF_MINMAX 0x004000
53#define GCIF_SCALEOFFSET 0x008000
54#define GCIF_UNITTYPE 0x010000
55#define GCIF_COLORTABLE 0x020000
56#define GCIF_COLORINTERP 0x020000
57#define GCIF_BAND_METADATA 0x040000
58#define GCIF_RAT 0x080000
59#define GCIF_MASK 0x100000
60#define GCIF_BAND_DESCRIPTION 0x200000
62#define GCIF_ONLY_IF_MISSING 0x10000000
63#define GCIF_PROCESS_BANDS 0x20000000
65#define GCIF_PAM_DEFAULT \
66 (GCIF_GEOTRANSFORM | GCIF_PROJECTION | GCIF_METADATA | GCIF_GCPS | \
67 GCIF_NODATA | GCIF_CATEGORYNAMES | GCIF_MINMAX | GCIF_SCALEOFFSET | \
68 GCIF_UNITTYPE | GCIF_COLORTABLE | GCIF_COLORINTERP | GCIF_BAND_METADATA | \
69 GCIF_RAT | GCIF_MASK | GCIF_ONLY_IF_MISSING | GCIF_PROCESS_BANDS | \
70 GCIF_BAND_DESCRIPTION)
75#define GPF_TRIED_READ_FAILED 0x02
76#define GPF_DISABLED 0x04
77#define GPF_AUXMODE 0x08
78#define GPF_NOSAVE 0x10
88class GDALDatasetPamInfo
91 char *pszPamFilename =
nullptr;
93 std::vector<CPLXMLTreeCloser> m_apoOtherNodes{};
97 int bHaveGeoTransform =
false;
98 double adfGeoTransform[6]{0, 0, 0, 0, 0, 0};
108 int bHasMetadata =
false;
122 int IsPamFilenameAPotentialSiblingFile();
128 GDALDatasetPamInfo *psPam =
nullptr;
130 virtual CPLXMLNode *SerializeToXML(
const char *);
133 virtual CPLErr TryLoadXML(
char **papszSiblingFiles =
nullptr);
134 virtual CPLErr TrySaveXML();
136 CPLErr TryLoadAux(
char **papszSiblingFiles =
nullptr);
139 virtual const char *BuildPamFilename();
141 void PamInitialize();
144 void SetPhysicalFilename(
const char *);
145 const char *GetPhysicalFilename();
146 void SetSubdatasetName(
const char *);
147 const char *GetSubdatasetName();
160 void DeleteGeoTransform();
170 const char *pszDomain =
"")
override;
172 const char *pszDomain =
"")
override;
173 char **
GetMetadata(
const char *pszDomain =
"")
override;
175 const char *pszDomain =
"")
override;
184 CPLErr IBuildOverviews(
const char *pszResampling,
int nOverviews,
185 const int *panOverviewList,
int nListBands,
186 const int *panBandList, GDALProgressFunc pfnProgress,
193 nPamFlags |= GPF_DIRTY;
195 GDALDatasetPamInfo *GetPamInfo()
203 void SetPamFlags(
int nValue)
215constexpr double GDAL_PAM_DEFAULT_NODATA_VALUE = 0;
219constexpr int64_t GDAL_PAM_DEFAULT_NODATA_VALUE_INT64 =
220 (std::numeric_limits<int64_t>::min)();
221constexpr uint64_t GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64 =
222 (std::numeric_limits<uint64_t>::max)();
232struct GDALRasterBandPamInfo
236 bool bNoDataValueSet =
false;
237 bool bNoDataValueSetAsInt64 =
false;
238 bool bNoDataValueSetAsUInt64 =
false;
240 double dfNoDataValue = GDAL_PAM_DEFAULT_NODATA_VALUE;
241 int64_t nNoDataValueInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_INT64;
242 uint64_t nNoDataValueUInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64;
248 char *pszUnitType =
nullptr;
249 char **papszCategoryNames =
nullptr;
251 double dfOffset = 0.0;
252 double dfScale = 1.0;
254 int bHaveMinMax = FALSE;
258 int bHaveStats = FALSE;
266 bool bOffsetSet =
false;
267 bool bScaleSet =
false;
281 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath);
284 void PamInitialize();
286 void PamInitializeNoParent();
289 GDALRasterBandPamInfo *psPam =
nullptr;
301 CPLErr SetNoDataValue(
double)
override;
302 CPLErr SetNoDataValueAsInt64(int64_t nNoData)
override;
303 CPLErr SetNoDataValueAsUInt64(uint64_t nNoData)
override;
304 double GetNoDataValue(
int *pbSuccess =
nullptr)
override;
305 int64_t GetNoDataValueAsInt64(
int *pbSuccess =
nullptr)
override;
306 uint64_t GetNoDataValueAsUInt64(
int *pbSuccess =
nullptr)
override;
307 CPLErr DeleteNoDataValue()
override;
315 const char *GetUnitType()
override;
316 CPLErr SetUnitType(
const char *)
override;
318 char **GetCategoryNames()
override;
319 CPLErr SetCategoryNames(
char **)
override;
321 double GetOffset(
int *pbSuccess =
nullptr)
override;
322 CPLErr SetOffset(
double)
override;
323 double GetScale(
int *pbSuccess =
nullptr)
override;
324 CPLErr SetScale(
double)
override;
326 CPLErr GetHistogram(
double dfMin,
double dfMax,
int nBuckets,
327 GUIntBig *panHistogram,
int bIncludeOutOfRange,
328 int bApproxOK, GDALProgressFunc,
329 void *pProgressData)
override;
331 CPLErr GetDefaultHistogram(
double *pdfMin,
double *pdfMax,
int *pnBuckets,
332 GUIntBig **ppanHistogram,
int bForce,
333 GDALProgressFunc,
void *pProgressData)
override;
335 CPLErr SetDefaultHistogram(
double dfMin,
double dfMax,
int nBuckets,
339 const char *pszDomain =
"")
override;
341 const char *pszDomain =
"")
override;
351 GDALRasterBandPamInfo *GetPamInfo()
359 void ResetNoDataValues();
371class CPL_DLL GDALPamMultiDim
374 std::unique_ptr<Private> d;
380 explicit GDALPamMultiDim(
const std::string &osFilename);
381 virtual ~GDALPamMultiDim();
383 std::shared_ptr<OGRSpatialReference>
389 CPLErr GetStatistics(
const std::string &osArrayFullName,
bool bApproxOK,
390 double *pdfMin,
double *pdfMax,
double *pdfMean,
391 double *pdfStdDev,
GUInt64 *pnValidCount);
393 void SetStatistics(
const std::string &osArrayFullName,
bool bApproxStats,
394 double dfMin,
double dfMax,
double dfMean,
395 double dfStdDev,
GUInt64 nValidCount);
409 std::shared_ptr<GDALPamMultiDim> m_poPam;
412 GDALPamMDArray(
const std::string &osParentName,
const std::string &osName,
413 const std::shared_ptr<GDALPamMultiDim> &poPam);
415 bool SetStatistics(
bool bApproxStats,
double dfMin,
double dfMax,
416 double dfMean,
double dfStdDev,
420 const std::shared_ptr<GDALPamMultiDim> &GetPAM()
const
425 CPLErr GetStatistics(
bool bApproxOK,
bool bForce,
double *pdfMin,
426 double *pdfMax,
double *pdfMean,
double *padfStdDev,
427 GUInt64 *pnValidCount, GDALProgressFunc pfnProgress,
428 void *pProgressData)
override;
434 std::shared_ptr<OGRSpatialReference>
GetSpatialRef()
const override;
438int CPL_DLL PamParseHistogram(
CPLXMLNode *psHistItem,
double *pdfMin,
439 double *pdfMax,
int *pnBuckets,
441 int *pbIncludeOutOfRange,
int *pbApproxOK);
443 double dfMin,
double dfMax,
445 int bIncludeOutOfRange,
447CPLXMLNode CPL_DLL *PamHistogramToXMLTree(
double dfMin,
double dfMax,
448 int nBuckets,
GUIntBig *panHistogram,
449 int bIncludeOutOfRange,
int bApprox);
452const char CPL_DLL *PamGetProxy(
const char *);
453const char CPL_DLL *PamAllocateProxy(
const char *);
454const char CPL_DLL *PamDeallocateProxy(
const char *);
455void CPL_DLL PamCleanProxyDB(
void);
Convenient string class based on std::string.
Definition cpl_string.h:312
A color table / palette.
Definition gdal_priv.h:1093
A set of associated raster bands, usually from one file.
Definition gdal_priv.h:348
virtual void FlushCache(bool bAtClosing=false)
Flush all write cached data to disk.
Definition gdaldataset.cpp:435
virtual int GetGCPCount()
Get number of GCPs.
Definition gdaldataset.cpp:1486
virtual CPLErr GetGeoTransform(double *padfTransform)
Fetch the affine transformation coefficients.
Definition gdaldataset.cpp:1105
virtual const OGRSpatialReference * GetGCPSpatialRef() const
Get output spatial reference system for GCPs.
Definition gdaldataset.cpp:1572
virtual void ClearStatistics()
Clear statistics.
Definition gdaldataset.cpp:8343
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
virtual CPLErr SetSpatialRef(const OGRSpatialReference *poSRS)
Set the spatial reference system for this dataset.
Definition gdaldataset.cpp:1026
virtual CPLErr SetGeoTransform(double *padfTransform)
Set the affine transformation coefficients.
Definition gdaldataset.cpp:1159
virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList, const OGRSpatialReference *poGCP_SRS)
Assign GCPs.
Definition gdaldataset.cpp:1736
virtual const OGRSpatialReference * GetSpatialRef() const
Fetch the spatial reference for this dataset.
Definition gdaldataset.cpp:921
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
void static void char ** GetMetadata(const char *pszDomain="") override
Fetch metadata.
Definition gdaldataset.cpp:4135
virtual const GDAL_GCP * GetGCPs()
Fetch GCPs.
Definition gdaldataset.cpp:1629
virtual char ** GetFileList(void)
Fetch files forming dataset.
Definition gdaldataset.cpp:2920
Class modeling a multi-dimensional array.
Definition gdal_priv.h:2646
virtual const char * GetMetadataItem(const char *pszName, const char *pszDomain="")
Fetch single metadata item.
Definition gdalmajorobject.cpp:341
virtual void SetDescription(const char *)
Set object description.
Definition gdalmajorobject.cpp:118
PAM dataset.
Definition gdal_pam.h:118
PAM raster band.
Definition gdal_pam.h:276
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_priv.h:1238
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:167
CPLErr
Error category.
Definition cpl_error.h:53
Definitions for CPL mini XML Parser/Serializer.
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition cpl_port.h:236
#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:1049
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1190
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition cpl_port.h:256
GDALColorInterp
Definition gdal.h:226
@ GCI_Undefined
Definition gdal.h:227
Document node structure.
Definition cpl_minixml.h:70
Ground Control Point.
Definition gdal.h:959