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 const char *_GetProjectionRef()
override;
135 virtual const char *_GetGCPProjection()
override;
136 virtual CPLErr _SetProjection(
const char * pszProjection )
override;
137 virtual CPLErr _SetGCPs(
int nGCPCount,
const GDAL_GCP *pasGCPList,
138 const char *pszGCPProjection )
override;
140 virtual CPLXMLNode *SerializeToXML(
const char *);
143 virtual CPLErr TryLoadXML(
char **papszSiblingFiles =
nullptr);
144 virtual CPLErr TrySaveXML();
146 CPLErr TryLoadAux(
char **papszSiblingFiles =
nullptr);
149 virtual const char *BuildPamFilename();
151 void PamInitialize();
154 void SetPhysicalFilename(
const char * );
155 const char *GetPhysicalFilename();
156 void SetSubdatasetName(
const char *);
157 const char *GetSubdatasetName();
170 void DeleteGeoTransform();
180 const char * pszDomain =
"" )
override;
182 const char * pszValue,
183 const char * pszDomain =
"" )
override;
184 char **
GetMetadata(
const char * pszDomain =
"" )
override;
186 const char * pszDomain =
"" )
override;
195 CPLErr IBuildOverviews(
const char *pszResampling,
196 int nOverviews,
int *panOverviewList,
197 int nListBands,
int *panBandList,
198 GDALProgressFunc pfnProgress,
199 void * pProgressData )
override;
202 void MarkPamDirty() { nPamFlags |= GPF_DIRTY; }
203 GDALDatasetPamInfo *GetPamInfo() {
return psPam; }
204 int GetPamFlags() {
return nPamFlags; }
205 void SetPamFlags(
int nValue ) { nPamFlags = nValue; }
214 constexpr
double GDAL_PAM_DEFAULT_NODATA_VALUE = 0;
215 constexpr int64_t GDAL_PAM_DEFAULT_NODATA_VALUE_INT64 = std::numeric_limits<int64_t>::min();
216 constexpr uint64_t GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64 = std::numeric_limits<uint64_t>::max();
226 struct GDALRasterBandPamInfo {
229 bool bNoDataValueSet =
false;
230 bool bNoDataValueSetAsInt64 =
false;
231 bool bNoDataValueSetAsUInt64 =
false;
233 double dfNoDataValue = GDAL_PAM_DEFAULT_NODATA_VALUE;
234 int64_t nNoDataValueInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_INT64;
235 uint64_t nNoDataValueUInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64;
241 char *pszUnitType =
nullptr;
242 char **papszCategoryNames =
nullptr;
244 double dfOffset = 0.0;
245 double dfScale = 1.0;
247 int bHaveMinMax = FALSE;
251 int bHaveStats = FALSE;
259 bool bOffsetSet =
false;
260 bool bScaleSet =
false;
274 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath );
277 void PamInitialize();
279 void PamInitializeNoParent();
282 GDALRasterBandPamInfo *psPam =
nullptr;
314 double GetOffset(
int *pbSuccess =
nullptr )
override;
316 double GetScale(
int *pbSuccess =
nullptr )
override;
320 int nBuckets,
GUIntBig * panHistogram,
321 int bIncludeOutOfRange,
int bApproxOK,
322 GDALProgressFunc,
void *pProgressData )
override;
325 int *pnBuckets,
GUIntBig ** ppanHistogram,
327 GDALProgressFunc,
void *pProgressData)
override;
330 int nBuckets,
GUIntBig *panHistogram )
override;
333 const char * pszDomain =
"" )
override;
335 const char * pszValue,
336 const char * pszDomain =
"" )
override;
346 GDALRasterBandPamInfo *GetPamInfo() {
return psPam; }
351 void ResetNoDataValues();
363 class CPL_DLL GDALPamMultiDim
366 std::unique_ptr<Private> d;
372 explicit GDALPamMultiDim(
const std::string& osFilename);
373 virtual ~GDALPamMultiDim();
375 std::shared_ptr<OGRSpatialReference> GetSpatialRef(
const std::string& osArrayFullName);
377 void SetSpatialRef(
const std::string& osArrayFullName,
380 CPLErr GetStatistics(
const std::string& osArrayFullName,
382 double *pdfMin,
double *pdfMax,
383 double *pdfMean,
double *pdfStdDev,
386 void SetStatistics(
const std::string& osArrayFullName,
388 double dfMin,
double dfMax,
389 double dfMean,
double dfStdDev,
392 void ClearStatistics();
394 void ClearStatistics(
const std::string& osArrayFullName );
404 std::shared_ptr<GDALPamMultiDim> m_poPam;
407 GDALPamMDArray(
const std::string& osParentName,
408 const std::string& osName,
409 const std::shared_ptr<GDALPamMultiDim>& poPam);
411 bool SetStatistics(
bool bApproxStats,
412 double dfMin,
double dfMax,
413 double dfMean,
double dfStdDev,
414 GUInt64 nValidCount )
override;
417 const std::shared_ptr<GDALPamMultiDim>& GetPAM()
const {
return m_poPam; }
420 double *pdfMin,
double *pdfMax,
421 double *pdfMean,
double *padfStdDev,
423 GDALProgressFunc pfnProgress,
void *pProgressData )
override;
429 std::shared_ptr<OGRSpatialReference>
GetSpatialRef()
const override;
433 int CPL_DLL PamParseHistogram(
CPLXMLNode *psHistItem,
434 double *pdfMin,
double *pdfMax,
435 int *pnBuckets,
GUIntBig **ppanHistogram,
436 int *pbIncludeOutOfRange,
int *pbApproxOK );
438 PamFindMatchingHistogram(
CPLXMLNode *psSavedHistograms,
439 double dfMin,
double dfMax,
int nBuckets,
440 int bIncludeOutOfRange,
int bApproxOK );
442 PamHistogramToXMLTree(
double dfMin,
double dfMax,
443 int nBuckets,
GUIntBig * panHistogram,
444 int bIncludeOutOfRange,
int bApprox );
447 const char CPL_DLL * PamGetProxy(
const char * );
448 const char CPL_DLL * PamAllocateProxy(
const char * );
449 const char CPL_DLL * PamDeallocateProxy(
const char * );
450 void CPL_DLL PamCleanProxyDB(
void );
virtual CPLErr SetNoDataValue(double dfNoData)
Set the no data value for this band.
Definition: gdalrasterband.cpp:1814
virtual std::shared_ptr< OGRSpatialReference > GetSpatialRef() const
Return the spatial reference system object associated with the array.
Definition: gdalmultidim.cpp:2137
virtual GDALColorTable * GetColorTable()
Fetch the color table associated with band.
Definition: gdalrasterband.cpp:2338
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition: cpl_port.h:251
virtual const char * GetUnitType()
Return raster unit type.
Definition: gdalrasterband.cpp:2915
virtual CPLErr DeleteNoDataValue()
Remove the no data value for this band.
Definition: gdalrasterband.cpp:2016
virtual double GetOffset(int *pbSuccess=nullptr)
Fetch the raster value offset.
Definition: gdalrasterband.cpp:2713
virtual CPLErr SetColorTable(GDALColorTable *poCT)
Set the raster color table.
Definition: gdalrasterband.cpp:2387
virtual CPLErr GetDefaultHistogram(double *pdfMin, double *pdfMax, int *pnBuckets, GUIntBig **ppanHistogram, int bForce, GDALProgressFunc, void *pProgressData)
Fetch default raster histogram.
Definition: gdalrasterband.cpp:3757
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:7532
PAM dataset.
Definition: gdal_pam.h:120
PAM raster band.
Definition: gdal_pam.h:268
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:6012
virtual CPLErr SetUnitType(const char *pszNewValue)
Set unit type.
Definition: gdalrasterband.cpp:2963
virtual GDALColorInterp GetColorInterpretation()
How should this band be interpreted as color?
Definition: gdalrasterband.cpp:2246
virtual char ** GetCategoryNames()
Fetch the list of category names for this raster.
Definition: gdalrasterband.cpp:1525
GDALColorInterp
Definition: gdal.h:204
virtual void SetDescription(const char *)
Set object description.
Definition: gdalmajorobject.cpp:120
Convenient string class based on std::string.
Definition: cpl_string.h:319
A single raster band (or channel).
Definition: gdal_priv.h:1150
void static void char ** GetMetadata(const char *pszDomain="") override
Fetch metadata.
Definition: gdaldataset.cpp:4229
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:344
virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList, const OGRSpatialReference *poGCP_SRS)
Assign GCPs.
Definition: gdaldataset.cpp:1834
virtual const GDAL_GCP * GetGCPs()
Fetch GCPs.
Definition: gdaldataset.cpp:1729
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:339
virtual CPLErr SetNoDataValueAsInt64(int64_t nNoData)
Set the no data value for this band.
Definition: gdalrasterband.cpp:1886
Class modeling a multi-dimensional array.
Definition: gdal_priv.h:2415
virtual CPLErr SetDefaultRAT(const GDALRasterAttributeTable *poRAT)
Set default Raster Attribute Table.
Definition: gdalrasterband.cpp:6159
virtual bool SetSpatialRef(const OGRSpatialReference *poSRS)
Assign a spatial reference system object to the the array.
Definition: gdalmultidim.cpp:2123
virtual void ClearStatistics()
Clear statistics.
Definition: gdaldataset.cpp:8433
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:1646
virtual CPLErr SetSpatialRef(const OGRSpatialReference *poSRS)
Set the spatial reference system for this dataset.
Definition: gdaldataset.cpp:1059
Ground Control Point.
Definition: gdal.h:732
virtual int GetGCPCount()
Get number of GCPs.
Definition: gdaldataset.cpp:1549
@ GCI_Undefined
Definition: gdal.h:206
virtual CPLErr SetScale(double dfNewScale)
Set scaling ratio.
Definition: gdalrasterband.cpp:2868
virtual double GetNoDataValue(int *pbSuccess=nullptr)
Fetch the no data value for this band.
Definition: gdalrasterband.cpp:1629
virtual int64_t GetNoDataValueAsInt64(int *pbSuccess=nullptr)
Fetch the no data value for this band.
Definition: gdalrasterband.cpp:1685
virtual CPLErr SetNoDataValueAsUInt64(uint64_t nNoData)
Set the no data value for this band.
Definition: gdalrasterband.cpp:1958
virtual const OGRSpatialReference * GetSpatialRef() const
Fetch the spatial reference for this dataset.
Definition: gdaldataset.cpp:928
virtual CPLErr SetGeoTransform(double *padfTransform)
Set the affine transformation coefficients.
Definition: gdaldataset.cpp:1232
virtual char ** GetFileList(void)
Fetch files forming dataset.
Definition: gdaldataset.cpp:3026
virtual GDALRasterAttributeTable * GetDefaultRAT()
Fetch default Raster Attribute Table.
Definition: gdalrasterband.cpp:6111
virtual void FlushCache(bool bAtClosing=false)
Flush all write cached data to disk.
Definition: gdaldataset.cpp:435
virtual double GetScale(int *pbSuccess=nullptr)
Fetch the raster value scale.
Definition: gdalrasterband.cpp:2819
virtual CPLErr SetColorInterpretation(GDALColorInterp eColorInterp)
Set color interpretation of a band.
Definition: gdalrasterband.cpp:2291
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:1573
virtual CPLErr GetHistogram(double dfMin, double dfMax, int nBuckets, GUIntBig *panHistogram, int bIncludeOutOfRange, int bApproxOK, GDALProgressFunc, void *pProgressData)
Compute raster histogram.
Definition: gdalrasterband.cpp:3215
virtual CPLErr GetGeoTransform(double *padfTransform)
Fetch the affine transformation coefficients.
Definition: gdaldataset.cpp:1177
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:2762
#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:927
virtual uint64_t GetNoDataValueAsUInt64(int *pbSuccess=nullptr)
Fetch the no data value for this band.
Definition: gdalrasterband.cpp:1746
A color table / palette.
Definition: gdal_priv.h:1032
virtual void ClearStatistics()
Clear statistics.
Definition: gdalmultidim.cpp:7773