00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef GDAL_PAM_H_INCLUDED
00052 #define GDAL_PAM_H_INCLUDED
00053
00054 #include "gdal_priv.h"
00055 #include "cpl_minixml.h"
00056
00057 class GDALPamRasterBand;
00058
00059
00060
00061 #define GCIF_GEOTRANSFORM 0x01
00062 #define GCIF_PROJECTION 0x02
00063 #define GCIF_METADATA 0x04
00064 #define GCIF_GCPS 0x08
00065
00066 #define GCIF_NODATA 0x001000
00067 #define GCIF_CATEGORYNAMES 0x002000
00068 #define GCIF_MINMAX 0x004000
00069 #define GCIF_SCALEOFFSET 0x008000
00070 #define GCIF_UNITTYPE 0x010000
00071 #define GCIF_COLORTABLE 0x020000
00072 #define GCIF_COLORINTERP 0x020000
00073 #define GCIF_BAND_METADATA 0x040000
00074 #define GCIF_RAT 0x080000
00075
00076 #define GCIF_ONLY_IF_MISSING 0x10000000
00077 #define GCIF_PROCESS_BANDS 0x20000000
00078
00079 #define GCIF_PAM_DEFAULT (GCIF_GEOTRANSFORM | GCIF_PROJECTION | \
00080 GCIF_METADATA | GCIF_GCPS | \
00081 GCIF_NODATA | GCIF_CATEGORYNAMES | \
00082 GCIF_MINMAX | GCIF_SCALEOFFSET | \
00083 GCIF_UNITTYPE | GCIF_COLORTABLE | \
00084 GCIF_COLORINTERP | GCIF_BAND_METADATA | \
00085 GCIF_RAT | \
00086 GCIF_ONLY_IF_MISSING | GCIF_PROCESS_BANDS )
00087
00088
00089 #define GPF_DIRTY 0x01 // .pam file needs to be written on close
00090 #define GPF_TRIED_READ_FAILED 0x02 // no need to keep trying to read .pam.
00091 #define GPF_DISABLED 0x04 // do not try any PAM stuff.
00092 #define GPF_AUXMODE 0x08 // store info in .aux (HFA) file.
00093
00094
00095
00096
00097
00098 class CPL_DLL GDALMultiDomainMetadata
00099 {
00100 private:
00101 char **papszDomainList;
00102 char ***papapszMetadataLists;
00103
00104 public:
00105 GDALMultiDomainMetadata();
00106 ~GDALMultiDomainMetadata();
00107
00108 int XMLInit( CPLXMLNode *psMetadata );
00109 CPLXMLNode *Serialize();
00110
00111 char **GetDomainList() { return papszDomainList; }
00112
00113 char **GetMetadata( const char * pszDomain = "" );
00114 CPLErr SetMetadata( char ** papszMetadata,
00115 const char * pszDomain = "" );
00116 const char *GetMetadataItem( const char * pszName,
00117 const char * pszDomain = "" );
00118 CPLErr SetMetadataItem( const char * pszName,
00119 const char * pszValue,
00120 const char * pszDomain = "" );
00121
00122 void Clear();
00123 };
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 typedef struct {
00134 char *pszPamFilename;
00135
00136 char *pszProjection;
00137
00138 int bHaveGeoTransform;
00139 double adfGeoTransform[6];
00140
00141 int nGCPCount;
00142 GDAL_GCP *pasGCPList;
00143 char *pszGCPProjection;
00144
00145 CPLXMLNode *psHistograms;
00146
00147 GDALMultiDomainMetadata oMDMD;
00148
00149 } GDALDatasetPamInfo;
00150
00151
00152
00153
00154
00155 class CPL_DLL GDALPamDataset : public GDALDataset
00156 {
00157 friend class GDALPamRasterBand;
00158
00159 protected:
00160 GDALPamDataset(void);
00161
00162 int nPamFlags;
00163 GDALDatasetPamInfo *psPam;
00164
00165 virtual CPLXMLNode *SerializeToXML( const char *);
00166 virtual CPLErr XMLInit( CPLXMLNode *, const char * );
00167
00168 virtual CPLErr TryLoadXML();
00169 virtual CPLErr TrySaveXML();
00170
00171 CPLErr TryLoadAux();
00172 CPLErr TrySaveAux();
00173
00174 virtual const char *BuildPamFilename();
00175
00176 void PamInitialize();
00177 void PamClear();
00178
00179 public:
00180 virtual ~GDALPamDataset();
00181
00182 virtual void FlushCache(void);
00183
00184 virtual const char *GetProjectionRef(void);
00185 virtual CPLErr SetProjection( const char * );
00186
00187 virtual CPLErr GetGeoTransform( double * );
00188 virtual CPLErr SetGeoTransform( double * );
00189
00190 virtual int GetGCPCount();
00191 virtual const char *GetGCPProjection();
00192 virtual const GDAL_GCP *GetGCPs();
00193 virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
00194 const char *pszGCPProjection );
00195
00196 virtual char **GetMetadata( const char * pszDomain = "" );
00197 virtual CPLErr SetMetadata( char ** papszMetadata,
00198 const char * pszDomain = "" );
00199 virtual const char *GetMetadataItem( const char * pszName,
00200 const char * pszDomain = "" );
00201 virtual CPLErr SetMetadataItem( const char * pszName,
00202 const char * pszValue,
00203 const char * pszDomain = "" );
00204
00205 virtual CPLErr CloneInfo( GDALDataset *poSrcDS, int nCloneInfoFlags );
00206
00207
00208
00209 void MarkPamDirty() { nPamFlags |= GPF_DIRTY; }
00210 GDALDatasetPamInfo *GetPamInfo() { return psPam; }
00211 };
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221 typedef struct {
00222 GDALPamDataset *poParentDS;
00223
00224 int bNoDataValueSet;
00225 double dfNoDataValue;
00226
00227 GDALColorTable *poColorTable;
00228
00229 GDALColorInterp eColorInterp;
00230
00231 char *pszUnitType;
00232 char **papszCategoryNames;
00233
00234 double dfOffset;
00235 double dfScale;
00236
00237 int bHaveMinMax;
00238 double dfMin;
00239 double dfMax;
00240
00241 int bHaveStats;
00242 double dfMean;
00243 double dfStdDev;
00244
00245 CPLXMLNode *psSavedHistograms;
00246
00247 GDALMultiDomainMetadata oMDMD;
00248
00249 GDALRasterAttributeTable *poDefaultRAT;
00250
00251 } GDALRasterBandPamInfo;
00252
00253
00254
00255
00256 class CPL_DLL GDALPamRasterBand : public GDALRasterBand
00257 {
00258 friend class GDALPamDataset;
00259
00260 protected:
00261
00262 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
00263 virtual CPLErr XMLInit( CPLXMLNode *, const char * );
00264
00265 void PamInitialize();
00266 void PamClear();
00267
00268 GDALRasterBandPamInfo *psPam;
00269
00270 public:
00271 GDALPamRasterBand();
00272 virtual ~GDALPamRasterBand();
00273
00274 virtual CPLErr SetNoDataValue( double );
00275 virtual double GetNoDataValue( int *pbSuccess = NULL );
00276
00277 virtual CPLErr SetColorTable( GDALColorTable * );
00278 virtual GDALColorTable *GetColorTable();
00279
00280 virtual CPLErr SetColorInterpretation( GDALColorInterp );
00281 virtual GDALColorInterp GetColorInterpretation();
00282
00283 virtual const char *GetUnitType();
00284 CPLErr SetUnitType( const char * );
00285
00286 virtual char **GetCategoryNames();
00287 virtual CPLErr SetCategoryNames( char ** );
00288
00289 virtual double GetOffset( int *pbSuccess = NULL );
00290 CPLErr SetOffset( double );
00291 virtual double GetScale( int *pbSuccess = NULL );
00292 CPLErr SetScale( double );
00293
00294 virtual CPLErr GetHistogram( double dfMin, double dfMax,
00295 int nBuckets, int * panHistogram,
00296 int bIncludeOutOfRange, int bApproxOK,
00297 GDALProgressFunc, void *pProgressData );
00298
00299 virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
00300 int *pnBuckets, int ** ppanHistogram,
00301 int bForce,
00302 GDALProgressFunc, void *pProgressData);
00303
00304 virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
00305 int nBuckets, int *panHistogram );
00306
00307 virtual char **GetMetadata( const char * pszDomain = "" );
00308 virtual CPLErr SetMetadata( char ** papszMetadata,
00309 const char * pszDomain = "" );
00310 virtual const char *GetMetadataItem( const char * pszName,
00311 const char * pszDomain = "" );
00312 virtual CPLErr SetMetadataItem( const char * pszName,
00313 const char * pszValue,
00314 const char * pszDomain = "" );
00315
00316 virtual const GDALRasterAttributeTable *GetDefaultRAT();
00317 virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
00318
00319
00320 virtual CPLErr CloneInfo( GDALRasterBand *poSrcBand, int nCloneInfoFlags );
00321
00322
00323 GDALRasterBandPamInfo *GetPamInfo() { return psPam; }
00324 };
00325
00326
00327 int CPL_DLL PamApplyMetadata( CPLXMLNode *psTree, GDALMajorObject *poMO );
00328 CPLXMLNode CPL_DLL *PamSerializeMetadata( GDALMajorObject *poMO );
00329
00330 #endif