GDAL
|
00001 /****************************************************************************** 00002 * $Id: gdal_priv.h 21431 2011-01-07 22:24:09Z warmerdam $ 00003 * 00004 * Name: gdal_priv.h 00005 * Project: GDAL Core 00006 * Purpose: GDAL Core C++/Private declarations. 00007 * Author: Frank Warmerdam, warmerdam@pobox.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 #ifndef GDAL_PRIV_H_INCLUDED 00032 #define GDAL_PRIV_H_INCLUDED 00033 00034 /* -------------------------------------------------------------------- */ 00035 /* Predeclare various classes before pulling in gdal.h, the */ 00036 /* public declarations. */ 00037 /* -------------------------------------------------------------------- */ 00038 class GDALMajorObject; 00039 class GDALDataset; 00040 class GDALRasterBand; 00041 class GDALDriver; 00042 class GDALRasterAttributeTable; 00043 class GDALProxyDataset; 00044 class GDALProxyRasterBand; 00045 class GDALAsyncReader; 00046 00047 /* -------------------------------------------------------------------- */ 00048 /* Pull in the public declarations. This gets the C apis, and */ 00049 /* also various constants. However, we will still get to */ 00050 /* provide the real class definitions for the GDAL classes. */ 00051 /* -------------------------------------------------------------------- */ 00052 00053 #include "gdal.h" 00054 #include "gdal_frmts.h" 00055 #include "cpl_vsi.h" 00056 #include "cpl_conv.h" 00057 #include "cpl_string.h" 00058 #include "cpl_minixml.h" 00059 #include <vector> 00060 00061 #define GMO_VALID 0x0001 00062 #define GMO_IGNORE_UNIMPLEMENTED 0x0002 00063 #define GMO_SUPPORT_MD 0x0004 00064 #define GMO_SUPPORT_MDMD 0x0008 00065 #define GMO_MD_DIRTY 0x0010 00066 #define GMO_PAM_CLASS 0x0020 00067 00068 /************************************************************************/ 00069 /* GDALMultiDomainMetadata */ 00070 /************************************************************************/ 00071 00072 class CPL_DLL GDALMultiDomainMetadata 00073 { 00074 private: 00075 char **papszDomainList; 00076 char ***papapszMetadataLists; 00077 00078 public: 00079 GDALMultiDomainMetadata(); 00080 ~GDALMultiDomainMetadata(); 00081 00082 int XMLInit( CPLXMLNode *psMetadata, int bMerge ); 00083 CPLXMLNode *Serialize(); 00084 00085 char **GetDomainList() { return papszDomainList; } 00086 00087 char **GetMetadata( const char * pszDomain = "" ); 00088 CPLErr SetMetadata( char ** papszMetadata, 00089 const char * pszDomain = "" ); 00090 const char *GetMetadataItem( const char * pszName, 00091 const char * pszDomain = "" ); 00092 CPLErr SetMetadataItem( const char * pszName, 00093 const char * pszValue, 00094 const char * pszDomain = "" ); 00095 00096 void Clear(); 00097 }; 00098 00099 /* ******************************************************************** */ 00100 /* GDALMajorObject */ 00101 /* */ 00102 /* Base class providing metadata, description and other */ 00103 /* services shared by major objects. */ 00104 /* ******************************************************************** */ 00105 00107 00108 class CPL_DLL GDALMajorObject 00109 { 00110 protected: 00111 int nFlags; // GMO_* flags. 00112 CPLString sDescription; 00113 GDALMultiDomainMetadata oMDMD; 00114 00115 public: 00116 GDALMajorObject(); 00117 virtual ~GDALMajorObject(); 00118 00119 int GetMOFlags(); 00120 void SetMOFlags(int nFlags); 00121 00122 virtual const char *GetDescription() const; 00123 virtual void SetDescription( const char * ); 00124 00125 virtual char **GetMetadata( const char * pszDomain = "" ); 00126 virtual CPLErr SetMetadata( char ** papszMetadata, 00127 const char * pszDomain = "" ); 00128 virtual const char *GetMetadataItem( const char * pszName, 00129 const char * pszDomain = "" ); 00130 virtual CPLErr SetMetadataItem( const char * pszName, 00131 const char * pszValue, 00132 const char * pszDomain = "" ); 00133 }; 00134 00135 /* ******************************************************************** */ 00136 /* GDALDefaultOverviews */ 00137 /* ******************************************************************** */ 00138 class CPL_DLL GDALDefaultOverviews 00139 { 00140 friend class GDALDataset; 00141 00142 GDALDataset *poDS; 00143 GDALDataset *poODS; 00144 00145 CPLString osOvrFilename; 00146 00147 int bOvrIsAux; 00148 00149 int bCheckedForMask; 00150 int bOwnMaskDS; 00151 GDALDataset *poMaskDS; 00152 00153 // for "overview datasets" we record base level info so we can 00154 // find our way back to get overview masks. 00155 GDALDataset *poBaseDS; 00156 00157 // Stuff for deferred initialize/overviewscans... 00158 bool bCheckedForOverviews; 00159 void OverviewScan(); 00160 char *pszInitName; 00161 int bInitNameIsOVR; 00162 char **papszInitSiblingFiles; 00163 00164 public: 00165 GDALDefaultOverviews(); 00166 ~GDALDefaultOverviews(); 00167 00168 void Initialize( GDALDataset *poDS, const char *pszName = NULL, 00169 char **papszSiblingFiles = NULL, 00170 int bNameIsOVR = FALSE ); 00171 00172 int IsInitialized(); 00173 00174 // Overview Related 00175 00176 int GetOverviewCount(int); 00177 GDALRasterBand *GetOverview(int,int); 00178 00179 CPLErr BuildOverviews( const char * pszBasename, 00180 const char * pszResampling, 00181 int nOverviews, int * panOverviewList, 00182 int nBands, int * panBandList, 00183 GDALProgressFunc pfnProgress, 00184 void *pProgressData ); 00185 00186 CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile, 00187 const char * pszResampling, 00188 int nOverviews, int * panOverviewList, 00189 int nBands, int * panBandList, 00190 GDALProgressFunc pfnProgress, 00191 void *pProgressData ); 00192 00193 CPLErr CleanOverviews(); 00194 00195 // Mask Related 00196 00197 CPLErr CreateMaskBand( int nFlags, int nBand = -1 ); 00198 GDALRasterBand *GetMaskBand( int nBand ); 00199 int GetMaskFlags( int nBand ); 00200 00201 int HaveMaskFile( char **papszSiblings = NULL, 00202 const char *pszBasename = NULL ); 00203 00204 }; 00205 00206 /* ******************************************************************** */ 00207 /* GDALDataset */ 00208 /* ******************************************************************** */ 00209 00210 /* Internal method for now. Might be subject to later revisions */ 00211 GDALDatasetH GDALOpenInternal( const char * pszFilename, GDALAccess eAccess, 00212 const char* const * papszAllowedDrivers); 00213 00215 00216 class CPL_DLL GDALDataset : public GDALMajorObject 00217 { 00218 friend GDALDatasetH CPL_STDCALL GDALOpen( const char *, GDALAccess); 00219 friend GDALDatasetH CPL_STDCALL GDALOpenShared( const char *, GDALAccess); 00220 00221 /* Internal method for now. Might be subject to later revisions */ 00222 friend GDALDatasetH GDALOpenInternal( const char *, GDALAccess, const char* const * papszAllowedDrivers); 00223 00224 friend class GDALDriver; 00225 friend class GDALDefaultOverviews; 00226 friend class GDALProxyDataset; 00227 00228 protected: 00229 GDALDriver *poDriver; 00230 GDALAccess eAccess; 00231 00232 // Stored raster information. 00233 int nRasterXSize; 00234 int nRasterYSize; 00235 int nBands; 00236 GDALRasterBand **papoBands; 00237 00238 int bForceCachedIO; 00239 00240 int nRefCount; 00241 int bShared; 00242 00243 GDALDataset(void); 00244 void RasterInitialize( int, int ); 00245 void SetBand( int, GDALRasterBand * ); 00246 00247 GDALDefaultOverviews oOvManager; 00248 00249 virtual CPLErr IBuildOverviews( const char *, int, int *, 00250 int, int *, GDALProgressFunc, void * ); 00251 00252 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, 00253 void *, int, int, GDALDataType, 00254 int, int *, int, int, int ); 00255 00256 CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int, 00257 void *, int, int, GDALDataType, 00258 int, int *, int, int, int ); 00259 void BlockBasedFlushCache(); 00260 00261 friend class GDALRasterBand; 00262 00263 public: 00264 virtual ~GDALDataset(); 00265 00266 int GetRasterXSize( void ); 00267 int GetRasterYSize( void ); 00268 int GetRasterCount( void ); 00269 GDALRasterBand *GetRasterBand( int ); 00270 00271 virtual void FlushCache(void); 00272 00273 virtual const char *GetProjectionRef(void); 00274 virtual CPLErr SetProjection( const char * ); 00275 00276 virtual CPLErr GetGeoTransform( double * ); 00277 virtual CPLErr SetGeoTransform( double * ); 00278 00279 virtual CPLErr AddBand( GDALDataType eType, 00280 char **papszOptions=NULL ); 00281 00282 virtual void *GetInternalHandle( const char * ); 00283 virtual GDALDriver *GetDriver(void); 00284 virtual char **GetFileList(void); 00285 00286 virtual int GetGCPCount(); 00287 virtual const char *GetGCPProjection(); 00288 virtual const GDAL_GCP *GetGCPs(); 00289 virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList, 00290 const char *pszGCPProjection ); 00291 00292 virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize, 00293 int nBufXSize, int nBufYSize, 00294 GDALDataType eDT, 00295 int nBandCount, int *panBandList, 00296 char **papszOptions ); 00297 00298 virtual CPLErr CreateMaskBand( int nFlags ); 00299 00300 virtual GDALAsyncReader* 00301 BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize, 00302 void *pBuf, int nBufXSize, int nBufYSize, 00303 GDALDataType eBufType, 00304 int nBandCount, int* panBandMap, 00305 int nPixelSpace, int nLineSpace, int nBandSpace, 00306 char **papszOptions); 00307 virtual void EndAsyncReader(GDALAsyncReader *); 00308 00309 CPLErr RasterIO( GDALRWFlag, int, int, int, int, 00310 void *, int, int, GDALDataType, 00311 int, int *, int, int, int ); 00312 00313 int Reference(); 00314 int Dereference(); 00315 GDALAccess GetAccess() { return eAccess; } 00316 00317 int GetShared(); 00318 void MarkAsShared(); 00319 00320 static GDALDataset **GetOpenDatasets( int *pnDatasetCount ); 00321 00322 CPLErr BuildOverviews( const char *, int, int *, 00323 int, int *, GDALProgressFunc, void * ); 00324 }; 00325 00326 /* ******************************************************************** */ 00327 /* GDALRasterBlock */ 00328 /* ******************************************************************** */ 00329 00331 00332 class CPL_DLL GDALRasterBlock 00333 { 00334 GDALDataType eType; 00335 00336 int bDirty; 00337 int nLockCount; 00338 00339 int nXOff; 00340 int nYOff; 00341 00342 int nXSize; 00343 int nYSize; 00344 00345 void *pData; 00346 00347 GDALRasterBand *poBand; 00348 00349 GDALRasterBlock *poNext; 00350 GDALRasterBlock *poPrevious; 00351 00352 public: 00353 GDALRasterBlock( GDALRasterBand *, int, int ); 00354 virtual ~GDALRasterBlock(); 00355 00356 CPLErr Internalize( void ); 00357 void Touch( void ); 00358 void MarkDirty( void ); 00359 void MarkClean( void ); 00360 void AddLock( void ) { nLockCount++; } 00361 void DropLock( void ) { nLockCount--; } 00362 void Detach(); 00363 00364 CPLErr Write(); 00365 00366 GDALDataType GetDataType() { return eType; } 00367 int GetXOff() { return nXOff; } 00368 int GetYOff() { return nYOff; } 00369 int GetXSize() { return nXSize; } 00370 int GetYSize() { return nYSize; } 00371 int GetDirty() { return bDirty; } 00372 int GetLockCount() { return nLockCount; } 00373 00374 void *GetDataRef( void ) { return pData; } 00375 00378 GDALRasterBand *GetBand() { return poBand; } 00379 00380 static int FlushCacheBlock(); 00381 static void Verify(); 00382 00383 static int SafeLockBlock( GDALRasterBlock ** ); 00384 }; 00385 00386 /* ******************************************************************** */ 00387 /* GDALColorTable */ 00388 /* ******************************************************************** */ 00389 00392 class CPL_DLL GDALColorTable 00393 { 00394 GDALPaletteInterp eInterp; 00395 00396 std::vector<GDALColorEntry> aoEntries; 00397 00398 public: 00399 GDALColorTable( GDALPaletteInterp = GPI_RGB ); 00400 ~GDALColorTable(); 00401 00402 GDALColorTable *Clone() const; 00403 00404 GDALPaletteInterp GetPaletteInterpretation() const; 00405 00406 int GetColorEntryCount() const; 00407 const GDALColorEntry *GetColorEntry( int ) const; 00408 int GetColorEntryAsRGB( int, GDALColorEntry * ) const; 00409 void SetColorEntry( int, const GDALColorEntry * ); 00410 int CreateColorRamp( int, const GDALColorEntry * , 00411 int, const GDALColorEntry * ); 00412 }; 00413 00414 /* ******************************************************************** */ 00415 /* GDALRasterBand */ 00416 /* ******************************************************************** */ 00417 00419 00420 class CPL_DLL GDALRasterBand : public GDALMajorObject 00421 { 00422 private: 00423 CPLErr eFlushBlockErr; 00424 00425 void SetFlushBlockErr( CPLErr eErr ); 00426 00427 friend class GDALRasterBlock; 00428 00429 protected: 00430 GDALDataset *poDS; 00431 int nBand; /* 1 based */ 00432 00433 int nRasterXSize; 00434 int nRasterYSize; 00435 00436 GDALDataType eDataType; 00437 GDALAccess eAccess; 00438 00439 /* stuff related to blocking, and raster cache */ 00440 int nBlockXSize; 00441 int nBlockYSize; 00442 int nBlocksPerRow; 00443 int nBlocksPerColumn; 00444 00445 int bSubBlockingActive; 00446 int nSubBlocksPerRow; 00447 int nSubBlocksPerColumn; 00448 GDALRasterBlock **papoBlocks; 00449 00450 int nBlockReads; 00451 int bForceCachedIO; 00452 00453 GDALRasterBand *poMask; 00454 bool bOwnMask; 00455 int nMaskFlags; 00456 00457 friend class GDALDataset; 00458 friend class GDALProxyRasterBand; 00459 00460 protected: 00461 virtual CPLErr IReadBlock( int, int, void * ) = 0; 00462 virtual CPLErr IWriteBlock( int, int, void * ); 00463 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, 00464 void *, int, int, GDALDataType, 00465 int, int ); 00466 CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int, 00467 void *, int, int, GDALDataType, 00468 int, int ); 00469 00470 int InitBlockInfo(); 00471 00472 CPLErr AdoptBlock( int, int, GDALRasterBlock * ); 00473 GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff ); 00474 00475 public: 00476 GDALRasterBand(); 00477 00478 virtual ~GDALRasterBand(); 00479 00480 int GetXSize(); 00481 int GetYSize(); 00482 int GetBand(); 00483 GDALDataset*GetDataset(); 00484 00485 GDALDataType GetRasterDataType( void ); 00486 void GetBlockSize( int *, int * ); 00487 GDALAccess GetAccess(); 00488 00489 CPLErr RasterIO( GDALRWFlag, int, int, int, int, 00490 void *, int, int, GDALDataType, 00491 int, int ); 00492 CPLErr ReadBlock( int, int, void * ); 00493 00494 CPLErr WriteBlock( int, int, void * ); 00495 00496 GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff, 00497 int bJustInitialize = FALSE ); 00498 CPLErr FlushBlock( int = -1, int = -1, int bWriteDirtyBlock = TRUE ); 00499 00500 unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand, 00501 unsigned char* pTranslationTable = NULL, 00502 int* pApproximateMatching = NULL); 00503 00504 // New OpengIS CV_SampleDimension stuff. 00505 00506 virtual CPLErr FlushCache(); 00507 virtual char **GetCategoryNames(); 00508 virtual double GetNoDataValue( int *pbSuccess = NULL ); 00509 virtual double GetMinimum( int *pbSuccess = NULL ); 00510 virtual double GetMaximum(int *pbSuccess = NULL ); 00511 virtual double GetOffset( int *pbSuccess = NULL ); 00512 virtual double GetScale( int *pbSuccess = NULL ); 00513 virtual const char *GetUnitType(); 00514 virtual GDALColorInterp GetColorInterpretation(); 00515 virtual GDALColorTable *GetColorTable(); 00516 virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0); 00517 00518 virtual CPLErr SetCategoryNames( char ** ); 00519 virtual CPLErr SetNoDataValue( double ); 00520 virtual CPLErr SetColorTable( GDALColorTable * ); 00521 virtual CPLErr SetColorInterpretation( GDALColorInterp ); 00522 virtual CPLErr SetOffset( double ); 00523 virtual CPLErr SetScale( double ); 00524 virtual CPLErr SetUnitType( const char * ); 00525 00526 virtual CPLErr GetStatistics( int bApproxOK, int bForce, 00527 double *pdfMin, double *pdfMax, 00528 double *pdfMean, double *padfStdDev ); 00529 virtual CPLErr ComputeStatistics( int bApproxOK, 00530 double *pdfMin, double *pdfMax, 00531 double *pdfMean, double *pdfStdDev, 00532 GDALProgressFunc, void *pProgressData ); 00533 virtual CPLErr SetStatistics( double dfMin, double dfMax, 00534 double dfMean, double dfStdDev ); 00535 virtual CPLErr ComputeRasterMinMax( int, double* ); 00536 00537 virtual int HasArbitraryOverviews(); 00538 virtual int GetOverviewCount(); 00539 virtual GDALRasterBand *GetOverview(int); 00540 virtual GDALRasterBand *GetRasterSampleOverview( 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 virtual GDALRasterBand *GetMaskBand(); 00564 virtual int GetMaskFlags(); 00565 virtual CPLErr CreateMaskBand( int nFlags ); 00566 }; 00567 00568 /* ******************************************************************** */ 00569 /* GDALAllValidMaskBand */ 00570 /* ******************************************************************** */ 00571 00572 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand 00573 { 00574 protected: 00575 virtual CPLErr IReadBlock( int, int, void * ); 00576 00577 public: 00578 GDALAllValidMaskBand( GDALRasterBand * ); 00579 virtual ~GDALAllValidMaskBand(); 00580 00581 virtual GDALRasterBand *GetMaskBand(); 00582 virtual int GetMaskFlags(); 00583 }; 00584 00585 /* ******************************************************************** */ 00586 /* GDALNoDataMaskBand */ 00587 /* ******************************************************************** */ 00588 00589 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand 00590 { 00591 double dfNoDataValue; 00592 GDALRasterBand *poParent; 00593 00594 protected: 00595 virtual CPLErr IReadBlock( int, int, void * ); 00596 00597 public: 00598 GDALNoDataMaskBand( GDALRasterBand * ); 00599 virtual ~GDALNoDataMaskBand(); 00600 }; 00601 00602 /* ******************************************************************** */ 00603 /* GDALNoDataValuesMaskBand */ 00604 /* ******************************************************************** */ 00605 00606 class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand 00607 { 00608 double *padfNodataValues; 00609 00610 protected: 00611 virtual CPLErr IReadBlock( int, int, void * ); 00612 00613 public: 00614 GDALNoDataValuesMaskBand( GDALDataset * ); 00615 virtual ~GDALNoDataValuesMaskBand(); 00616 }; 00617 00618 /* ******************************************************************** */ 00619 /* GDALOpenInfo */ 00620 /* */ 00621 /* Structure of data about dataset for open functions. */ 00622 /* ******************************************************************** */ 00623 00624 class CPL_DLL GDALOpenInfo 00625 { 00626 public: 00627 GDALOpenInfo( const char * pszFile, GDALAccess eAccessIn, 00628 char **papszSiblingFiles = NULL ); 00629 ~GDALOpenInfo( void ); 00630 00631 char *pszFilename; 00632 char **papszSiblingFiles; 00633 00634 GDALAccess eAccess; 00635 00636 int bStatOK; 00637 int bIsDirectory; 00638 00639 FILE *fp; 00640 00641 int nHeaderBytes; 00642 GByte *pabyHeader; 00643 00644 }; 00645 00646 /* ******************************************************************** */ 00647 /* GDALDriver */ 00648 /* ******************************************************************** */ 00649 00650 00662 class CPL_DLL GDALDriver : public GDALMajorObject 00663 { 00664 public: 00665 GDALDriver(); 00666 ~GDALDriver(); 00667 00668 /* -------------------------------------------------------------------- */ 00669 /* Public C++ methods. */ 00670 /* -------------------------------------------------------------------- */ 00671 GDALDataset *Create( const char * pszName, 00672 int nXSize, int nYSize, int nBands, 00673 GDALDataType eType, char ** papszOptions ); 00674 00675 CPLErr Delete( const char * pszName ); 00676 CPLErr Rename( const char * pszNewName, 00677 const char * pszOldName ); 00678 CPLErr CopyFiles( const char * pszNewName, 00679 const char * pszOldName ); 00680 00681 GDALDataset *CreateCopy( const char *, GDALDataset *, 00682 int, char **, 00683 GDALProgressFunc pfnProgress, 00684 void * pProgressData ); 00685 00686 /* -------------------------------------------------------------------- */ 00687 /* The following are semiprivate, not intended to be accessed */ 00688 /* by anyone but the formats instantiating and populating the */ 00689 /* drivers. */ 00690 /* -------------------------------------------------------------------- */ 00691 GDALDataset *(*pfnOpen)( GDALOpenInfo * ); 00692 00693 GDALDataset *(*pfnCreate)( const char * pszName, 00694 int nXSize, int nYSize, int nBands, 00695 GDALDataType eType, 00696 char ** papszOptions ); 00697 00698 CPLErr (*pfnDelete)( const char * pszName ); 00699 00700 GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *, 00701 int, char **, 00702 GDALProgressFunc pfnProgress, 00703 void * pProgressData ); 00704 00705 void *pDriverData; 00706 00707 void (*pfnUnloadDriver)(GDALDriver *); 00708 00709 int (*pfnIdentify)( GDALOpenInfo * ); 00710 00711 CPLErr (*pfnRename)( const char * pszNewName, 00712 const char * pszOldName ); 00713 CPLErr (*pfnCopyFiles)( const char * pszNewName, 00714 const char * pszOldName ); 00715 00716 /* -------------------------------------------------------------------- */ 00717 /* Helper methods. */ 00718 /* -------------------------------------------------------------------- */ 00719 GDALDataset *DefaultCreateCopy( const char *, GDALDataset *, 00720 int, char **, 00721 GDALProgressFunc pfnProgress, 00722 void * pProgressData ); 00723 static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS, 00724 GDALDataset *poDstDS, 00725 int bStrict ); 00726 static CPLErr QuietDelete( const char * pszName ); 00727 00728 CPLErr DefaultRename( const char * pszNewName, 00729 const char * pszOldName ); 00730 CPLErr DefaultCopyFiles( const char * pszNewName, 00731 const char * pszOldName ); 00732 }; 00733 00734 /* ******************************************************************** */ 00735 /* GDALDriverManager */ 00736 /* ******************************************************************** */ 00737 00745 class CPL_DLL GDALDriverManager : public GDALMajorObject 00746 { 00747 int nDrivers; 00748 GDALDriver **papoDrivers; 00749 00750 char *pszHome; 00751 00752 public: 00753 GDALDriverManager(); 00754 ~GDALDriverManager(); 00755 00756 int GetDriverCount( void ); 00757 GDALDriver *GetDriver( int ); 00758 GDALDriver *GetDriverByName( const char * ); 00759 00760 int RegisterDriver( GDALDriver * ); 00761 void MoveDriver( GDALDriver *, int ); 00762 void DeregisterDriver( GDALDriver * ); 00763 00764 void AutoLoadDrivers(); 00765 void AutoSkipDrivers(); 00766 00767 const char *GetHome(); 00768 void SetHome( const char * ); 00769 }; 00770 00771 CPL_C_START 00772 GDALDriverManager CPL_DLL * GetGDALDriverManager( void ); 00773 CPL_C_END 00774 00775 /* ******************************************************************** */ 00776 /* GDALAsyncReader */ 00777 /* ******************************************************************** */ 00778 00784 class CPL_DLL GDALAsyncReader 00785 { 00786 protected: 00787 GDALDataset* poDS; 00788 int nXOff; 00789 int nYOff; 00790 int nXSize; 00791 int nYSize; 00792 void * pBuf; 00793 int nBufXSize; 00794 int nBufYSize; 00795 GDALDataType eBufType; 00796 int nBandCount; 00797 int* panBandMap; 00798 int nPixelSpace; 00799 int nLineSpace; 00800 int nBandSpace; 00801 00802 public: 00803 GDALAsyncReader(); 00804 virtual ~GDALAsyncReader(); 00805 00806 GDALDataset* GetGDALDataset() {return poDS;} 00807 int GetXOffset() {return nXOff;} 00808 int GetYOffset() {return nYOff;} 00809 int GetXSize() {return nXSize;} 00810 int GetYSize() {return nYSize;} 00811 void * GetBuffer() {return pBuf;} 00812 int GetBufferXSize() {return nBufXSize;} 00813 int GetBufferYSize() {return nBufYSize;} 00814 GDALDataType GetBufferType() {return eBufType;} 00815 int GetBandCount() {return nBandCount;} 00816 int* GetBandMap() {return panBandMap;} 00817 int GetPixelSpace() {return nPixelSpace;} 00818 int GetLineSpace() {return nLineSpace;} 00819 int GetBandSpace() {return nBandSpace;} 00820 00821 virtual GDALAsyncStatusType 00822 GetNextUpdatedRegion(double dfTimeout, 00823 int* pnBufXOff, int* pnBufYOff, 00824 int* pnBufXSize, int* pnBufYSize) = 0; 00825 virtual int LockBuffer( double dfTimeout = -1.0 ); 00826 virtual void UnlockBuffer(); 00827 }; 00828 00829 /* ==================================================================== */ 00830 /* An assortment of overview related stuff. */ 00831 /* ==================================================================== */ 00832 00833 /* Not a public symbol for the moment */ 00834 CPLErr 00835 GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands, 00836 int nOverviews, 00837 GDALRasterBand*** papapoOverviewBands, 00838 const char * pszResampling, 00839 GDALProgressFunc pfnProgress, void * pProgressData ); 00840 00841 CPL_C_START 00842 00843 #ifndef WIN32CE 00844 00845 CPLErr CPL_DLL 00846 HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS, 00847 GDALDataset **ppoDS, 00848 int nBands, int *panBandList, 00849 int nNewOverviews, int *panNewOverviewList, 00850 const char *pszResampling, 00851 GDALProgressFunc pfnProgress, 00852 void *pProgressData ); 00853 00854 #endif /* WIN32CE */ 00855 00856 CPLErr CPL_DLL 00857 GTIFFBuildOverviews( const char * pszFilename, 00858 int nBands, GDALRasterBand **papoBandList, 00859 int nOverviews, int * panOverviewList, 00860 const char * pszResampling, 00861 GDALProgressFunc pfnProgress, void * pProgressData ); 00862 00863 CPLErr CPL_DLL 00864 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename, 00865 const char * pszResampling, 00866 int nOverviews, int * panOverviewList, 00867 int nBands, int * panBandList, 00868 GDALProgressFunc pfnProgress, void * pProgressData); 00869 00870 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand, 00871 int &nXOff, int &nYOff, 00872 int &nXSize, int &nYSize, 00873 int nBufXSize, int nBufYSize); 00874 00875 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize ); 00876 00877 GDALDataset CPL_DLL * 00878 GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess, 00879 GDALDataset *poDependentDS ); 00880 00881 /* ==================================================================== */ 00882 /* Misc functions. */ 00883 /* ==================================================================== */ 00884 00885 CPLErr CPL_DLL GDALParseGMLCoverage( CPLXMLNode *psTree, 00886 int *pnXSize, int *pnYSize, 00887 double *padfGeoTransform, 00888 char **ppszProjection ); 00889 00890 /* ==================================================================== */ 00891 /* Infrastructure to check that dataset characteristics are valid */ 00892 /* ==================================================================== */ 00893 00894 int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize ); 00895 int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed ); 00896 00897 00898 // Test if pixel value matches nodata value. Avoid using strict comparison as 00899 // the stored nodata value in GeoTIFF files is stored as a string, so there might 00900 // be numerical imprecision when reading it back. See #3573 00901 #define EQUAL_TO_NODATA(dfValue, dfNoDataValue) \ 00902 (dfValue == dfNoDataValue || (dfNoDataValue != 0 && fabs(1 - dfValue / dfNoDataValue) < 1e-10 )) 00903 00904 00905 CPL_C_END 00906 00907 #endif /* ndef GDAL_PRIV_H_INCLUDED */