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 #ifndef GDAL_PRIV_H_INCLUDED
00108 #define GDAL_PRIV_H_INCLUDED
00109
00110
00111
00112
00113
00114 class GDALMajorObject;
00115 class GDALDataset;
00116 class GDALRasterBand;
00117 class GDALDriver;
00118 class GDALRasterAttributeTable;
00119
00120
00121
00122
00123
00124
00125
00126 #include "gdal.h"
00127 #include "gdal_frmts.h"
00128 #include "cpl_vsi.h"
00129 #include "cpl_conv.h"
00130 #include "cpl_string.h"
00131 #include "cpl_minixml.h"
00132 #include <vector>
00133
00134 #define GMO_VALID 0x0001
00135 #define GMO_IGNORE_UNIMPLEMENTED 0x0002
00136 #define GMO_SUPPORT_MD 0x0004
00137 #define GMO_SUPPORT_MDMD 0x0008
00138 #define GMO_MD_DIRTY 0x0010
00139 #define GMO_PAM_CLASS 0x0020
00140
00141
00142
00143
00144
00145 class CPL_DLL GDALMultiDomainMetadata
00146 {
00147 private:
00148 char **papszDomainList;
00149 char ***papapszMetadataLists;
00150
00151 public:
00152 GDALMultiDomainMetadata();
00153 ~GDALMultiDomainMetadata();
00154
00155 int XMLInit( CPLXMLNode *psMetadata, int bMerge );
00156 CPLXMLNode *Serialize();
00157
00158 char **GetDomainList() { return papszDomainList; }
00159
00160 char **GetMetadata( const char * pszDomain = "" );
00161 CPLErr SetMetadata( char ** papszMetadata,
00162 const char * pszDomain = "" );
00163 const char *GetMetadataItem( const char * pszName,
00164 const char * pszDomain = "" );
00165 CPLErr SetMetadataItem( const char * pszName,
00166 const char * pszValue,
00167 const char * pszDomain = "" );
00168
00169 void Clear();
00170 };
00171
00172
00173
00174
00175
00176
00177
00178
00180
00181 class CPL_DLL GDALMajorObject
00182 {
00183 protected:
00184 int nFlags;
00185 CPLString sDescription;
00186 GDALMultiDomainMetadata oMDMD;
00187
00188 public:
00189 GDALMajorObject();
00190 virtual ~GDALMajorObject();
00191
00192 int GetMOFlags();
00193 void SetMOFlags(int nFlags);
00194
00195 virtual const char *GetDescription() const;
00196 virtual void SetDescription( const char * );
00197
00198 virtual char **GetMetadata( const char * pszDomain = "" );
00199 virtual CPLErr SetMetadata( char ** papszMetadata,
00200 const char * pszDomain = "" );
00201 virtual const char *GetMetadataItem( const char * pszName,
00202 const char * pszDomain = "" );
00203 virtual CPLErr SetMetadataItem( const char * pszName,
00204 const char * pszValue,
00205 const char * pszDomain = "" );
00206 };
00207
00208
00209
00210
00211 class CPL_DLL GDALDefaultOverviews
00212 {
00213 GDALDataset *poDS;
00214 GDALDataset *poODS;
00215
00216 CPLString osOvrFilename;
00217
00218 int bOvrIsAux;
00219
00220 public:
00221 GDALDefaultOverviews();
00222 ~GDALDefaultOverviews();
00223
00224 void Initialize( GDALDataset *poDS, const char *pszName = NULL,
00225 int bNameIsOVR = FALSE );
00226 int IsInitialized() { return poDS != NULL; }
00227
00228 int GetOverviewCount(int);
00229 GDALRasterBand *GetOverview(int,int);
00230
00231 CPLErr BuildOverviews( const char * pszBasename,
00232 const char * pszResampling,
00233 int nOverviews, int * panOverviewList,
00234 int nBands, int * panBandList,
00235 GDALProgressFunc pfnProgress,
00236 void *pProgressData );
00237 };
00238
00239
00240
00241
00242
00244
00245 class CPL_DLL GDALDataset : public GDALMajorObject
00246 {
00247 friend GDALDatasetH CPL_STDCALL GDALOpen( const char *, GDALAccess);
00248 friend GDALDatasetH CPL_STDCALL GDALOpenShared( const char *, GDALAccess);
00249 friend class GDALDriver;
00250
00251 protected:
00252 GDALDriver *poDriver;
00253 GDALAccess eAccess;
00254
00255
00256 int nRasterXSize;
00257 int nRasterYSize;
00258 int nBands;
00259 GDALRasterBand **papoBands;
00260
00261 int bForceCachedIO;
00262
00263 int nRefCount;
00264 int bShared;
00265
00266 GDALDataset(void);
00267 void RasterInitialize( int, int );
00268 void SetBand( int, GDALRasterBand * );
00269
00270 GDALDefaultOverviews oOvManager;
00271
00272 virtual CPLErr IBuildOverviews( const char *, int, int *,
00273 int, int *, GDALProgressFunc, void * );
00274
00275 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00276 void *, int, int, GDALDataType,
00277 int, int *, int, int, int );
00278
00279 CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
00280 void *, int, int, GDALDataType,
00281 int, int *, int, int, int );
00282 void BlockBasedFlushCache();
00283
00284 friend class GDALRasterBand;
00285
00286 public:
00287 virtual ~GDALDataset();
00288
00289 int GetRasterXSize( void );
00290 int GetRasterYSize( void );
00291 int GetRasterCount( void );
00292 GDALRasterBand *GetRasterBand( int );
00293
00294 virtual void FlushCache(void);
00295
00296 virtual const char *GetProjectionRef(void);
00297 virtual CPLErr SetProjection( const char * );
00298
00299 virtual CPLErr GetGeoTransform( double * );
00300 virtual CPLErr SetGeoTransform( double * );
00301
00302 virtual CPLErr AddBand( GDALDataType eType,
00303 char **papszOptions=NULL );
00304
00305 virtual void *GetInternalHandle( const char * );
00306 virtual GDALDriver *GetDriver(void);
00307
00308 virtual int GetGCPCount();
00309 virtual const char *GetGCPProjection();
00310 virtual const GDAL_GCP *GetGCPs();
00311 virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
00312 const char *pszGCPProjection );
00313
00314 virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
00315 int nBufXSize, int nBufYSize,
00316 GDALDataType eDT,
00317 int nBandCount, int *panBandList,
00318 char **papszOptions );
00319
00320 CPLErr RasterIO( GDALRWFlag, int, int, int, int,
00321 void *, int, int, GDALDataType,
00322 int, int *, int, int, int );
00323
00324 int Reference();
00325 int Dereference();
00326 GDALAccess GetAccess() { return eAccess; }
00327
00328 int GetShared();
00329 void MarkAsShared();
00330
00331 static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
00332
00333 CPLErr BuildOverviews( const char *, int, int *,
00334 int, int *, GDALProgressFunc, void * );
00335 };
00336
00337
00338
00339
00340
00343 class CPL_DLL GDALRasterBlock
00344 {
00345 GDALDataType eType;
00346
00347 int bDirty;
00348 int nLockCount;
00349
00350 int nXOff;
00351 int nYOff;
00352
00353 int nXSize;
00354 int nYSize;
00355
00356 void *pData;
00357
00358 GDALRasterBand *poBand;
00359
00360 GDALRasterBlock *poNext;
00361 GDALRasterBlock *poPrevious;
00362
00363 public:
00364 GDALRasterBlock( GDALRasterBand *, int, int );
00365 virtual ~GDALRasterBlock();
00366
00367 CPLErr Internalize( void );
00368 void Touch( void );
00369 void MarkDirty( void );
00370 void MarkClean( void );
00371 void AddLock( void ) { nLockCount++; }
00372 void DropLock( void ) { nLockCount--; }
00373 void Detach();
00374
00375 CPLErr Write();
00376
00377 GDALDataType GetDataType() { return eType; }
00378 int GetXOff() { return nXOff; }
00379 int GetYOff() { return nYOff; }
00380 int GetXSize() { return nXSize; }
00381 int GetYSize() { return nYSize; }
00382 int GetDirty() { return bDirty; }
00383 int GetLockCount() { return nLockCount; }
00384
00385 void *GetDataRef( void ) { return pData; }
00386
00387 GDALRasterBand *GetBand() { return poBand; }
00388
00389 static int FlushCacheBlock();
00390 static void Verify();
00391
00392 static int SafeLockBlock( GDALRasterBlock ** );
00393 };
00394
00395
00396
00397
00398
00399 class CPL_DLL GDALColorTable
00400 {
00401 GDALPaletteInterp eInterp;
00402
00403 std::vector<GDALColorEntry> aoEntries;
00404
00405 public:
00406 GDALColorTable( GDALPaletteInterp = GPI_RGB );
00407 ~GDALColorTable();
00408
00409 GDALColorTable *Clone() const;
00410
00411 GDALPaletteInterp GetPaletteInterpretation() const;
00412
00413 int GetColorEntryCount() const;
00414 const GDALColorEntry *GetColorEntry( int ) const;
00415 int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
00416 void SetColorEntry( int, const GDALColorEntry * );
00417 };
00418
00419
00420
00421
00422
00424
00425 class CPL_DLL GDALRasterBand : public GDALMajorObject
00426 {
00427 protected:
00428 GDALDataset *poDS;
00429 int nBand;
00430
00431 int nRasterXSize;
00432 int nRasterYSize;
00433
00434 GDALDataType eDataType;
00435 GDALAccess eAccess;
00436
00437
00438 int nBlockXSize;
00439 int nBlockYSize;
00440 int nBlocksPerRow;
00441 int nBlocksPerColumn;
00442
00443 int bSubBlockingActive;
00444 int nSubBlocksPerRow;
00445 int nSubBlocksPerColumn;
00446 GDALRasterBlock **papoBlocks;
00447
00448 int nBlockReads;
00449 int bForceCachedIO;
00450
00451 friend class GDALDataset;
00452 friend class GDALRasterBlock;
00453
00454 protected:
00455 virtual CPLErr IReadBlock( int, int, void * ) = 0;
00456 virtual CPLErr IWriteBlock( int, int, void * );
00457 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00458 void *, int, int, GDALDataType,
00459 int, int );
00460 CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
00461 void *, int, int, GDALDataType,
00462 int, int );
00463
00464 int InitBlockInfo();
00465
00466 CPLErr AdoptBlock( int, int, GDALRasterBlock * );
00467 GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
00468
00469 public:
00470 GDALRasterBand();
00471
00472 virtual ~GDALRasterBand();
00473
00474 int GetXSize();
00475 int GetYSize();
00476 int GetBand();
00477 GDALDataset*GetDataset();
00478
00479 GDALDataType GetRasterDataType( void );
00480 void GetBlockSize( int *, int * );
00481 GDALAccess GetAccess();
00482
00483 CPLErr RasterIO( GDALRWFlag, int, int, int, int,
00484 void *, int, int, GDALDataType,
00485 int, int );
00486 CPLErr ReadBlock( int, int, void * );
00487
00488 CPLErr WriteBlock( int, int, void * );
00489
00490 GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
00491 int bJustInitialize = FALSE );
00492 CPLErr FlushBlock( int = -1, int = -1 );
00493
00494
00495
00496 virtual CPLErr FlushCache();
00497 virtual char **GetCategoryNames();
00498 virtual double GetNoDataValue( int *pbSuccess = NULL );
00499 virtual double GetMinimum( int *pbSuccess = NULL );
00500 virtual double GetMaximum(int *pbSuccess = NULL );
00501 virtual double GetOffset( int *pbSuccess = NULL );
00502 virtual double GetScale( int *pbSuccess = NULL );
00503 virtual const char *GetUnitType();
00504 virtual GDALColorInterp GetColorInterpretation();
00505 virtual GDALColorTable *GetColorTable();
00506 virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
00507
00508 virtual CPLErr SetCategoryNames( char ** );
00509 virtual CPLErr SetNoDataValue( double );
00510 virtual CPLErr SetColorTable( GDALColorTable * );
00511 virtual CPLErr SetColorInterpretation( GDALColorInterp );
00512 virtual CPLErr SetOffset( double );
00513 virtual CPLErr SetScale( double );
00514 virtual CPLErr SetUnitType( const char * );
00515
00516 virtual CPLErr GetStatistics( int bApproxOK, int bForce,
00517 double *pdfMin, double *pdfMax,
00518 double *pdfMean, double *padfStdDev );
00519 virtual CPLErr SetStatistics( double dfMin, double dfMax,
00520 double dfMean, double dfStdDev );
00521
00522 virtual int HasArbitraryOverviews();
00523 virtual int GetOverviewCount();
00524 virtual GDALRasterBand *GetOverview(int);
00525 virtual CPLErr BuildOverviews( const char *, int, int *,
00526 GDALProgressFunc, void * );
00527
00528 virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
00529 int nBufXSize, int nBufYSize,
00530 GDALDataType eDT, char **papszOptions );
00531
00532 virtual CPLErr GetHistogram( double dfMin, double dfMax,
00533 int nBuckets, int * panHistogram,
00534 int bIncludeOutOfRange, int bApproxOK,
00535 GDALProgressFunc, void *pProgressData );
00536
00537 virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
00538 int *pnBuckets, int ** ppanHistogram,
00539 int bForce,
00540 GDALProgressFunc, void *pProgressData);
00541 virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
00542 int nBuckets, int *panHistogram );
00543
00544 virtual const GDALRasterAttributeTable *GetDefaultRAT();
00545 virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
00546 };
00547
00548
00549
00550
00551
00552
00553
00554 class CPL_DLL GDALOpenInfo
00555 {
00556 public:
00557
00558 GDALOpenInfo( const char * pszFile, GDALAccess eAccessIn );
00559 ~GDALOpenInfo( void );
00560
00561 char *pszFilename;
00562
00563 GDALAccess eAccess;
00564
00565 int bStatOK;
00566 int bIsDirectory;
00567
00568 FILE *fp;
00569
00570 int nHeaderBytes;
00571 GByte *pabyHeader;
00572
00573 };
00574
00575
00576
00577
00578
00579
00591 class CPL_DLL GDALDriver : public GDALMajorObject
00592 {
00593 public:
00594 GDALDriver();
00595 ~GDALDriver();
00596
00597
00598
00599
00600 GDALDataset *Create( const char * pszName,
00601 int nXSize, int nYSize, int nBands,
00602 GDALDataType eType, char ** papszOptions );
00603
00604 CPLErr Delete( const char * pszName );
00605
00606 GDALDataset *CreateCopy( const char *, GDALDataset *,
00607 int, char **,
00608 GDALProgressFunc pfnProgress,
00609 void * pProgressData );
00610
00611
00612
00613
00614
00615
00616 GDALDataset *(*pfnOpen)( GDALOpenInfo * );
00617
00618 GDALDataset *(*pfnCreate)( const char * pszName,
00619 int nXSize, int nYSize, int nBands,
00620 GDALDataType eType,
00621 char ** papszOptions );
00622
00623 CPLErr (*pfnDelete)( const char * pszName );
00624
00625 GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
00626 int, char **,
00627 GDALProgressFunc pfnProgress,
00628 void * pProgressData );
00629
00630 void *pDriverData;
00631
00632 void (*pfnUnloadDriver)(GDALDriver *);
00633 };
00634
00635
00636
00637
00638
00646 class CPL_DLL GDALDriverManager : public GDALMajorObject
00647 {
00648 int nDrivers;
00649 GDALDriver **papoDrivers;
00650
00651 char *pszHome;
00652
00653 public:
00654 GDALDriverManager();
00655 ~GDALDriverManager();
00656
00657 int GetDriverCount( void );
00658 GDALDriver *GetDriver( int );
00659 GDALDriver *GetDriverByName( const char * );
00660
00661 int RegisterDriver( GDALDriver * );
00662 void MoveDriver( GDALDriver *, int );
00663 void DeregisterDriver( GDALDriver * );
00664
00665 void AutoLoadDrivers();
00666 void AutoSkipDrivers();
00667
00668 const char *GetHome();
00669 void SetHome( const char * );
00670 };
00671
00672 CPL_C_START
00673 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
00674 CPL_C_END
00675
00676
00677
00678
00679
00680 CPL_C_START
00681
00682 CPLErr CPL_DLL
00683 HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
00684 GDALDataset **ppoDS,
00685 int nBands, int *panBandList,
00686 int nNewOverviews, int *panNewOverviewList,
00687 const char *pszResampling,
00688 GDALProgressFunc pfnProgress,
00689 void *pProgressData );
00690 CPLErr CPL_DLL
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 CPL_DLL
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 CPL_DLL
00706 GDALRegenerateOverviews( GDALRasterBand *, int, GDALRasterBand **,
00707 const char *, GDALProgressFunc, void * );
00708
00709 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize );
00710
00711 GDALDataset CPL_DLL *
00712 GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess );
00713
00714 CPL_C_END
00715
00716 #endif