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