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
75 #define GPF_TRIED_READ_FAILED 0x02
76 #define GPF_DISABLED 0x04
77 #define GPF_AUXMODE 0x08
78 #define GPF_NOSAVE 0x10
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};
100 std::vector<gdal::GCP> asGCPs{};
108 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,
195 GDALDatasetPamInfo *GetPamInfo()
205 void SetPamFlags(
int nValue)
218 constexpr
double GDAL_PAM_DEFAULT_NODATA_VALUE = 0;
222 constexpr int64_t GDAL_PAM_DEFAULT_NODATA_VALUE_INT64 =
223 (std::numeric_limits<int64_t>::min)();
224 constexpr uint64_t GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64 =
225 (std::numeric_limits<uint64_t>::max)();
235 struct GDALRasterBandPamInfo
239 bool bNoDataValueSet =
false;
240 bool bNoDataValueSetAsInt64 =
false;
241 bool bNoDataValueSetAsUInt64 =
false;
243 double dfNoDataValue = GDAL_PAM_DEFAULT_NODATA_VALUE;
244 int64_t nNoDataValueInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_INT64;
245 uint64_t nNoDataValueUInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64;
251 char *pszUnitType =
nullptr;
252 char **papszCategoryNames =
nullptr;
254 double dfOffset = 0.0;
255 double dfScale = 1.0;
257 int bHaveMinMax = FALSE;
261 int bHaveStats = FALSE;
269 bool bOffsetSet =
false;
270 bool bScaleSet =
false;
285 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath);
288 void PamInitialize();
290 void PamInitializeNoParent();
293 GDALRasterBandPamInfo *psPam =
nullptr;
305 CPLErr SetNoDataValue(
double)
override;
306 CPLErr SetNoDataValueAsInt64(int64_t nNoData)
override;
307 CPLErr SetNoDataValueAsUInt64(uint64_t nNoData)
override;
308 double GetNoDataValue(
int *pbSuccess =
nullptr)
override;
309 int64_t GetNoDataValueAsInt64(
int *pbSuccess =
nullptr)
override;
310 uint64_t GetNoDataValueAsUInt64(
int *pbSuccess =
nullptr)
override;
311 CPLErr DeleteNoDataValue()
override;
319 const char *GetUnitType()
override;
320 CPLErr SetUnitType(
const char *)
override;
322 char **GetCategoryNames()
override;
323 CPLErr SetCategoryNames(
char **)
override;
325 double GetOffset(
int *pbSuccess =
nullptr)
override;
326 CPLErr SetOffset(
double)
override;
327 double GetScale(
int *pbSuccess =
nullptr)
override;
328 CPLErr SetScale(
double)
override;
330 CPLErr GetHistogram(
double dfMin,
double dfMax,
int nBuckets,
331 GUIntBig *panHistogram,
int bIncludeOutOfRange,
332 int bApproxOK, GDALProgressFunc,
333 void *pProgressData)
override;
335 CPLErr GetDefaultHistogram(
double *pdfMin,
double *pdfMax,
int *pnBuckets,
336 GUIntBig **ppanHistogram,
int bForce,
337 GDALProgressFunc,
void *pProgressData)
override;
339 CPLErr SetDefaultHistogram(
double dfMin,
double dfMax,
int nBuckets,
343 const char *pszDomain =
"")
override;
345 const char *pszDomain =
"")
override;
355 GDALRasterBandPamInfo *GetPamInfo()
364 void ResetNoDataValues();
376 class CPL_DLL GDALPamMultiDim
379 std::unique_ptr<Private> d;
385 explicit GDALPamMultiDim(
const std::string &osFilename);
386 virtual ~GDALPamMultiDim();
388 std::shared_ptr<OGRSpatialReference>
390 const std::string &osContext);
393 const std::string &osContext,
396 CPLErr GetStatistics(
const std::string &osArrayFullName,
397 const std::string &osContext,
bool bApproxOK,
398 double *pdfMin,
double *pdfMax,
double *pdfMean,
399 double *pdfStdDev,
GUInt64 *pnValidCount);
401 void SetStatistics(
const std::string &osArrayFullName,
402 const std::string &osContext,
bool bApproxStats,
403 double dfMin,
double dfMax,
double dfMean,
404 double dfStdDev,
GUInt64 nValidCount);
409 const std::string &osContext);
411 static std::shared_ptr<GDALPamMultiDim>
412 GetPAM(
const std::shared_ptr<GDALMDArray> &poParent);
422 std::shared_ptr<GDALPamMultiDim> m_poPam;
425 GDALPamMDArray(
const std::string &osParentName,
const std::string &osName,
426 const std::shared_ptr<GDALPamMultiDim> &poPam,
427 const std::string &osContext = std::string());
429 bool SetStatistics(
bool bApproxStats,
double dfMin,
double dfMax,
430 double dfMean,
double dfStdDev,
GUInt64 nValidCount,
434 const std::shared_ptr<GDALPamMultiDim> &GetPAM()
const
439 CPLErr GetStatistics(
bool bApproxOK,
bool bForce,
double *pdfMin,
440 double *pdfMax,
double *pdfMean,
double *padfStdDev,
441 GUInt64 *pnValidCount, GDALProgressFunc pfnProgress,
442 void *pProgressData)
override;
448 std::shared_ptr<OGRSpatialReference>
GetSpatialRef()
const override;
452 int CPL_DLL PamParseHistogram(
CPLXMLNode *psHistItem,
double *pdfMin,
453 double *pdfMax,
int *pnBuckets,
455 int *pbIncludeOutOfRange,
int *pbApproxOK);
457 double dfMin,
double dfMax,
459 int bIncludeOutOfRange,
461 CPLXMLNode CPL_DLL *PamHistogramToXMLTree(
double dfMin,
double dfMax,
462 int nBuckets,
GUIntBig *panHistogram,
463 int bIncludeOutOfRange,
int bApprox);
466 const char CPL_DLL *PamGetProxy(
const char *);
467 const char CPL_DLL *PamAllocateProxy(
const char *);
468 const char CPL_DLL *PamDeallocateProxy(
const char *);
469 void CPL_DLL PamCleanProxyDB(
void);
Convenient string class based on std::string.
Definition: cpl_string.h:320
A color table / palette.
Definition: gdal_priv.h:1348
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:503
virtual int GetGCPCount()
Get number of GCPs.
Definition: gdaldataset.cpp:1773
virtual CPLErr GetGeoTransform(double *padfTransform)
Fetch the affine transformation coefficients.
Definition: gdaldataset.cpp:1379
virtual const OGRSpatialReference * GetGCPSpatialRef() const
Get output spatial reference system for GCPs.
Definition: gdaldataset.cpp:1858
virtual void ClearStatistics()
Clear statistics.
Definition: gdaldataset.cpp:8988
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:1300
virtual CPLErr FlushCache(bool bAtClosing=false)
Flush all write cached data to disk.
Definition: gdaldataset.cpp:561
virtual CPLErr SetGeoTransform(double *padfTransform)
Set the affine transformation coefficients.
Definition: gdaldataset.cpp:1433
virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList, const OGRSpatialReference *poGCP_SRS)
Assign GCPs.
Definition: gdaldataset.cpp:2022
virtual const OGRSpatialReference * GetSpatialRef() const
Fetch the spatial reference for this dataset.
Definition: gdaldataset.cpp:1195
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:4593
virtual const GDAL_GCP * GetGCPs()
Fetch GCPs.
Definition: gdaldataset.cpp:1915
virtual char ** GetFileList(void)
Fetch files forming dataset.
Definition: gdaldataset.cpp:3225
Class modeling a multi-dimensional array.
Definition: gdal_priv.h:3345
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:119
PAM raster band.
Definition: gdal_pam.h:280
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:1504
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:169
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:218
#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
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1183
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition: cpl_port.h:238
GDALColorInterp
Definition: gdal.h:227
@ GCI_Undefined
Definition: gdal.h:228
Document node structure.
Definition: cpl_minixml.h:71
Ground Control Point.
Definition: gdal.h:1075