Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

gdal_pam.h

00001 /******************************************************************************
00002  * $Id: gdal_pam.h 10646 2007-01-18 02:38:10Z 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 
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 /* GDAL PAM Flags */
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 /*      GDALDatasetPamInfo                                              */
00074 /*                                                                      */
00075 /*      We make these things a seperate structure of information        */
00076 /*      primarily so we can modify it without altering the size of      */
00077 /*      the GDALPamDataset.  It is an effort to reduce ABI churn for    */
00078 /*      driver plugins.                                                 */
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 /*                           GDALPamDataset                             */
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     // "semi private" methods.
00149     void   MarkPamDirty() { nPamFlags |= GPF_DIRTY; }
00150     GDALDatasetPamInfo *GetPamInfo() { return psPam; }
00151 };
00152 
00153 /* ==================================================================== */
00154 /*      GDALDatasetPamInfo                                              */
00155 /*                                                                      */
00156 /*      We make these things a seperate structure of information        */
00157 /*      primarily so we can modify it without altering the size of      */
00158 /*      the GDALPamDataset.  It is an effort to reduce ABI churn for    */
00159 /*      driver plugins.                                                 */
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 /*                          GDALPamRasterBand                           */
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     // new in GDALPamRasterBand. 
00255     virtual CPLErr CloneInfo( GDALRasterBand *poSrcBand, int nCloneInfoFlags );
00256 
00257     // "semi private" methods.
00258     GDALRasterBandPamInfo *GetPamInfo() { return psPam; }
00259 };
00260 
00261 // These are mainly helper functions for internal use.
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 /* ndef GDAL_PAM_H_INCLUDED */

Generated for GDAL by doxygen 1.4.4.