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