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