LCOV - code coverage report
Current view: directory - gcore - gdal_pam.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 4 4 100.0 %
Date: 2010-01-09 Functions: 5 5 100.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: gdal_pam.h 16731 2009-04-07 02:18:52Z warmerdam $
       3                 :  *
       4                 :  * Project:  GDAL Core
       5                 :  * Purpose:  Declaration for Peristable Auxilary Metadata classes.
       6                 :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  *
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  *
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : #ifndef GDAL_PAM_H_INCLUDED
      31                 : #define GDAL_PAM_H_INCLUDED
      32                 : 
      33                 : #include "gdal_priv.h"
      34                 : 
      35                 : class GDALPamRasterBand;
      36                 : 
      37                 : /* Clone Info Flags */
      38                 : 
      39                 : #define GCIF_GEOTRANSFORM       0x01
      40                 : #define GCIF_PROJECTION         0x02
      41                 : #define GCIF_METADATA           0x04
      42                 : #define GCIF_GCPS               0x08
      43                 : 
      44                 : #define GCIF_NODATA             0x001000
      45                 : #define GCIF_CATEGORYNAMES      0x002000
      46                 : #define GCIF_MINMAX             0x004000
      47                 : #define GCIF_SCALEOFFSET        0x008000
      48                 : #define GCIF_UNITTYPE           0x010000
      49                 : #define GCIF_COLORTABLE         0x020000
      50                 : #define GCIF_COLORINTERP        0x020000
      51                 : #define GCIF_BAND_METADATA      0x040000
      52                 : #define GCIF_RAT                0x080000
      53                 : #define GCIF_MASK               0x100000
      54                 : 
      55                 : #define GCIF_ONLY_IF_MISSING    0x10000000
      56                 : #define GCIF_PROCESS_BANDS      0x20000000
      57                 : 
      58                 : #define GCIF_PAM_DEFAULT        (GCIF_GEOTRANSFORM | GCIF_PROJECTION |     \
      59                 :                                  GCIF_METADATA | GCIF_GCPS |               \
      60                 :                                  GCIF_NODATA | GCIF_CATEGORYNAMES |        \
      61                 :                                  GCIF_MINMAX | GCIF_SCALEOFFSET |          \
      62                 :                                  GCIF_UNITTYPE | GCIF_COLORTABLE |         \
      63                 :                                  GCIF_COLORINTERP | GCIF_BAND_METADATA |   \
      64                 :                                  GCIF_RAT | GCIF_MASK |                    \
      65                 :                                  GCIF_ONLY_IF_MISSING | GCIF_PROCESS_BANDS )
      66                 : 
      67                 : /* GDAL PAM Flags */
      68                 : #define GPF_DIRTY   0x01  // .pam file needs to be written on close
      69                 : #define GPF_TRIED_READ_FAILED   0x02  // no need to keep trying to read .pam.
      70                 : #define GPF_DISABLED            0x04  // do not try any PAM stuff. 
      71                 : #define GPF_AUXMODE             0x08  // store info in .aux (HFA) file.
      72                 : #define GPF_NOSAVE              0x10  // do not try to save pam info.
      73                 : 
      74                 : /* ==================================================================== */
      75                 : /*      GDALDatasetPamInfo                                              */
      76                 : /*                                                                      */
      77                 : /*      We make these things a seperate structure of information        */
      78                 : /*      primarily so we can modify it without altering the size of      */
      79                 : /*      the GDALPamDataset.  It is an effort to reduce ABI churn for    */
      80                 : /*      driver plugins.                                                 */
      81                 : /* ==================================================================== */
      82                 : class GDALDatasetPamInfo
      83            9839 : {
      84                 : public:
      85                 :     char        *pszPamFilename;
      86                 : 
      87                 :     char  *pszProjection;
      88                 : 
      89                 :     int         bHaveGeoTransform;
      90                 :     double      adfGeoTransform[6];
      91                 : 
      92                 :     int         nGCPCount;
      93                 :     GDAL_GCP   *pasGCPList;
      94                 :     char       *pszGCPProjection;
      95                 : 
      96                 :     CPLString   osPhysicalFilename;
      97                 :     CPLString   osSubdatasetName;
      98                 : };
      99                 : 
     100                 : /* ******************************************************************** */
     101                 : /*                           GDALPamDataset                             */
     102                 : /* ******************************************************************** */
     103                 : 
     104                 : class CPL_DLL GDALPamDataset : public GDALDataset
     105                 : {
     106                 :     friend class GDALPamRasterBand;
     107                 : 
     108                 :   protected:
     109                 :                 GDALPamDataset(void);
     110                 : 
     111                 :     int         nPamFlags;
     112                 :     GDALDatasetPamInfo *psPam;
     113                 : 
     114                 :     virtual CPLXMLNode *SerializeToXML( const char *);
     115                 :     virtual CPLErr      XMLInit( CPLXMLNode *, const char * );
     116                 :     
     117                 :     virtual CPLErr TryLoadXML();
     118                 :     virtual CPLErr TrySaveXML();
     119                 : 
     120                 :     CPLErr  TryLoadAux();
     121                 :     CPLErr  TrySaveAux();
     122                 : 
     123                 :     virtual const char *BuildPamFilename();
     124                 : 
     125                 :     void   PamInitialize();
     126                 :     void   PamClear();
     127                 : 
     128                 :     void   SetPhysicalFilename( const char * );
     129                 :     const char *GetPhysicalFilename();
     130                 :     void   SetSubdatasetName( const char *);
     131                 :     const char *GetSubdatasetName();
     132                 : 
     133                 :   public:
     134                 :     virtual     ~GDALPamDataset();
     135                 : 
     136                 :     virtual void FlushCache(void);
     137                 : 
     138                 :     virtual const char *GetProjectionRef(void);
     139                 :     virtual CPLErr SetProjection( const char * );
     140                 : 
     141                 :     virtual CPLErr GetGeoTransform( double * );
     142                 :     virtual CPLErr SetGeoTransform( double * );
     143                 : 
     144                 :     virtual int    GetGCPCount();
     145                 :     virtual const char *GetGCPProjection();
     146                 :     virtual const GDAL_GCP *GetGCPs();
     147                 :     virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
     148                 :                             const char *pszGCPProjection );
     149                 : 
     150                 :     virtual CPLErr      SetMetadata( char ** papszMetadata,
     151                 :                                      const char * pszDomain = "" );
     152                 :     virtual CPLErr      SetMetadataItem( const char * pszName,
     153                 :                                          const char * pszValue,
     154                 :                                          const char * pszDomain = "" );
     155                 :     virtual char      **GetMetadata( const char * pszDomain = "" );
     156                 :     virtual const char *GetMetadataItem( const char * pszName,
     157                 :                                          const char * pszDomain = "" );
     158                 : 
     159                 :     virtual char      **GetFileList(void);
     160                 : 
     161                 :     virtual CPLErr CloneInfo( GDALDataset *poSrcDS, int nCloneInfoFlags );
     162                 : 
     163                 :     virtual CPLErr IBuildOverviews( const char *pszResampling, 
     164                 :                                     int nOverviews, int *panOverviewList, 
     165                 :                                     int nListBands, int *panBandList,
     166                 :                                     GDALProgressFunc pfnProgress, 
     167                 :                                     void * pProgressData );
     168                 : 
     169                 : 
     170                 :     // "semi private" methods.
     171            5839 :     void   MarkPamDirty() { nPamFlags |= GPF_DIRTY; }
     172                 :     GDALDatasetPamInfo *GetPamInfo() { return psPam; }
     173             101 :     int    GetPamFlags() { return nPamFlags; }
     174              67 :     void   SetPamFlags(int nValue ) { nPamFlags = nValue; }
     175                 : };
     176                 : 
     177                 : /* ==================================================================== */
     178                 : /*      GDALRasterBandPamInfo                                           */
     179                 : /*                                                                      */
     180                 : /*      We make these things a seperate structure of information        */
     181                 : /*      primarily so we can modify it without altering the size of      */
     182                 : /*      the GDALPamDataset.  It is an effort to reduce ABI churn for    */
     183                 : /*      driver plugins.                                                 */
     184                 : /* ==================================================================== */
     185                 : typedef struct {
     186                 :     GDALPamDataset *poParentDS;
     187                 : 
     188                 :     int            bNoDataValueSet;
     189                 :     double         dfNoDataValue;
     190                 : 
     191                 :     GDALColorTable *poColorTable;
     192                 : 
     193                 :     GDALColorInterp eColorInterp;
     194                 : 
     195                 :     char           *pszUnitType;
     196                 :     char           **papszCategoryNames;
     197                 :     
     198                 :     double         dfOffset;
     199                 :     double         dfScale;
     200                 : 
     201                 :     int            bHaveMinMax;
     202                 :     double         dfMin;
     203                 :     double         dfMax;
     204                 : 
     205                 :     int            bHaveStats;
     206                 :     double         dfMean;
     207                 :     double         dfStdDev;
     208                 : 
     209                 :     CPLXMLNode     *psSavedHistograms;
     210                 : 
     211                 :     GDALRasterAttributeTable *poDefaultRAT;
     212                 : 
     213                 : } GDALRasterBandPamInfo;
     214                 : 
     215                 : /* ******************************************************************** */
     216                 : /*                          GDALPamRasterBand                           */
     217                 : /* ******************************************************************** */
     218                 : class CPL_DLL GDALPamRasterBand : public GDALRasterBand
     219                 : {
     220                 :     friend class GDALPamDataset;
     221                 : 
     222                 :   protected:
     223                 : 
     224                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     225                 :     virtual CPLErr      XMLInit( CPLXMLNode *, const char * );
     226                 :     
     227                 :     void   PamInitialize();
     228                 :     void   PamClear();
     229                 : 
     230                 :     GDALRasterBandPamInfo *psPam;
     231                 : 
     232                 :   public:
     233                 :                 GDALPamRasterBand();
     234                 :     virtual     ~GDALPamRasterBand();
     235                 : 
     236                 :     virtual CPLErr SetNoDataValue( double );
     237                 :     virtual double GetNoDataValue( int *pbSuccess = NULL );
     238                 : 
     239                 :     virtual CPLErr SetColorTable( GDALColorTable * ); 
     240                 :     virtual GDALColorTable *GetColorTable();
     241                 : 
     242                 :     virtual CPLErr SetColorInterpretation( GDALColorInterp );
     243                 :     virtual GDALColorInterp GetColorInterpretation();
     244                 : 
     245                 :     virtual const char *GetUnitType();
     246                 :     CPLErr SetUnitType( const char * ); 
     247                 : 
     248                 :     virtual char **GetCategoryNames();
     249                 :     virtual CPLErr SetCategoryNames( char ** );
     250                 : 
     251                 :     virtual double GetOffset( int *pbSuccess = NULL );
     252                 :     CPLErr SetOffset( double );
     253                 :     virtual double GetScale( int *pbSuccess = NULL );
     254                 :     CPLErr SetScale( double );
     255                 : 
     256                 :     virtual CPLErr  GetHistogram( double dfMin, double dfMax,
     257                 :                           int nBuckets, int * panHistogram,
     258                 :                           int bIncludeOutOfRange, int bApproxOK,
     259                 :                           GDALProgressFunc, void *pProgressData );
     260                 : 
     261                 :     virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
     262                 :                                         int *pnBuckets, int ** ppanHistogram,
     263                 :                                         int bForce,
     264                 :                                         GDALProgressFunc, void *pProgressData);
     265                 : 
     266                 :     virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
     267                 :                                         int nBuckets, int *panHistogram );
     268                 : 
     269                 :     virtual CPLErr      SetMetadata( char ** papszMetadata,
     270                 :                                      const char * pszDomain = "" );
     271                 :     virtual CPLErr      SetMetadataItem( const char * pszName,
     272                 :                                          const char * pszValue,
     273                 :                                          const char * pszDomain = "" );
     274                 : 
     275                 :     virtual const GDALRasterAttributeTable *GetDefaultRAT();
     276                 :     virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
     277                 : 
     278                 :     // new in GDALPamRasterBand. 
     279                 :     virtual CPLErr CloneInfo( GDALRasterBand *poSrcBand, int nCloneInfoFlags );
     280                 : 
     281                 :     // "semi private" methods.
     282                 :     GDALRasterBandPamInfo *GetPamInfo() { return psPam; }
     283                 : };
     284                 : 
     285                 : // These are mainly helper functions for internal use.
     286                 : int CPL_DLL PamParseHistogram( CPLXMLNode *psHistItem, 
     287                 :                                double *pdfMin, double *pdfMax, 
     288                 :                                int *pnBuckets, int **ppanHistogram, 
     289                 :                                int *pbIncludeOutOfRange, int *pbApproxOK );
     290                 : CPLXMLNode CPL_DLL *
     291                 : PamFindMatchingHistogram( CPLXMLNode *psSavedHistograms,
     292                 :                           double dfMin, double dfMax, int nBuckets, 
     293                 :                           int bIncludeOutOfRange, int bApproxOK );
     294                 : CPLXMLNode CPL_DLL *
     295                 : PamHistogramToXMLTree( double dfMin, double dfMax,
     296                 :                        int nBuckets, int * panHistogram,
     297                 :                        int bIncludeOutOfRange, int bApprox );
     298                 : 
     299                 : // For managing the proxy file database.
     300                 : const char CPL_DLL * PamGetProxy( const char * );
     301                 : const char CPL_DLL * PamAllocateProxy( const char * );
     302                 : const char CPL_DLL * PamDeallocateProxy( const char * );
     303                 : void CPL_DLL PamCleanProxyDB( void );
     304                 : 
     305                 : #endif /* ndef GDAL_PAM_H_INCLUDED */

Generated by: LCOV version 1.7