GDAL
|
00001 /****************************************************************************** 00002 * $Id: gdal_pam.h 21291 2010-12-19 20:42:06Z rouault $ 00003 * 00004 * Project: GDAL Core 00005 * Purpose: Declaration for Peristable Auxilary Metadata classes. 00006 * Author: Frank Warmerdam, warmerdam@pobox.com 00007 * 00008 ****************************************************************************** 00009 * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com> 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining a 00012 * copy of this software and associated documentation files (the "Software"), 00013 * to deal in the Software without restriction, including without limitation 00014 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00015 * and/or sell copies of the Software, and to permit persons to whom the 00016 * Software is furnished to do so, subject to the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be included 00019 * in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00022 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00023 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00024 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00025 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00026 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00027 * DEALINGS IN THE SOFTWARE. 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 /* Clone Info Flags */ 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 #define GCIF_MASK 0x100000 00054 #define GCIF_BAND_DESCRIPTION 0x200000 00055 00056 #define GCIF_ONLY_IF_MISSING 0x10000000 00057 #define GCIF_PROCESS_BANDS 0x20000000 00058 00059 #define GCIF_PAM_DEFAULT (GCIF_GEOTRANSFORM | GCIF_PROJECTION | \ 00060 GCIF_METADATA | GCIF_GCPS | \ 00061 GCIF_NODATA | GCIF_CATEGORYNAMES | \ 00062 GCIF_MINMAX | GCIF_SCALEOFFSET | \ 00063 GCIF_UNITTYPE | GCIF_COLORTABLE | \ 00064 GCIF_COLORINTERP | GCIF_BAND_METADATA | \ 00065 GCIF_RAT | GCIF_MASK | \ 00066 GCIF_ONLY_IF_MISSING | GCIF_PROCESS_BANDS|\ 00067 GCIF_BAND_DESCRIPTION) 00068 00069 /* GDAL PAM Flags */ 00070 #define GPF_DIRTY 0x01 // .pam file needs to be written on close 00071 #define GPF_TRIED_READ_FAILED 0x02 // no need to keep trying to read .pam. 00072 #define GPF_DISABLED 0x04 // do not try any PAM stuff. 00073 #define GPF_AUXMODE 0x08 // store info in .aux (HFA) file. 00074 #define GPF_NOSAVE 0x10 // do not try to save pam info. 00075 00076 /* ==================================================================== */ 00077 /* GDALDatasetPamInfo */ 00078 /* */ 00079 /* We make these things a seperate structure of information */ 00080 /* primarily so we can modify it without altering the size of */ 00081 /* the GDALPamDataset. It is an effort to reduce ABI churn for */ 00082 /* driver plugins. */ 00083 /* ==================================================================== */ 00084 class GDALDatasetPamInfo 00085 { 00086 public: 00087 char *pszPamFilename; 00088 00089 char *pszProjection; 00090 00091 int bHaveGeoTransform; 00092 double adfGeoTransform[6]; 00093 00094 int nGCPCount; 00095 GDAL_GCP *pasGCPList; 00096 char *pszGCPProjection; 00097 00098 CPLString osPhysicalFilename; 00099 CPLString osSubdatasetName; 00100 CPLString osAuxFilename; 00101 }; 00102 00103 /* ******************************************************************** */ 00104 /* GDALPamDataset */ 00105 /* ******************************************************************** */ 00106 00107 class CPL_DLL GDALPamDataset : public GDALDataset 00108 { 00109 friend class GDALPamRasterBand; 00110 00111 protected: 00112 GDALPamDataset(void); 00113 00114 int nPamFlags; 00115 GDALDatasetPamInfo *psPam; 00116 00117 virtual CPLXMLNode *SerializeToXML( const char *); 00118 virtual CPLErr XMLInit( CPLXMLNode *, const char * ); 00119 00120 virtual CPLErr TryLoadXML(); 00121 virtual CPLErr TrySaveXML(); 00122 00123 CPLErr TryLoadAux(); 00124 CPLErr TrySaveAux(); 00125 00126 virtual const char *BuildPamFilename(); 00127 00128 void PamInitialize(); 00129 void PamClear(); 00130 00131 void SetPhysicalFilename( const char * ); 00132 const char *GetPhysicalFilename(); 00133 void SetSubdatasetName( const char *); 00134 const char *GetSubdatasetName(); 00135 00136 public: 00137 virtual ~GDALPamDataset(); 00138 00139 virtual void FlushCache(void); 00140 00141 virtual const char *GetProjectionRef(void); 00142 virtual CPLErr SetProjection( const char * ); 00143 00144 virtual CPLErr GetGeoTransform( double * ); 00145 virtual CPLErr SetGeoTransform( double * ); 00146 00147 virtual int GetGCPCount(); 00148 virtual const char *GetGCPProjection(); 00149 virtual const GDAL_GCP *GetGCPs(); 00150 virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList, 00151 const char *pszGCPProjection ); 00152 00153 virtual CPLErr SetMetadata( char ** papszMetadata, 00154 const char * pszDomain = "" ); 00155 virtual CPLErr SetMetadataItem( const char * pszName, 00156 const char * pszValue, 00157 const char * pszDomain = "" ); 00158 virtual char **GetMetadata( const char * pszDomain = "" ); 00159 virtual const char *GetMetadataItem( const char * pszName, 00160 const char * pszDomain = "" ); 00161 00162 virtual char **GetFileList(void); 00163 00164 virtual CPLErr CloneInfo( GDALDataset *poSrcDS, int nCloneInfoFlags ); 00165 00166 virtual CPLErr IBuildOverviews( const char *pszResampling, 00167 int nOverviews, int *panOverviewList, 00168 int nListBands, int *panBandList, 00169 GDALProgressFunc pfnProgress, 00170 void * pProgressData ); 00171 00172 00173 // "semi private" methods. 00174 void MarkPamDirty() { nPamFlags |= GPF_DIRTY; } 00175 GDALDatasetPamInfo *GetPamInfo() { return psPam; } 00176 int GetPamFlags() { return nPamFlags; } 00177 void SetPamFlags(int nValue ) { nPamFlags = nValue; } 00178 }; 00179 00180 /* ==================================================================== */ 00181 /* GDALRasterBandPamInfo */ 00182 /* */ 00183 /* We make these things a seperate structure of information */ 00184 /* primarily so we can modify it without altering the size of */ 00185 /* the GDALPamDataset. It is an effort to reduce ABI churn for */ 00186 /* driver plugins. */ 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 /* GDALPamRasterBand */ 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 void SetDescription( const char * ); 00240 00241 virtual CPLErr SetNoDataValue( double ); 00242 virtual double GetNoDataValue( int *pbSuccess = NULL ); 00243 00244 virtual CPLErr SetColorTable( GDALColorTable * ); 00245 virtual GDALColorTable *GetColorTable(); 00246 00247 virtual CPLErr SetColorInterpretation( GDALColorInterp ); 00248 virtual GDALColorInterp GetColorInterpretation(); 00249 00250 virtual const char *GetUnitType(); 00251 CPLErr SetUnitType( const char * ); 00252 00253 virtual char **GetCategoryNames(); 00254 virtual CPLErr SetCategoryNames( char ** ); 00255 00256 virtual double GetOffset( int *pbSuccess = NULL ); 00257 CPLErr SetOffset( double ); 00258 virtual double GetScale( int *pbSuccess = NULL ); 00259 CPLErr SetScale( double ); 00260 00261 virtual CPLErr GetHistogram( double dfMin, double dfMax, 00262 int nBuckets, int * panHistogram, 00263 int bIncludeOutOfRange, int bApproxOK, 00264 GDALProgressFunc, void *pProgressData ); 00265 00266 virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax, 00267 int *pnBuckets, int ** ppanHistogram, 00268 int bForce, 00269 GDALProgressFunc, void *pProgressData); 00270 00271 virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax, 00272 int nBuckets, int *panHistogram ); 00273 00274 virtual CPLErr SetMetadata( char ** papszMetadata, 00275 const char * pszDomain = "" ); 00276 virtual CPLErr SetMetadataItem( const char * pszName, 00277 const char * pszValue, 00278 const char * pszDomain = "" ); 00279 00280 virtual const GDALRasterAttributeTable *GetDefaultRAT(); 00281 virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * ); 00282 00283 // new in GDALPamRasterBand. 00284 virtual CPLErr CloneInfo( GDALRasterBand *poSrcBand, int nCloneInfoFlags ); 00285 00286 // "semi private" methods. 00287 GDALRasterBandPamInfo *GetPamInfo() { return psPam; } 00288 }; 00289 00290 // These are mainly helper functions for internal use. 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 // For managing the proxy file database. 00305 const char CPL_DLL * PamGetProxy( const char * ); 00306 const char CPL_DLL * PamAllocateProxy( const char * ); 00307 const char CPL_DLL * PamDeallocateProxy( const char * ); 00308 void CPL_DLL PamCleanProxyDB( void ); 00309 00310 #endif /* ndef GDAL_PAM_H_INCLUDED */