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