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