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