GDAL

gdal_pam.h

00001 /******************************************************************************
00002  * $Id: gdal_pam.h 16731 2009-04-07 02:18:52Z 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     const char *GetPhysicalFilename();
00130     void   SetSubdatasetName( const char *);
00131     const char *GetSubdatasetName();
00132 
00133   public:
00134     virtual     ~GDALPamDataset();
00135 
00136     virtual void FlushCache(void);
00137 
00138     virtual const char *GetProjectionRef(void);
00139     virtual CPLErr SetProjection( const char * );
00140 
00141     virtual CPLErr GetGeoTransform( double * );
00142     virtual CPLErr SetGeoTransform( double * );
00143 
00144     virtual int    GetGCPCount();
00145     virtual const char *GetGCPProjection();
00146     virtual const GDAL_GCP *GetGCPs();
00147     virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
00148                             const char *pszGCPProjection );
00149 
00150     virtual CPLErr      SetMetadata( char ** papszMetadata,
00151                                      const char * pszDomain = "" );
00152     virtual CPLErr      SetMetadataItem( const char * pszName,
00153                                          const char * pszValue,
00154                                          const char * pszDomain = "" );
00155     virtual char      **GetMetadata( const char * pszDomain = "" );
00156     virtual const char *GetMetadataItem( const char * pszName,
00157                                          const char * pszDomain = "" );
00158 
00159     virtual char      **GetFileList(void);
00160 
00161     virtual CPLErr CloneInfo( GDALDataset *poSrcDS, int nCloneInfoFlags );
00162 
00163     virtual CPLErr IBuildOverviews( const char *pszResampling, 
00164                                     int nOverviews, int *panOverviewList, 
00165                                     int nListBands, int *panBandList,
00166                                     GDALProgressFunc pfnProgress, 
00167                                     void * pProgressData );
00168 
00169 
00170     // "semi private" methods.
00171     void   MarkPamDirty() { nPamFlags |= GPF_DIRTY; }
00172     GDALDatasetPamInfo *GetPamInfo() { return psPam; }
00173     int    GetPamFlags() { return nPamFlags; }
00174     void   SetPamFlags(int nValue ) { nPamFlags = nValue; }
00175 };
00176 
00177 /* ==================================================================== */
00178 /*      GDALRasterBandPamInfo                                           */
00179 /*                                                                      */
00180 /*      We make these things a seperate structure of information        */
00181 /*      primarily so we can modify it without altering the size of      */
00182 /*      the GDALPamDataset.  It is an effort to reduce ABI churn for    */
00183 /*      driver plugins.                                                 */
00184 /* ==================================================================== */
00185 typedef struct {
00186     GDALPamDataset *poParentDS;
00187 
00188     int            bNoDataValueSet;
00189     double         dfNoDataValue;
00190 
00191     GDALColorTable *poColorTable;
00192 
00193     GDALColorInterp eColorInterp;
00194 
00195     char           *pszUnitType;
00196     char           **papszCategoryNames;
00197     
00198     double         dfOffset;
00199     double         dfScale;
00200 
00201     int            bHaveMinMax;
00202     double         dfMin;
00203     double         dfMax;
00204 
00205     int            bHaveStats;
00206     double         dfMean;
00207     double         dfStdDev;
00208 
00209     CPLXMLNode     *psSavedHistograms;
00210 
00211     GDALRasterAttributeTable *poDefaultRAT;
00212 
00213 } GDALRasterBandPamInfo;
00214 
00215 /* ******************************************************************** */
00216 /*                          GDALPamRasterBand                           */
00217 /* ******************************************************************** */
00218 class CPL_DLL GDALPamRasterBand : public GDALRasterBand
00219 {
00220     friend class GDALPamDataset;
00221 
00222   protected:
00223 
00224     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
00225     virtual CPLErr      XMLInit( CPLXMLNode *, const char * );
00226     
00227     void   PamInitialize();
00228     void   PamClear();
00229 
00230     GDALRasterBandPamInfo *psPam;
00231 
00232   public:
00233                 GDALPamRasterBand();
00234     virtual     ~GDALPamRasterBand();
00235 
00236     virtual CPLErr SetNoDataValue( double );
00237     virtual double GetNoDataValue( int *pbSuccess = NULL );
00238 
00239     virtual CPLErr SetColorTable( GDALColorTable * ); 
00240     virtual GDALColorTable *GetColorTable();
00241 
00242     virtual CPLErr SetColorInterpretation( GDALColorInterp );
00243     virtual GDALColorInterp GetColorInterpretation();
00244 
00245     virtual const char *GetUnitType();
00246     CPLErr SetUnitType( const char * ); 
00247 
00248     virtual char **GetCategoryNames();
00249     virtual CPLErr SetCategoryNames( char ** );
00250 
00251     virtual double GetOffset( int *pbSuccess = NULL );
00252     CPLErr SetOffset( double );
00253     virtual double GetScale( int *pbSuccess = NULL );
00254     CPLErr SetScale( double );
00255 
00256     virtual CPLErr  GetHistogram( double dfMin, double dfMax,
00257                           int nBuckets, int * panHistogram,
00258                           int bIncludeOutOfRange, int bApproxOK,
00259                           GDALProgressFunc, void *pProgressData );
00260 
00261     virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
00262                                         int *pnBuckets, int ** ppanHistogram,
00263                                         int bForce,
00264                                         GDALProgressFunc, void *pProgressData);
00265 
00266     virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
00267                                         int nBuckets, int *panHistogram );
00268 
00269     virtual CPLErr      SetMetadata( char ** papszMetadata,
00270                                      const char * pszDomain = "" );
00271     virtual CPLErr      SetMetadataItem( const char * pszName,
00272                                          const char * pszValue,
00273                                          const char * pszDomain = "" );
00274 
00275     virtual const GDALRasterAttributeTable *GetDefaultRAT();
00276     virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
00277 
00278     // new in GDALPamRasterBand. 
00279     virtual CPLErr CloneInfo( GDALRasterBand *poSrcBand, int nCloneInfoFlags );
00280 
00281     // "semi private" methods.
00282     GDALRasterBandPamInfo *GetPamInfo() { return psPam; }
00283 };
00284 
00285 // These are mainly helper functions for internal use.
00286 int CPL_DLL PamParseHistogram( CPLXMLNode *psHistItem, 
00287                                double *pdfMin, double *pdfMax, 
00288                                int *pnBuckets, int **ppanHistogram, 
00289                                int *pbIncludeOutOfRange, int *pbApproxOK );
00290 CPLXMLNode CPL_DLL *
00291 PamFindMatchingHistogram( CPLXMLNode *psSavedHistograms,
00292                           double dfMin, double dfMax, int nBuckets, 
00293                           int bIncludeOutOfRange, int bApproxOK );
00294 CPLXMLNode CPL_DLL *
00295 PamHistogramToXMLTree( double dfMin, double dfMax,
00296                        int nBuckets, int * panHistogram,
00297                        int bIncludeOutOfRange, int bApprox );
00298 
00299 // For managing the proxy file database.
00300 const char CPL_DLL * PamGetProxy( const char * );
00301 const char CPL_DLL * PamAllocateProxy( const char * );
00302 const char CPL_DLL * PamDeallocateProxy( const char * );
00303 void CPL_DLL PamCleanProxyDB( void );
00304 
00305 #endif /* ndef GDAL_PAM_H_INCLUDED */

Generated for GDAL by doxygen 1.7.3.