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

gdal_priv.h

00001 /******************************************************************************
00002  * $Id: gdal_priv_h-source.html,v 1.6 2000/11/06 04:49:01 warmerda Exp $
00003  *
00004  * Name:     gdal_priv.h
00005  * Project:  GDAL Core
00006  * Purpose:  GDAL Core C++/Private declarations. 
00007  * Author:   Frank Warmerdam, warmerda@home.com
00008  *
00009  ******************************************************************************
00010  * Copyright (c) 1998, Frank Warmerdam
00011  *
00012  * Permission is hereby granted, free of charge, to any person obtaining a
00013  * copy of this software and associated documentation files (the "Software"),
00014  * to deal in the Software without restriction, including without limitation
00015  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00016  * and/or sell copies of the Software, and to permit persons to whom the
00017  * Software is furnished to do so, subject to the following conditions:
00018  *
00019  * The above copyright notice and this permission notice shall be included
00020  * in all copies or substantial portions of the Software.
00021  *
00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00023  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00024  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00025  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00026  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00027  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00028  * DEALINGS IN THE SOFTWARE.
00029  ******************************************************************************
00030  *
00031  * $Log: gdal_priv_h-source.html,v $
00031  * Revision 1.6  2000/11/06 04:49:01  warmerda
00031  * *** empty log message ***
00031  *
00032  * Revision 1.22  2000/10/06 15:26:08  warmerda
00033  * added SetNoDataValue, SetCategoryNames
00034  *
00035  * Revision 1.21  2000/07/20 13:38:26  warmerda
00036  * make GetGDALDriverManager public with CPL_DLL
00037  *
00038  * Revision 1.20  2000/04/30 23:22:16  warmerda
00039  * added CreateCopy support
00040  *
00041  * Revision 1.19  2000/04/21 21:55:01  warmerda
00042  * majorobject updates, and overview building
00043  *
00044  * Revision 1.18  2000/04/04 23:44:29  warmerda
00045  * added AutoLoadDrivers() to GDALDriverManager
00046  *
00047  * Revision 1.17  2000/03/31 13:41:24  warmerda
00048  * added gcps
00049  *
00050  * Revision 1.16  2000/03/24 00:09:05  warmerda
00051  * rewrote cache management
00052  *
00053  * Revision 1.15  2000/03/09 23:22:03  warmerda
00054  * added GetHistogram
00055  *
00056  * Revision 1.14  2000/03/06 02:20:35  warmerda
00057  * added colortables, overviews, etc
00058  *
00059  * Revision 1.12  2000/01/31 15:00:25  warmerda
00060  * added some documentation
00061  *
00062  * Revision 1.11  2000/01/31 14:24:36  warmerda
00063  * implemented dataset delete
00064  *
00065  * Revision 1.10  1999/11/11 21:59:07  warmerda
00066  * added GetDriver() for datasets
00067  *
00068  * Revision 1.9  1999/10/21 13:23:45  warmerda
00069  * Added a bit of driver related documentation.
00070  *
00071  * Revision 1.8  1999/10/21 12:04:11  warmerda
00072  * Reorganized header.
00073  *
00074  * Revision 1.7  1999/10/01 14:44:02  warmerda
00075  * added documentation
00076  *
00077  * Revision 1.6  1999/04/21 04:16:25  warmerda
00078  * experimental docs
00079  *
00080  * Revision 1.5  1999/01/11 15:36:18  warmerda
00081  * Added projections support, and a few other things.
00082  *
00083  * Revision 1.4  1998/12/31 18:54:25  warmerda
00084  * Implement initial GDALRasterBlock support, and block cache
00085  *
00086  * Revision 1.3  1998/12/06 22:17:09  warmerda
00087  * Fill out rasterio support.
00088  *
00089  * Revision 1.2  1998/12/03 18:34:06  warmerda
00090  * Update to use CPL
00091  *
00092  * Revision 1.1  1998/10/18 06:15:11  warmerda
00093  * Initial implementation.
00094  *
00095  */
00096 
00097 #ifndef GDAL_PRIV_H_INCLUDED
00098 #define GDAL_PRIV_H_INCLUDED
00099 
00100 /* -------------------------------------------------------------------- */
00101 /*      Predeclare various classes before pulling in gdal.h, the        */
00102 /*      public declarations.                                            */
00103 /* -------------------------------------------------------------------- */
00104 class GDALMajorObject;
00105 class GDALDataset;
00106 class GDALRasterBand;
00107 class GDALDriver;
00108 
00109 /* -------------------------------------------------------------------- */
00110 /*      Pull in the public declarations.  This gets the C apis, and     */
00111 /*      also various constants.  However, we will still get to          */
00112 /*      provide the real class definitions for the GDAL classes.        */
00113 /* -------------------------------------------------------------------- */
00114 
00115 #include "gdal.h"
00116 #include "cpl_vsi.h"
00117 #include "cpl_conv.h"
00118 
00119 /* ******************************************************************** */
00120 /*                           GDALMajorObject                            */
00121 /*                                                                      */
00122 /*      Base class providing metadata, description and other            */
00123 /*      services shared by major objects.                               */
00124 /* ******************************************************************** */
00125 
00126 class CPL_DLL GDALMajorObject
00127 {
00128   protected:
00129     char             *pszDescription;
00130     char            **papszMetadata;
00131     
00132   public:
00133                         GDALMajorObject();
00134     virtual            ~GDALMajorObject();
00135                         
00136     const char *        GetDescription() const;
00137     void                SetDescription( const char * );
00138 
00139     virtual char      **GetMetadata( const char * pszDomain = "" );
00140     virtual CPLErr      SetMetadata( char ** papszMetadata,
00141                                      const char * pszDomain = "" );
00142     virtual const char *GetMetadataItem( const char * pszName,
00143                                          const char * pszDomain = "" );
00144     virtual CPLErr      SetMetadataItem( const char * pszName,
00145                                          const char * pszValue,
00146                                          const char * pszDomain = "" );
00147 };
00148 
00149 /* ******************************************************************** */
00150 /*                             GDALProjDef                              */
00151 /* ******************************************************************** */
00152 
00154 
00155 class CPL_DLL GDALProjDef
00156 {
00157     void        *psPJ;
00158 
00159     char        *pszProjection;
00160 
00161   public:
00162                 GDALProjDef( const char * = NULL );
00163                 ~GDALProjDef();
00164 
00165     CPLErr      ToLongLat( double * padfX, double * padfY );
00166     CPLErr      FromLongLat( double * padfX, double * padfY );
00167 
00168     const char  *GetProjectionString( void ) { return pszProjection; }
00169     CPLErr      SetProjectionString( const char * );
00170 };
00171 
00172 /* ******************************************************************** */
00173 /*                         GDALDefaultOverviews                         */
00174 /* ******************************************************************** */
00175 class GDALDefaultOverviews
00176 {
00177     GDALDataset *poDS;
00178     GDALDataset *poODS;
00179     
00180   public:
00181                GDALDefaultOverviews();
00182                ~GDALDefaultOverviews();
00183 
00184     void       Initialize( GDALDataset *, const char * = NULL );
00185     int        IsInitialized() { return poDS != NULL; }
00186 
00187     int        GetOverviewCount(int);
00188     GDALRasterBand *GetOverview(int,int);
00189 
00190     CPLErr     BuildOverviews( const char * pszBasename,
00191                                const char * pszResampling, 
00192                                int nOverviews, int * panOverviewList,
00193                                int nBands, int * panBandList,
00194                                GDALProgressFunc pfnProgress,
00195                                void *pProgressData );
00196 };
00197 
00198 /* ******************************************************************** */
00199 /*                             GDALDataset                              */
00200 /* ******************************************************************** */
00201 
00208 class CPL_DLL GDALDataset : public GDALMajorObject
00209 {
00210     friend GDALDatasetH GDALOpen( const char *, GDALAccess);
00211     
00212   protected:
00213     GDALDriver  *poDriver;
00214     GDALAccess  eAccess;
00215     
00216     // Stored raster information.
00217     int         nRasterXSize;
00218     int         nRasterYSize;
00219     int         nBands;
00220     GDALRasterBand **papoBands;
00221 
00222     int         nRefCount;
00223 
00224                 GDALDataset(void);
00225     void        RasterInitialize( int, int );
00226     void        SetBand( int, GDALRasterBand * );
00227 
00228     GDALDefaultOverviews oOvManager;
00229     
00230     virtual CPLErr IBuildOverviews( const char *, int, int *,
00231                                     int, int *, GDALProgressFunc, void * );
00232     
00233     friend class GDALRasterBand;
00234     
00235   public:
00236     virtual     ~GDALDataset();
00237 
00238     int         GetRasterXSize( void );
00239     int         GetRasterYSize( void );
00240     int         GetRasterCount( void );
00241     GDALRasterBand *GetRasterBand( int );
00242 
00243     virtual void FlushCache(void);
00244 
00245     virtual const char *GetProjectionRef(void);
00246     virtual CPLErr SetProjection( const char * );
00247 
00248     virtual CPLErr GetGeoTransform( double * );
00249     virtual CPLErr SetGeoTransform( double * );
00250 
00251     virtual void *GetInternalHandle( const char * );
00252     virtual GDALDriver *GetDriver(void);
00253 
00254     virtual int    GetGCPCount();
00255     virtual const char *GetGCPProjection();
00256     virtual const GDAL_GCP *GetGCPs();
00257  
00258     int           Reference();
00259     int           Dereference();
00260     GDALAccess    GetAccess() { return eAccess; }
00261 
00262     CPLErr BuildOverviews( const char *, int, int *,
00263                            int, int *, GDALProgressFunc, void * );
00264 };
00265 
00266 /* ******************************************************************** */
00267 /*                           GDALRasterBlock                            */
00268 /* ******************************************************************** */
00269 
00272 class CPL_DLL GDALRasterBlock
00273 {
00274     GDALDataType        eType;
00275     
00276     int                 nAge;
00277     int                 bDirty;
00278 
00279     int                 nXOff;
00280     int                 nYOff;
00281        
00282     int                 nXSize;
00283     int                 nYSize;
00284     
00285     void                *pData;
00286 
00287     GDALRasterBand      *poBand;
00288     
00289     GDALRasterBlock     *poNext;
00290     GDALRasterBlock     *poPrevious;
00291 
00292   public:
00293                 GDALRasterBlock( GDALRasterBand *, int, int );
00294     virtual     ~GDALRasterBlock();
00295 
00296     CPLErr      Internalize( void );    /* make copy of data */
00297     void        Touch( void );          /* update age */
00298     void        MarkDirty( void );      /* data has been modified since read */
00299     void        MarkClean( void );
00300 
00301     CPLErr      Write();
00302 
00303     GDALDataType GetDataType() { return eType; }
00304     int         GetXOff() { return nXOff; }
00305     int         GetYOff() { return nYOff; }
00306     int         GetXSize() { return nXSize; }
00307     int         GetYSize() { return nYSize; }
00308     int         GetAge() { return nAge; }
00309     int         GetDirty() { return bDirty; }
00310 
00311     void        *GetDataRef( void ) { return pData; }
00312 
00313     GDALRasterBand *GetBand() { return poBand; }
00314 
00315     static void FlushOldestBlock();
00316     static void Verify();
00317 
00318 };
00319 
00320 
00321 /* ******************************************************************** */
00322 /*                             GDALColorTable                           */
00323 /* ******************************************************************** */
00324 
00325 class CPL_DLL GDALColorTable
00326 {
00327     GDALPaletteInterp eInterp;
00328 
00329     int         nEntryCount;
00330     GDALColorEntry *paoEntries;
00331 
00332 public:
00333                 GDALColorTable( GDALPaletteInterp = GPI_RGB );
00334                 ~GDALColorTable();
00335 
00336     GDALColorTable *Clone() const;
00337 
00338     GDALPaletteInterp GetPaletteInterpretation() const;
00339 
00340     int           GetColorEntryCount() const;
00341     const GDALColorEntry *GetColorEntry( int ) const;
00342     int           GetColorEntryAsRGB( int, GDALColorEntry * ) const;
00343     void          SetColorEntry( int, const GDALColorEntry * );
00344 };
00345 
00346 /* ******************************************************************** */
00347 /*                            GDALRasterBand                            */
00348 /* ******************************************************************** */
00349 
00351 
00352 class CPL_DLL GDALRasterBand : public GDALMajorObject
00353 {
00354   protected:
00355     GDALDataset *poDS;
00356     int         nBand; /* 1 based */
00357 
00358     int         nRasterXSize;
00359     int         nRasterYSize;
00360     
00361     GDALDataType eDataType;
00362     GDALAccess  eAccess;
00363 
00364     /* stuff related to blocking, and raster cache */
00365     int         nBlockXSize;
00366     int         nBlockYSize;
00367     int         nBlocksPerRow;
00368     int         nBlocksPerColumn;
00369 
00370     GDALRasterBlock **papoBlocks;
00371 
00372     friend class GDALDataset;
00373     friend class GDALRasterBlock;
00374 
00375   protected:
00376     virtual CPLErr IReadBlock( int, int, void * ) = 0;
00377     virtual CPLErr IWriteBlock( int, int, void * );
00378     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00379                               void *, int, int, GDALDataType,
00380                               int, int );
00381     CPLErr         OverviewRasterIO( GDALRWFlag, int, int, int, int,
00382                                      void *, int, int, GDALDataType,
00383                                      int, int );
00384 
00385     CPLErr         AdoptBlock( int, int, GDALRasterBlock * );
00386     void           InitBlockInfo();
00387 
00388   public:
00389                 GDALRasterBand();
00390                 
00391     virtual     ~GDALRasterBand();
00392 
00393     int         GetXSize();
00394     int         GetYSize();
00395 
00396     GDALDataType GetRasterDataType( void );
00397     void        GetBlockSize( int *, int * );
00398     GDALAccess  GetAccess();
00399     
00400     CPLErr      RasterIO( GDALRWFlag, int, int, int, int,
00401                           void *, int, int, GDALDataType,
00402                           int, int );
00403     CPLErr      ReadBlock( int, int, void * );
00404 
00405     CPLErr      WriteBlock( int, int, void * );
00406 
00407     GDALRasterBlock *GetBlockRef( int, int );
00408     CPLErr      FlushCache();
00409     CPLErr      FlushBlock( int = -1, int = -1 );
00410 
00411     // New OpengIS CV_SampleDimension stuff.
00412 
00413     virtual const char  *GetDescription();
00414     virtual char **GetCategoryNames();
00415     virtual double GetNoDataValue( int *pbSuccess = NULL );
00416     virtual double GetMinimum( int *pbSuccess = NULL );
00417     virtual double GetMaximum(int *pbSuccess = NULL );
00418     virtual double GetOffset( int *pbSuccess = NULL );
00419     virtual double GetScale( int *pbSuccess = NULL );
00420     virtual const char *GetUnitType();
00421     virtual GDALColorInterp GetColorInterpretation();
00422     virtual GDALColorTable *GetColorTable();
00423 
00424     virtual CPLErr SetCategoryNames( char ** );
00425     virtual CPLErr SetNoDataValue( double );
00426     virtual CPLErr SetColorTable( GDALColorTable * ); 
00427 
00428     virtual int HasArbitraryOverviews();
00429     virtual int GetOverviewCount();
00430     virtual GDALRasterBand *GetOverview(int);
00431     virtual CPLErr BuildOverviews( const char *, int, int *,
00432                                    GDALProgressFunc, void * );
00433 
00434     CPLErr  GetHistogram( double dfMin, double dfMax,
00435                           int nBuckets, int * panHistogram,
00436                           int bIncludeOutOfRange, int bApproxOK,
00437                           GDALProgressFunc, void *pProgressData );
00438 };
00439 
00440 /* ******************************************************************** */
00441 /*                             GDALOpenInfo                             */
00442 /*                                                                      */
00443 /*      Structure of data about dataset for open functions.             */
00444 /* ******************************************************************** */
00445 
00446 class CPL_DLL GDALOpenInfo
00447 {
00448   public:
00449 
00450                 GDALOpenInfo( const char * pszFile, GDALAccess eAccessIn );
00451                 ~GDALOpenInfo( void );
00452     
00453     char        *pszFilename;
00454 
00455     GDALAccess  eAccess;
00456 
00457     GBool       bStatOK;
00458     VSIStatBuf  sStat;
00459     
00460     FILE        *fp;
00461 
00462     int         nHeaderBytes;
00463     GByte       *pabyHeader;
00464 
00465 };
00466 
00467 /* ******************************************************************** */
00468 /*                              GDALDriver                              */
00469 /* ******************************************************************** */
00470 
00480 class CPL_DLL GDALDriver : public GDALMajorObject
00481 {
00482   public:
00483                         GDALDriver();
00484                         ~GDALDriver();
00485 
00487     char                *pszShortName;
00488 
00490     char                *pszLongName;
00491 
00493     char                *pszHelpTopic;
00494     
00495     GDALDataset         *(*pfnOpen)( GDALOpenInfo * );
00496 
00497     GDALDataset         *(*pfnCreate)( const char * pszName,
00498                                        int nXSize, int nYSize, int nBands,
00499                                        GDALDataType eType,
00500                                        char ** papszOptions );
00501 
00502     GDALDataset         *Create( const char * pszName,
00503                                  int nXSize, int nYSize, int nBands,
00504                                  GDALDataType eType, char ** papszOptions );
00505 
00506     CPLErr              (*pfnDelete)( const char * pszName );
00507 
00508     CPLErr              Delete( const char * pszName );
00509 
00510     GDALDataset         *CreateCopy( const char *, GDALDataset *, 
00511                                      int, char **,
00512                                      GDALProgressFunc pfnProgress, 
00513                                      void * pProgressData );
00514     
00515     GDALDataset         *(*pfnCreateCopy)( const char *, GDALDataset *, 
00516                                            int, char **,
00517                                            GDALProgressFunc pfnProgress, 
00518                                            void * pProgressData );
00519 };
00520 
00521 /* ******************************************************************** */
00522 /*                          GDALDriverManager                           */
00523 /* ******************************************************************** */
00524 
00532 class CPL_DLL GDALDriverManager : public GDALMajorObject
00533 {
00534     int         nDrivers;
00535     GDALDriver  **papoDrivers;
00536 
00537     char        *pszHome;
00538     
00539  public:
00540                 GDALDriverManager();
00541                 ~GDALDriverManager();
00542                 
00543     int         GetDriverCount( void );
00544     GDALDriver  *GetDriver( int );
00545     GDALDriver  *GetDriverByName( const char * );
00546 
00547     int         RegisterDriver( GDALDriver * );
00548     void        MoveDriver( GDALDriver *, int );
00549     void        DeregisterDriver( GDALDriver * );
00550 
00551     void        AutoLoadDrivers();
00552 
00553     const char *GetHome();
00554     void        SetHome( const char * );
00555 };
00556 
00557 CPL_C_START
00558 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
00559 CPL_C_END
00560 
00561 /* ==================================================================== */
00562 /*      An assortment of overview related stuff.                        */
00563 /* ==================================================================== */
00564 
00565 CPL_C_START
00566 
00567 CPLErr 
00568 GTIFFBuildOverviews( const char * pszFilename,
00569                      int nBands, GDALRasterBand **papoBandList, 
00570                      int nOverviews, int * panOverviewList,
00571                      const char * pszResampling, 
00572                      GDALProgressFunc pfnProgress, void * pProgressData );
00573 
00574 CPLErr
00575 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
00576                            const char * pszResampling, 
00577                            int nOverviews, int * panOverviewList,
00578                            int nBands, int * panBandList,
00579                            GDALProgressFunc pfnProgress, void * pProgressData);
00580                            
00581 
00582 CPLErr
00583 GDALRegenerateOverviews( GDALRasterBand *, int, GDALRasterBand **,
00584                          const char *, GDALProgressFunc, void * );
00585 
00586 CPL_C_END
00587 
00588 #endif /* ndef GDAL_PRIV_H_INCLUDED */

doxygen1.2.3-20001105 Dimitri van Heesch, © 1997-2000