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 00031 00031 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 #ifndef GDAL_PRIV_H_INCLUDED
00095 #define GDAL_PRIV_H_INCLUDED
00096
00097
00098
00099
00100
00101 class GDALMajorObject;
00102 class GDALDataset;
00103 class GDALRasterBand;
00104 class GDALDriver;
00105
00106
00107
00108
00109
00110
00111
00112 #include "gdal.h"
00113 #include "cpl_vsi.h"
00114 #include "cpl_conv.h"
00115
00116
00117
00118
00119
00120
00121
00122
00123 class CPL_DLL GDALMajorObject
00124 {
00125 protected:
00126 char *pszDescription;
00127 char **papszMetadata;
00128
00129 public:
00130 GDALMajorObject();
00131 virtual ~GDALMajorObject();
00132
00133 const char * GetDescription() const;
00134 void SetDescription( const char * );
00135
00136 virtual char **GetMetadata( const char * pszDomain = "" );
00137 virtual CPLErr SetMetadata( char ** papszMetadata,
00138 const char * pszDomain = "" );
00139 virtual const char *GetMetadataItem( const char * pszName,
00140 const char * pszDomain = "" );
00141 virtual CPLErr SetMetadataItem( const char * pszName,
00142 const char * pszValue,
00143 const char * pszDomain = "" );
00144 };
00145
00146
00147
00148
00149
00151
00152 class CPL_DLL GDALProjDef
00153 {
00154 void *psPJ;
00155
00156 char *pszProjection;
00157
00158 public:
00159 GDALProjDef( const char * = NULL );
00160 ~GDALProjDef();
00161
00162 CPLErr ToLongLat( double * padfX, double * padfY );
00163 CPLErr FromLongLat( double * padfX, double * padfY );
00164
00165 const char *GetProjectionString( void ) { return pszProjection; }
00166 CPLErr SetProjectionString( const char * );
00167 };
00168
00169
00170
00171
00172 class GDALDefaultOverviews
00173 {
00174 GDALDataset *poDS;
00175 GDALDataset *poODS;
00176
00177 public:
00178 GDALDefaultOverviews();
00179 ~GDALDefaultOverviews();
00180
00181 void Initialize( GDALDataset *, const char * = NULL );
00182 int IsInitialized() { return poDS != NULL; }
00183
00184 int GetOverviewCount(int);
00185 GDALRasterBand *GetOverview(int,int);
00186
00187 CPLErr BuildOverviews( const char * pszBasename,
00188 const char * pszResampling,
00189 int nOverviews, int * panOverviewList,
00190 int nBands, int * panBandList,
00191 GDALProgressFunc pfnProgress,
00192 void *pProgressData );
00193 };
00194
00195
00196
00197
00198
00205 class CPL_DLL GDALDataset : public GDALMajorObject
00206 {
00207 friend GDALDatasetH GDALOpen( const char *, GDALAccess);
00208
00209 protected:
00210 GDALDriver *poDriver;
00211 GDALAccess eAccess;
00212
00213
00214 int nRasterXSize;
00215 int nRasterYSize;
00216 int nBands;
00217 GDALRasterBand **papoBands;
00218
00219 int nRefCount;
00220
00221 GDALDataset(void);
00222 void RasterInitialize( int, int );
00223 void SetBand( int, GDALRasterBand * );
00224
00225 GDALDefaultOverviews oOvManager;
00226
00227 virtual CPLErr IBuildOverviews( const char *, int, int *,
00228 int, int *, GDALProgressFunc, void * );
00229
00230 friend class GDALRasterBand;
00231
00232 public:
00233 virtual ~GDALDataset();
00234
00235 int GetRasterXSize( void );
00236 int GetRasterYSize( void );
00237 int GetRasterCount( void );
00238 GDALRasterBand *GetRasterBand( int );
00239
00240 virtual void FlushCache(void);
00241
00242 virtual const char *GetProjectionRef(void);
00243 virtual CPLErr SetProjection( const char * );
00244
00245 virtual CPLErr GetGeoTransform( double * );
00246 virtual CPLErr SetGeoTransform( double * );
00247
00248 virtual void *GetInternalHandle( const char * );
00249 virtual GDALDriver *GetDriver(void);
00250
00251 virtual int GetGCPCount();
00252 virtual const char *GetGCPProjection();
00253 virtual const GDAL_GCP *GetGCPs();
00254
00255 int Reference();
00256 int Dereference();
00257 GDALAccess GetAccess() { return eAccess; }
00258
00259 CPLErr BuildOverviews( const char *, int, int *,
00260 int, int *, GDALProgressFunc, void * );
00261 };
00262
00263
00264
00265
00266
00269 class CPL_DLL GDALRasterBlock
00270 {
00271 GDALDataType eType;
00272
00273 int nAge;
00274 int bDirty;
00275
00276 int nXOff;
00277 int nYOff;
00278
00279 int nXSize;
00280 int nYSize;
00281
00282 void *pData;
00283
00284 GDALRasterBand *poBand;
00285
00286 GDALRasterBlock *poNext;
00287 GDALRasterBlock *poPrevious;
00288
00289 public:
00290 GDALRasterBlock( GDALRasterBand *, int, int );
00291 virtual ~GDALRasterBlock();
00292
00293 CPLErr Internalize( void );
00294 void Touch( void );
00295 void MarkDirty( void );
00296 void MarkClean( void );
00297
00298 CPLErr Write();
00299
00300 GDALDataType GetDataType() { return eType; }
00301 int GetXOff() { return nXOff; }
00302 int GetYOff() { return nYOff; }
00303 int GetXSize() { return nXSize; }
00304 int GetYSize() { return nYSize; }
00305 int GetAge() { return nAge; }
00306 int GetDirty() { return bDirty; }
00307
00308 void *GetDataRef( void ) { return pData; }
00309
00310 GDALRasterBand *GetBand() { return poBand; }
00311
00312 static void FlushOldestBlock();
00313 static void Verify();
00314
00315 };
00316
00317
00318
00319
00320
00321
00322 class CPL_DLL GDALColorTable
00323 {
00324 GDALPaletteInterp eInterp;
00325
00326 int nEntryCount;
00327 GDALColorEntry *paoEntries;
00328
00329 public:
00330 GDALColorTable( GDALPaletteInterp = GPI_RGB );
00331 ~GDALColorTable();
00332
00333 GDALColorTable *Clone() const;
00334
00335 GDALPaletteInterp GetPaletteInterpretation() const;
00336
00337 int GetColorEntryCount() const;
00338 const GDALColorEntry *GetColorEntry( int ) const;
00339 int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
00340 void SetColorEntry( int, const GDALColorEntry * );
00341 };
00342
00343
00344
00345
00346
00348
00349 class CPL_DLL GDALRasterBand : public GDALMajorObject
00350 {
00351 protected:
00352 GDALDataset *poDS;
00353 int nBand;
00354
00355 int nRasterXSize;
00356 int nRasterYSize;
00357
00358 GDALDataType eDataType;
00359 GDALAccess eAccess;
00360
00361
00362 int nBlockXSize;
00363 int nBlockYSize;
00364 int nBlocksPerRow;
00365 int nBlocksPerColumn;
00366
00367 GDALRasterBlock **papoBlocks;
00368
00369 friend class GDALDataset;
00370 friend class GDALRasterBlock;
00371
00372 protected:
00373 virtual CPLErr IReadBlock( int, int, void * ) = 0;
00374 virtual CPLErr IWriteBlock( int, int, void * );
00375 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00376 void *, int, int, GDALDataType,
00377 int, int );
00378 CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
00379 void *, int, int, GDALDataType,
00380 int, int );
00381
00382 CPLErr AdoptBlock( int, int, GDALRasterBlock * );
00383 void InitBlockInfo();
00384
00385 public:
00386 GDALRasterBand();
00387
00388 virtual ~GDALRasterBand();
00389
00390 int GetXSize();
00391 int GetYSize();
00392
00393 GDALDataType GetRasterDataType( void );
00394 void GetBlockSize( int *, int * );
00395 GDALAccess GetAccess();
00396
00397 CPLErr RasterIO( GDALRWFlag, int, int, int, int,
00398 void *, int, int, GDALDataType,
00399 int, int );
00400 CPLErr ReadBlock( int, int, void * );
00401
00402 CPLErr WriteBlock( int, int, void * );
00403
00404 GDALRasterBlock *GetBlockRef( int, int );
00405 CPLErr FlushCache();
00406 CPLErr FlushBlock( int = -1, int = -1 );
00407
00408
00409
00410 virtual const char *GetDescription();
00411 virtual char **GetCategoryNames();
00412 virtual double GetNoDataValue( int *pbSuccess = NULL );
00413 virtual double GetMinimum( int *pbSuccess = NULL );
00414 virtual double GetMaximum(int *pbSuccess = NULL );
00415 virtual double GetOffset( int *pbSuccess = NULL );
00416 virtual double GetScale( int *pbSuccess = NULL );
00417 virtual const char *GetUnitType();
00418 virtual GDALColorInterp GetColorInterpretation();
00419 virtual GDALColorTable *GetColorTable();
00420
00421 virtual int HasArbitraryOverviews();
00422 virtual int GetOverviewCount();
00423 virtual GDALRasterBand *GetOverview(int);
00424 virtual CPLErr BuildOverviews( const char *, int, int *,
00425 GDALProgressFunc, void * );
00426
00427 CPLErr GetHistogram( double dfMin, double dfMax,
00428 int nBuckets, int * panHistogram,
00429 int bIncludeOutOfRange, int bApproxOK,
00430 GDALProgressFunc, void *pProgressData );
00431 };
00432
00433
00434
00435
00436
00437
00438
00439 class CPL_DLL GDALOpenInfo
00440 {
00441 public:
00442
00443 GDALOpenInfo( const char * pszFile, GDALAccess eAccessIn );
00444 ~GDALOpenInfo( void );
00445
00446 char *pszFilename;
00447
00448 GDALAccess eAccess;
00449
00450 GBool bStatOK;
00451 VSIStatBuf sStat;
00452
00453 FILE *fp;
00454
00455 int nHeaderBytes;
00456 GByte *pabyHeader;
00457
00458 };
00459
00460
00461
00462
00463
00473 class CPL_DLL GDALDriver : public GDALMajorObject
00474 {
00475 public:
00476 GDALDriver();
00477 ~GDALDriver();
00478
00480 char *pszShortName;
00481
00483 char *pszLongName;
00484
00486 char *pszHelpTopic;
00487
00488 GDALDataset *(*pfnOpen)( GDALOpenInfo * );
00489
00490 GDALDataset *(*pfnCreate)( const char * pszName,
00491 int nXSize, int nYSize, int nBands,
00492 GDALDataType eType,
00493 char ** papszOptions );
00494
00495 GDALDataset *Create( const char * pszName,
00496 int nXSize, int nYSize, int nBands,
00497 GDALDataType eType, char ** papszOptions );
00498
00499 CPLErr (*pfnDelete)( const char * pszName );
00500
00501 CPLErr Delete( const char * pszName );
00502
00503 GDALDataset *CreateCopy( const char *, GDALDataset *,
00504 int, char **,
00505 GDALProgressFunc pfnProgress,
00506 void * pProgressData );
00507
00508 GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
00509 int, char **,
00510 GDALProgressFunc pfnProgress,
00511 void * pProgressData );
00512 };
00513
00514
00515
00516
00517
00525 class CPL_DLL GDALDriverManager : public GDALMajorObject
00526 {
00527 int nDrivers;
00528 GDALDriver **papoDrivers;
00529
00530 char *pszHome;
00531
00532 public:
00533 GDALDriverManager();
00534 ~GDALDriverManager();
00535
00536 int GetDriverCount( void );
00537 GDALDriver *GetDriver( int );
00538 GDALDriver *GetDriverByName( const char * );
00539
00540 int RegisterDriver( GDALDriver * );
00541 void MoveDriver( GDALDriver *, int );
00542 void DeregisterDriver( GDALDriver * );
00543
00544 void AutoLoadDrivers();
00545
00546 const char *GetHome();
00547 void SetHome( const char * );
00548 };
00549
00550 CPL_C_START
00551 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
00552 CPL_C_END
00553
00554
00555
00556
00557
00558 CPL_C_START
00559
00560 CPLErr
00561 GTIFFBuildOverviews( const char * pszFilename,
00562 int nBands, GDALRasterBand **papoBandList,
00563 int nOverviews, int * panOverviewList,
00564 const char * pszResampling,
00565 GDALProgressFunc pfnProgress, void * pProgressData );
00566
00567 CPLErr
00568 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
00569 const char * pszResampling,
00570 int nOverviews, int * panOverviewList,
00571 int nBands, int * panBandList,
00572 GDALProgressFunc pfnProgress, void * pProgressData);
00573
00574
00575 CPLErr
00576 GDALRegenerateOverviews( GDALRasterBand *, int, GDALRasterBand **,
00577 const char *, GDALProgressFunc, void * );
00578
00579 CPL_C_END
00580
00581 #endif