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