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