00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef GDAL_PRIV_H_INCLUDED
00032 #define GDAL_PRIV_H_INCLUDED
00033
00034
00035
00036
00037
00038 class GDALMajorObject;
00039 class GDALDataset;
00040 class GDALRasterBand;
00041 class GDALDriver;
00042 class GDALRasterAttributeTable;
00043 class GDALProxyDataset;
00044 class GDALProxyRasterBand;
00045
00046
00047
00048
00049
00050
00051
00052 #include "gdal.h"
00053 #include "gdal_frmts.h"
00054 #include "cpl_vsi.h"
00055 #include "cpl_conv.h"
00056 #include "cpl_string.h"
00057 #include "cpl_minixml.h"
00058 #include <vector>
00059
00060 #define GMO_VALID 0x0001
00061 #define GMO_IGNORE_UNIMPLEMENTED 0x0002
00062 #define GMO_SUPPORT_MD 0x0004
00063 #define GMO_SUPPORT_MDMD 0x0008
00064 #define GMO_MD_DIRTY 0x0010
00065 #define GMO_PAM_CLASS 0x0020
00066
00067
00068
00069
00070
00071 class CPL_DLL GDALMultiDomainMetadata
00072 {
00073 private:
00074 char **papszDomainList;
00075 char ***papapszMetadataLists;
00076
00077 public:
00078 GDALMultiDomainMetadata();
00079 ~GDALMultiDomainMetadata();
00080
00081 int XMLInit( CPLXMLNode *psMetadata, int bMerge );
00082 CPLXMLNode *Serialize();
00083
00084 char **GetDomainList() { return papszDomainList; }
00085
00086 char **GetMetadata( const char * pszDomain = "" );
00087 CPLErr SetMetadata( char ** papszMetadata,
00088 const char * pszDomain = "" );
00089 const char *GetMetadataItem( const char * pszName,
00090 const char * pszDomain = "" );
00091 CPLErr SetMetadataItem( const char * pszName,
00092 const char * pszValue,
00093 const char * pszDomain = "" );
00094
00095 void Clear();
00096 };
00097
00098
00099
00100
00101
00102
00103
00104
00106
00107 class CPL_DLL GDALMajorObject
00108 {
00109 protected:
00110 int nFlags;
00111 CPLString sDescription;
00112 GDALMultiDomainMetadata oMDMD;
00113
00114 public:
00115 GDALMajorObject();
00116 virtual ~GDALMajorObject();
00117
00118 int GetMOFlags();
00119 void SetMOFlags(int nFlags);
00120
00121 virtual const char *GetDescription() const;
00122 virtual void SetDescription( const char * );
00123
00124 virtual char **GetMetadata( const char * pszDomain = "" );
00125 virtual CPLErr SetMetadata( char ** papszMetadata,
00126 const char * pszDomain = "" );
00127 virtual const char *GetMetadataItem( const char * pszName,
00128 const char * pszDomain = "" );
00129 virtual CPLErr SetMetadataItem( const char * pszName,
00130 const char * pszValue,
00131 const char * pszDomain = "" );
00132 };
00133
00134
00135
00136
00137 class CPL_DLL GDALDefaultOverviews
00138 {
00139 friend class GDALDataset;
00140
00141 GDALDataset *poDS;
00142 GDALDataset *poODS;
00143
00144 CPLString osOvrFilename;
00145
00146 int bOvrIsAux;
00147
00148 int bCheckedForMask;
00149 int bOwnMaskDS;
00150 GDALDataset *poMaskDS;
00151
00152
00153
00154 GDALDataset *poBaseDS;
00155
00156 public:
00157 GDALDefaultOverviews();
00158 ~GDALDefaultOverviews();
00159
00160 void Initialize( GDALDataset *poDS, const char *pszName = NULL,
00161 char **papszSiblingFiles = NULL,
00162 int bNameIsOVR = FALSE );
00163
00164 int IsInitialized() { return poDS != NULL && strlen(osOvrFilename) > 0; }
00165
00166
00167
00168 int GetOverviewCount(int);
00169 GDALRasterBand *GetOverview(int,int);
00170
00171 CPLErr BuildOverviews( const char * pszBasename,
00172 const char * pszResampling,
00173 int nOverviews, int * panOverviewList,
00174 int nBands, int * panBandList,
00175 GDALProgressFunc pfnProgress,
00176 void *pProgressData );
00177
00178
00179
00180 CPLErr CreateMaskBand( int nFlags, int nBand = -1 );
00181 GDALRasterBand *GetMaskBand( int nBand );
00182 int GetMaskFlags( int nBand );
00183
00184 int HaveMaskFile( char **papszSiblings = NULL,
00185 const char *pszBasename = NULL );
00186
00187 };
00188
00189
00190
00191
00192
00194
00195 class CPL_DLL GDALDataset : public GDALMajorObject
00196 {
00197 friend GDALDatasetH CPL_STDCALL GDALOpen( const char *, GDALAccess);
00198 friend GDALDatasetH CPL_STDCALL GDALOpenShared( const char *, GDALAccess);
00199 friend class GDALDriver;
00200 friend class GDALDefaultOverviews;
00201 friend class GDALProxyDataset;
00202
00203 protected:
00204 GDALDriver *poDriver;
00205 GDALAccess eAccess;
00206
00207
00208 int nRasterXSize;
00209 int nRasterYSize;
00210 int nBands;
00211 GDALRasterBand **papoBands;
00212
00213 int bForceCachedIO;
00214
00215 int nRefCount;
00216 int bShared;
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 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00228 void *, int, int, GDALDataType,
00229 int, int *, int, int, int );
00230
00231 CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
00232 void *, int, int, GDALDataType,
00233 int, int *, int, int, int );
00234 void BlockBasedFlushCache();
00235
00236 friend class GDALRasterBand;
00237
00238 public:
00239 virtual ~GDALDataset();
00240
00241 int GetRasterXSize( void );
00242 int GetRasterYSize( void );
00243 int GetRasterCount( void );
00244 GDALRasterBand *GetRasterBand( int );
00245
00246 virtual void FlushCache(void);
00247
00248 virtual const char *GetProjectionRef(void);
00249 virtual CPLErr SetProjection( const char * );
00250
00251 virtual CPLErr GetGeoTransform( double * );
00252 virtual CPLErr SetGeoTransform( double * );
00253
00254 virtual CPLErr AddBand( GDALDataType eType,
00255 char **papszOptions=NULL );
00256
00257 virtual void *GetInternalHandle( const char * );
00258 virtual GDALDriver *GetDriver(void);
00259 virtual char **GetFileList(void);
00260
00261 virtual int GetGCPCount();
00262 virtual const char *GetGCPProjection();
00263 virtual const GDAL_GCP *GetGCPs();
00264 virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
00265 const char *pszGCPProjection );
00266
00267 virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
00268 int nBufXSize, int nBufYSize,
00269 GDALDataType eDT,
00270 int nBandCount, int *panBandList,
00271 char **papszOptions );
00272
00273 virtual CPLErr CreateMaskBand( int nFlags );
00274
00275 CPLErr RasterIO( GDALRWFlag, int, int, int, int,
00276 void *, int, int, GDALDataType,
00277 int, int *, int, int, int );
00278
00279 int Reference();
00280 int Dereference();
00281 GDALAccess GetAccess() { return eAccess; }
00282
00283 int GetShared();
00284 void MarkAsShared();
00285
00286 static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
00287
00288 CPLErr BuildOverviews( const char *, int, int *,
00289 int, int *, GDALProgressFunc, void * );
00290 };
00291
00292
00293
00294
00295
00296 class CPL_DLL GDALRasterBlock
00297 {
00298 GDALDataType eType;
00299
00300 int bDirty;
00301 int nLockCount;
00302
00303 int nXOff;
00304 int nYOff;
00305
00306 int nXSize;
00307 int nYSize;
00308
00309 void *pData;
00310
00311 GDALRasterBand *poBand;
00312
00313 GDALRasterBlock *poNext;
00314 GDALRasterBlock *poPrevious;
00315
00316 public:
00317 GDALRasterBlock( GDALRasterBand *, int, int );
00318 virtual ~GDALRasterBlock();
00319
00320 CPLErr Internalize( void );
00321 void Touch( void );
00322 void MarkDirty( void );
00323 void MarkClean( void );
00324 void AddLock( void ) { nLockCount++; }
00325 void DropLock( void ) { nLockCount--; }
00326 void Detach();
00327
00328 CPLErr Write();
00329
00330 GDALDataType GetDataType() { return eType; }
00331 int GetXOff() { return nXOff; }
00332 int GetYOff() { return nYOff; }
00333 int GetXSize() { return nXSize; }
00334 int GetYSize() { return nYSize; }
00335 int GetDirty() { return bDirty; }
00336 int GetLockCount() { return nLockCount; }
00337
00338 void *GetDataRef( void ) { return pData; }
00339
00340 GDALRasterBand *GetBand() { return poBand; }
00341
00342 static int FlushCacheBlock();
00343 static void Verify();
00344
00345 static int SafeLockBlock( GDALRasterBlock ** );
00346 };
00347
00348
00349
00350
00351
00354 class CPL_DLL GDALColorTable
00355 {
00356 GDALPaletteInterp eInterp;
00357
00358 std::vector<GDALColorEntry> aoEntries;
00359
00360 public:
00361 GDALColorTable( GDALPaletteInterp = GPI_RGB );
00362 ~GDALColorTable();
00363
00364 GDALColorTable *Clone() const;
00365
00366 GDALPaletteInterp GetPaletteInterpretation() const;
00367
00368 int GetColorEntryCount() const;
00369 const GDALColorEntry *GetColorEntry( int ) const;
00370 int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
00371 void SetColorEntry( int, const GDALColorEntry * );
00372 int CreateColorRamp( int, const GDALColorEntry * ,
00373 int, const GDALColorEntry * );
00374 };
00375
00376
00377
00378
00379
00381
00382 class CPL_DLL GDALRasterBand : public GDALMajorObject
00383 {
00384 protected:
00385 GDALDataset *poDS;
00386 int nBand;
00387
00388 int nRasterXSize;
00389 int nRasterYSize;
00390
00391 GDALDataType eDataType;
00392 GDALAccess eAccess;
00393
00394
00395 int nBlockXSize;
00396 int nBlockYSize;
00397 int nBlocksPerRow;
00398 int nBlocksPerColumn;
00399
00400 int bSubBlockingActive;
00401 int nSubBlocksPerRow;
00402 int nSubBlocksPerColumn;
00403 GDALRasterBlock **papoBlocks;
00404
00405 int nBlockReads;
00406 int bForceCachedIO;
00407
00408 GDALRasterBand *poMask;
00409 bool bOwnMask;
00410 int nMaskFlags;
00411
00412 friend class GDALDataset;
00413 friend class GDALRasterBlock;
00414 friend class GDALProxyRasterBand;
00415
00416 protected:
00417 virtual CPLErr IReadBlock( int, int, void * ) = 0;
00418 virtual CPLErr IWriteBlock( int, int, void * );
00419 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00420 void *, int, int, GDALDataType,
00421 int, int );
00422 CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
00423 void *, int, int, GDALDataType,
00424 int, int );
00425
00426 int InitBlockInfo();
00427
00428 CPLErr AdoptBlock( int, int, GDALRasterBlock * );
00429 GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
00430
00431 public:
00432 GDALRasterBand();
00433
00434 virtual ~GDALRasterBand();
00435
00436 int GetXSize();
00437 int GetYSize();
00438 int GetBand();
00439 GDALDataset*GetDataset();
00440
00441 GDALDataType GetRasterDataType( void );
00442 void GetBlockSize( int *, int * );
00443 GDALAccess GetAccess();
00444
00445 CPLErr RasterIO( GDALRWFlag, int, int, int, int,
00446 void *, int, int, GDALDataType,
00447 int, int );
00448 CPLErr ReadBlock( int, int, void * );
00449
00450 CPLErr WriteBlock( int, int, void * );
00451
00452 GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
00453 int bJustInitialize = FALSE );
00454 CPLErr FlushBlock( int = -1, int = -1 );
00455
00456 unsigned char* GetIndexColorTranslationTo( GDALRasterBand* poReferenceBand,
00457 unsigned char* pTranslationTable = NULL,
00458 int* pApproximateMatching = NULL);
00459
00460
00461
00462 virtual CPLErr FlushCache();
00463 virtual char **GetCategoryNames();
00464 virtual double GetNoDataValue( int *pbSuccess = NULL );
00465 virtual double GetMinimum( int *pbSuccess = NULL );
00466 virtual double GetMaximum(int *pbSuccess = NULL );
00467 virtual double GetOffset( int *pbSuccess = NULL );
00468 virtual double GetScale( int *pbSuccess = NULL );
00469 virtual const char *GetUnitType();
00470 virtual GDALColorInterp GetColorInterpretation();
00471 virtual GDALColorTable *GetColorTable();
00472 virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
00473
00474 virtual CPLErr SetCategoryNames( char ** );
00475 virtual CPLErr SetNoDataValue( double );
00476 virtual CPLErr SetColorTable( GDALColorTable * );
00477 virtual CPLErr SetColorInterpretation( GDALColorInterp );
00478 virtual CPLErr SetOffset( double );
00479 virtual CPLErr SetScale( double );
00480 virtual CPLErr SetUnitType( const char * );
00481
00482 virtual CPLErr GetStatistics( int bApproxOK, int bForce,
00483 double *pdfMin, double *pdfMax,
00484 double *pdfMean, double *padfStdDev );
00485 virtual CPLErr ComputeStatistics( int bApproxOK,
00486 double *pdfMin, double *pdfMax,
00487 double *pdfMean, double *pdfStdDev,
00488 GDALProgressFunc, void *pProgressData );
00489 virtual CPLErr SetStatistics( double dfMin, double dfMax,
00490 double dfMean, double dfStdDev );
00491 virtual CPLErr ComputeRasterMinMax( int, double* );
00492
00493 virtual int HasArbitraryOverviews();
00494 virtual int GetOverviewCount();
00495 virtual GDALRasterBand *GetOverview(int);
00496 virtual GDALRasterBand *GetRasterSampleOverview( int );
00497 virtual CPLErr BuildOverviews( const char *, int, int *,
00498 GDALProgressFunc, void * );
00499
00500 virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
00501 int nBufXSize, int nBufYSize,
00502 GDALDataType eDT, char **papszOptions );
00503
00504 virtual CPLErr GetHistogram( double dfMin, double dfMax,
00505 int nBuckets, int * panHistogram,
00506 int bIncludeOutOfRange, int bApproxOK,
00507 GDALProgressFunc, void *pProgressData );
00508
00509 virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
00510 int *pnBuckets, int ** ppanHistogram,
00511 int bForce,
00512 GDALProgressFunc, void *pProgressData);
00513 virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
00514 int nBuckets, int *panHistogram );
00515
00516 virtual const GDALRasterAttributeTable *GetDefaultRAT();
00517 virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
00518
00519 virtual GDALRasterBand *GetMaskBand();
00520 virtual int GetMaskFlags();
00521 virtual CPLErr CreateMaskBand( int nFlags );
00522 };
00523
00524
00525
00526
00527
00528 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
00529 {
00530 protected:
00531 virtual CPLErr IReadBlock( int, int, void * );
00532
00533 public:
00534 GDALAllValidMaskBand( GDALRasterBand * );
00535 virtual ~GDALAllValidMaskBand();
00536
00537 virtual GDALRasterBand *GetMaskBand();
00538 virtual int GetMaskFlags();
00539 };
00540
00541
00542
00543
00544
00545 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
00546 {
00547 double dfNoDataValue;
00548 GDALRasterBand *poParent;
00549
00550 protected:
00551 virtual CPLErr IReadBlock( int, int, void * );
00552
00553 public:
00554 GDALNoDataMaskBand( GDALRasterBand * );
00555 virtual ~GDALNoDataMaskBand();
00556 };
00557
00558
00559
00560
00561
00562 class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
00563 {
00564 double *padfNodataValues;
00565
00566 protected:
00567 virtual CPLErr IReadBlock( int, int, void * );
00568
00569 public:
00570 GDALNoDataValuesMaskBand( GDALDataset * );
00571 virtual ~GDALNoDataValuesMaskBand();
00572 };
00573
00574
00575
00576
00577
00578
00579
00580 class CPL_DLL GDALOpenInfo
00581 {
00582 public:
00583 GDALOpenInfo( const char * pszFile, GDALAccess eAccessIn,
00584 char **papszSiblingFiles = NULL );
00585 ~GDALOpenInfo( void );
00586
00587 char *pszFilename;
00588 char **papszSiblingFiles;
00589
00590 GDALAccess eAccess;
00591
00592 int bStatOK;
00593 int bIsDirectory;
00594
00595 FILE *fp;
00596
00597 int nHeaderBytes;
00598 GByte *pabyHeader;
00599
00600 };
00601
00602
00603
00604
00605
00606
00618 class CPL_DLL GDALDriver : public GDALMajorObject
00619 {
00620 public:
00621 GDALDriver();
00622 ~GDALDriver();
00623
00624
00625
00626
00627 GDALDataset *Create( const char * pszName,
00628 int nXSize, int nYSize, int nBands,
00629 GDALDataType eType, char ** papszOptions );
00630
00631 CPLErr Delete( const char * pszName );
00632 CPLErr Rename( const char * pszNewName,
00633 const char * pszOldName );
00634 CPLErr CopyFiles( const char * pszNewName,
00635 const char * pszOldName );
00636
00637 GDALDataset *CreateCopy( const char *, GDALDataset *,
00638 int, char **,
00639 GDALProgressFunc pfnProgress,
00640 void * pProgressData );
00641
00642
00643
00644
00645
00646
00647 GDALDataset *(*pfnOpen)( GDALOpenInfo * );
00648
00649 GDALDataset *(*pfnCreate)( const char * pszName,
00650 int nXSize, int nYSize, int nBands,
00651 GDALDataType eType,
00652 char ** papszOptions );
00653
00654 CPLErr (*pfnDelete)( const char * pszName );
00655
00656 GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
00657 int, char **,
00658 GDALProgressFunc pfnProgress,
00659 void * pProgressData );
00660
00661 void *pDriverData;
00662
00663 void (*pfnUnloadDriver)(GDALDriver *);
00664
00665 int (*pfnIdentify)( GDALOpenInfo * );
00666
00667 CPLErr (*pfnRename)( const char * pszNewName,
00668 const char * pszOldName );
00669 CPLErr (*pfnCopyFiles)( const char * pszNewName,
00670 const char * pszOldName );
00671
00672
00673
00674
00675 GDALDataset *DefaultCreateCopy( const char *, GDALDataset *,
00676 int, char **,
00677 GDALProgressFunc pfnProgress,
00678 void * pProgressData );
00679 static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
00680 GDALDataset *poDstDS,
00681 int bStrict );
00682 static CPLErr QuietDelete( const char * pszName );
00683 };
00684
00685
00686
00687
00688
00696 class CPL_DLL GDALDriverManager : public GDALMajorObject
00697 {
00698 int nDrivers;
00699 GDALDriver **papoDrivers;
00700
00701 char *pszHome;
00702
00703 public:
00704 GDALDriverManager();
00705 ~GDALDriverManager();
00706
00707 int GetDriverCount( void );
00708 GDALDriver *GetDriver( int );
00709 GDALDriver *GetDriverByName( const char * );
00710
00711 int RegisterDriver( GDALDriver * );
00712 void MoveDriver( GDALDriver *, int );
00713 void DeregisterDriver( GDALDriver * );
00714
00715 void AutoLoadDrivers();
00716 void AutoSkipDrivers();
00717
00718 const char *GetHome();
00719 void SetHome( const char * );
00720 };
00721
00722
00723 CPLErr
00724 GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands,
00725 int nOverviews,
00726 GDALRasterBand*** papapoOverviewBands,
00727 const char * pszResampling,
00728 GDALProgressFunc pfnProgress, void * pProgressData );
00729
00730 CPL_C_START
00731 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
00732 CPL_C_END
00733
00734
00735
00736
00737
00738 CPL_C_START
00739
00740 #ifndef WIN32CE
00741
00742 CPLErr CPL_DLL
00743 HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
00744 GDALDataset **ppoDS,
00745 int nBands, int *panBandList,
00746 int nNewOverviews, int *panNewOverviewList,
00747 const char *pszResampling,
00748 GDALProgressFunc pfnProgress,
00749 void *pProgressData );
00750
00751 #endif
00752
00753 CPLErr CPL_DLL
00754 GTIFFBuildOverviews( const char * pszFilename,
00755 int nBands, GDALRasterBand **papoBandList,
00756 int nOverviews, int * panOverviewList,
00757 const char * pszResampling,
00758 GDALProgressFunc pfnProgress, void * pProgressData );
00759
00760 CPLErr CPL_DLL
00761 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
00762 const char * pszResampling,
00763 int nOverviews, int * panOverviewList,
00764 int nBands, int * panBandList,
00765 GDALProgressFunc pfnProgress, void * pProgressData);
00766
00767
00768
00769 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize );
00770
00771 GDALDataset CPL_DLL *
00772 GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
00773 GDALDataset *poDependentDS );
00774
00775
00776
00777
00778
00779 CPLErr CPL_DLL GDALParseGMLCoverage( CPLXMLNode *psTree,
00780 int *pnXSize, int *pnYSize,
00781 double *padfGeoTransform,
00782 char **ppszProjection );
00783
00784 CPL_C_END
00785
00786 #endif