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