gdal_pam.h

00001 /******************************************************************************
00002  * $Id: gdal_pam.h,v 1.6 2005/09/24 19:02:15 fwarmerdam Exp $
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  * $Log: gdal_pam.h,v $
00031  * Revision 1.6  2005/09/24 19:02:15  fwarmerdam
00032  * added RasterAttributeTable support
00033  *
00034  * Revision 1.5  2005/09/11 18:03:34  fwarmerdam
00035  * added Clear() method on multidomainmetadata
00036  *
00037  * Revision 1.4  2005/05/22 08:14:06  fwarmerdam
00038  * added multidomain metadata support
00039  *
00040  * Revision 1.3  2005/05/13 18:19:04  fwarmerdam
00041  * Added SetDefaultHistogram
00042  *
00043  * Revision 1.2  2005/05/11 14:04:21  fwarmerdam
00044  * added getdefaulthistogram
00045  *
00046  * Revision 1.1  2005/04/27 16:27:44  fwarmerdam
00047  * New
00048  *
00049  */
00050 
00051 #ifndef GDAL_PAM_H_INCLUDED
00052 #define GDAL_PAM_H_INCLUDED
00053 
00054 #include "gdal_priv.h"
00055 #include "cpl_minixml.h"
00056 
00057 class GDALPamRasterBand;
00058 
00059 /* Clone Info Flags */
00060 
00061 #define GCIF_GEOTRANSFORM       0x01
00062 #define GCIF_PROJECTION         0x02
00063 #define GCIF_METADATA           0x04
00064 #define GCIF_GCPS               0x08
00065 
00066 #define GCIF_NODATA             0x001000
00067 #define GCIF_CATEGORYNAMES      0x002000
00068 #define GCIF_MINMAX             0x004000
00069 #define GCIF_SCALEOFFSET        0x008000
00070 #define GCIF_UNITTYPE           0x010000
00071 #define GCIF_COLORTABLE         0x020000
00072 #define GCIF_COLORINTERP        0x020000
00073 #define GCIF_BAND_METADATA      0x040000
00074 #define GCIF_RAT                0x080000
00075 
00076 #define GCIF_ONLY_IF_MISSING    0x10000000
00077 #define GCIF_PROCESS_BANDS      0x20000000
00078 
00079 #define GCIF_PAM_DEFAULT        (GCIF_GEOTRANSFORM | GCIF_PROJECTION |     \
00080                                  GCIF_METADATA | GCIF_GCPS |               \
00081                                  GCIF_NODATA | GCIF_CATEGORYNAMES |        \
00082                                  GCIF_MINMAX | GCIF_SCALEOFFSET |          \
00083                                  GCIF_UNITTYPE | GCIF_COLORTABLE |         \
00084                                  GCIF_COLORINTERP | GCIF_BAND_METADATA |   \
00085                                  GCIF_RAT |                                \
00086                                  GCIF_ONLY_IF_MISSING | GCIF_PROCESS_BANDS )
00087 
00088 /* GDAL PAM Flags */
00089 #define GPF_DIRTY               0x01  // .pam file needs to be written on close
00090 #define GPF_TRIED_READ_FAILED   0x02  // no need to keep trying to read .pam.
00091 #define GPF_DISABLED            0x04  // do not try any PAM stuff. 
00092 #define GPF_AUXMODE             0x08  // store info in .aux (HFA) file.
00093 
00094 /************************************************************************/
00095 /*                       GDALMultiDomainMetadata                        */
00096 /************************************************************************/
00097 
00098 class CPL_DLL GDALMultiDomainMetadata
00099 {
00100 private:
00101     char **papszDomainList;
00102     char ***papapszMetadataLists;
00103 
00104 public:
00105     GDALMultiDomainMetadata();
00106     ~GDALMultiDomainMetadata();
00107 
00108     int         XMLInit( CPLXMLNode *psMetadata );
00109     CPLXMLNode  *Serialize();
00110 
00111     char      **GetDomainList() { return papszDomainList; }
00112 
00113     char      **GetMetadata( const char * pszDomain = "" );
00114     CPLErr      SetMetadata( char ** papszMetadata,
00115                              const char * pszDomain = "" );
00116     const char *GetMetadataItem( const char * pszName,
00117                                  const char * pszDomain = "" );
00118     CPLErr      SetMetadataItem( const char * pszName,
00119                                  const char * pszValue,
00120                                  const char * pszDomain = "" );
00121 
00122     void        Clear();
00123 };
00124 
00125 /* ==================================================================== */
00126 /*      GDALDatasetPamInfo                                              */
00127 /*                                                                      */
00128 /*      We make these things a seperate structure of information        */
00129 /*      primarily so we can modify it without altering the size of      */
00130 /*      the GDALPamDataset.  It is an effort to reduce ABI churn for    */
00131 /*      driver plugins.                                                 */
00132 /* ==================================================================== */
00133 typedef struct {
00134     char       *pszPamFilename;
00135 
00136     char        *pszProjection;
00137 
00138     int         bHaveGeoTransform;
00139     double      adfGeoTransform[6];
00140 
00141     int         nGCPCount;
00142     GDAL_GCP   *pasGCPList;
00143     char       *pszGCPProjection;
00144 
00145     CPLXMLNode *psHistograms;
00146 
00147     GDALMultiDomainMetadata  oMDMD;
00148 
00149 } GDALDatasetPamInfo;
00150 
00151 /* ******************************************************************** */
00152 /*                           GDALPamDataset                             */
00153 /* ******************************************************************** */
00154 
00155 class CPL_DLL GDALPamDataset : public GDALDataset
00156 {
00157     friend class GDALPamRasterBand;
00158 
00159   protected:
00160                 GDALPamDataset(void);
00161 
00162     int         nPamFlags;
00163     GDALDatasetPamInfo *psPam;
00164 
00165     virtual CPLXMLNode *SerializeToXML( const char *);
00166     virtual CPLErr      XMLInit( CPLXMLNode *, const char * );
00167     
00168     virtual CPLErr TryLoadXML();
00169     virtual CPLErr TrySaveXML();
00170 
00171     CPLErr  TryLoadAux();
00172     CPLErr  TrySaveAux();
00173 
00174     virtual const char *BuildPamFilename();
00175 
00176     void   PamInitialize();
00177     void   PamClear();
00178 
00179   public:
00180     virtual     ~GDALPamDataset();
00181 
00182     virtual void FlushCache(void);
00183 
00184     virtual const char *GetProjectionRef(void);
00185     virtual CPLErr SetProjection( const char * );
00186 
00187     virtual CPLErr GetGeoTransform( double * );
00188     virtual CPLErr SetGeoTransform( double * );
00189 
00190     virtual int    GetGCPCount();
00191     virtual const char *GetGCPProjection();
00192     virtual const GDAL_GCP *GetGCPs();
00193     virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
00194                             const char *pszGCPProjection );
00195 
00196     virtual char      **GetMetadata( const char * pszDomain = "" );
00197     virtual CPLErr      SetMetadata( char ** papszMetadata,
00198                                      const char * pszDomain = "" );
00199     virtual const char *GetMetadataItem( const char * pszName,
00200                                  const char * pszDomain = "" );
00201     virtual CPLErr      SetMetadataItem( const char * pszName,
00202                                          const char * pszValue,
00203                                          const char * pszDomain = "" );
00204 
00205     virtual CPLErr CloneInfo( GDALDataset *poSrcDS, int nCloneInfoFlags );
00206 
00207 
00208     // "semi private" methods.
00209     void   MarkPamDirty() { nPamFlags |= GPF_DIRTY; }
00210     GDALDatasetPamInfo *GetPamInfo() { return psPam; }
00211 };
00212 
00213 /* ==================================================================== */
00214 /*      GDALDatasetPamInfo                                              */
00215 /*                                                                      */
00216 /*      We make these things a seperate structure of information        */
00217 /*      primarily so we can modify it without altering the size of      */
00218 /*      the GDALPamDataset.  It is an effort to reduce ABI churn for    */
00219 /*      driver plugins.                                                 */
00220 /* ==================================================================== */
00221 typedef struct {
00222     GDALPamDataset *poParentDS;
00223 
00224     int            bNoDataValueSet;
00225     double         dfNoDataValue;
00226 
00227     GDALColorTable *poColorTable;
00228 
00229     GDALColorInterp eColorInterp;
00230 
00231     char           *pszUnitType;
00232     char           **papszCategoryNames;
00233     
00234     double         dfOffset;
00235     double         dfScale;
00236 
00237     int            bHaveMinMax;
00238     double         dfMin;
00239     double         dfMax;
00240 
00241     int            bHaveStats;
00242     double         dfMean;
00243     double         dfStdDev;
00244 
00245     CPLXMLNode     *psSavedHistograms;
00246 
00247     GDALMultiDomainMetadata  oMDMD;
00248 
00249     GDALRasterAttributeTable *poDefaultRAT;
00250 
00251 } GDALRasterBandPamInfo;
00252 
00253 /* ******************************************************************** */
00254 /*                          GDALPamRasterBand                           */
00255 /* ******************************************************************** */
00256 class CPL_DLL GDALPamRasterBand : public GDALRasterBand
00257 {
00258     friend class GDALPamDataset;
00259 
00260   protected:
00261 
00262     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
00263     virtual CPLErr      XMLInit( CPLXMLNode *, const char * );
00264     
00265     void   PamInitialize();
00266     void   PamClear();
00267 
00268     GDALRasterBandPamInfo *psPam;
00269 
00270   public:
00271                 GDALPamRasterBand();
00272     virtual     ~GDALPamRasterBand();
00273 
00274     virtual CPLErr SetNoDataValue( double );
00275     virtual double GetNoDataValue( int *pbSuccess = NULL );
00276 
00277     virtual CPLErr SetColorTable( GDALColorTable * ); 
00278     virtual GDALColorTable *GetColorTable();
00279 
00280     virtual CPLErr SetColorInterpretation( GDALColorInterp );
00281     virtual GDALColorInterp GetColorInterpretation();
00282 
00283     virtual const char *GetUnitType();
00284     CPLErr SetUnitType( const char * ); 
00285 
00286     virtual char **GetCategoryNames();
00287     virtual CPLErr SetCategoryNames( char ** );
00288 
00289     virtual double GetOffset( int *pbSuccess = NULL );
00290     CPLErr SetOffset( double );
00291     virtual double GetScale( int *pbSuccess = NULL );
00292     CPLErr SetScale( double );
00293 
00294     virtual CPLErr  GetHistogram( double dfMin, double dfMax,
00295                           int nBuckets, int * panHistogram,
00296                           int bIncludeOutOfRange, int bApproxOK,
00297                           GDALProgressFunc, void *pProgressData );
00298 
00299     virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
00300                                         int *pnBuckets, int ** ppanHistogram,
00301                                         int bForce,
00302                                         GDALProgressFunc, void *pProgressData);
00303 
00304     virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
00305                                         int nBuckets, int *panHistogram );
00306 
00307     virtual char      **GetMetadata( const char * pszDomain = "" );
00308     virtual CPLErr      SetMetadata( char ** papszMetadata,
00309                                      const char * pszDomain = "" );
00310     virtual const char *GetMetadataItem( const char * pszName,
00311                                  const char * pszDomain = "" );
00312     virtual CPLErr      SetMetadataItem( const char * pszName,
00313                                          const char * pszValue,
00314                                          const char * pszDomain = "" );
00315 
00316     virtual const GDALRasterAttributeTable *GetDefaultRAT();
00317     virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
00318 
00319     // new in GDALPamRasterBand. 
00320     virtual CPLErr CloneInfo( GDALRasterBand *poSrcBand, int nCloneInfoFlags );
00321 
00322     // "semi private" methods.
00323     GDALRasterBandPamInfo *GetPamInfo() { return psPam; }
00324 };
00325 
00326 // These are mainly helper functions for internal use.
00327 int CPL_DLL PamApplyMetadata( CPLXMLNode *psTree, GDALMajorObject *poMO );
00328 CPLXMLNode CPL_DLL *PamSerializeMetadata( GDALMajorObject *poMO );
00329 
00330 #endif /* ndef GDAL_PAM_H_INCLUDED */

Generated on Sun Jul 2 22:18:26 2006 for GDAL by  doxygen 1.4.6