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 #ifndef GDAL_PRIV_H_INCLUDED
00220 #define GDAL_PRIV_H_INCLUDED
00221
00222
00223
00224
00225
00226 class GDALMajorObject;
00227 class GDALDataset;
00228 class GDALRasterBand;
00229 class GDALDriver;
00230
00231
00232
00233
00234
00235
00236
00237 #include "gdal.h"
00238 #include "gdal_frmts.h"
00239 #include "cpl_vsi.h"
00240 #include "cpl_conv.h"
00241 #include <string>
00242 #include <vector>
00243
00244
00245
00246
00247
00248
00249
00250
00252
00253 class CPL_DLL GDALMajorObject
00254 {
00255 protected:
00256 std::string sDescription;
00257 char **papszMetadata;
00258
00259 public:
00260 GDALMajorObject();
00261 virtual ~GDALMajorObject();
00262
00263 virtual const char *GetDescription() const;
00264 virtual void SetDescription( const char * );
00265
00266 virtual char **GetMetadata( const char * pszDomain = "" );
00267 virtual CPLErr SetMetadata( char ** papszMetadata,
00268 const char * pszDomain = "" );
00269 virtual const char *GetMetadataItem( const char * pszName,
00270 const char * pszDomain = "" );
00271 virtual CPLErr SetMetadataItem( const char * pszName,
00272 const char * pszValue,
00273 const char * pszDomain = "" );
00274 };
00275
00276
00277
00278
00279 class CPL_DLL GDALDefaultOverviews
00280 {
00281 GDALDataset *poDS;
00282 GDALDataset *poODS;
00283
00284 char *pszOvrFilename;
00285
00286 public:
00287 GDALDefaultOverviews();
00288 ~GDALDefaultOverviews();
00289
00290 void Initialize( GDALDataset *poDS, const char *pszName = NULL,
00291 int bNameIsOVR = FALSE );
00292 int IsInitialized() { return poDS != NULL; }
00293
00294 int GetOverviewCount(int);
00295 GDALRasterBand *GetOverview(int,int);
00296
00297 CPLErr BuildOverviews( const char * pszBasename,
00298 const char * pszResampling,
00299 int nOverviews, int * panOverviewList,
00300 int nBands, int * panBandList,
00301 GDALProgressFunc pfnProgress,
00302 void *pProgressData );
00303 };
00304
00305
00306
00307
00308
00310
00311 class CPL_DLL GDALDataset : public GDALMajorObject
00312 {
00313 friend GDALDatasetH CPL_STDCALL GDALOpen( const char *, GDALAccess);
00314 friend GDALDatasetH CPL_STDCALL GDALOpenShared( const char *, GDALAccess);
00315 friend class GDALDriver;
00316
00317 protected:
00318 GDALDriver *poDriver;
00319 GDALAccess eAccess;
00320
00321
00322 int nRasterXSize;
00323 int nRasterYSize;
00324 int nBands;
00325 GDALRasterBand **papoBands;
00326
00327 int bForceCachedIO;
00328
00329 int nRefCount;
00330 int bShared;
00331
00332 GDALDataset(void);
00333 void RasterInitialize( int, int );
00334 void SetBand( int, GDALRasterBand * );
00335
00336 GDALDefaultOverviews oOvManager;
00337
00338 virtual CPLErr IBuildOverviews( const char *, int, int *,
00339 int, int *, GDALProgressFunc, void * );
00340
00341 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00342 void *, int, int, GDALDataType,
00343 int, int *, int, int, int );
00344
00345 CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
00346 void *, int, int, GDALDataType,
00347 int, int *, int, int, int );
00348 void BlockBasedFlushCache();
00349
00350 friend class GDALRasterBand;
00351
00352 public:
00353 virtual ~GDALDataset();
00354
00355 int GetRasterXSize( void );
00356 int GetRasterYSize( void );
00357 int GetRasterCount( void );
00358 GDALRasterBand *GetRasterBand( int );
00359
00360 virtual void FlushCache(void);
00361
00362 virtual const char *GetProjectionRef(void);
00363 virtual CPLErr SetProjection( const char * );
00364
00365 virtual CPLErr GetGeoTransform( double * );
00366 virtual CPLErr SetGeoTransform( double * );
00367
00368 virtual CPLErr AddBand( GDALDataType eType,
00369 char **papszOptions=NULL );
00370
00371 virtual void *GetInternalHandle( const char * );
00372 virtual GDALDriver *GetDriver(void);
00373
00374 virtual int GetGCPCount();
00375 virtual const char *GetGCPProjection();
00376 virtual const GDAL_GCP *GetGCPs();
00377 virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
00378 const char *pszGCPProjection );
00379
00380 virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
00381 int nBufXSize, int nBufYSize,
00382 GDALDataType eDT,
00383 int nBandCount, int *panBandList,
00384 char **papszOptions );
00385
00386 CPLErr RasterIO( GDALRWFlag, int, int, int, int,
00387 void *, int, int, GDALDataType,
00388 int, int *, int, int, int );
00389
00390 int Reference();
00391 int Dereference();
00392 GDALAccess GetAccess() { return eAccess; }
00393
00394 int GetShared();
00395 void MarkAsShared();
00396
00397 static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
00398
00399 CPLErr BuildOverviews( const char *, int, int *,
00400 int, int *, GDALProgressFunc, void * );
00401 };
00402
00403
00404
00405
00406
00409 class CPL_DLL GDALRasterBlock
00410 {
00411 GDALDataType eType;
00412
00413 int bDirty;
00414 int nLockCount;
00415
00416 int nXOff;
00417 int nYOff;
00418
00419 int nXSize;
00420 int nYSize;
00421
00422 void *pData;
00423
00424 GDALRasterBand *poBand;
00425
00426 GDALRasterBlock *poNext;
00427 GDALRasterBlock *poPrevious;
00428
00429 public:
00430 GDALRasterBlock( GDALRasterBand *, int, int );
00431 virtual ~GDALRasterBlock();
00432
00433 CPLErr Internalize( void );
00434 void Touch( void );
00435 void MarkDirty( void );
00436 void MarkClean( void );
00437 void AddLock( void ) { nLockCount++; }
00438 void DropLock( void ) { nLockCount--; }
00439 void Detach();
00440
00441 CPLErr Write();
00442
00443 GDALDataType GetDataType() { return eType; }
00444 int GetXOff() { return nXOff; }
00445 int GetYOff() { return nYOff; }
00446 int GetXSize() { return nXSize; }
00447 int GetYSize() { return nYSize; }
00448 int GetDirty() { return bDirty; }
00449 int GetLockCount() { return nLockCount; }
00450
00451 void *GetDataRef( void ) { return pData; }
00452
00453 GDALRasterBand *GetBand() { return poBand; }
00454
00455 static int FlushCacheBlock();
00456 static void Verify();
00457
00458 static int SafeLockBlock( GDALRasterBlock ** );
00459 };
00460
00461
00462
00463
00464
00465 class CPL_DLL GDALColorTable
00466 {
00467 GDALPaletteInterp eInterp;
00468
00469 std::vector<GDALColorEntry> aoEntries;
00470
00471 public:
00472 GDALColorTable( GDALPaletteInterp = GPI_RGB );
00473 ~GDALColorTable();
00474
00475 GDALColorTable *Clone() const;
00476
00477 GDALPaletteInterp GetPaletteInterpretation() const;
00478
00479 int GetColorEntryCount() const;
00480 const GDALColorEntry *GetColorEntry( int ) const;
00481 int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
00482 void SetColorEntry( int, const GDALColorEntry * );
00483 };
00484
00485
00486
00487
00488
00490
00491 class CPL_DLL GDALRasterBand : public GDALMajorObject
00492 {
00493 protected:
00494 GDALDataset *poDS;
00495 int nBand;
00496
00497 int nRasterXSize;
00498 int nRasterYSize;
00499
00500 GDALDataType eDataType;
00501 GDALAccess eAccess;
00502
00503
00504 int nBlockXSize;
00505 int nBlockYSize;
00506 int nBlocksPerRow;
00507 int nBlocksPerColumn;
00508
00509 int bSubBlockingActive;
00510 int nSubBlocksPerRow;
00511 int nSubBlocksPerColumn;
00512 GDALRasterBlock **papoBlocks;
00513
00514 int nBlockReads;
00515 int bForceCachedIO;
00516
00517 friend class GDALDataset;
00518 friend class GDALRasterBlock;
00519
00520 protected:
00521 virtual CPLErr IReadBlock( int, int, void * ) = 0;
00522 virtual CPLErr IWriteBlock( int, int, void * );
00523 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00524 void *, int, int, GDALDataType,
00525 int, int );
00526 CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
00527 void *, int, int, GDALDataType,
00528 int, int );
00529
00530 void InitBlockInfo();
00531
00532 CPLErr AdoptBlock( int, int, GDALRasterBlock * );
00533 GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
00534
00535 public:
00536 GDALRasterBand();
00537
00538 virtual ~GDALRasterBand();
00539
00540 int GetXSize();
00541 int GetYSize();
00542 int GetBand();
00543 GDALDataset*GetDataset();
00544
00545 GDALDataType GetRasterDataType( void );
00546 void GetBlockSize( int *, int * );
00547 GDALAccess GetAccess();
00548
00549 CPLErr RasterIO( GDALRWFlag, int, int, int, int,
00550 void *, int, int, GDALDataType,
00551 int, int );
00552 CPLErr ReadBlock( int, int, void * );
00553
00554 CPLErr WriteBlock( int, int, void * );
00555
00556 GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
00557 int bJustInitialize = FALSE );
00558 CPLErr FlushBlock( int = -1, int = -1 );
00559
00560
00561
00562 virtual CPLErr FlushCache();
00563 virtual char **GetCategoryNames();
00564 virtual double GetNoDataValue( int *pbSuccess = NULL );
00565 virtual double GetMinimum( int *pbSuccess = NULL );
00566 virtual double GetMaximum(int *pbSuccess = NULL );
00567 virtual double GetOffset( int *pbSuccess = NULL );
00568 virtual double GetScale( int *pbSuccess = NULL );
00569 virtual const char *GetUnitType();
00570 virtual GDALColorInterp GetColorInterpretation();
00571 virtual GDALColorTable *GetColorTable();
00572 virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
00573
00574 virtual CPLErr SetCategoryNames( char ** );
00575 virtual CPLErr SetNoDataValue( double );
00576 virtual CPLErr SetColorTable( GDALColorTable * );
00577 virtual CPLErr SetColorInterpretation( GDALColorInterp );
00578 virtual CPLErr SetOffset( double );
00579 virtual CPLErr SetScale( double );
00580 virtual CPLErr SetUnitType( const char * );
00581
00582 virtual CPLErr GetStatistics( int bApproxOK, int bForce,
00583 double *pdfMin, double *pdfMax,
00584 double *pdfMean, double *padfStdDev );
00585 virtual CPLErr SetStatistics( double dfMin, double dfMax,
00586 double dfMean, double dfStdDev );
00587
00588 virtual int HasArbitraryOverviews();
00589 virtual int GetOverviewCount();
00590 virtual GDALRasterBand *GetOverview(int);
00591 virtual CPLErr BuildOverviews( const char *, int, int *,
00592 GDALProgressFunc, void * );
00593
00594 virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
00595 int nBufXSize, int nBufYSize,
00596 GDALDataType eDT, char **papszOptions );
00597
00598 virtual CPLErr GetHistogram( double dfMin, double dfMax,
00599 int nBuckets, int * panHistogram,
00600 int bIncludeOutOfRange, int bApproxOK,
00601 GDALProgressFunc, void *pProgressData );
00602
00603 virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
00604 int *pnBuckets, int ** ppanHistogram,
00605 int bForce,
00606 GDALProgressFunc, void *pProgressData);
00607 virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
00608 int nBuckets, int *panHistogram );
00609 };
00610
00611
00612
00613
00614
00615
00616
00617 class CPL_DLL GDALOpenInfo
00618 {
00619 public:
00620
00621 GDALOpenInfo( const char * pszFile, GDALAccess eAccessIn );
00622 ~GDALOpenInfo( void );
00623
00624 char *pszFilename;
00625
00626 GDALAccess eAccess;
00627
00628 int bStatOK;
00629 int bIsDirectory;
00630
00631 FILE *fp;
00632
00633 int nHeaderBytes;
00634 GByte *pabyHeader;
00635
00636 };
00637
00638
00639
00640
00641
00642
00654 class CPL_DLL GDALDriver : public GDALMajorObject
00655 {
00656 public:
00657 GDALDriver();
00658 ~GDALDriver();
00659
00660
00661
00662
00663 GDALDataset *Create( const char * pszName,
00664 int nXSize, int nYSize, int nBands,
00665 GDALDataType eType, char ** papszOptions );
00666
00667 CPLErr Delete( const char * pszName );
00668
00669 GDALDataset *CreateCopy( const char *, GDALDataset *,
00670 int, char **,
00671 GDALProgressFunc pfnProgress,
00672 void * pProgressData );
00673
00674
00675
00676
00677
00678
00679 GDALDataset *(*pfnOpen)( GDALOpenInfo * );
00680
00681 GDALDataset *(*pfnCreate)( const char * pszName,
00682 int nXSize, int nYSize, int nBands,
00683 GDALDataType eType,
00684 char ** papszOptions );
00685
00686 CPLErr (*pfnDelete)( const char * pszName );
00687
00688 GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
00689 int, char **,
00690 GDALProgressFunc pfnProgress,
00691 void * pProgressData );
00692
00693 void *pDriverData;
00694
00695 void (*pfnUnloadDriver)(GDALDriver *);
00696 };
00697
00698
00699
00700
00701
00709 class CPL_DLL GDALDriverManager : public GDALMajorObject
00710 {
00711 int nDrivers;
00712 GDALDriver **papoDrivers;
00713
00714 char *pszHome;
00715
00716 public:
00717 GDALDriverManager();
00718 ~GDALDriverManager();
00719
00720 int GetDriverCount( void );
00721 GDALDriver *GetDriver( int );
00722 GDALDriver *GetDriverByName( const char * );
00723
00724 int RegisterDriver( GDALDriver * );
00725 void MoveDriver( GDALDriver *, int );
00726 void DeregisterDriver( GDALDriver * );
00727
00728 void AutoLoadDrivers();
00729 void AutoSkipDrivers();
00730
00731 const char *GetHome();
00732 void SetHome( const char * );
00733 };
00734
00735 CPL_C_START
00736 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
00737 CPL_C_END
00738
00739
00740
00741
00742
00743 CPL_C_START
00744
00745 CPLErr CPL_DLL
00746 GTIFFBuildOverviews( const char * pszFilename,
00747 int nBands, GDALRasterBand **papoBandList,
00748 int nOverviews, int * panOverviewList,
00749 const char * pszResampling,
00750 GDALProgressFunc pfnProgress, void * pProgressData );
00751
00752 CPLErr CPL_DLL
00753 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
00754 const char * pszResampling,
00755 int nOverviews, int * panOverviewList,
00756 int nBands, int * panBandList,
00757 GDALProgressFunc pfnProgress, void * pProgressData);
00758
00759
00760 CPLErr CPL_DLL
00761 GDALRegenerateOverviews( GDALRasterBand *, int, GDALRasterBand **,
00762 const char *, GDALProgressFunc, void * );
00763
00764 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize );
00765
00766 CPL_C_END
00767
00768 #endif