00001 /****************************************************************************** 00002 * $Id: gdal_priv_h-source.html,v 1.11 2002/04/16 13:11:48 warmerda Exp $ 00003 * 00004 * Name: gdal_priv.h 00005 * Project: GDAL Core 00006 * Purpose: GDAL Core C++/Private declarations. 00007 * Author: Frank Warmerdam, warmerda@home.com 00008 * 00009 ****************************************************************************** 00010 * Copyright (c) 1998, Frank Warmerdam 00011 * 00012 * Permission is hereby granted, free of charge, to any person obtaining a 00013 * copy of this software and associated documentation files (the "Software"), 00014 * to deal in the Software without restriction, including without limitation 00015 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00016 * and/or sell copies of the Software, and to permit persons to whom the 00017 * Software is furnished to do so, subject to the following conditions: 00018 * 00019 * The above copyright notice and this permission notice shall be included 00020 * in all copies or substantial portions of the Software. 00021 * 00022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00023 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00024 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00025 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00026 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00027 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00028 * DEALINGS IN THE SOFTWARE. 00029 ****************************************************************************** 00030 * 00031 * $Log: gdal_priv_h-source.html,v $ 00031 * Revision 1.11 2002/04/16 13:11:48 warmerda 00031 * updated 00031 * 00032 * Revision 1.30 2002/03/01 14:29:09 warmerda 00033 * added GetBand() method on GDALRasterBand 00034 * 00035 * Revision 1.29 2001/12/15 15:42:27 warmerda 00036 * *** empty log message *** 00037 * 00038 * Revision 1.28 2001/11/18 00:52:15 warmerda 00039 * removed GDALProjDef 00040 * 00041 * Revision 1.27 2001/11/16 21:36:01 warmerda 00042 * added the AddBand() method on GDALDataset 00043 * 00044 * Revision 1.26 2001/10/17 21:47:02 warmerda 00045 * added SetGCPs() on GDALDataset 00046 * 00047 * Revision 1.25 2001/10/02 13:15:16 warmerda 00048 * added CPL_DLL for GDALDefaultOverviews 00049 * 00050 * Revision 1.24 2001/06/20 16:08:54 warmerda 00051 * GDALDefaultOverviews now remembers ovr filename, and allows explicit setting 00052 * 00053 * Revision 1.23 2001/02/06 16:30:21 warmerda 00054 * Added gdal_frmts.h 00055 * 00056 * Revision 1.22 2000/10/06 15:26:08 warmerda 00057 * added SetNoDataValue, SetCategoryNames 00058 * 00059 * Revision 1.21 2000/07/20 13:38:26 warmerda 00060 * make GetGDALDriverManager public with CPL_DLL 00061 * 00062 * Revision 1.20 2000/04/30 23:22:16 warmerda 00063 * added CreateCopy support 00064 * 00065 * Revision 1.19 2000/04/21 21:55:01 warmerda 00066 * majorobject updates, and overview building 00067 * 00068 * Revision 1.18 2000/04/04 23:44:29 warmerda 00069 * added AutoLoadDrivers() to GDALDriverManager 00070 * 00071 * Revision 1.17 2000/03/31 13:41:24 warmerda 00072 * added gcps 00073 * 00074 * Revision 1.16 2000/03/24 00:09:05 warmerda 00075 * rewrote cache management 00076 * 00077 * Revision 1.15 2000/03/09 23:22:03 warmerda 00078 * added GetHistogram 00079 * 00080 * Revision 1.14 2000/03/06 02:20:35 warmerda 00081 * added colortables, overviews, etc 00082 * 00083 * Revision 1.12 2000/01/31 15:00:25 warmerda 00084 * added some documentation 00085 * 00086 * Revision 1.11 2000/01/31 14:24:36 warmerda 00087 * implemented dataset delete 00088 * 00089 * Revision 1.10 1999/11/11 21:59:07 warmerda 00090 * added GetDriver() for datasets 00091 * 00092 * Revision 1.9 1999/10/21 13:23:45 warmerda 00093 * Added a bit of driver related documentation. 00094 * 00095 * Revision 1.8 1999/10/21 12:04:11 warmerda 00096 * Reorganized header. 00097 * 00098 * Revision 1.7 1999/10/01 14:44:02 warmerda 00099 * added documentation 00100 * 00101 * Revision 1.6 1999/04/21 04:16:25 warmerda 00102 * experimental docs 00103 * 00104 * Revision 1.5 1999/01/11 15:36:18 warmerda 00105 * Added projections support, and a few other things. 00106 * 00107 * Revision 1.4 1998/12/31 18:54:25 warmerda 00108 * Implement initial GDALRasterBlock support, and block cache 00109 * 00110 * Revision 1.3 1998/12/06 22:17:09 warmerda 00111 * Fill out rasterio support. 00112 * 00113 * Revision 1.2 1998/12/03 18:34:06 warmerda 00114 * Update to use CPL 00115 * 00116 * Revision 1.1 1998/10/18 06:15:11 warmerda 00117 * Initial implementation. 00118 * 00119 */ 00120 00121 #ifndef GDAL_PRIV_H_INCLUDED 00122 #define GDAL_PRIV_H_INCLUDED 00123 00124 /* -------------------------------------------------------------------- */ 00125 /* Predeclare various classes before pulling in gdal.h, the */ 00126 /* public declarations. */ 00127 /* -------------------------------------------------------------------- */ 00128 class GDALMajorObject; 00129 class GDALDataset; 00130 class GDALRasterBand; 00131 class GDALDriver; 00132 00133 /* -------------------------------------------------------------------- */ 00134 /* Pull in the public declarations. This gets the C apis, and */ 00135 /* also various constants. However, we will still get to */ 00136 /* provide the real class definitions for the GDAL classes. */ 00137 /* -------------------------------------------------------------------- */ 00138 00139 #include "gdal.h" 00140 #include "gdal_frmts.h" 00141 #include "cpl_vsi.h" 00142 #include "cpl_conv.h" 00143 00144 /* ******************************************************************** */ 00145 /* GDALMajorObject */ 00146 /* */ 00147 /* Base class providing metadata, description and other */ 00148 /* services shared by major objects. */ 00149 /* ******************************************************************** */ 00150 00151 class CPL_DLL GDALMajorObject 00152 { 00153 protected: 00154 char *pszDescription; 00155 char **papszMetadata; 00156 00157 public: 00158 GDALMajorObject(); 00159 virtual ~GDALMajorObject(); 00160 00161 const char * GetDescription() const; 00162 void SetDescription( const char * ); 00163 00164 virtual char **GetMetadata( const char * pszDomain = "" ); 00165 virtual CPLErr SetMetadata( char ** papszMetadata, 00166 const char * pszDomain = "" ); 00167 virtual const char *GetMetadataItem( const char * pszName, 00168 const char * pszDomain = "" ); 00169 virtual CPLErr SetMetadataItem( const char * pszName, 00170 const char * pszValue, 00171 const char * pszDomain = "" ); 00172 }; 00173 00174 /* ******************************************************************** */ 00175 /* GDALDefaultOverviews */ 00176 /* ******************************************************************** */ 00177 class CPL_DLL GDALDefaultOverviews 00178 { 00179 GDALDataset *poDS; 00180 GDALDataset *poODS; 00181 00182 char *pszOvrFilename; 00183 00184 public: 00185 GDALDefaultOverviews(); 00186 ~GDALDefaultOverviews(); 00187 00188 void Initialize( GDALDataset *poDS, const char *pszName = NULL, 00189 int bNameIsOVR = FALSE ); 00190 int IsInitialized() { return poDS != NULL; } 00191 00192 int GetOverviewCount(int); 00193 GDALRasterBand *GetOverview(int,int); 00194 00195 CPLErr BuildOverviews( const char * pszBasename, 00196 const char * pszResampling, 00197 int nOverviews, int * panOverviewList, 00198 int nBands, int * panBandList, 00199 GDALProgressFunc pfnProgress, 00200 void *pProgressData ); 00201 }; 00202 00203 /* ******************************************************************** */ 00204 /* GDALDataset */ 00205 /* ******************************************************************** */ 00206 00213 class CPL_DLL GDALDataset : public GDALMajorObject 00214 { 00215 friend GDALDatasetH GDALOpen( const char *, GDALAccess); 00216 friend class GDALDriver; 00217 00218 protected: 00219 GDALDriver *poDriver; 00220 GDALAccess eAccess; 00221 00222 // Stored raster information. 00223 int nRasterXSize; 00224 int nRasterYSize; 00225 int nBands; 00226 GDALRasterBand **papoBands; 00227 00228 int nRefCount; 00229 00230 GDALDataset(void); 00231 void RasterInitialize( int, int ); 00232 void SetBand( int, GDALRasterBand * ); 00233 00234 GDALDefaultOverviews oOvManager; 00235 00236 virtual CPLErr IBuildOverviews( const char *, int, int *, 00237 int, int *, GDALProgressFunc, void * ); 00238 00239 friend class GDALRasterBand; 00240 00241 public: 00242 virtual ~GDALDataset(); 00243 00244 int GetRasterXSize( void ); 00245 int GetRasterYSize( void ); 00246 int GetRasterCount( void ); 00247 GDALRasterBand *GetRasterBand( int ); 00248 00249 virtual void FlushCache(void); 00250 00251 virtual const char *GetProjectionRef(void); 00252 virtual CPLErr SetProjection( const char * ); 00253 00254 virtual CPLErr GetGeoTransform( double * ); 00255 virtual CPLErr SetGeoTransform( double * ); 00256 00257 virtual CPLErr AddBand( GDALDataType eType, 00258 char **papszOptions=NULL ); 00259 00260 virtual void *GetInternalHandle( const char * ); 00261 virtual GDALDriver *GetDriver(void); 00262 00263 virtual int GetGCPCount(); 00264 virtual const char *GetGCPProjection(); 00265 virtual const GDAL_GCP *GetGCPs(); 00266 virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList, 00267 const char *pszGCPProjection ); 00268 00269 int Reference(); 00270 int Dereference(); 00271 GDALAccess GetAccess() { return eAccess; } 00272 00273 CPLErr BuildOverviews( const char *, int, int *, 00274 int, int *, GDALProgressFunc, void * ); 00275 00276 }; 00277 00278 /* ******************************************************************** */ 00279 /* GDALRasterBlock */ 00280 /* ******************************************************************** */ 00281 00284 class CPL_DLL GDALRasterBlock 00285 { 00286 GDALDataType eType; 00287 00288 int nAge; 00289 int bDirty; 00290 00291 int nXOff; 00292 int nYOff; 00293 00294 int nXSize; 00295 int nYSize; 00296 00297 void *pData; 00298 00299 GDALRasterBand *poBand; 00300 00301 GDALRasterBlock *poNext; 00302 GDALRasterBlock *poPrevious; 00303 00304 public: 00305 GDALRasterBlock( GDALRasterBand *, int, int ); 00306 virtual ~GDALRasterBlock(); 00307 00308 CPLErr Internalize( void ); /* make copy of data */ 00309 void Touch( void ); /* update age */ 00310 void MarkDirty( void ); /* data has been modified since read */ 00311 void MarkClean( void ); 00312 00313 CPLErr Write(); 00314 00315 GDALDataType GetDataType() { return eType; } 00316 int GetXOff() { return nXOff; } 00317 int GetYOff() { return nYOff; } 00318 int GetXSize() { return nXSize; } 00319 int GetYSize() { return nYSize; } 00320 int GetAge() { return nAge; } 00321 int GetDirty() { return bDirty; } 00322 00323 void *GetDataRef( void ) { return pData; } 00324 00325 GDALRasterBand *GetBand() { return poBand; } 00326 00327 static void FlushOldestBlock(); 00328 static void Verify(); 00329 00330 }; 00331 00332 00333 /* ******************************************************************** */ 00334 /* GDALColorTable */ 00335 /* ******************************************************************** */ 00336 00337 class CPL_DLL GDALColorTable 00338 { 00339 GDALPaletteInterp eInterp; 00340 00341 int nEntryCount; 00342 GDALColorEntry *paoEntries; 00343 00344 public: 00345 GDALColorTable( GDALPaletteInterp = GPI_RGB ); 00346 ~GDALColorTable(); 00347 00348 GDALColorTable *Clone() const; 00349 00350 GDALPaletteInterp GetPaletteInterpretation() const; 00351 00352 int GetColorEntryCount() const; 00353 const GDALColorEntry *GetColorEntry( int ) const; 00354 int GetColorEntryAsRGB( int, GDALColorEntry * ) const; 00355 void SetColorEntry( int, const GDALColorEntry * ); 00356 }; 00357 00358 /* ******************************************************************** */ 00359 /* GDALRasterBand */ 00360 /* ******************************************************************** */ 00361 00363 00364 class CPL_DLL GDALRasterBand : public GDALMajorObject 00365 { 00366 protected: 00367 GDALDataset *poDS; 00368 int nBand; /* 1 based */ 00369 00370 int nRasterXSize; 00371 int nRasterYSize; 00372 00373 GDALDataType eDataType; 00374 GDALAccess eAccess; 00375 00376 /* stuff related to blocking, and raster cache */ 00377 int nBlockXSize; 00378 int nBlockYSize; 00379 int nBlocksPerRow; 00380 int nBlocksPerColumn; 00381 00382 GDALRasterBlock **papoBlocks; 00383 00384 friend class GDALDataset; 00385 friend class GDALRasterBlock; 00386 00387 protected: 00388 virtual CPLErr IReadBlock( int, int, void * ) = 0; 00389 virtual CPLErr IWriteBlock( int, int, void * ); 00390 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, 00391 void *, int, int, GDALDataType, 00392 int, int ); 00393 CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int, 00394 void *, int, int, GDALDataType, 00395 int, int ); 00396 00397 CPLErr AdoptBlock( int, int, GDALRasterBlock * ); 00398 void InitBlockInfo(); 00399 00400 public: 00401 GDALRasterBand(); 00402 00403 virtual ~GDALRasterBand(); 00404 00405 int GetXSize(); 00406 int GetYSize(); 00407 int GetBand(); 00408 00409 GDALDataType GetRasterDataType( void ); 00410 void GetBlockSize( int *, int * ); 00411 GDALAccess GetAccess(); 00412 00413 CPLErr RasterIO( GDALRWFlag, int, int, int, int, 00414 void *, int, int, GDALDataType, 00415 int, int ); 00416 CPLErr ReadBlock( int, int, void * ); 00417 00418 CPLErr WriteBlock( int, int, void * ); 00419 00420 GDALRasterBlock *GetBlockRef( int, int ); 00421 CPLErr FlushCache(); 00422 CPLErr FlushBlock( int = -1, int = -1 ); 00423 00424 // New OpengIS CV_SampleDimension stuff. 00425 00426 virtual const char *GetDescription(); 00427 virtual char **GetCategoryNames(); 00428 virtual double GetNoDataValue( int *pbSuccess = NULL ); 00429 virtual double GetMinimum( int *pbSuccess = NULL ); 00430 virtual double GetMaximum(int *pbSuccess = NULL ); 00431 virtual double GetOffset( int *pbSuccess = NULL ); 00432 virtual double GetScale( int *pbSuccess = NULL ); 00433 virtual const char *GetUnitType(); 00434 virtual GDALColorInterp GetColorInterpretation(); 00435 virtual GDALColorTable *GetColorTable(); 00436 00437 virtual CPLErr SetCategoryNames( char ** ); 00438 virtual CPLErr SetNoDataValue( double ); 00439 virtual CPLErr SetColorTable( GDALColorTable * ); 00440 00441 virtual int HasArbitraryOverviews(); 00442 virtual int GetOverviewCount(); 00443 virtual GDALRasterBand *GetOverview(int); 00444 virtual CPLErr BuildOverviews( const char *, int, int *, 00445 GDALProgressFunc, void * ); 00446 00447 CPLErr GetHistogram( double dfMin, double dfMax, 00448 int nBuckets, int * panHistogram, 00449 int bIncludeOutOfRange, int bApproxOK, 00450 GDALProgressFunc, void *pProgressData ); 00451 }; 00452 00453 /* ******************************************************************** */ 00454 /* GDALOpenInfo */ 00455 /* */ 00456 /* Structure of data about dataset for open functions. */ 00457 /* ******************************************************************** */ 00458 00459 class CPL_DLL GDALOpenInfo 00460 { 00461 public: 00462 00463 GDALOpenInfo( const char * pszFile, GDALAccess eAccessIn ); 00464 ~GDALOpenInfo( void ); 00465 00466 char *pszFilename; 00467 00468 GDALAccess eAccess; 00469 00470 GBool bStatOK; 00471 VSIStatBuf sStat; 00472 00473 FILE *fp; 00474 00475 int nHeaderBytes; 00476 GByte *pabyHeader; 00477 00478 }; 00479 00480 /* ******************************************************************** */ 00481 /* GDALDriver */ 00482 /* ******************************************************************** */ 00483 00493 class CPL_DLL GDALDriver : public GDALMajorObject 00494 { 00495 public: 00496 GDALDriver(); 00497 ~GDALDriver(); 00498 00500 char *pszShortName; 00501 00503 char *pszLongName; 00504 00506 char *pszHelpTopic; 00507 00508 GDALDataset *(*pfnOpen)( GDALOpenInfo * ); 00509 00510 GDALDataset *(*pfnCreate)( const char * pszName, 00511 int nXSize, int nYSize, int nBands, 00512 GDALDataType eType, 00513 char ** papszOptions ); 00514 00515 GDALDataset *Create( const char * pszName, 00516 int nXSize, int nYSize, int nBands, 00517 GDALDataType eType, char ** papszOptions ); 00518 00519 CPLErr (*pfnDelete)( const char * pszName ); 00520 00521 CPLErr Delete( const char * pszName ); 00522 00523 GDALDataset *CreateCopy( const char *, GDALDataset *, 00524 int, char **, 00525 GDALProgressFunc pfnProgress, 00526 void * pProgressData ); 00527 00528 GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *, 00529 int, char **, 00530 GDALProgressFunc pfnProgress, 00531 void * pProgressData ); 00532 }; 00533 00534 /* ******************************************************************** */ 00535 /* GDALDriverManager */ 00536 /* ******************************************************************** */ 00537 00545 class CPL_DLL GDALDriverManager : public GDALMajorObject 00546 { 00547 int nDrivers; 00548 GDALDriver **papoDrivers; 00549 00550 char *pszHome; 00551 00552 public: 00553 GDALDriverManager(); 00554 ~GDALDriverManager(); 00555 00556 int GetDriverCount( void ); 00557 GDALDriver *GetDriver( int ); 00558 GDALDriver *GetDriverByName( const char * ); 00559 00560 int RegisterDriver( GDALDriver * ); 00561 void MoveDriver( GDALDriver *, int ); 00562 void DeregisterDriver( GDALDriver * ); 00563 00564 void AutoLoadDrivers(); 00565 00566 const char *GetHome(); 00567 void SetHome( const char * ); 00568 }; 00569 00570 CPL_C_START 00571 GDALDriverManager CPL_DLL * GetGDALDriverManager( void ); 00572 CPL_C_END 00573 00574 /* ==================================================================== */ 00575 /* An assortment of overview related stuff. */ 00576 /* ==================================================================== */ 00577 00578 CPL_C_START 00579 00580 CPLErr 00581 GTIFFBuildOverviews( const char * pszFilename, 00582 int nBands, GDALRasterBand **papoBandList, 00583 int nOverviews, int * panOverviewList, 00584 const char * pszResampling, 00585 GDALProgressFunc pfnProgress, void * pProgressData ); 00586 00587 CPLErr 00588 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename, 00589 const char * pszResampling, 00590 int nOverviews, int * panOverviewList, 00591 int nBands, int * panBandList, 00592 GDALProgressFunc pfnProgress, void * pProgressData); 00593 00594 00595 CPLErr 00596 GDALRegenerateOverviews( GDALRasterBand *, int, GDALRasterBand **, 00597 const char *, GDALProgressFunc, void * ); 00598 00599 CPL_C_END 00600 00601 #endif /* ndef GDAL_PRIV_H_INCLUDED */