| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
#ifndef GDAL_PAM_H_INCLUDED |
|---|
| 58 |
#define GDAL_PAM_H_INCLUDED |
|---|
| 59 |
|
|---|
| 60 |
#include "gdal_priv.h" |
|---|
| 61 |
|
|---|
| 62 |
class GDALPamRasterBand; |
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
#define GCIF_GEOTRANSFORM 0x01 |
|---|
| 67 |
#define GCIF_PROJECTION 0x02 |
|---|
| 68 |
#define GCIF_METADATA 0x04 |
|---|
| 69 |
#define GCIF_GCPS 0x08 |
|---|
| 70 |
|
|---|
| 71 |
#define GCIF_NODATA 0x001000 |
|---|
| 72 |
#define GCIF_CATEGORYNAMES 0x002000 |
|---|
| 73 |
#define GCIF_MINMAX 0x004000 |
|---|
| 74 |
#define GCIF_SCALEOFFSET 0x008000 |
|---|
| 75 |
#define GCIF_UNITTYPE 0x010000 |
|---|
| 76 |
#define GCIF_COLORTABLE 0x020000 |
|---|
| 77 |
#define GCIF_COLORINTERP 0x020000 |
|---|
| 78 |
#define GCIF_BAND_METADATA 0x040000 |
|---|
| 79 |
#define GCIF_RAT 0x080000 |
|---|
| 80 |
|
|---|
| 81 |
#define GCIF_ONLY_IF_MISSING 0x10000000 |
|---|
| 82 |
#define GCIF_PROCESS_BANDS 0x20000000 |
|---|
| 83 |
|
|---|
| 84 |
#define GCIF_PAM_DEFAULT (GCIF_GEOTRANSFORM | GCIF_PROJECTION | \ |
|---|
| 85 |
GCIF_METADATA | GCIF_GCPS | \ |
|---|
| 86 |
GCIF_NODATA | GCIF_CATEGORYNAMES | \ |
|---|
| 87 |
GCIF_MINMAX | GCIF_SCALEOFFSET | \ |
|---|
| 88 |
GCIF_UNITTYPE | GCIF_COLORTABLE | \ |
|---|
| 89 |
GCIF_COLORINTERP | GCIF_BAND_METADATA | \ |
|---|
| 90 |
GCIF_RAT | \ |
|---|
| 91 |
GCIF_ONLY_IF_MISSING | GCIF_PROCESS_BANDS ) |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
#define GPF_DIRTY 0x01 // .pam file needs to be written on close |
|---|
| 95 |
#define GPF_TRIED_READ_FAILED 0x02 // no need to keep trying to read .pam. |
|---|
| 96 |
#define GPF_DISABLED 0x04 // do not try any PAM stuff. |
|---|
| 97 |
#define GPF_AUXMODE 0x08 // store info in .aux (HFA) file. |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
typedef struct { |
|---|
| 108 |
char *pszPamFilename; |
|---|
| 109 |
|
|---|
| 110 |
char *pszProjection; |
|---|
| 111 |
|
|---|
| 112 |
int bHaveGeoTransform; |
|---|
| 113 |
double adfGeoTransform[6]; |
|---|
| 114 |
|
|---|
| 115 |
int nGCPCount; |
|---|
| 116 |
GDAL_GCP *pasGCPList; |
|---|
| 117 |
char *pszGCPProjection; |
|---|
| 118 |
|
|---|
| 119 |
} GDALDatasetPamInfo; |
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
class CPL_DLL GDALPamDataset : public GDALDataset |
|---|
| 126 |
{ |
|---|
| 127 |
friend class GDALPamRasterBand; |
|---|
| 128 |
|
|---|
| 129 |
protected: |
|---|
| 130 |
GDALPamDataset(void); |
|---|
| 131 |
|
|---|
| 132 |
int nPamFlags; |
|---|
| 133 |
GDALDatasetPamInfo *psPam; |
|---|
| 134 |
|
|---|
| 135 |
virtual CPLXMLNode *SerializeToXML( const char *); |
|---|
| 136 |
virtual CPLErr XMLInit( CPLXMLNode *, const char * ); |
|---|
| 137 |
|
|---|
| 138 |
virtual CPLErr TryLoadXML(); |
|---|
| 139 |
virtual CPLErr TrySaveXML(); |
|---|
| 140 |
|
|---|
| 141 |
CPLErr TryLoadAux(); |
|---|
| 142 |
CPLErr TrySaveAux(); |
|---|
| 143 |
|
|---|
| 144 |
virtual const char *BuildPamFilename(); |
|---|
| 145 |
|
|---|
| 146 |
void PamInitialize(); |
|---|
| 147 |
void PamClear(); |
|---|
| 148 |
|
|---|
| 149 |
public: |
|---|
| 150 |
virtual ~GDALPamDataset(); |
|---|
| 151 |
|
|---|
| 152 |
virtual void FlushCache(void); |
|---|
| 153 |
|
|---|
| 154 |
virtual const char *GetProjectionRef(void); |
|---|
| 155 |
virtual CPLErr SetProjection( const char * ); |
|---|
| 156 |
|
|---|
| 157 |
virtual CPLErr GetGeoTransform( double * ); |
|---|
| 158 |
virtual CPLErr SetGeoTransform( double * ); |
|---|
| 159 |
|
|---|
| 160 |
virtual int GetGCPCount(); |
|---|
| 161 |
virtual const char *GetGCPProjection(); |
|---|
| 162 |
virtual const GDAL_GCP *GetGCPs(); |
|---|
| 163 |
virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList, |
|---|
| 164 |
const char *pszGCPProjection ); |
|---|
| 165 |
|
|---|
| 166 |
virtual CPLErr SetMetadata( char ** papszMetadata, |
|---|
| 167 |
const char * pszDomain = "" ); |
|---|
| 168 |
virtual CPLErr SetMetadataItem( const char * pszName, |
|---|
| 169 |
const char * pszValue, |
|---|
| 170 |
const char * pszDomain = "" ); |
|---|
| 171 |
|
|---|
| 172 |
virtual CPLErr CloneInfo( GDALDataset *poSrcDS, int nCloneInfoFlags ); |
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
void MarkPamDirty() { nPamFlags |= GPF_DIRTY; } |
|---|
| 177 |
GDALDatasetPamInfo *GetPamInfo() { return psPam; } |
|---|
| 178 |
}; |
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
typedef struct { |
|---|
| 189 |
GDALPamDataset *poParentDS; |
|---|
| 190 |
|
|---|
| 191 |
int bNoDataValueSet; |
|---|
| 192 |
double dfNoDataValue; |
|---|
| 193 |
|
|---|
| 194 |
GDALColorTable *poColorTable; |
|---|
| 195 |
|
|---|
| 196 |
GDALColorInterp eColorInterp; |
|---|
| 197 |
|
|---|
| 198 |
char *pszUnitType; |
|---|
| 199 |
char **papszCategoryNames; |
|---|
| 200 |
|
|---|
| 201 |
double dfOffset; |
|---|
| 202 |
double dfScale; |
|---|
| 203 |
|
|---|
| 204 |
int bHaveMinMax; |
|---|
| 205 |
double dfMin; |
|---|
| 206 |
double dfMax; |
|---|
| 207 |
|
|---|
| 208 |
int bHaveStats; |
|---|
| 209 |
double dfMean; |
|---|
| 210 |
double dfStdDev; |
|---|
| 211 |
|
|---|
| 212 |
CPLXMLNode *psSavedHistograms; |
|---|
| 213 |
|
|---|
| 214 |
GDALRasterAttributeTable *poDefaultRAT; |
|---|
| 215 |
|
|---|
| 216 |
} GDALRasterBandPamInfo; |
|---|
| 217 |
|
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 |
class CPL_DLL GDALPamRasterBand : public GDALRasterBand |
|---|
| 222 |
{ |
|---|
| 223 |
friend class GDALPamDataset; |
|---|
| 224 |
|
|---|
| 225 |
protected: |
|---|
| 226 |
|
|---|
| 227 |
virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); |
|---|
| 228 |
virtual CPLErr XMLInit( CPLXMLNode *, const char * ); |
|---|
| 229 |
|
|---|
| 230 |
void PamInitialize(); |
|---|
| 231 |
void PamClear(); |
|---|
| 232 |
|
|---|
| 233 |
GDALRasterBandPamInfo *psPam; |
|---|
| 234 |
|
|---|
| 235 |
public: |
|---|
| 236 |
GDALPamRasterBand(); |
|---|
| 237 |
virtual ~GDALPamRasterBand(); |
|---|
| 238 |
|
|---|
| 239 |
virtual CPLErr SetNoDataValue( double ); |
|---|
| 240 |
virtual double GetNoDataValue( int *pbSuccess = NULL ); |
|---|
| 241 |
|
|---|
| 242 |
virtual CPLErr SetColorTable( GDALColorTable * ); |
|---|
| 243 |
virtual GDALColorTable *GetColorTable(); |
|---|
| 244 |
|
|---|
| 245 |
virtual CPLErr SetColorInterpretation( GDALColorInterp ); |
|---|
| 246 |
virtual GDALColorInterp GetColorInterpretation(); |
|---|
| 247 |
|
|---|
| 248 |
virtual const char *GetUnitType(); |
|---|
| 249 |
CPLErr SetUnitType( const char * ); |
|---|
| 250 |
|
|---|
| 251 |
virtual char **GetCategoryNames(); |
|---|
| 252 |
virtual CPLErr SetCategoryNames( char ** ); |
|---|
| 253 |
|
|---|
| 254 |
virtual double GetOffset( int *pbSuccess = NULL ); |
|---|
| 255 |
CPLErr SetOffset( double ); |
|---|
| 256 |
virtual double GetScale( int *pbSuccess = NULL ); |
|---|
| 257 |
CPLErr SetScale( double ); |
|---|
| 258 |
|
|---|
| 259 |
virtual CPLErr GetHistogram( double dfMin, double dfMax, |
|---|
| 260 |
int nBuckets, int * panHistogram, |
|---|
| 261 |
int bIncludeOutOfRange, int bApproxOK, |
|---|
| 262 |
GDALProgressFunc, void *pProgressData ); |
|---|
| 263 |
|
|---|
| 264 |
virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax, |
|---|
| 265 |
int *pnBuckets, int ** ppanHistogram, |
|---|
| 266 |
int bForce, |
|---|
| 267 |
GDALProgressFunc, void *pProgressData); |
|---|
| 268 |
|
|---|
| 269 |
virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax, |
|---|
| 270 |
int nBuckets, int *panHistogram ); |
|---|
| 271 |
|
|---|
| 272 |
virtual CPLErr SetMetadata( char ** papszMetadata, |
|---|
| 273 |
const char * pszDomain = "" ); |
|---|
| 274 |
virtual CPLErr SetMetadataItem( const char * pszName, |
|---|
| 275 |
const char * pszValue, |
|---|
| 276 |
const char * pszDomain = "" ); |
|---|
| 277 |
|
|---|
| 278 |
virtual const GDALRasterAttributeTable *GetDefaultRAT(); |
|---|
| 279 |
virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * ); |
|---|
| 280 |
|
|---|
| 281 |
|
|---|
| 282 |
virtual CPLErr CloneInfo( GDALRasterBand *poSrcBand, int nCloneInfoFlags ); |
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
GDALRasterBandPamInfo *GetPamInfo() { return psPam; } |
|---|
| 286 |
}; |
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 |
int CPL_DLL PamApplyMetadata( CPLXMLNode *psTree, GDALMajorObject *poMO ); |
|---|
| 290 |
CPLXMLNode CPL_DLL *PamSerializeMetadata( GDALMajorObject *poMO ); |
|---|
| 291 |
int CPL_DLL PamParseHistogram( CPLXMLNode *psHistItem, |
|---|
| 292 |
double *pdfMin, double *pdfMax, |
|---|
| 293 |
int *pnBuckets, int **ppanHistogram, |
|---|
| 294 |
int *pbIncludeOutOfRange, int *pbApproxOK ); |
|---|
| 295 |
CPLXMLNode CPL_DLL * |
|---|
| 296 |
PamFindMatchingHistogram( CPLXMLNode *psSavedHistograms, |
|---|
| 297 |
double dfMin, double dfMax, int nBuckets, |
|---|
| 298 |
int bIncludeOutOfRange, int bApproxOK ); |
|---|
| 299 |
CPLXMLNode CPL_DLL * |
|---|
| 300 |
PamHistogramToXMLTree( double dfMin, double dfMax, |
|---|
| 301 |
int nBuckets, int * panHistogram, |
|---|
| 302 |
int bIncludeOutOfRange, int bApprox ); |
|---|
| 303 |
|
|---|
| 304 |
#endif |
|---|