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
48 #define GCIF_GCPS 0x08
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)
74 #define GPF_DIRTY 0x01 // .pam file needs to be written on close
75 #define GPF_TRIED_READ_FAILED 0x02 // no need to keep trying to read .pam.
76 #define GPF_DISABLED 0x04 // do not try any PAM stuff.
77 #define GPF_AUXMODE 0x08 // store info in .aux (HFA) file.
78 #define GPF_NOSAVE 0x10 // do not try to save pam info.
88 class 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};
109 int bHasMetadata =
false;
123 int IsPamFilenameAPotentialSiblingFile();
129 GDALDatasetPamInfo *psPam =
nullptr;
131 virtual CPLXMLNode *SerializeToXML(
const char *);
134 virtual CPLErr TryLoadXML(
char **papszSiblingFiles =
nullptr);
135 virtual CPLErr TrySaveXML();
137 CPLErr TryLoadAux(
char **papszSiblingFiles =
nullptr);
140 virtual const char *BuildPamFilename();
142 void PamInitialize();
145 void SetPhysicalFilename(
const char *);
146 const char *GetPhysicalFilename();
147 void SetSubdatasetName(
const char *);
148 const char *GetSubdatasetName();
149 void SetDerivedDatasetName(
const char *);
162 void DeleteGeoTransform();
172 const char *pszDomain =
"")
override;
174 const char *pszDomain =
"")
override;
175 char **
GetMetadata(
const char *pszDomain =
"")
override;
177 const char *pszDomain =
"")
override;
186 CPLErr IBuildOverviews(
const char *pszResampling,
int nOverviews,
187 const int *panOverviewList,
int nListBands,
188 const int *panBandList, GDALProgressFunc pfnProgress,
194 GDALDatasetPamInfo *GetPamInfo()
202 void SetPamFlags(
int nValue)
214 constexpr
double GDAL_PAM_DEFAULT_NODATA_VALUE = 0;
218 constexpr int64_t GDAL_PAM_DEFAULT_NODATA_VALUE_INT64 =
219 (std::numeric_limits<int64_t>::min)();
220 constexpr uint64_t GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64 =
221 (std::numeric_limits<uint64_t>::max)();
231 struct GDALRasterBandPamInfo
235 bool bNoDataValueSet =
false;
236 bool bNoDataValueSetAsInt64 =
false;
237 bool bNoDataValueSetAsUInt64 =
false;
239 double dfNoDataValue = GDAL_PAM_DEFAULT_NODATA_VALUE;
240 int64_t nNoDataValueInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_INT64;
241 uint64_t nNoDataValueUInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64;
247 char *pszUnitType =
nullptr;
248 char **papszCategoryNames =
nullptr;
250 double dfOffset = 0.0;
251 double dfScale = 1.0;
253 int bHaveMinMax = FALSE;
257 int bHaveStats = FALSE;
265 bool bOffsetSet =
false;
266 bool bScaleSet =
false;
280 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath);
283 void PamInitialize();
285 void PamInitializeNoParent();
288 GDALRasterBandPamInfo *psPam =
nullptr;
320 double GetOffset(
int *pbSuccess =
nullptr)
override;
322 double GetScale(
int *pbSuccess =
nullptr)
override;
326 GUIntBig *panHistogram,
int bIncludeOutOfRange,
327 int bApproxOK, GDALProgressFunc,
328 void *pProgressData)
override;
331 GUIntBig **ppanHistogram,
int bForce,
332 GDALProgressFunc,
void *pProgressData)
override;
338 const char *pszDomain =
"")
override;
340 const char *pszDomain =
"")
override;
350 GDALRasterBandPamInfo *GetPamInfo()
358 void ResetNoDataValues();
370 class CPL_DLL GDALPamMultiDim
373 std::unique_ptr<Private> d;
379 explicit GDALPamMultiDim(
const std::string &osFilename);
380 virtual ~GDALPamMultiDim();
382 std::shared_ptr<OGRSpatialReference>
383 GetSpatialRef(
const std::string &osArrayFullName,
384 const std::string &osContext);
386 void SetSpatialRef(
const std::string &osArrayFullName,
387 const std::string &osContext,
390 CPLErr GetStatistics(
const std::string &osArrayFullName,
391 const std::string &osContext,
bool bApproxOK,
392 double *pdfMin,
double *pdfMax,
double *pdfMean,
393 double *pdfStdDev,
GUInt64 *pnValidCount);
395 void SetStatistics(
const std::string &osArrayFullName,
396 const std::string &osContext,
bool bApproxStats,
397 double dfMin,
double dfMax,
double dfMean,
398 double dfStdDev,
GUInt64 nValidCount);
400 void ClearStatistics();
402 void ClearStatistics(
const std::string &osArrayFullName,
403 const std::string &osContext);
405 static std::shared_ptr<GDALPamMultiDim>
406 GetPAM(
const std::shared_ptr<GDALMDArray> &poParent);
416 std::shared_ptr<GDALPamMultiDim> m_poPam;
419 GDALPamMDArray(
const std::string &osParentName,
const std::string &osName,
420 const std::shared_ptr<GDALPamMultiDim> &poPam,
421 const std::string &osContext = std::string());
423 bool SetStatistics(
bool bApproxStats,
double dfMin,
double dfMax,
424 double dfMean,
double dfStdDev,
GUInt64 nValidCount,
428 const std::shared_ptr<GDALPamMultiDim> &GetPAM()
const
434 double *pdfMax,
double *pdfMean,
double *padfStdDev,
435 GUInt64 *pnValidCount, GDALProgressFunc pfnProgress,
436 void *pProgressData)
override;
442 std::shared_ptr<OGRSpatialReference>
GetSpatialRef()
const override;
446 int CPL_DLL PamParseHistogram(
CPLXMLNode *psHistItem,
double *pdfMin,
447 double *pdfMax,
int *pnBuckets,
449 int *pbIncludeOutOfRange,
int *pbApproxOK);
451 double dfMin,
double dfMax,
453 int bIncludeOutOfRange,
455 CPLXMLNode CPL_DLL *PamHistogramToXMLTree(
double dfMin,
double dfMax,
456 int nBuckets,
GUIntBig *panHistogram,
457 int bIncludeOutOfRange,
int bApprox);
460 const char CPL_DLL *PamGetProxy(
const char *);
461 const char CPL_DLL *PamAllocateProxy(
const char *);
462 const char CPL_DLL *PamDeallocateProxy(
const char *);
463 void CPL_DLL PamCleanProxyDB(
void);
virtual CPLErr SetNoDataValue(double dfNoData)
Set the no data value for this band.
Definition: gdalrasterband.cpp:1911
virtual std::shared_ptr< OGRSpatialReference > GetSpatialRef() const
Return the spatial reference system object associated with the array.
Definition: gdalmultidim.cpp:2574
virtual GDALColorTable * GetColorTable()
Fetch the color table associated with band.
Definition: gdalrasterband.cpp:2460
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition: cpl_port.h:249
virtual const char * GetUnitType()
Return raster unit type.
Definition: gdalrasterband.cpp:3041
virtual CPLErr DeleteNoDataValue()
Remove the no data value for this band.
Definition: gdalrasterband.cpp:2113
virtual double GetOffset(int *pbSuccess=nullptr)
Fetch the raster value offset.
Definition: gdalrasterband.cpp:2840
virtual CPLErr SetColorTable(GDALColorTable *poCT)
Set the raster color table.
Definition: gdalrasterband.cpp:2509
virtual CPLErr GetDefaultHistogram(double *pdfMin, double *pdfMax, int *pnBuckets, GUIntBig **ppanHistogram, int bForce, GDALProgressFunc, void *pProgressData)
Fetch default raster histogram.
Definition: gdalrasterband.cpp:4005
virtual CPLErr GetStatistics(bool bApproxOK, bool bForce, double *pdfMin, double *pdfMax, double *pdfMean, double *padfStdDev, GUInt64 *pnValidCount, GDALProgressFunc pfnProgress, void *pProgressData)
Fetch statistics.
Definition: gdalmultidim.cpp:9422
PAM dataset.
Definition: gdal_pam.h:118
PAM raster band.
Definition: gdal_pam.h:274
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:166
virtual CPLErr SetDefaultHistogram(double dfMin, double dfMax, int nBuckets, GUIntBig *panHistogram)
Set default histogram.
Definition: gdalrasterband.cpp:6825
virtual CPLErr SetUnitType(const char *pszNewValue)
Set unit type.
Definition: gdalrasterband.cpp:3089
virtual GDALColorInterp GetColorInterpretation()
How should this band be interpreted as color?
Definition: gdalrasterband.cpp:2371
virtual char ** GetCategoryNames()
Fetch the list of category names for this raster.
Definition: gdalrasterband.cpp:1622
GDALColorInterp
Definition: gdal.h:226
virtual void SetDescription(const char *)
Set object description.
Definition: gdalmajorobject.cpp:118
Convenient string class based on std::string.
Definition: cpl_string.h:311
A single raster band (or channel).
Definition: gdal_priv.h:1270
void static void char ** GetMetadata(const char *pszDomain="") override
Fetch metadata.
Definition: gdaldataset.cpp:4362
Document node structure.
Definition: cpl_minixml.h:69
virtual const char * GetMetadataItem(const char *pszName, const char *pszDomain="")
Fetch single metadata item.
Definition: gdalmajorobject.cpp:341
virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList, const OGRSpatialReference *poGCP_SRS)
Assign GCPs.
Definition: gdaldataset.cpp:1914
virtual const GDAL_GCP * GetGCPs()
Fetch GCPs.
Definition: gdaldataset.cpp:1807
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:348
virtual CPLErr SetNoDataValueAsInt64(int64_t nNoData)
Set the no data value for this band.
Definition: gdalrasterband.cpp:1983
Class modeling a multi-dimensional array.
Definition: gdal_priv.h:2836
virtual CPLErr SetDefaultRAT(const GDALRasterAttributeTable *poRAT)
Set default Raster Attribute Table.
Definition: gdalrasterband.cpp:6972
virtual bool SetSpatialRef(const OGRSpatialReference *poSRS)
Assign a spatial reference system object to the array.
Definition: gdalmultidim.cpp:2560
virtual void ClearStatistics()
Clear statistics.
Definition: gdaldataset.cpp:8550
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1178
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:229
virtual const OGRSpatialReference * GetGCPSpatialRef() const
Get output spatial reference system for GCPs.
Definition: gdaldataset.cpp:1750
virtual CPLErr SetSpatialRef(const OGRSpatialReference *poSRS)
Set the spatial reference system for this dataset.
Definition: gdaldataset.cpp:1202
Ground Control Point.
Definition: gdal.h:1051
virtual int GetGCPCount()
Get number of GCPs.
Definition: gdaldataset.cpp:1665
@ GCI_Undefined
Definition: gdal.h:228
virtual CPLErr SetScale(double dfNewScale)
Set scaling ratio.
Definition: gdalrasterband.cpp:2995
virtual double GetNoDataValue(int *pbSuccess=nullptr)
Fetch the no data value for this band.
Definition: gdalrasterband.cpp:1726
virtual int64_t GetNoDataValueAsInt64(int *pbSuccess=nullptr)
Fetch the no data value for this band.
Definition: gdalrasterband.cpp:1782
virtual CPLErr SetNoDataValueAsUInt64(uint64_t nNoData)
Set the no data value for this band.
Definition: gdalrasterband.cpp:2055
virtual const OGRSpatialReference * GetSpatialRef() const
Fetch the spatial reference for this dataset.
Definition: gdaldataset.cpp:1097
virtual CPLErr SetGeoTransform(double *padfTransform)
Set the affine transformation coefficients.
Definition: gdaldataset.cpp:1335
virtual char ** GetFileList(void)
Fetch files forming dataset.
Definition: gdaldataset.cpp:3117
virtual GDALRasterAttributeTable * GetDefaultRAT()
Fetch default Raster Attribute Table.
Definition: gdalrasterband.cpp:6923
virtual double GetScale(int *pbSuccess=nullptr)
Fetch the raster value scale.
Definition: gdalrasterband.cpp:2946
virtual CPLErr SetColorInterpretation(GDALColorInterp eColorInterp)
Set color interpretation of a band.
Definition: gdalrasterband.cpp:2415
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
CPLErr
Error category.
Definition: cpl_error.h:52
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
virtual CPLErr SetCategoryNames(char **papszNames)
Set the category names for this band.
Definition: gdalrasterband.cpp:1670
virtual CPLErr GetHistogram(double dfMin, double dfMax, int nBuckets, GUIntBig *panHistogram, int bIncludeOutOfRange, int bApproxOK, GDALProgressFunc, void *pProgressData)
Compute raster histogram.
Definition: gdalrasterband.cpp:3342
virtual CPLErr GetGeoTransform(double *padfTransform)
Fetch the affine transformation coefficients.
Definition: gdaldataset.cpp:1281
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Definition: gdal_rat.h:47
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
virtual CPLErr SetOffset(double dfNewOffset)
Set scaling offset.
Definition: gdalrasterband.cpp:2889
#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:1042
virtual uint64_t GetNoDataValueAsUInt64(int *pbSuccess=nullptr)
Fetch the no data value for this band.
Definition: gdalrasterband.cpp:1843
A color table / palette.
Definition: gdal_priv.h:1121
virtual CPLErr FlushCache(bool bAtClosing=false)
Flush all write cached data to disk.
Definition: gdaldataset.cpp:556
virtual void ClearStatistics()
Clear statistics.
Definition: gdalmultidim.cpp:9673