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