GDAL
gdal_priv.h
00001 /******************************************************************************
00002  * $Id: gdal_priv.h 25615 2013-02-08 22:24:32Z rouault $
00003  *
00004  * Name:     gdal_priv.h
00005  * Project:  GDAL Core
00006  * Purpose:  GDAL Core C++/Private declarations. 
00007  * Author:   Frank Warmerdam, warmerdam@pobox.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 #ifndef GDAL_PRIV_H_INCLUDED
00032 #define GDAL_PRIV_H_INCLUDED
00033 
00034 /* -------------------------------------------------------------------- */
00035 /*      Predeclare various classes before pulling in gdal.h, the        */
00036 /*      public declarations.                                            */
00037 /* -------------------------------------------------------------------- */
00038 class GDALMajorObject;
00039 class GDALDataset;
00040 class GDALRasterBand;
00041 class GDALDriver;
00042 class GDALRasterAttributeTable;
00043 class GDALProxyDataset;
00044 class GDALProxyRasterBand;
00045 class GDALAsyncReader;
00046 
00047 /* -------------------------------------------------------------------- */
00048 /*      Pull in the public declarations.  This gets the C apis, and     */
00049 /*      also various constants.  However, we will still get to          */
00050 /*      provide the real class definitions for the GDAL classes.        */
00051 /* -------------------------------------------------------------------- */
00052 
00053 #include "gdal.h"
00054 #include "gdal_frmts.h"
00055 #include "cpl_vsi.h"
00056 #include "cpl_conv.h"
00057 #include "cpl_string.h"
00058 #include "cpl_minixml.h"
00059 #include <vector>
00060 
00061 #define GMO_VALID                0x0001
00062 #define GMO_IGNORE_UNIMPLEMENTED 0x0002
00063 #define GMO_SUPPORT_MD           0x0004
00064 #define GMO_SUPPORT_MDMD         0x0008
00065 #define GMO_MD_DIRTY             0x0010
00066 #define GMO_PAM_CLASS            0x0020
00067 
00068 /************************************************************************/
00069 /*                       GDALMultiDomainMetadata                        */
00070 /************************************************************************/
00071 
00072 class CPL_DLL GDALMultiDomainMetadata
00073 {
00074 private:
00075     char **papszDomainList;
00076     CPLStringList **papoMetadataLists;
00077 
00078 public:
00079     GDALMultiDomainMetadata();
00080     ~GDALMultiDomainMetadata();
00081 
00082     int         XMLInit( CPLXMLNode *psMetadata, int bMerge );
00083     CPLXMLNode  *Serialize();
00084 
00085     char      **GetDomainList() { return papszDomainList; }
00086 
00087     char      **GetMetadata( const char * pszDomain = "" );
00088     CPLErr      SetMetadata( char ** papszMetadata,
00089                              const char * pszDomain = "" );
00090     const char *GetMetadataItem( const char * pszName,
00091                                  const char * pszDomain = "" );
00092     CPLErr      SetMetadataItem( const char * pszName,
00093                                  const char * pszValue,
00094                                  const char * pszDomain = "" );
00095 
00096     void        Clear();
00097 };
00098 
00099 /* ******************************************************************** */
00100 /*                           GDALMajorObject                            */
00101 /*                                                                      */
00102 /*      Base class providing metadata, description and other            */
00103 /*      services shared by major objects.                               */
00104 /* ******************************************************************** */
00105 
00107 
00108 class CPL_DLL GDALMajorObject
00109 {
00110   protected:
00111     int                 nFlags; // GMO_* flags. 
00112     CPLString           sDescription;
00113     GDALMultiDomainMetadata oMDMD;
00114     
00115   public:
00116                         GDALMajorObject();
00117     virtual            ~GDALMajorObject();
00118 
00119     int                 GetMOFlags();
00120     void                SetMOFlags(int nFlags);
00121                         
00122     virtual const char *GetDescription() const;
00123     virtual void        SetDescription( const char * );
00124 
00125     virtual char      **GetMetadata( const char * pszDomain = "" );
00126     virtual CPLErr      SetMetadata( char ** papszMetadata,
00127                                      const char * pszDomain = "" );
00128     virtual const char *GetMetadataItem( const char * pszName,
00129                                          const char * pszDomain = "" );
00130     virtual CPLErr      SetMetadataItem( const char * pszName,
00131                                          const char * pszValue,
00132                                          const char * pszDomain = "" );
00133 };
00134 
00135 /* ******************************************************************** */
00136 /*                         GDALDefaultOverviews                         */
00137 /* ******************************************************************** */
00138 class CPL_DLL GDALDefaultOverviews
00139 {
00140     friend class GDALDataset;
00141 
00142     GDALDataset *poDS;
00143     GDALDataset *poODS;
00144     
00145     CPLString   osOvrFilename;
00146 
00147     int         bOvrIsAux;
00148 
00149     int         bCheckedForMask;
00150     int         bOwnMaskDS;
00151     GDALDataset *poMaskDS;
00152 
00153     // for "overview datasets" we record base level info so we can 
00154     // find our way back to get overview masks.
00155     GDALDataset *poBaseDS;
00156 
00157     // Stuff for deferred initialize/overviewscans...
00158     bool        bCheckedForOverviews;
00159     void        OverviewScan();
00160     char       *pszInitName;
00161     int         bInitNameIsOVR;
00162     char      **papszInitSiblingFiles;
00163 
00164   public:
00165                GDALDefaultOverviews();
00166                ~GDALDefaultOverviews();
00167 
00168     void       Initialize( GDALDataset *poDS, const char *pszName = NULL, 
00169                            char **papszSiblingFiles = NULL,
00170                            int bNameIsOVR = FALSE );
00171 
00172     int        IsInitialized();
00173 
00174     int        CloseDependentDatasets();
00175 
00176     // Overview Related
00177 
00178     int        GetOverviewCount(int);
00179     GDALRasterBand *GetOverview(int,int);
00180 
00181     CPLErr     BuildOverviews( const char * pszBasename,
00182                                const char * pszResampling, 
00183                                int nOverviews, int * panOverviewList,
00184                                int nBands, int * panBandList,
00185                                GDALProgressFunc pfnProgress,
00186                                void *pProgressData );
00187 
00188     CPLErr     BuildOverviewsSubDataset( const char * pszPhysicalFile,
00189                                          const char * pszResampling, 
00190                                          int nOverviews, int * panOverviewList,
00191                                          int nBands, int * panBandList,
00192                                          GDALProgressFunc pfnProgress,
00193                                          void *pProgressData );
00194 
00195     CPLErr     CleanOverviews();
00196 
00197     // Mask Related
00198 
00199     CPLErr     CreateMaskBand( int nFlags, int nBand = -1 );
00200     GDALRasterBand *GetMaskBand( int nBand );
00201     int        GetMaskFlags( int nBand );
00202 
00203     int        HaveMaskFile( char **papszSiblings = NULL, 
00204                              const char *pszBasename = NULL );
00205 
00206     char**     GetSiblingFiles() { return papszInitSiblingFiles; }
00207 };
00208 
00209 /* ******************************************************************** */
00210 /*                             GDALOpenInfo                             */
00211 /*                                                                      */
00212 /*      Structure of data about dataset for open functions.             */
00213 /* ******************************************************************** */
00214 
00215 class CPL_DLL GDALOpenInfo
00216 {
00217   public:
00218                 GDALOpenInfo( const char * pszFile, GDALAccess eAccessIn,
00219                               char **papszSiblingFiles = NULL );
00220                 ~GDALOpenInfo( void );
00221 
00222     char        *pszFilename;
00223     char        **papszSiblingFiles;
00224 
00225     GDALAccess  eAccess;
00226 
00227     int         bStatOK;
00228     int         bIsDirectory;
00229 
00230     FILE        *fp;
00231 
00232     int         nHeaderBytes;
00233     GByte       *pabyHeader;
00234 
00235 };
00236 
00237 /* ******************************************************************** */
00238 /*                             GDALDataset                              */
00239 /* ******************************************************************** */
00240 
00241 /* Internal method for now. Might be subject to later revisions */
00242 GDALDatasetH GDALOpenInternal( const char * pszFilename, GDALAccess eAccess,
00243                                const char* const * papszAllowedDrivers);
00244 GDALDatasetH GDALOpenInternal( GDALOpenInfo& oOpenInfo,
00245                                const char* const * papszAllowedDrivers);
00246 
00248 
00249 class CPL_DLL GDALDataset : public GDALMajorObject
00250 {
00251     friend GDALDatasetH CPL_STDCALL GDALOpen( const char *, GDALAccess);
00252     friend GDALDatasetH CPL_STDCALL GDALOpenShared( const char *, GDALAccess);
00253 
00254     /* Internal method for now. Might be subject to later revisions */
00255     friend GDALDatasetH GDALOpenInternal( const char *, GDALAccess, const char* const * papszAllowedDrivers);
00256     friend GDALDatasetH GDALOpenInternal( GDALOpenInfo& oOpenInfo,
00257                                           const char* const * papszAllowedDrivers);
00258 
00259     friend class GDALDriver;
00260     friend class GDALDefaultOverviews;
00261     friend class GDALProxyDataset;
00262     friend class GDALDriverManager;
00263 
00264   protected:
00265     GDALDriver  *poDriver;
00266     GDALAccess  eAccess;
00267     
00268     // Stored raster information.
00269     int         nRasterXSize;
00270     int         nRasterYSize;
00271     int         nBands;
00272     GDALRasterBand **papoBands;
00273 
00274     int         bForceCachedIO;
00275 
00276     int         nRefCount;
00277     int         bShared;
00278 
00279                 GDALDataset(void);
00280     void        RasterInitialize( int, int );
00281     void        SetBand( int, GDALRasterBand * );
00282 
00283     GDALDefaultOverviews oOvManager;
00284     
00285     virtual CPLErr IBuildOverviews( const char *, int, int *,
00286                                     int, int *, GDALProgressFunc, void * );
00287     
00288     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00289                               void *, int, int, GDALDataType,
00290                               int, int *, int, int, int );
00291 
00292     CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
00293                                void *, int, int, GDALDataType,
00294                                int, int *, int, int, int );
00295     void   BlockBasedFlushCache();
00296 
00297     virtual int         CloseDependentDatasets();
00298 
00299     friend class GDALRasterBand;
00300     
00301   public:
00302     virtual     ~GDALDataset();
00303 
00304     int         GetRasterXSize( void );
00305     int         GetRasterYSize( void );
00306     int         GetRasterCount( void );
00307     GDALRasterBand *GetRasterBand( int );
00308 
00309     virtual void FlushCache(void);
00310 
00311     virtual const char *GetProjectionRef(void);
00312     virtual CPLErr SetProjection( const char * );
00313 
00314     virtual CPLErr GetGeoTransform( double * );
00315     virtual CPLErr SetGeoTransform( double * );
00316 
00317     virtual CPLErr        AddBand( GDALDataType eType, 
00318                                    char **papszOptions=NULL );
00319 
00320     virtual void *GetInternalHandle( const char * );
00321     virtual GDALDriver *GetDriver(void);
00322     virtual char      **GetFileList(void);
00323 
00324     virtual int    GetGCPCount();
00325     virtual const char *GetGCPProjection();
00326     virtual const GDAL_GCP *GetGCPs();
00327     virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
00328                             const char *pszGCPProjection );
00329 
00330     virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
00331                                int nBufXSize, int nBufYSize, 
00332                                GDALDataType eDT, 
00333                                int nBandCount, int *panBandList,
00334                                char **papszOptions );
00335 
00336     virtual CPLErr          CreateMaskBand( int nFlags );
00337 
00338     virtual GDALAsyncReader* 
00339         BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize,
00340                          void *pBuf, int nBufXSize, int nBufYSize,
00341                          GDALDataType eBufType,
00342                          int nBandCount, int* panBandMap,
00343                          int nPixelSpace, int nLineSpace, int nBandSpace,
00344                          char **papszOptions);
00345     virtual void EndAsyncReader(GDALAsyncReader *);
00346 
00347     CPLErr      RasterIO( GDALRWFlag, int, int, int, int,
00348                           void *, int, int, GDALDataType,
00349                           int, int *, int, int, int );
00350 
00351     int           Reference();
00352     int           Dereference();
00353     GDALAccess    GetAccess() { return eAccess; }
00354 
00355     int           GetShared();
00356     void          MarkAsShared();
00357 
00358     static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
00359 
00360     CPLErr BuildOverviews( const char *, int, int *,
00361                            int, int *, GDALProgressFunc, void * );
00362 
00363     void ReportError(CPLErr eErrClass, int err_no, const char *fmt, ...)  CPL_PRINT_FUNC_FORMAT (4, 5);
00364 };
00365 
00366 /* ******************************************************************** */
00367 /*                           GDALRasterBlock                            */
00368 /* ******************************************************************** */
00369 
00371 
00372 class CPL_DLL GDALRasterBlock
00373 {
00374     GDALDataType        eType;
00375     
00376     int                 bDirty;
00377     int                 nLockCount;
00378 
00379     int                 nXOff;
00380     int                 nYOff;
00381        
00382     int                 nXSize;
00383     int                 nYSize;
00384     
00385     void                *pData;
00386 
00387     GDALRasterBand      *poBand;
00388     
00389     GDALRasterBlock     *poNext;
00390     GDALRasterBlock     *poPrevious;
00391 
00392   public:
00393                 GDALRasterBlock( GDALRasterBand *, int, int );
00394     virtual     ~GDALRasterBlock();
00395 
00396     CPLErr      Internalize( void );
00397     void        Touch( void );      
00398     void        MarkDirty( void );  
00399     void        MarkClean( void );
00400     void        AddLock( void ) { nLockCount++; }
00401     void        DropLock( void ) { nLockCount--; }
00402     void        Detach();
00403 
00404     CPLErr      Write();
00405 
00406     GDALDataType GetDataType() { return eType; }
00407     int         GetXOff() { return nXOff; }
00408     int         GetYOff() { return nYOff; }
00409     int         GetXSize() { return nXSize; }
00410     int         GetYSize() { return nYSize; }
00411     int         GetDirty() { return bDirty; }
00412     int         GetLockCount() { return nLockCount; }
00413 
00414     void        *GetDataRef( void ) { return pData; }
00415 
00418     GDALRasterBand *GetBand() { return poBand; }
00419 
00420     static int  FlushCacheBlock();
00421     static void Verify();
00422 
00423     static int  SafeLockBlock( GDALRasterBlock ** );
00424 };
00425 
00426 /* ******************************************************************** */
00427 /*                             GDALColorTable                           */
00428 /* ******************************************************************** */
00429 
00432 class CPL_DLL GDALColorTable
00433 {
00434     GDALPaletteInterp eInterp;
00435 
00436     std::vector<GDALColorEntry> aoEntries;
00437 
00438 public:
00439                 GDALColorTable( GDALPaletteInterp = GPI_RGB );
00440                 ~GDALColorTable();
00441 
00442     GDALColorTable *Clone() const;
00443 
00444     GDALPaletteInterp GetPaletteInterpretation() const;
00445 
00446     int           GetColorEntryCount() const;
00447     const GDALColorEntry *GetColorEntry( int ) const;
00448     int           GetColorEntryAsRGB( int, GDALColorEntry * ) const;
00449     void          SetColorEntry( int, const GDALColorEntry * );
00450     int           CreateColorRamp( int, const GDALColorEntry * ,
00451                                    int, const GDALColorEntry * );
00452 };
00453 
00454 /* ******************************************************************** */
00455 /*                            GDALRasterBand                            */
00456 /* ******************************************************************** */
00457 
00459 
00460 class CPL_DLL GDALRasterBand : public GDALMajorObject
00461 {
00462   private:
00463     CPLErr eFlushBlockErr;
00464 
00465     void           SetFlushBlockErr( CPLErr eErr );
00466 
00467     friend class GDALRasterBlock;
00468 
00469   protected:
00470     GDALDataset *poDS;
00471     int         nBand; /* 1 based */
00472 
00473     int         nRasterXSize;
00474     int         nRasterYSize;
00475     
00476     GDALDataType eDataType;
00477     GDALAccess  eAccess;
00478 
00479     /* stuff related to blocking, and raster cache */
00480     int         nBlockXSize;
00481     int         nBlockYSize;
00482     int         nBlocksPerRow;
00483     int         nBlocksPerColumn;
00484 
00485     int         bSubBlockingActive;
00486     int         nSubBlocksPerRow;
00487     int         nSubBlocksPerColumn;
00488     GDALRasterBlock **papoBlocks;
00489 
00490     int         nBlockReads;
00491     int         bForceCachedIO;
00492 
00493     GDALRasterBand *poMask;
00494     bool        bOwnMask;
00495     int         nMaskFlags;
00496 
00497     friend class GDALDataset;
00498     friend class GDALProxyRasterBand;
00499 
00500   protected:
00501     virtual CPLErr IReadBlock( int, int, void * ) = 0;
00502     virtual CPLErr IWriteBlock( int, int, void * );
00503     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00504                               void *, int, int, GDALDataType,
00505                               int, int );
00506     CPLErr         OverviewRasterIO( GDALRWFlag, int, int, int, int,
00507                                      void *, int, int, GDALDataType,
00508                                      int, int );
00509 
00510     int            InitBlockInfo();
00511 
00512     CPLErr         AdoptBlock( int, int, GDALRasterBlock * );
00513     GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
00514 
00515   public:
00516                 GDALRasterBand();
00517                 
00518     virtual     ~GDALRasterBand();
00519 
00520     int         GetXSize();
00521     int         GetYSize();
00522     int         GetBand();
00523     GDALDataset*GetDataset();
00524 
00525     GDALDataType GetRasterDataType( void );
00526     void        GetBlockSize( int *, int * );
00527     GDALAccess  GetAccess();
00528     
00529     CPLErr      RasterIO( GDALRWFlag, int, int, int, int,
00530                           void *, int, int, GDALDataType,
00531                           int, int );
00532     CPLErr      ReadBlock( int, int, void * );
00533 
00534     CPLErr      WriteBlock( int, int, void * );
00535 
00536     GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff, 
00537                                         int bJustInitialize = FALSE );
00538     CPLErr      FlushBlock( int = -1, int = -1, int bWriteDirtyBlock = TRUE );
00539 
00540     unsigned char*  GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand,
00541                                                unsigned char* pTranslationTable = NULL,
00542                                                int* pApproximateMatching = NULL);
00543 
00544     // New OpengIS CV_SampleDimension stuff.
00545 
00546     virtual CPLErr FlushCache();
00547     virtual char **GetCategoryNames();
00548     virtual double GetNoDataValue( int *pbSuccess = NULL );
00549     virtual double GetMinimum( int *pbSuccess = NULL );
00550     virtual double GetMaximum(int *pbSuccess = NULL );
00551     virtual double GetOffset( int *pbSuccess = NULL );
00552     virtual double GetScale( int *pbSuccess = NULL );
00553     virtual const char *GetUnitType();
00554     virtual GDALColorInterp GetColorInterpretation();
00555     virtual GDALColorTable *GetColorTable();
00556     virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
00557 
00558     virtual CPLErr SetCategoryNames( char ** );
00559     virtual CPLErr SetNoDataValue( double );
00560     virtual CPLErr SetColorTable( GDALColorTable * ); 
00561     virtual CPLErr SetColorInterpretation( GDALColorInterp );
00562     virtual CPLErr SetOffset( double );
00563     virtual CPLErr SetScale( double );
00564     virtual CPLErr SetUnitType( const char * );
00565 
00566     virtual CPLErr GetStatistics( int bApproxOK, int bForce,
00567                                   double *pdfMin, double *pdfMax, 
00568                                   double *pdfMean, double *padfStdDev );
00569     virtual CPLErr ComputeStatistics( int bApproxOK, 
00570                                       double *pdfMin, double *pdfMax, 
00571                                       double *pdfMean, double *pdfStdDev,
00572                                       GDALProgressFunc, void *pProgressData );
00573     virtual CPLErr SetStatistics( double dfMin, double dfMax, 
00574                                   double dfMean, double dfStdDev );
00575     virtual CPLErr ComputeRasterMinMax( int, double* );
00576 
00577     virtual int HasArbitraryOverviews();
00578     virtual int GetOverviewCount();
00579     virtual GDALRasterBand *GetOverview(int);
00580     virtual GDALRasterBand *GetRasterSampleOverview( int );
00581     virtual CPLErr BuildOverviews( const char *, int, int *,
00582                                    GDALProgressFunc, void * );
00583 
00584     virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
00585                                int nBufXSize, int nBufYSize, 
00586                                GDALDataType eDT, char **papszOptions );
00587 
00588     virtual CPLErr  GetHistogram( double dfMin, double dfMax,
00589                           int nBuckets, int * panHistogram,
00590                           int bIncludeOutOfRange, int bApproxOK,
00591                           GDALProgressFunc, void *pProgressData );
00592 
00593     virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
00594                                         int *pnBuckets, int ** ppanHistogram,
00595                                         int bForce,
00596                                         GDALProgressFunc, void *pProgressData);
00597     virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
00598                                         int nBuckets, int *panHistogram );
00599 
00600     virtual const GDALRasterAttributeTable *GetDefaultRAT();
00601     virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
00602 
00603     virtual GDALRasterBand *GetMaskBand();
00604     virtual int             GetMaskFlags();
00605     virtual CPLErr          CreateMaskBand( int nFlags );
00606 
00607     void ReportError(CPLErr eErrClass, int err_no, const char *fmt, ...)  CPL_PRINT_FUNC_FORMAT (4, 5);
00608 };
00609 
00610 /* ******************************************************************** */
00611 /*                         GDALAllValidMaskBand                         */
00612 /* ******************************************************************** */
00613 
00614 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
00615 {
00616   protected:
00617     virtual CPLErr IReadBlock( int, int, void * );
00618 
00619   public:
00620                 GDALAllValidMaskBand( GDALRasterBand * );
00621     virtual     ~GDALAllValidMaskBand();
00622 
00623     virtual GDALRasterBand *GetMaskBand();
00624     virtual int             GetMaskFlags();
00625 };
00626 
00627 /* ******************************************************************** */
00628 /*                         GDALNoDataMaskBand                           */
00629 /* ******************************************************************** */
00630 
00631 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
00632 {
00633     double          dfNoDataValue;
00634     GDALRasterBand *poParent;
00635 
00636   protected:
00637     virtual CPLErr IReadBlock( int, int, void * );
00638     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00639                               void *, int, int, GDALDataType,
00640                               int, int );
00641 
00642   public:
00643                 GDALNoDataMaskBand( GDALRasterBand * );
00644     virtual     ~GDALNoDataMaskBand();
00645 };
00646 
00647 /* ******************************************************************** */
00648 /*                  GDALNoDataValuesMaskBand                            */
00649 /* ******************************************************************** */
00650 
00651 class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
00652 {
00653     double      *padfNodataValues;
00654 
00655   protected:
00656     virtual CPLErr IReadBlock( int, int, void * );
00657 
00658   public:
00659                 GDALNoDataValuesMaskBand( GDALDataset * );
00660     virtual     ~GDALNoDataValuesMaskBand();
00661 };
00662 
00663 /* ******************************************************************** */
00664 /*                              GDALDriver                              */
00665 /* ******************************************************************** */
00666 
00667 
00679 class CPL_DLL GDALDriver : public GDALMajorObject
00680 {
00681   public:
00682                         GDALDriver();
00683                         ~GDALDriver();
00684 
00685 /* -------------------------------------------------------------------- */
00686 /*      Public C++ methods.                                             */
00687 /* -------------------------------------------------------------------- */
00688     GDALDataset         *Create( const char * pszName,
00689                                  int nXSize, int nYSize, int nBands,
00690                                  GDALDataType eType, char ** papszOptions ) CPL_WARN_UNUSED_RESULT;
00691 
00692     CPLErr              Delete( const char * pszName );
00693     CPLErr              Rename( const char * pszNewName,
00694                                 const char * pszOldName );
00695     CPLErr              CopyFiles( const char * pszNewName,
00696                                    const char * pszOldName );
00697 
00698     GDALDataset         *CreateCopy( const char *, GDALDataset *, 
00699                                      int, char **,
00700                                      GDALProgressFunc pfnProgress, 
00701                                      void * pProgressData ) CPL_WARN_UNUSED_RESULT;
00702     
00703 /* -------------------------------------------------------------------- */
00704 /*      The following are semiprivate, not intended to be accessed      */
00705 /*      by anyone but the formats instantiating and populating the      */
00706 /*      drivers.                                                        */
00707 /* -------------------------------------------------------------------- */
00708     GDALDataset         *(*pfnOpen)( GDALOpenInfo * );
00709 
00710     GDALDataset         *(*pfnCreate)( const char * pszName,
00711                                        int nXSize, int nYSize, int nBands,
00712                                        GDALDataType eType,
00713                                        char ** papszOptions );
00714 
00715     CPLErr              (*pfnDelete)( const char * pszName );
00716 
00717     GDALDataset         *(*pfnCreateCopy)( const char *, GDALDataset *, 
00718                                            int, char **,
00719                                            GDALProgressFunc pfnProgress, 
00720                                            void * pProgressData );
00721 
00722     void                *pDriverData;
00723 
00724     void                (*pfnUnloadDriver)(GDALDriver *);
00725 
00726     int                 (*pfnIdentify)( GDALOpenInfo * );
00727 
00728     CPLErr              (*pfnRename)( const char * pszNewName,
00729                                       const char * pszOldName );
00730     CPLErr              (*pfnCopyFiles)( const char * pszNewName,
00731                                          const char * pszOldName );
00732 
00733 /* -------------------------------------------------------------------- */
00734 /*      Helper methods.                                                 */
00735 /* -------------------------------------------------------------------- */
00736     GDALDataset         *DefaultCreateCopy( const char *, GDALDataset *, 
00737                                             int, char **,
00738                                             GDALProgressFunc pfnProgress, 
00739                                             void * pProgressData ) CPL_WARN_UNUSED_RESULT;
00740     static CPLErr        DefaultCopyMasks( GDALDataset *poSrcDS, 
00741                                            GDALDataset *poDstDS, 
00742                                            int bStrict );
00743     static CPLErr       QuietDelete( const char * pszName );
00744 
00745     CPLErr              DefaultRename( const char * pszNewName,
00746                                        const char * pszOldName );
00747     CPLErr              DefaultCopyFiles( const char * pszNewName,
00748                                           const char * pszOldName );
00749 };
00750 
00751 /* ******************************************************************** */
00752 /*                          GDALDriverManager                           */
00753 /* ******************************************************************** */
00754 
00762 class CPL_DLL GDALDriverManager : public GDALMajorObject
00763 {
00764     int         nDrivers;
00765     GDALDriver  **papoDrivers;
00766 
00767     char        *pszHome;
00768     
00769  public:
00770                 GDALDriverManager();
00771                 ~GDALDriverManager();
00772                 
00773     int         GetDriverCount( void );
00774     GDALDriver  *GetDriver( int );
00775     GDALDriver  *GetDriverByName( const char * );
00776 
00777     int         RegisterDriver( GDALDriver * );
00778     void        MoveDriver( GDALDriver *, int );
00779     void        DeregisterDriver( GDALDriver * );
00780 
00781     void        AutoLoadDrivers();
00782     void        AutoSkipDrivers();
00783 
00784     const char *GetHome();
00785     void        SetHome( const char * );
00786 };
00787 
00788 CPL_C_START
00789 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
00790 CPL_C_END
00791 
00792 /* ******************************************************************** */
00793 /*                          GDALAsyncReader                             */
00794 /* ******************************************************************** */
00795 
00801 class CPL_DLL GDALAsyncReader
00802 {
00803   protected:
00804     GDALDataset* poDS;
00805     int          nXOff;
00806     int          nYOff;
00807     int          nXSize;
00808     int          nYSize;
00809     void *       pBuf;
00810     int          nBufXSize;
00811     int          nBufYSize;
00812     GDALDataType eBufType;
00813     int          nBandCount;
00814     int*         panBandMap;
00815     int          nPixelSpace;
00816     int          nLineSpace;
00817     int          nBandSpace;
00818 
00819   public:
00820     GDALAsyncReader();
00821     virtual ~GDALAsyncReader();
00822 
00823     GDALDataset* GetGDALDataset() {return poDS;}
00824     int GetXOffset() {return nXOff;}
00825     int GetYOffset() {return nYOff;}
00826     int GetXSize() {return nXSize;}
00827     int GetYSize() {return nYSize;}
00828     void * GetBuffer() {return pBuf;}
00829     int GetBufferXSize() {return nBufXSize;}
00830     int GetBufferYSize() {return nBufYSize;}
00831     GDALDataType GetBufferType() {return eBufType;}
00832     int GetBandCount() {return nBandCount;}
00833     int* GetBandMap() {return panBandMap;}
00834     int GetPixelSpace() {return nPixelSpace;}
00835     int GetLineSpace() {return nLineSpace;}
00836     int GetBandSpace() {return nBandSpace;}
00837 
00838     virtual GDALAsyncStatusType 
00839         GetNextUpdatedRegion(double dfTimeout,
00840                              int* pnBufXOff, int* pnBufYOff,
00841                              int* pnBufXSize, int* pnBufYSize) = 0;
00842     virtual int LockBuffer( double dfTimeout = -1.0 );
00843     virtual void UnlockBuffer();
00844 };
00845 
00846 /* ==================================================================== */
00847 /*      An assortment of overview related stuff.                        */
00848 /* ==================================================================== */
00849 
00850 /* Not a public symbol for the moment */
00851 CPLErr 
00852 GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands,
00853                                  int nOverviews,
00854                                  GDALRasterBand*** papapoOverviewBands,
00855                                  const char * pszResampling, 
00856                                  GDALProgressFunc pfnProgress, void * pProgressData );
00857 
00858 CPL_C_START
00859 
00860 #ifndef WIN32CE
00861 
00862 CPLErr CPL_DLL
00863 HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
00864                       GDALDataset **ppoDS,
00865                       int nBands, int *panBandList,
00866                       int nNewOverviews, int *panNewOverviewList, 
00867                       const char *pszResampling, 
00868                       GDALProgressFunc pfnProgress, 
00869                       void *pProgressData );
00870 
00871 #endif /* WIN32CE */
00872 
00873 CPLErr CPL_DLL 
00874 GTIFFBuildOverviews( const char * pszFilename,
00875                      int nBands, GDALRasterBand **papoBandList, 
00876                      int nOverviews, int * panOverviewList,
00877                      const char * pszResampling, 
00878                      GDALProgressFunc pfnProgress, void * pProgressData );
00879 
00880 CPLErr CPL_DLL
00881 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
00882                            const char * pszResampling, 
00883                            int nOverviews, int * panOverviewList,
00884                            int nBands, int * panBandList,
00885                            GDALProgressFunc pfnProgress, void * pProgressData);
00886                            
00887 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
00888                                          int &nXOff, int &nYOff,
00889                                          int &nXSize, int &nYSize,
00890                                          int nBufXSize, int nBufYSize);
00891 
00892 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize );
00893 
00894 GDALDataset CPL_DLL *
00895 GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
00896                            GDALDataset *poDependentDS );
00897 
00898 /* ==================================================================== */
00899 /*      Misc functions.                                                 */
00900 /* ==================================================================== */
00901 
00902 CPLErr CPL_DLL GDALParseGMLCoverage( CPLXMLNode *psTree, 
00903                                      int *pnXSize, int *pnYSize,
00904                                      double *padfGeoTransform,
00905                                      char **ppszProjection );
00906 
00907 /* ==================================================================== */
00908 /*  Infrastructure to check that dataset characteristics are valid      */
00909 /* ==================================================================== */
00910 
00911 int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize );
00912 int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed );
00913 
00914 
00915 // Test if 2 floating point values match. Usefull when comparing values
00916 // stored as a string at some point. See #3573, #4183, #4506
00917 #define ARE_REAL_EQUAL(dfVal1, dfVal2) \
00918  (dfVal1 == dfVal2 || fabs(dfVal1 - dfVal2) < 1e-10 || (dfVal2 != 0 && fabs(1 - dfVal1 / dfVal2) < 1e-10 ))
00919 
00920 /* Internal use only */
00921 
00922 /* CPL_DLL exported, but only for in-tree drivers that can be built as plugins */
00923 int CPL_DLL GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension,
00924                                 double *padfGeoTransform, char** papszSiblingFiles,
00925                                 char** ppszWorldFileNameOut);
00926 int GDALReadTabFile2( const char * pszBaseFilename,
00927                       double *padfGeoTransform, char **ppszWKT,
00928                       int *pnGCPCount, GDAL_GCP **ppasGCPs,
00929                       char** papszSiblingFiles, char** ppszTabFileNameOut );
00930 
00931 CPL_C_END
00932 
00933 void GDALNullifyOpenDatasetsList();
00934 void** GDALGetphDMMutex();
00935 void** GDALGetphDLMutex();
00936 void GDALNullifyProxyPoolSingleton();
00937 GDALDriver* GDALGetAPIPROXYDriver();
00938 void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
00939 GIntBig GDALGetResponsiblePIDForCurrentThread();
00940 
00941 CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt,
00942                                   char **papszSiblingFiles, int nFlags );
00943 
00944 CPLErr EXIFExtractMetadata(char**& papszMetadata,
00945                            void *fpL, int nOffset,
00946                            int bSwabflag, int nTIFFHEADER,
00947                            int& nExifOffset, int& nInterOffset, int& nGPSOffset);
00948 
00949 #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) )
00950 
00951 // Number of data samples that will be used to compute approximate statistics
00952 // (minimum value, maximum value, etc.)
00953 #define GDALSTAT_APPROX_NUMSAMPLES 2500
00954 
00955 #endif /* ndef GDAL_PRIV_H_INCLUDED */

Generated for GDAL by doxygen 1.7.6.1.