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