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

# gdal_priv.h

    00001 /******************************************************************************
    00002  * $Id: gdal_priv.h,v 1.20 2000/04/30 23:22:16 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,v $
    00032  * Revision 1.20  2000/04/30 23:22:16  warmerda
    00033  * added CreateCopy support
    00034  *
    00035  * Revision 1.19  2000/04/21 21:55:01  warmerda
    00036  * majorobject updates, and overview building
    00037  *
    00038  * Revision 1.18  2000/04/04 23:44:29  warmerda
    00039  * added AutoLoadDrivers() to GDALDriverManager
    00040  *
    00041  * Revision 1.17  2000/03/31 13:41:24  warmerda
    00042  * added gcps
    00043  *
    00044  * Revision 1.16  2000/03/24 00:09:05  warmerda
    00045  * rewrote cache management
    00046  *
    00047  * Revision 1.15  2000/03/09 23:22:03  warmerda
    00048  * added GetHistogram
    00049  *
    00050  * Revision 1.14  2000/03/06 02:20:35  warmerda
    00051  * added colortables, overviews, etc
    00052  *
    00053  * Revision 1.12  2000/01/31 15:00:25  warmerda
    00054  * added some documentation
    00055  *
    00056  * Revision 1.11  2000/01/31 14:24:36  warmerda
    00057  * implemented dataset delete
    00058  *
    00059  * Revision 1.10  1999/11/11 21:59:07  warmerda
    00060  * added GetDriver() for datasets
    00061  *
    00062  * Revision 1.9  1999/10/21 13:23:45  warmerda
    00063  * Added a bit of driver related documentation.
    00064  *
    00065  * Revision 1.8  1999/10/21 12:04:11  warmerda
    00066  * Reorganized header.
    00067  *
    00068  * Revision 1.7  1999/10/01 14:44:02  warmerda
    00069  * added documentation
    00070  *
    00071  * Revision 1.6  1999/04/21 04:16:25  warmerda
    00072  * experimental docs
    00073  *
    00074  * Revision 1.5  1999/01/11 15:36:18  warmerda
    00075  * Added projections support, and a few other things.
    00076  *
    00077  * Revision 1.4  1998/12/31 18:54:25  warmerda
    00078  * Implement initial GDALRasterBlock support, and block cache
    00079  *
    00080  * Revision 1.3  1998/12/06 22:17:09  warmerda
    00081  * Fill out rasterio support.
    00082  *
    00083  * Revision 1.2  1998/12/03 18:34:06  warmerda
    00084  * Update to use CPL
    00085  *
    00086  * Revision 1.1  1998/10/18 06:15:11  warmerda
    00087  * Initial implementation.
    00088  *
    00089  */
    00090
    00091 #ifndef GDAL_PRIV_H_INCLUDED
    00092 #define GDAL_PRIV_H_INCLUDED
    00093
    00094 /* -------------------------------------------------------------------- */
    00095 /*      Predeclare various classes before pulling in gdal.h, the        */
    00096 /*      public declarations.                                            */
    00097 /* -------------------------------------------------------------------- */
    00098 class GDALMajorObject;
    00099 class GDALDataset;
    00100 class GDALRasterBand;
    00101 class GDALDriver;
    00102
    00103 /* -------------------------------------------------------------------- */
    00104 /*      Pull in the public declarations.  This gets the C apis, and     */
    00105 /*      also various constants.  However, we will still get to          */
    00106 /*      provide the real class definitions for the GDAL classes.        */
    00107 /* -------------------------------------------------------------------- */
    00108
    00109 #include "gdal.h"
    00110 #include "cpl_vsi.h"
    00111 #include "cpl_conv.h"
    00112
    00113 /* ******************************************************************** */
    00114 /*                           GDALMajorObject                            */
    00115 /*                                                                      */
    00116 /*      Base class providing metadata, description and other            */
    00117 /*      services shared by major objects.                               */
    00118 /* ******************************************************************** */
    00119
    00120 class CPL_DLL GDALMajorObject
    00121 {
    00122   protected:
    00123     char             *pszDescription;
    00124     char            **papszMetadata;
    00125
    00126   public:
    00127                         GDALMajorObject();
    00128     virtual            ~GDALMajorObject();
    00129
    00130     const char *        GetDescription() const;
    00131     void                SetDescription( const char * );
    00132
    00133     virtual char      **GetMetadata( const char * pszDomain = "" );
    00134     virtual CPLErr      SetMetadata( char ** papszMetadata,
    00135                                      const char * pszDomain = "" );
    00136     virtual const char *GetMetadataItem( const char * pszName,
    00137                                          const char * pszDomain = "" );
    00138     virtual CPLErr      SetMetadataItem( const char * pszName,
    00139                                          const char * pszValue,
    00140                                          const char * pszDomain = "" );
    00141 };
    00142
    00143 /* ******************************************************************** */
    00144 /*                             GDALProjDef                              */
    00145 /* ******************************************************************** */
    00146
    00148
    00149 class CPL_DLL GDALProjDef
    00150 {
    00151     void        *psPJ;
    00152
    00153     char        *pszProjection;
    00154
    00155   public:
    00156                 GDALProjDef( const char * = NULL );
    00157                 ~GDALProjDef();
    00158
    00159     CPLErr      ToLongLat( double * padfX, double * padfY );
    00160     CPLErr      FromLongLat( double * padfX, double * padfY );
    00161
    00162     const char  *GetProjectionString( void ) { return pszProjection; }
    00163     CPLErr      SetProjectionString( const char * );
    00164 };
    00165
    00166 /* ******************************************************************** */
    00167 /*                         GDALDefaultOverviews                         */
    00168 /* ******************************************************************** */
    00169 class GDALDefaultOverviews
    00170 {
    00171     GDALDataset *poDS;
    00172     GDALDataset *poODS;
    00173
    00174   public:
    00175                GDALDefaultOverviews();
    00176                ~GDALDefaultOverviews();
    00177
    00178     void       Initialize( GDALDataset *, const char * = NULL );
    00179     int        IsInitialized() { return poDS != NULL; }
    00180
    00181     int        GetOverviewCount(int);
    00182     GDALRasterBand *GetOverview(int,int);
    00183
    00184     CPLErr     BuildOverviews( const char * pszBasename,
    00185                                const char * pszResampling,
    00186                                int nOverviews, int * panOverviewList,
    00187                                int nBands, int * panBandList,
    00188                                GDALProgressFunc pfnProgress,
    00189                                void *pProgressData );
    00190 };
    00191
    00192 /* ******************************************************************** */
    00193 /*                             GDALDataset                              */
    00194 /* ******************************************************************** */
    00195
    00202 class CPL_DLL GDALDataset : public GDALMajorObject
    00203 {
    00204     friend GDALDatasetH GDALOpen( const char *, GDALAccess);
    00205
    00206   protected:
    00207     GDALDriver  *poDriver;
    00208     GDALAccess  eAccess;
    00209
    00210     // Stored raster information.
    00211     int         nRasterXSize;
    00212     int         nRasterYSize;
    00213     int         nBands;
    00214     GDALRasterBand **papoBands;
    00215
    00216     int         nRefCount;
    00217
    00218                 GDALDataset(void);
    00219     void        RasterInitialize( int, int );
    00220     void        SetBand( int, GDALRasterBand * );
    00221
    00222     GDALDefaultOverviews oOvManager;
    00223
    00224     virtual CPLErr IBuildOverviews( const char *, int, int *,
    00225                                     int, int *, GDALProgressFunc, void * );
    00226
    00227     friend class GDALRasterBand;
    00228
    00229   public:
    00230     virtual     ~GDALDataset();
    00231
    00232     int         GetRasterXSize( void );
    00233     int         GetRasterYSize( void );
    00234     int         GetRasterCount( void );
    00235     GDALRasterBand *GetRasterBand( int );
    00236
    00237     virtual void FlushCache(void);
    00238
    00239     virtual const char *GetProjectionRef(void);
    00240     virtual CPLErr SetProjection( const char * );
    00241
    00242     virtual CPLErr GetGeoTransform( double * );
    00243     virtual CPLErr SetGeoTransform( double * );
    00244
    00245     virtual void *GetInternalHandle( const char * );
    00246     virtual GDALDriver *GetDriver(void);
    00247
    00248     virtual int    GetGCPCount();
    00249     virtual const char *GetGCPProjection();
    00250     virtual const GDAL_GCP *GetGCPs();
    00251
    00252     int           Reference();
    00253     int           Dereference();
    00254     GDALAccess    GetAccess() { return eAccess; }
    00255
    00256     CPLErr BuildOverviews( const char *, int, int *,
    00257                            int, int *, GDALProgressFunc, void * );
    00258 };
    00259
    00260 /* ******************************************************************** */
    00261 /*                           GDALRasterBlock                            */
    00262 /* ******************************************************************** */
    00263
    00266 class CPL_DLL GDALRasterBlock
    00267 {
    00268     GDALDataType        eType;
    00269
    00270     int                 nAge;
    00271     int                 bDirty;
    00272
    00273     int                 nXOff;
    00274     int                 nYOff;
    00275
    00276     int                 nXSize;
    00277     int                 nYSize;
    00278
    00279     void                *pData;
    00280
    00281     GDALRasterBand      *poBand;
    00282
    00283     GDALRasterBlock     *poNext;
    00284     GDALRasterBlock     *poPrevious;
    00285
    00286   public:
    00287                 GDALRasterBlock( GDALRasterBand *, int, int );
    00288     virtual     ~GDALRasterBlock();
    00289
    00290     CPLErr      Internalize( void );    /* make copy of data */
    00291     void        Touch( void );          /* update age */
    00292     void        MarkDirty( void );      /* data has been modified since read */
    00293     void        MarkClean( void );
    00294
    00295     CPLErr      Write();
    00296
    00297     GDALDataType GetDataType() { return eType; }
    00298     int         GetXOff() { return nXOff; }
    00299     int         GetYOff() { return nYOff; }
    00300     int         GetXSize() { return nXSize; }
    00301     int         GetYSize() { return nYSize; }
    00302     int         GetAge() { return nAge; }
    00303     int         GetDirty() { return bDirty; }
    00304
    00305     void        *GetDataRef( void ) { return pData; }
    00306
    00307     GDALRasterBand *GetBand() { return poBand; }
    00308
    00309     static void FlushOldestBlock();
    00310     static void Verify();
    00311
    00312 };
    00313
    00314
    00315 /* ******************************************************************** */
    00316 /*                             GDALColorTable                           */
    00317 /* ******************************************************************** */
    00318
    00319 class CPL_DLL GDALColorTable
    00320 {
    00321     GDALPaletteInterp eInterp;
    00322
    00323     int         nEntryCount;
    00324     GDALColorEntry *paoEntries;
    00325
    00326 public:
    00327                 GDALColorTable( GDALPaletteInterp = GPI_RGB );
    00328                 ~GDALColorTable();
    00329
    00330     GDALColorTable *Clone() const;
    00331
    00332     GDALPaletteInterp GetPaletteInterpretation() const;
    00333
    00334     int           GetColorEntryCount() const;
    00335     const GDALColorEntry *GetColorEntry( int ) const;
    00336     int           GetColorEntryAsRGB( int, GDALColorEntry * ) const;
    00337     void          SetColorEntry( int, const GDALColorEntry * );
    00338 };
    00339
    00340 /* ******************************************************************** */
    00341 /*                            GDALRasterBand                            */
    00342 /* ******************************************************************** */
    00343
    00345
    00346 class CPL_DLL GDALRasterBand : public GDALMajorObject
    00347 {
    00348   protected:
    00349     GDALDataset *poDS;
    00350     int         nBand; /* 1 based */
    00351
    00352     int         nRasterXSize;
    00353     int         nRasterYSize;
    00354
    00355     GDALDataType eDataType;
    00356     GDALAccess  eAccess;
    00357
    00358     /* stuff related to blocking, and raster cache */
    00359     int         nBlockXSize;
    00360     int         nBlockYSize;
    00361     int         nBlocksPerRow;
    00362     int         nBlocksPerColumn;
    00363
    00364     GDALRasterBlock **papoBlocks;
    00365
    00366     friend class GDALDataset;
    00367     friend class GDALRasterBlock;
    00368
    00369   protected:
    00370     virtual CPLErr IReadBlock( int, int, void * ) = 0;
    00371     virtual CPLErr IWriteBlock( int, int, void * );
    00372     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
    00373                               void *, int, int, GDALDataType,
    00374                               int, int );
    00375     CPLErr         OverviewRasterIO( GDALRWFlag, int, int, int, int,
    00376                                      void *, int, int, GDALDataType,
    00377                                      int, int );
    00378
    00379     CPLErr         AdoptBlock( int, int, GDALRasterBlock * );
    00380     void           InitBlockInfo();
    00381
    00382   public:
    00383                 GDALRasterBand();
    00384
    00385     virtual     ~GDALRasterBand();
    00386
    00387     int         GetXSize();
    00388     int         GetYSize();
    00389
    00390     GDALDataType GetRasterDataType( void );
    00391     void        GetBlockSize( int *, int * );
    00392     GDALAccess  GetAccess();
    00393
    00394     CPLErr      RasterIO( GDALRWFlag, int, int, int, int,
    00395                           void *, int, int, GDALDataType,
    00396                           int, int );
    00397     CPLErr      ReadBlock( int, int, void * );
    00398
    00399     CPLErr      WriteBlock( int, int, void * );
    00400
    00401     GDALRasterBlock *GetBlockRef( int, int );
    00402     CPLErr      FlushCache();
    00403     CPLErr      FlushBlock( int = -1, int = -1 );
    00404
    00405     // New OpengIS CV_SampleDimension stuff.
    00406
    00407     virtual const char  *GetDescription();
    00408     virtual char **GetCategoryNames();
    00409     virtual double GetNoDataValue( int *pbSuccess = NULL );
    00410     virtual double GetMinimum( int *pbSuccess = NULL );
    00411     virtual double GetMaximum(int *pbSuccess = NULL );
    00412     virtual double GetOffset( int *pbSuccess = NULL );
    00413     virtual double GetScale( int *pbSuccess = NULL );
    00414     virtual const char *GetUnitType();
    00415     virtual GDALColorInterp GetColorInterpretation();
    00416     virtual GDALColorTable *GetColorTable();
    00417
    00418     virtual int HasArbitraryOverviews();
    00419     virtual int GetOverviewCount();
    00420     virtual GDALRasterBand *GetOverview(int);
    00421     virtual CPLErr BuildOverviews( const char *, int, int *,
    00422                                    GDALProgressFunc, void * );
    00423
    00424     CPLErr  GetHistogram( double dfMin, double dfMax,
    00425                           int nBuckets, int * panHistogram,
    00426                           int bIncludeOutOfRange, int bApproxOK,
    00427                           GDALProgressFunc, void *pProgressData );
    00428 };
    00429
    00430 /* ******************************************************************** */
    00431 /*                             GDALOpenInfo                             */
    00432 /*                                                                      */
    00433 /*      Structure of data about dataset for open functions.             */
    00434 /* ******************************************************************** */
    00435
    00436 class CPL_DLL GDALOpenInfo
    00437 {
    00438   public:
    00439
    00440                 GDALOpenInfo( const char * pszFile, GDALAccess eAccessIn );
    00441                 ~GDALOpenInfo( void );
    00442
    00443     char        *pszFilename;
    00444
    00445     GDALAccess  eAccess;
    00446
    00447     GBool       bStatOK;
    00448     VSIStatBuf  sStat;
    00449
    00450     FILE        *fp;
    00451
    00452     int         nHeaderBytes;
    00453     GByte       *pabyHeader;
    00454
    00455 };
    00456
    00457 /* ******************************************************************** */
    00458 /*                              GDALDriver                              */
    00459 /* ******************************************************************** */
    00460
    00470 class CPL_DLL GDALDriver : public GDALMajorObject
    00471 {
    00472   public:
    00473                         GDALDriver();
    00474                         ~GDALDriver();
    00475
    00477     char                *pszShortName;
    00478
    00480     char                *pszLongName;
    00481
    00483     char                *pszHelpTopic;
    00484
    00485     GDALDataset         *(*pfnOpen)( GDALOpenInfo * );
    00486
    00487     GDALDataset         *(*pfnCreate)( const char * pszName,
    00488                                        int nXSize, int nYSize, int nBands,
    00489                                        GDALDataType eType,
    00490                                        char ** papszOptions );
    00491
    00492     GDALDataset         *Create( const char * pszName,
    00493                                  int nXSize, int nYSize, int nBands,
    00494                                  GDALDataType eType, char ** papszOptions );
    00495
    00496     CPLErr              (*pfnDelete)( const char * pszName );
    00497
    00498     CPLErr              Delete( const char * pszName );
    00499
    00500     GDALDataset         *CreateCopy( const char *, GDALDataset *,
    00501                                      int, char **,
    00502                                      GDALProgressFunc pfnProgress,
    00503                                      void * pProgressData );
    00504
    00505     GDALDataset         *(*pfnCreateCopy)( const char *, GDALDataset *,
    00506                                            int, char **,
    00507                                            GDALProgressFunc pfnProgress,
    00508                                            void * pProgressData );
    00509 };
    00510
    00511 /* ******************************************************************** */
    00512 /*                          GDALDriverManager                           */
    00513 /* ******************************************************************** */
    00514
    00522 class CPL_DLL GDALDriverManager : public GDALMajorObject
    00523 {
    00524     int         nDrivers;
    00525     GDALDriver  **papoDrivers;
    00526
    00527     char        *pszHome;
    00528
    00529  public:
    00530                 GDALDriverManager();
    00531                 ~GDALDriverManager();
    00532
    00533     int         GetDriverCount( void );
    00534     GDALDriver  *GetDriver( int );
    00535     GDALDriver  *GetDriverByName( const char * );
    00536
    00537     int         RegisterDriver( GDALDriver * );
    00538     void        MoveDriver( GDALDriver *, int );
    00539     void        DeregisterDriver( GDALDriver * );
    00540
    00541     void        AutoLoadDrivers();
    00542
    00543     const char *GetHome();
    00544     void        SetHome( const char * );
    00545 };
    00546
    00547 CPL_C_START
    00548 GDALDriverManager * GetGDALDriverManager( void );
    00549 CPL_C_END
    00550
    00551 /* ==================================================================== */
    00552 /*      An assortment of overview related stuff.                        */
    00553 /* ==================================================================== */
    00554
    00555 CPL_C_START
    00556
    00557 CPLErr
    00558 GTIFFBuildOverviews( const char * pszFilename,
    00559                      int nBands, GDALRasterBand **papoBandList,
    00560                      int nOverviews, int * panOverviewList,
    00561                      const char * pszResampling,
    00562                      GDALProgressFunc pfnProgress, void * pProgressData );
    00563
    00564 CPLErr
    00565 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
    00566                            const char * pszResampling,
    00567                            int nOverviews, int * panOverviewList,
    00568                            int nBands, int * panBandList,
    00569                            GDALProgressFunc pfnProgress, void * pProgressData);
    00570
    00571
    00572 CPLErr
    00573 GDALRegenerateOverviews( GDALRasterBand *, int, GDALRasterBand **,
    00574                          const char *, GDALProgressFunc, void * );
    00575
    00576 CPL_C_END
    00577
    00578 #endif /* ndef GDAL_PRIV_H_INCLUDED */