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