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