13#ifndef GDAL_PAM_H_INCLUDED
14#define GDAL_PAM_H_INCLUDED
18#if !defined(GDAL_COMPILATION) && \
19 !defined(GDAL_PAM_SKIP_OTHER_GDAL_HEADERS) && !defined(GDAL_4_0_COMPAT)
23#include "gdal_pam_multidim.h"
27#include "gdal_dataset.h"
28#include "gdal_rasterband.h"
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
57#define GCIF_COLORINTERP 0x020000
58#define GCIF_BAND_METADATA 0x040000
59#define GCIF_RAT 0x080000
60#define GCIF_MASK 0x100000
61#define GCIF_BAND_DESCRIPTION 0x200000
63#define GCIF_ONLY_IF_MISSING 0x10000000
64#define GCIF_PROCESS_BANDS 0x20000000
66#define GCIF_PAM_DEFAULT \
67 (GCIF_GEOTRANSFORM | GCIF_PROJECTION | GCIF_METADATA | GCIF_GCPS | \
68 GCIF_NODATA | GCIF_CATEGORYNAMES | GCIF_MINMAX | GCIF_SCALEOFFSET | \
69 GCIF_UNITTYPE | GCIF_COLORTABLE | GCIF_BAND_METADATA | GCIF_RAT | \
70 GCIF_MASK | GCIF_ONLY_IF_MISSING | GCIF_PROCESS_BANDS | \
71 GCIF_BAND_DESCRIPTION)
76#define GPF_TRIED_READ_FAILED 0x02
77#define GPF_DISABLED 0x04
78#define GPF_AUXMODE 0x08
79#define GPF_NOSAVE 0x10
89class GDALDatasetPamInfo
92 char *pszPamFilename =
nullptr;
94 std::vector<CPLXMLTreeCloser> m_apoOtherNodes{};
96 OGRSpatialReference *poSRS =
nullptr;
98 bool bHaveGeoTransform =
false;
99 GDALGeoTransform gt{};
101 std::vector<gdal::GCP> asGCPs{};
102 OGRSpatialReference *poGCP_SRS =
nullptr;
104 CPLString osPhysicalFilename{};
105 CPLString osSubdatasetName{};
106 CPLString osDerivedDatasetName{};
107 CPLString osAuxFilename{};
109 int bHasMetadata =
false;
121 friend class GDALPamRasterBand;
124 int IsPamFilenameAPotentialSiblingFile();
127 GDALPamDataset(
void);
130 GDALDatasetPamInfo *psPam =
nullptr;
132 virtual CPLXMLNode *SerializeToXML(
const char *);
136 virtual CPLErr TrySaveXML();
141 virtual const char *BuildPamFilename();
143 void PamInitialize();
146 void SetPhysicalFilename(
const char *);
147 const char *GetPhysicalFilename();
148 void SetSubdatasetName(
const char *);
149 const char *GetSubdatasetName();
150 void SetDerivedDatasetName(
const char *);
154 ~GDALPamDataset()
override;
176 const char *pszDomain =
"")
override;
178 const char *pszDomain =
"")
override;
179 char **
GetMetadata(
const char *pszDomain =
"")
override;
181 const char *pszDomain =
"")
override;
190 CPLErr IBuildOverviews(
const char *pszResampling,
int nOverviews,
191 const int *panOverviewList,
int nListBands,
192 const int *panBandList, GDALProgressFunc pfnProgress,
199 GDALDatasetPamInfo *GetPamInfo()
209 void SetPamFlags(
int nValue)
220 std::string m_osOverviewFile{};
225constexpr double GDAL_PAM_DEFAULT_NODATA_VALUE = 0;
229constexpr int64_t GDAL_PAM_DEFAULT_NODATA_VALUE_INT64 =
230 (std::numeric_limits<int64_t>::min)();
231constexpr uint64_t GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64 =
232 (std::numeric_limits<uint64_t>::max)();
242struct GDALRasterBandPamInfo
246 bool bNoDataValueSet =
false;
247 bool bNoDataValueSetAsInt64 =
false;
248 bool bNoDataValueSetAsUInt64 =
false;
250 double dfNoDataValue = GDAL_PAM_DEFAULT_NODATA_VALUE;
251 int64_t nNoDataValueInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_INT64;
252 uint64_t nNoDataValueUInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64;
258 char *pszUnitType =
nullptr;
259 char **papszCategoryNames =
nullptr;
261 double dfOffset = 0.0;
262 double dfScale = 1.0;
264 int bHaveMinMax = FALSE;
268 int bHaveStats = FALSE;
276 bool bOffsetSet =
false;
277 bool bScaleSet =
false;
279 void CopyFrom(
const GDALRasterBandPamInfo &sOther);
290 friend class GDALPamDataset;
294 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath);
297 void PamInitialize();
299 void PamInitializeNoParent();
302 GDALRasterBandPamInfo *psPam =
nullptr;
308 explicit GDALPamRasterBand(
int bForceCachedIO);
310 ~GDALPamRasterBand()
override;
334 double GetOffset(
int *pbSuccess =
nullptr)
override;
336 double GetScale(
int *pbSuccess =
nullptr)
override;
340 GUIntBig *panHistogram,
int bIncludeOutOfRange,
341 int bApproxOK, GDALProgressFunc,
342 void *pProgressData)
override;
345 GUIntBig **ppanHistogram,
int bForce,
346 GDALProgressFunc,
void *pProgressData)
override;
352 const char *pszDomain =
"")
override;
354 const char *pszDomain =
"")
override;
364 GDALRasterBandPamInfo *GetPamInfo()
373 void ResetNoDataValues();
379int CPL_DLL PamParseHistogram(
CPLXMLNode *psHistItem,
double *pdfMin,
380 double *pdfMax,
int *pnBuckets,
382 int *pbIncludeOutOfRange,
int *pbApproxOK);
384 double dfMin,
double dfMax,
386 int bIncludeOutOfRange,
388CPLXMLNode CPL_DLL *PamHistogramToXMLTree(
double dfMin,
double dfMax,
389 int nBuckets,
GUIntBig *panHistogram,
390 int bIncludeOutOfRange,
int bApprox);
393const char CPL_DLL *PamGetProxy(
const char *);
394const char CPL_DLL *PamAllocateProxy(
const char *);
395const char CPL_DLL *PamDeallocateProxy(
const char *);
396void CPL_DLL PamCleanProxyDB(
void);
A color table / palette.
Definition gdal_colortable.h:32
A set of associated raster bands, usually from one file.
Definition gdal_dataset.h:76
virtual const OGRSpatialReference * GetSpatialRefRasterOnly() const
Fetch the spatial reference for this dataset (ignoring vector layers).
Definition gdaldataset.cpp:1315
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
virtual CPLErr Close()
Do final cleanup before a dataset is destroyed.
Definition gdaldataset.cpp:457
virtual int GetGCPCount()
Get number of GCPs.
Definition gdaldataset.cpp:1983
virtual const OGRSpatialReference * GetGCPSpatialRef() const
Get output spatial reference system for GCPs.
Definition gdaldataset.cpp:2073
virtual CPLErr SetSpatialRef(const OGRSpatialReference *poSRS)
Set the spatial reference system for this dataset.
Definition gdaldataset.cpp:1425
virtual void ClearStatistics()
Clear statistics.
Definition gdaldataset.cpp:9777
virtual CPLErr GetGeoTransform(GDALGeoTransform >) const
Fetch the affine transformation coefficients.
Definition gdaldataset.cpp:1506
virtual CPLErr FlushCache(bool bAtClosing=false)
Flush all write cached data to disk.
Definition gdaldataset.cpp:600
virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList, const OGRSpatialReference *poGCP_SRS)
Assign GCPs.
Definition gdaldataset.cpp:2237
virtual const OGRSpatialReference * GetSpatialRef() const
Fetch the spatial reference for this dataset.
Definition gdaldataset.cpp:1251
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
void static void char ** GetMetadata(const char *pszDomain="") override
Fetch metadata.
Definition gdaldataset.cpp:4951
virtual const GDAL_GCP * GetGCPs()
Fetch GCPs.
Definition gdaldataset.cpp:2130
virtual char ** GetFileList(void)
Fetch files forming dataset.
Definition gdaldataset.cpp:3562
virtual CPLErr SetGeoTransform(const GDALGeoTransform >)
Set the affine transformation coefficients.
Definition gdaldataset.cpp:1594
virtual const char * GetMetadataItem(const char *pszName, const char *pszDomain="")
Fetch single metadata item.
Definition gdalmajorobject.cpp:322
virtual void SetDescription(const char *)
Set object description.
Definition gdalmajorobject.cpp:102
PAM dataset.
Definition gdal_pam.h:120
void DeleteGeoTransform()
Remove geotransform from PAM.
Definition gdalpamdataset.cpp:1450
PAM raster band.
Definition gdal_pam.h:289
GDALColorInterp GetColorInterpretation() override
How should this band be interpreted as color?
Definition gdalpamrasterband.cpp:1257
const char * GetUnitType() override
Return raster unit type.
Definition gdalpamrasterband.cpp:1116
CPLErr SetDefaultRAT(const GDALRasterAttributeTable *) override
Set default Raster Attribute Table.
Definition gdalpamrasterband.cpp:1598
CPLErr SetColorTable(GDALColorTable *) override
Set the raster color table.
Definition gdalpamrasterband.cpp:1207
double GetNoDataValue(int *pbSuccess=nullptr) override
Fetch the no data value for this band.
Definition gdalpamrasterband.cpp:943
CPLErr SetScale(double) override
Set scaling ratio.
Definition gdalpamrasterband.cpp:1094
CPLErr GetHistogram(double dfMin, double dfMax, int nBuckets, GUIntBig *panHistogram, int bIncludeOutOfRange, int bApproxOK, GDALProgressFunc, void *pProgressData) override
Compute raster histogram.
Definition gdalpamrasterband.cpp:1428
double GetOffset(int *pbSuccess=nullptr) override
Fetch the raster value offset.
Definition gdalpamrasterband.cpp:1039
GDALColorTable * GetColorTable() override
Fetch the color table associated with band.
Definition gdalpamrasterband.cpp:1194
int64_t GetNoDataValueAsInt64(int *pbSuccess=nullptr) override
Fetch the no data value for this band.
Definition gdalpamrasterband.cpp:973
CPLErr SetCategoryNames(char **) override
Set the category names for this band.
Definition gdalpamrasterband.cpp:1176
CPLErr SetOffset(double) override
Set scaling offset.
Definition gdalpamrasterband.cpp:1055
CPLErr SetNoDataValue(double) override
Set the no data value for this band.
Definition gdalpamrasterband.cpp:861
CPLErr SetNoDataValueAsUInt64(uint64_t nNoData) override
Set the no data value for this band.
Definition gdalpamrasterband.cpp:903
CPLErr SetColorInterpretation(GDALColorInterp) override
Set color interpretation of a band.
Definition gdalpamrasterband.cpp:1236
CPLErr SetDefaultHistogram(double dfMin, double dfMax, int nBuckets, GUIntBig *panHistogram) override
Set default histogram.
Definition gdalpamrasterband.cpp:1497
GDALRasterAttributeTable * GetDefaultRAT() override
Fetch default Raster Attribute Table.
Definition gdalpamrasterband.cpp:1583
CPLErr SetUnitType(const char *) override
Set unit type.
Definition gdalpamrasterband.cpp:1132
CPLErr GetDefaultHistogram(double *pdfMin, double *pdfMax, int *pnBuckets, GUIntBig **ppanHistogram, int bForce, GDALProgressFunc, void *pProgressData) override
Fetch default raster histogram.
Definition gdalpamrasterband.cpp:1548
CPLErr DeleteNoDataValue() override
Remove the no data value for this band.
Definition gdalpamrasterband.cpp:924
uint64_t GetNoDataValueAsUInt64(int *pbSuccess=nullptr) override
Fetch the no data value for this band.
Definition gdalpamrasterband.cpp:1006
char ** GetCategoryNames() override
Fetch the list of category names for this raster.
Definition gdalpamrasterband.cpp:1163
CPLErr SetNoDataValueAsInt64(int64_t nNoData) override
Set the no data value for this band.
Definition gdalpamrasterband.cpp:882
double GetScale(int *pbSuccess=nullptr) override
Fetch the raster value scale.
Definition gdalpamrasterband.cpp:1078
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition gdal_rat.h:48
GDALRasterBand()
Definition gdalrasterband.cpp:59
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:152
CPLErr
Error category.
Definition cpl_error.h:37
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:208
#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:936
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
GDALColorInterp
Types of color interpretation for raster bands.
Definition gdal.h:270
@ GCI_Undefined
Definition gdal.h:271
This file is legacy since GDAL 3.12, but will be kept at least in the whole GDAL 3....
Document node structure.
Definition cpl_minixml.h:54
Ground Control Point.
Definition gdal.h:1221