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 (GCIF_GEOTRANSFORM | GCIF_PROJECTION | \
66 GCIF_METADATA | GCIF_GCPS | \
67 GCIF_NODATA | GCIF_CATEGORYNAMES | \
68 GCIF_MINMAX | GCIF_SCALEOFFSET | \
69 GCIF_UNITTYPE | GCIF_COLORTABLE | \
70 GCIF_COLORINTERP | GCIF_BAND_METADATA | \
71 GCIF_RAT | GCIF_MASK | \
72 GCIF_ONLY_IF_MISSING | GCIF_PROCESS_BANDS|\
73 GCIF_BAND_DESCRIPTION)
77 #define GPF_DIRTY 0x01 // .pam file needs to be written on close
78 #define GPF_TRIED_READ_FAILED 0x02 // no need to keep trying to read .pam.
79 #define GPF_DISABLED 0x04 // do not try any PAM stuff.
80 #define GPF_AUXMODE 0x08 // store info in .aux (HFA) file.
81 #define GPF_NOSAVE 0x10 // do not try to save pam info.
91 class GDALDatasetPamInfo
94 char *pszPamFilename =
nullptr;
96 std::vector<CPLXMLTreeCloser> m_apoOtherNodes{};
100 int bHaveGeoTransform =
false;
101 double adfGeoTransform[6]{0,0,0,0,0,0};
111 int bHasMetadata =
false;
125 int IsPamFilenameAPotentialSiblingFile();
132 GDALDatasetPamInfo *psPam =
nullptr;
134 virtual CPLXMLNode *SerializeToXML(
const char *);
137 virtual CPLErr TryLoadXML(
char **papszSiblingFiles =
nullptr);
138 virtual CPLErr TrySaveXML();
140 CPLErr TryLoadAux(
char **papszSiblingFiles =
nullptr);
143 virtual const char *BuildPamFilename();
145 void PamInitialize();
148 void SetPhysicalFilename(
const char * );
149 const char *GetPhysicalFilename();
150 void SetSubdatasetName(
const char *);
151 const char *GetSubdatasetName();
164 void DeleteGeoTransform();
174 const char * pszDomain =
"" )
override;
176 const char * pszValue,
177 const char * pszDomain =
"" )
override;
178 char **
GetMetadata(
const char * pszDomain =
"" )
override;
180 const char * pszDomain =
"" )
override;
189 CPLErr IBuildOverviews(
const char *pszResampling,
190 int nOverviews,
const int *panOverviewList,
191 int nListBands,
const int *panBandList,
192 GDALProgressFunc pfnProgress,
193 void * pProgressData,
197 void MarkPamDirty() { nPamFlags |= GPF_DIRTY; }
198 GDALDatasetPamInfo *GetPamInfo() {
return psPam; }
199 int GetPamFlags() {
return nPamFlags; }
200 void SetPamFlags(
int nValue ) { nPamFlags = nValue; }
209 constexpr
double GDAL_PAM_DEFAULT_NODATA_VALUE = 0;
210 constexpr int64_t GDAL_PAM_DEFAULT_NODATA_VALUE_INT64 = std::numeric_limits<int64_t>::min();
211 constexpr uint64_t GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64 = std::numeric_limits<uint64_t>::max();
221 struct GDALRasterBandPamInfo {
224 bool bNoDataValueSet =
false;
225 bool bNoDataValueSetAsInt64 =
false;
226 bool bNoDataValueSetAsUInt64 =
false;
228 double dfNoDataValue = GDAL_PAM_DEFAULT_NODATA_VALUE;
229 int64_t nNoDataValueInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_INT64;
230 uint64_t nNoDataValueUInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64;
236 char *pszUnitType =
nullptr;
237 char **papszCategoryNames =
nullptr;
239 double dfOffset = 0.0;
240 double dfScale = 1.0;
242 int bHaveMinMax = FALSE;
246 int bHaveStats = FALSE;
254 bool bOffsetSet =
false;
255 bool bScaleSet =
false;
269 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath );
272 void PamInitialize();
274 void PamInitializeNoParent();
277 GDALRasterBandPamInfo *psPam =
nullptr;
309 double GetOffset(
int *pbSuccess =
nullptr )
override;
311 double GetScale(
int *pbSuccess =
nullptr )
override;
315 int nBuckets,
GUIntBig * panHistogram,
316 int bIncludeOutOfRange,
int bApproxOK,
317 GDALProgressFunc,
void *pProgressData )
override;
320 int *pnBuckets,
GUIntBig ** ppanHistogram,
322 GDALProgressFunc,
void *pProgressData)
override;
325 int nBuckets,
GUIntBig *panHistogram )
override;
328 const char * pszDomain =
"" )
override;
330 const char * pszValue,
331 const char * pszDomain =
"" )
override;
341 GDALRasterBandPamInfo *GetPamInfo() {
return psPam; }
346 void ResetNoDataValues();
358 class CPL_DLL GDALPamMultiDim
361 std::unique_ptr<Private> d;
367 explicit GDALPamMultiDim(
const std::string& osFilename);
368 virtual ~GDALPamMultiDim();
370 std::shared_ptr<OGRSpatialReference> GetSpatialRef(
const std::string& osArrayFullName);
372 void SetSpatialRef(
const std::string& osArrayFullName,
375 CPLErr GetStatistics(
const std::string& osArrayFullName,
377 double *pdfMin,
double *pdfMax,
378 double *pdfMean,
double *pdfStdDev,
381 void SetStatistics(
const std::string& osArrayFullName,
383 double dfMin,
double dfMax,
384 double dfMean,
double dfStdDev,
387 void ClearStatistics();
389 void ClearStatistics(
const std::string& osArrayFullName );
399 std::shared_ptr<GDALPamMultiDim> m_poPam;
402 GDALPamMDArray(
const std::string& osParentName,
403 const std::string& osName,
404 const std::shared_ptr<GDALPamMultiDim>& poPam);
406 bool SetStatistics(
bool bApproxStats,
407 double dfMin,
double dfMax,
408 double dfMean,
double dfStdDev,
409 GUInt64 nValidCount )
override;
412 const std::shared_ptr<GDALPamMultiDim>& GetPAM()
const {
return m_poPam; }
415 double *pdfMin,
double *pdfMax,
416 double *pdfMean,
double *padfStdDev,
418 GDALProgressFunc pfnProgress,
void *pProgressData )
override;
424 std::shared_ptr<OGRSpatialReference>
GetSpatialRef()
const override;
428 int CPL_DLL PamParseHistogram(
CPLXMLNode *psHistItem,
429 double *pdfMin,
double *pdfMax,
430 int *pnBuckets,
GUIntBig **ppanHistogram,
431 int *pbIncludeOutOfRange,
int *pbApproxOK );
433 PamFindMatchingHistogram(
CPLXMLNode *psSavedHistograms,
434 double dfMin,
double dfMax,
int nBuckets,
435 int bIncludeOutOfRange,
int bApproxOK );
437 PamHistogramToXMLTree(
double dfMin,
double dfMax,
438 int nBuckets,
GUIntBig * panHistogram,
439 int bIncludeOutOfRange,
int bApprox );
442 const char CPL_DLL * PamGetProxy(
const char * );
443 const char CPL_DLL * PamAllocateProxy(
const char * );
444 const char CPL_DLL * PamDeallocateProxy(
const char * );
445 void CPL_DLL PamCleanProxyDB(
void );
virtual CPLErr SetNoDataValue(double dfNoData)
Set the no data value for this band.
Definition: gdalrasterband.cpp:1850
virtual std::shared_ptr< OGRSpatialReference > GetSpatialRef() const
Return the spatial reference system object associated with the array.
Definition: gdalmultidim.cpp:2183
virtual GDALColorTable * GetColorTable()
Fetch the color table associated with band.
Definition: gdalrasterband.cpp:2374
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition: cpl_port.h:251
virtual const char * GetUnitType()
Return raster unit type.
Definition: gdalrasterband.cpp:2954
virtual CPLErr DeleteNoDataValue()
Remove the no data value for this band.
Definition: gdalrasterband.cpp:2052
virtual double GetOffset(int *pbSuccess=nullptr)
Fetch the raster value offset.
Definition: gdalrasterband.cpp:2752
virtual CPLErr SetColorTable(GDALColorTable *poCT)
Set the raster color table.
Definition: gdalrasterband.cpp:2423
virtual CPLErr GetDefaultHistogram(double *pdfMin, double *pdfMax, int *pnBuckets, GUIntBig **ppanHistogram, int bForce, GDALProgressFunc, void *pProgressData)
Fetch default raster histogram.
Definition: gdalrasterband.cpp:3825
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:7941
PAM dataset.
Definition: gdal_pam.h:120
PAM raster band.
Definition: gdal_pam.h:263
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:157
virtual CPLErr SetDefaultHistogram(double dfMin, double dfMax, int nBuckets, GUIntBig *panHistogram)
Set default histogram.
Definition: gdalrasterband.cpp:6488
virtual CPLErr SetUnitType(const char *pszNewValue)
Set unit type.
Definition: gdalrasterband.cpp:3002
virtual GDALColorInterp GetColorInterpretation()
How should this band be interpreted as color?
Definition: gdalrasterband.cpp:2282
virtual char ** GetCategoryNames()
Fetch the list of category names for this raster.
Definition: gdalrasterband.cpp:1561
GDALColorInterp
Definition: gdal.h:204
virtual void SetDescription(const char *)
Set object description.
Definition: gdalmajorobject.cpp:119
Convenient string class based on std::string.
Definition: cpl_string.h:320
A single raster band (or channel).
Definition: gdal_priv.h:1179
void static void char ** GetMetadata(const char *pszDomain="") override
Fetch metadata.
Definition: gdaldataset.cpp:4113
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:343
virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList, const OGRSpatialReference *poGCP_SRS)
Assign GCPs.
Definition: gdaldataset.cpp:1714
virtual const GDAL_GCP * GetGCPs()
Fetch GCPs.
Definition: gdaldataset.cpp:1609
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:342
virtual CPLErr SetNoDataValueAsInt64(int64_t nNoData)
Set the no data value for this band.
Definition: gdalrasterband.cpp:1922
Class modeling a multi-dimensional array.
Definition: gdal_priv.h:2456
virtual CPLErr SetDefaultRAT(const GDALRasterAttributeTable *poRAT)
Set default Raster Attribute Table.
Definition: gdalrasterband.cpp:6635
virtual bool SetSpatialRef(const OGRSpatialReference *poSRS)
Assign a spatial reference system object to the the array.
Definition: gdalmultidim.cpp:2169
virtual void ClearStatistics()
Clear statistics.
Definition: gdaldataset.cpp:8321
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1056
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:233
virtual const OGRSpatialReference * GetGCPSpatialRef() const
Get output spatial reference system for GCPs.
Definition: gdaldataset.cpp:1551
virtual CPLErr SetSpatialRef(const OGRSpatialReference *poSRS)
Set the spatial reference system for this dataset.
Definition: gdaldataset.cpp:1017
Ground Control Point.
Definition: gdal.h:892
virtual int GetGCPCount()
Get number of GCPs.
Definition: gdaldataset.cpp:1468
@ GCI_Undefined
Definition: gdal.h:206
virtual CPLErr SetScale(double dfNewScale)
Set scaling ratio.
Definition: gdalrasterband.cpp:2907
virtual double GetNoDataValue(int *pbSuccess=nullptr)
Fetch the no data value for this band.
Definition: gdalrasterband.cpp:1665
virtual int64_t GetNoDataValueAsInt64(int *pbSuccess=nullptr)
Fetch the no data value for this band.
Definition: gdalrasterband.cpp:1721
virtual CPLErr SetNoDataValueAsUInt64(uint64_t nNoData)
Set the no data value for this band.
Definition: gdalrasterband.cpp:1994
virtual const OGRSpatialReference * GetSpatialRef() const
Fetch the spatial reference for this dataset.
Definition: gdaldataset.cpp:911
virtual CPLErr SetGeoTransform(double *padfTransform)
Set the affine transformation coefficients.
Definition: gdaldataset.cpp:1151
virtual char ** GetFileList(void)
Fetch files forming dataset.
Definition: gdaldataset.cpp:2907
virtual GDALRasterAttributeTable * GetDefaultRAT()
Fetch default Raster Attribute Table.
Definition: gdalrasterband.cpp:6587
virtual void FlushCache(bool bAtClosing=false)
Flush all write cached data to disk.
Definition: gdaldataset.cpp:434
virtual double GetScale(int *pbSuccess=nullptr)
Fetch the raster value scale.
Definition: gdalrasterband.cpp:2858
virtual CPLErr SetColorInterpretation(GDALColorInterp eColorInterp)
Set color interpretation of a band.
Definition: gdalrasterband.cpp:2327
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:1609
virtual CPLErr GetHistogram(double dfMin, double dfMax, int nBuckets, GUIntBig *panHistogram, int bIncludeOutOfRange, int bApproxOK, GDALProgressFunc, void *pProgressData)
Compute raster histogram.
Definition: gdalrasterband.cpp:3254
virtual CPLErr GetGeoTransform(double *padfTransform)
Fetch the affine transformation coefficients.
Definition: gdaldataset.cpp:1096
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
Definition: gdal_rat.h:47
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
virtual CPLErr SetOffset(double dfNewOffset)
Set scaling offset.
Definition: gdalrasterband.cpp:2801
#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:930
virtual uint64_t GetNoDataValueAsUInt64(int *pbSuccess=nullptr)
Fetch the no data value for this band.
Definition: gdalrasterband.cpp:1782
A color table / palette.
Definition: gdal_priv.h:1044
virtual void ClearStatistics()
Clear statistics.
Definition: gdalmultidim.cpp:8182