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