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

gdal_pam.h

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

Generated on Mon Aug 29 04:05:35 2005 for GDAL by doxygen 1.3.6