|
GDAL
|
00001 /****************************************************************************** 00002 * $Id: gdal_priv.h 39966 2017-08-30 15:28:52Z rouault $ 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 * Copyright (c) 2007-2014, Even Rouault <even dot rouault at mines-paris dot org> 00012 * 00013 * Permission is hereby granted, free of charge, to any person obtaining a 00014 * copy of this software and associated documentation files (the "Software"), 00015 * to deal in the Software without restriction, including without limitation 00016 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00017 * and/or sell copies of the Software, and to permit persons to whom the 00018 * Software is furnished to do so, subject to the following conditions: 00019 * 00020 * The above copyright notice and this permission notice shall be included 00021 * in all copies or substantial portions of the Software. 00022 * 00023 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00024 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00025 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00026 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00027 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00028 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00029 * DEALINGS IN THE SOFTWARE. 00030 ****************************************************************************/ 00031 00032 #ifndef GDAL_PRIV_H_INCLUDED 00033 #define GDAL_PRIV_H_INCLUDED 00034 00041 /* -------------------------------------------------------------------- */ 00042 /* Predeclare various classes before pulling in gdal.h, the */ 00043 /* public declarations. */ 00044 /* -------------------------------------------------------------------- */ 00045 class GDALMajorObject; 00046 class GDALDataset; 00047 class GDALRasterBand; 00048 class GDALDriver; 00049 class GDALRasterAttributeTable; 00050 class GDALProxyDataset; 00051 class GDALProxyRasterBand; 00052 class GDALAsyncReader; 00053 00054 /* -------------------------------------------------------------------- */ 00055 /* Pull in the public declarations. This gets the C apis, and */ 00056 /* also various constants. However, we will still get to */ 00057 /* provide the real class definitions for the GDAL classes. */ 00058 /* -------------------------------------------------------------------- */ 00059 00060 #include "gdal.h" 00061 #include "gdal_frmts.h" 00062 #include "cpl_vsi.h" 00063 #include "cpl_conv.h" 00064 #include "cpl_string.h" 00065 #include "cpl_minixml.h" 00066 #include "cpl_multiproc.h" 00067 #include "cpl_atomic_ops.h" 00068 #include <vector> 00069 #include <map> 00070 #include "ogr_core.h" 00071 00073 #define GMO_VALID 0x0001 00074 #define GMO_IGNORE_UNIMPLEMENTED 0x0002 00075 #define GMO_SUPPORT_MD 0x0004 00076 #define GMO_SUPPORT_MDMD 0x0008 00077 #define GMO_MD_DIRTY 0x0010 00078 #define GMO_PAM_CLASS 0x0020 00079 00080 00081 /************************************************************************/ 00082 /* GDALMultiDomainMetadata */ 00083 /************************************************************************/ 00084 00086 class CPL_DLL GDALMultiDomainMetadata 00087 { 00088 private: 00089 char **papszDomainList; 00090 CPLStringList **papoMetadataLists; 00091 00092 public: 00093 GDALMultiDomainMetadata(); 00094 ~GDALMultiDomainMetadata(); 00095 00096 int XMLInit( CPLXMLNode *psMetadata, int bMerge ); 00097 CPLXMLNode *Serialize(); 00098 00099 char **GetDomainList() { return papszDomainList; } 00100 00101 char **GetMetadata( const char * pszDomain = "" ); 00102 CPLErr SetMetadata( char ** papszMetadata, 00103 const char * pszDomain = "" ); 00104 const char *GetMetadataItem( const char * pszName, 00105 const char * pszDomain = "" ); 00106 CPLErr SetMetadataItem( const char * pszName, 00107 const char * pszValue, 00108 const char * pszDomain = "" ); 00109 00110 void Clear(); 00111 00112 private: 00113 CPL_DISALLOW_COPY_ASSIGN(GDALMultiDomainMetadata) 00114 }; 00116 00117 /* ******************************************************************** */ 00118 /* GDALMajorObject */ 00119 /* */ 00120 /* Base class providing metadata, description and other */ 00121 /* services shared by major objects. */ 00122 /* ******************************************************************** */ 00123 00125 class CPL_DLL GDALMajorObject 00126 { 00127 protected: 00129 int nFlags; // GMO_* flags. 00130 CPLString sDescription; 00131 GDALMultiDomainMetadata oMDMD; 00132 00134 00135 char **BuildMetadataDomainList( char** papszList, 00136 int bCheckNonEmpty, ... ) CPL_NULL_TERMINATED; 00137 public: 00138 GDALMajorObject(); 00139 virtual ~GDALMajorObject(); 00140 00141 int GetMOFlags() const; 00142 void SetMOFlags( int nFlagsIn ); 00143 00144 virtual const char *GetDescription() const; 00145 virtual void SetDescription( const char * ); 00146 00147 virtual char **GetMetadataDomainList(); 00148 00149 virtual char **GetMetadata( const char * pszDomain = "" ); 00150 virtual CPLErr SetMetadata( char ** papszMetadata, 00151 const char * pszDomain = "" ); 00152 virtual const char *GetMetadataItem( const char * pszName, 00153 const char * pszDomain = "" ); 00154 virtual CPLErr SetMetadataItem( const char * pszName, 00155 const char * pszValue, 00156 const char * pszDomain = "" ); 00157 }; 00158 00159 /* ******************************************************************** */ 00160 /* GDALDefaultOverviews */ 00161 /* ******************************************************************** */ 00162 00164 class CPL_DLL GDALDefaultOverviews 00165 { 00166 friend class GDALDataset; 00167 00168 GDALDataset *poDS; 00169 GDALDataset *poODS; 00170 00171 CPLString osOvrFilename; 00172 00173 bool bOvrIsAux; 00174 00175 bool bCheckedForMask; 00176 bool bOwnMaskDS; 00177 GDALDataset *poMaskDS; 00178 00179 // For "overview datasets" we record base level info so we can 00180 // find our way back to get overview masks. 00181 GDALDataset *poBaseDS; 00182 00183 // Stuff for deferred initialize/overviewscans. 00184 bool bCheckedForOverviews; 00185 void OverviewScan(); 00186 char *pszInitName; 00187 bool bInitNameIsOVR; 00188 char **papszInitSiblingFiles; 00189 00190 public: 00191 GDALDefaultOverviews(); 00192 ~GDALDefaultOverviews(); 00193 00194 void Initialize( GDALDataset *poDSIn, const char *pszName = NULL, 00195 char **papszSiblingFiles = NULL, 00196 int bNameIsOVR = FALSE ); 00197 00198 void TransferSiblingFiles( char** papszSiblingFiles ); 00199 00200 int IsInitialized(); 00201 00202 int CloseDependentDatasets(); 00203 00204 // Overview Related 00205 00206 int GetOverviewCount( int nBand ); 00207 GDALRasterBand *GetOverview( int nBand, int iOverview ); 00208 00209 CPLErr BuildOverviews( const char * pszBasename, 00210 const char * pszResampling, 00211 int nOverviews, int * panOverviewList, 00212 int nBands, int * panBandList, 00213 GDALProgressFunc pfnProgress, 00214 void *pProgressData ); 00215 00216 CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile, 00217 const char * pszResampling, 00218 int nOverviews, int * panOverviewList, 00219 int nBands, int * panBandList, 00220 GDALProgressFunc pfnProgress, 00221 void *pProgressData ); 00222 00223 CPLErr CleanOverviews(); 00224 00225 // Mask Related 00226 00227 CPLErr CreateMaskBand( int nFlags, int nBand = -1 ); 00228 GDALRasterBand *GetMaskBand( int nBand ); 00229 int GetMaskFlags( int nBand ); 00230 00231 int HaveMaskFile( char **papszSiblings = NULL, 00232 const char *pszBasename = NULL ); 00233 00234 char** GetSiblingFiles() { return papszInitSiblingFiles; } 00235 00236 private: 00237 CPL_DISALLOW_COPY_ASSIGN(GDALDefaultOverviews) 00238 }; 00240 00241 /* ******************************************************************** */ 00242 /* GDALOpenInfo */ 00243 /* ******************************************************************** */ 00244 00246 class CPL_DLL GDALOpenInfo 00247 { 00248 bool bHasGotSiblingFiles; 00249 char **papszSiblingFiles; 00250 int nHeaderBytesTried; 00251 00252 public: 00253 GDALOpenInfo( const char * pszFile, int nOpenFlagsIn, 00254 char **papszSiblingFiles = NULL ); 00255 ~GDALOpenInfo( void ); 00256 00258 char *pszFilename; 00260 char** papszOpenOptions; 00261 00263 GDALAccess eAccess; 00265 int nOpenFlags; 00266 00268 int bStatOK; 00270 int bIsDirectory; 00271 00273 VSILFILE *fpL; 00274 00276 int nHeaderBytes; 00278 GByte *pabyHeader; 00279 00281 const char* const* papszAllowedDrivers; 00282 00283 int TryToIngest(int nBytes); 00284 char **GetSiblingFiles(); 00285 char **StealSiblingFiles(); 00286 bool AreSiblingFilesLoaded() const; 00287 00288 private: 00289 CPL_DISALLOW_COPY_ASSIGN(GDALOpenInfo) 00290 }; 00291 00292 /* ******************************************************************** */ 00293 /* GDALDataset */ 00294 /* ******************************************************************** */ 00295 00296 class OGRLayer; 00297 class OGRGeometry; 00298 class OGRSpatialReference; 00299 class OGRStyleTable; 00300 class swq_select; 00301 class swq_select_parse_options; 00302 00304 typedef struct GDALSQLParseInfo GDALSQLParseInfo; 00306 00307 #ifdef DETECT_OLD_IRASTERIO 00308 typedef void signature_changed; 00309 #endif 00310 00312 #ifdef GDAL_COMPILATION 00313 #define OPTIONAL_OUTSIDE_GDAL(val) 00314 #else 00315 #define OPTIONAL_OUTSIDE_GDAL(val) = val 00316 #endif 00317 00318 00319 class OGRFeature; 00320 00322 class CPL_DLL GDALDataset : public GDALMajorObject 00323 { 00324 friend GDALDatasetH CPL_STDCALL GDALOpenEx( const char* pszFilename, 00325 unsigned int nOpenFlags, 00326 const char* const* papszAllowedDrivers, 00327 const char* const* papszOpenOptions, 00328 const char* const* papszSiblingFiles ); 00329 friend void CPL_STDCALL GDALClose( GDALDatasetH hDS ); 00330 00331 friend class GDALDriver; 00332 friend class GDALDefaultOverviews; 00333 friend class GDALProxyDataset; 00334 friend class GDALDriverManager; 00335 00336 void AddToDatasetOpenList(); 00337 00338 void Init( bool bForceCachedIO ); 00339 00340 protected: 00342 GDALDriver *poDriver; 00343 GDALAccess eAccess; 00344 00345 // Stored raster information. 00346 int nRasterXSize; 00347 int nRasterYSize; 00348 int nBands; 00349 GDALRasterBand **papoBands; 00350 00351 int nOpenFlags; 00352 00353 int nRefCount; 00354 bool bForceCachedIO; 00355 bool bShared; 00356 bool bIsInternal; 00357 bool bSuppressOnClose; 00358 00359 GDALDataset(void); 00360 explicit GDALDataset(int bForceCachedIO); 00361 00362 void RasterInitialize( int, int ); 00363 void SetBand( int, GDALRasterBand * ); 00364 00365 GDALDefaultOverviews oOvManager; 00366 00367 virtual CPLErr IBuildOverviews( const char *, int, int *, 00368 int, int *, GDALProgressFunc, void * ); 00369 00370 #ifdef DETECT_OLD_IRASTERIO 00371 virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int, 00372 void *, int, int, GDALDataType, 00373 int, int *, int, int, int ) {}; 00374 #endif 00375 00376 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, 00377 void *, int, int, GDALDataType, 00378 int, int *, GSpacing, GSpacing, GSpacing, 00379 GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; 00380 00381 CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int, 00382 void *, int, int, GDALDataType, 00383 int, int *, GSpacing, GSpacing, GSpacing, 00384 GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; 00385 void BlockBasedFlushCache(); 00386 00387 CPLErr BandBasedRasterIO( GDALRWFlag eRWFlag, 00388 int nXOff, int nYOff, int nXSize, int nYSize, 00389 void * pData, int nBufXSize, int nBufYSize, 00390 GDALDataType eBufType, 00391 int nBandCount, int *panBandMap, 00392 GSpacing nPixelSpace, GSpacing nLineSpace, 00393 GSpacing nBandSpace, 00394 GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; 00395 00396 CPLErr RasterIOResampled( GDALRWFlag eRWFlag, 00397 int nXOff, int nYOff, int nXSize, int nYSize, 00398 void * pData, int nBufXSize, int nBufYSize, 00399 GDALDataType eBufType, 00400 int nBandCount, int *panBandMap, 00401 GSpacing nPixelSpace, GSpacing nLineSpace, 00402 GSpacing nBandSpace, 00403 GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; 00404 00405 CPLErr ValidateRasterIOOrAdviseReadParameters( 00406 const char* pszCallingFunc, 00407 int* pbStopProcessingOnCENone, 00408 int nXOff, int nYOff, int nXSize, int nYSize, 00409 int nBufXSize, int nBufYSize, 00410 int nBandCount, int *panBandMap); 00411 00412 CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag, 00413 int nXOff, int nYOff, int nXSize, int nYSize, 00414 void * pData, int nBufXSize, int nBufYSize, 00415 GDALDataType eBufType, 00416 int nBandCount, int *panBandMap, 00417 GSpacing nPixelSpace, GSpacing nLineSpace, 00418 GSpacing nBandSpace, 00419 GDALRasterIOExtraArg* psExtraArg, 00420 int* pbTried); 00421 00423 virtual int CloseDependentDatasets(); 00425 int ValidateLayerCreationOptions( const char* const* papszLCO ); 00426 00427 char **papszOpenOptions; 00428 00429 friend class GDALRasterBand; 00430 00431 // The below methods related to read write mutex are fragile logic, and 00432 // should not be used by out-of-tree code if possible. 00433 int EnterReadWrite(GDALRWFlag eRWFlag); 00434 void LeaveReadWrite(); 00435 void InitRWLock(); 00436 00437 void TemporarilyDropReadWriteLock(); 00438 void ReacquireReadWriteLock(); 00439 00440 void DisableReadWriteMutex(); 00441 00442 int AcquireMutex(); 00443 void ReleaseMutex(); 00445 00446 public: 00447 virtual ~GDALDataset(); 00448 00449 int GetRasterXSize( void ); 00450 int GetRasterYSize( void ); 00451 int GetRasterCount( void ); 00452 GDALRasterBand *GetRasterBand( int ); 00453 00454 virtual void FlushCache(void); 00455 00456 virtual const char *GetProjectionRef(void); 00457 virtual CPLErr SetProjection( const char * pszProjection ); 00458 00459 virtual CPLErr GetGeoTransform( double * padfTransform ); 00460 virtual CPLErr SetGeoTransform( double * padfTransform ); 00461 00462 virtual CPLErr AddBand( GDALDataType eType, 00463 char **papszOptions=NULL ); 00464 00465 virtual void *GetInternalHandle( const char * pszHandleName ); 00466 virtual GDALDriver *GetDriver(void); 00467 virtual char **GetFileList(void); 00468 00469 virtual const char* GetDriverName(); 00470 00471 virtual int GetGCPCount(); 00472 virtual const char *GetGCPProjection(); 00473 virtual const GDAL_GCP *GetGCPs(); 00474 virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList, 00475 const char *pszGCPProjection ); 00476 00477 virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize, 00478 int nBufXSize, int nBufYSize, 00479 GDALDataType eDT, 00480 int nBandCount, int *panBandList, 00481 char **papszOptions ); 00482 00483 virtual CPLErr CreateMaskBand( int nFlagsIn ); 00484 00485 virtual GDALAsyncReader* 00486 BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize, 00487 void *pBuf, int nBufXSize, int nBufYSize, 00488 GDALDataType eBufType, 00489 int nBandCount, int* panBandMap, 00490 int nPixelSpace, int nLineSpace, int nBandSpace, 00491 char **papszOptions); 00492 virtual void EndAsyncReader(GDALAsyncReader *); 00493 00494 CPLErr RasterIO( GDALRWFlag, int, int, int, int, 00495 void *, int, int, GDALDataType, 00496 int, int *, GSpacing, GSpacing, GSpacing, 00497 GDALRasterIOExtraArg* psExtraArg 00498 #ifndef DOXYGEN_SKIP 00499 OPTIONAL_OUTSIDE_GDAL(NULL) 00500 #endif 00501 ) CPL_WARN_UNUSED_RESULT; 00502 00503 int Reference(); 00504 int Dereference(); 00505 int ReleaseRef(); 00506 00510 GDALAccess GetAccess() const { return eAccess; } 00511 00512 int GetShared() const; 00513 void MarkAsShared(); 00514 00516 void MarkSuppressOnClose() { bSuppressOnClose = true; } 00517 00521 char **GetOpenOptions() { return papszOpenOptions; } 00522 00523 static GDALDataset **GetOpenDatasets( int *pnDatasetCount ); 00524 00525 CPLErr BuildOverviews( const char *, int, int *, 00526 int, int *, GDALProgressFunc, void * ); 00527 00528 void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5); 00529 00530 virtual char ** GetMetadata(const char * pszDomain = "") CPL_OVERRIDE; 00531 00532 // Only defined when Doxygen enabled 00533 #ifdef DOXYGEN_SKIP 00534 virtual CPLErr SetMetadata( char ** papszMetadata, 00535 const char * pszDomain ) CPL_OVERRIDE; 00536 virtual const char *GetMetadataItem( const char * pszName, 00537 const char * pszDomain ) CPL_OVERRIDE; 00538 virtual CPLErr SetMetadataItem( const char * pszName, 00539 const char * pszValue, 00540 const char * pszDomain ) CPL_OVERRIDE; 00541 #endif 00542 00543 virtual char ** GetMetadataDomainList() CPL_OVERRIDE; 00544 00545 private: 00546 void *m_hPrivateData; 00547 00548 OGRLayer* BuildLayerFromSelectInfo(swq_select* psSelectInfo, 00549 OGRGeometry *poSpatialFilter, 00550 const char *pszDialect, 00551 swq_select_parse_options* poSelectParseOptions); 00552 CPLStringList oDerivedMetadataList; 00553 public: 00554 00555 virtual int GetLayerCount(); 00556 virtual OGRLayer *GetLayer(int iLayer); 00557 virtual OGRLayer *GetLayerByName(const char *); 00558 virtual OGRErr DeleteLayer(int iLayer); 00559 00560 virtual void ResetReading(); 00561 virtual OGRFeature* GetNextFeature( OGRLayer** ppoBelongingLayer, 00562 double* pdfProgressPct, 00563 GDALProgressFunc pfnProgress, 00564 void* pProgressData ); 00565 00566 virtual int TestCapability( const char * ); 00567 00568 virtual OGRLayer *CreateLayer( const char *pszName, 00569 OGRSpatialReference *poSpatialRef = NULL, 00570 OGRwkbGeometryType eGType = wkbUnknown, 00571 char ** papszOptions = NULL ); 00572 virtual OGRLayer *CopyLayer( OGRLayer *poSrcLayer, 00573 const char *pszNewName, 00574 char **papszOptions = NULL ); 00575 00576 virtual OGRStyleTable *GetStyleTable(); 00577 virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable ); 00578 00579 virtual void SetStyleTable(OGRStyleTable *poStyleTable); 00580 00581 virtual OGRLayer * ExecuteSQL( const char *pszStatement, 00582 OGRGeometry *poSpatialFilter, 00583 const char *pszDialect ); 00584 virtual void ReleaseResultSet( OGRLayer * poResultsSet ); 00585 00586 int GetRefCount() const; 00587 int GetSummaryRefCount() const; 00588 OGRErr Release(); 00589 00590 virtual OGRErr StartTransaction(int bForce=FALSE); 00591 virtual OGRErr CommitTransaction(); 00592 virtual OGRErr RollbackTransaction(); 00593 00595 static int IsGenericSQLDialect(const char* pszDialect); 00596 00597 // Semi-public methods. Only to be used by in-tree drivers. 00598 GDALSQLParseInfo* BuildParseInfo(swq_select* psSelectInfo, 00599 swq_select_parse_options* poSelectParseOptions); 00600 static void DestroyParseInfo(GDALSQLParseInfo* psParseInfo ); 00601 OGRLayer * ExecuteSQL( const char *pszStatement, 00602 OGRGeometry *poSpatialFilter, 00603 const char *pszDialect, 00604 swq_select_parse_options* poSelectParseOptions); 00606 00607 protected: 00608 virtual OGRLayer *ICreateLayer( const char *pszName, 00609 OGRSpatialReference *poSpatialRef = NULL, 00610 OGRwkbGeometryType eGType = wkbUnknown, 00611 char ** papszOptions = NULL ); 00612 00614 OGRErr ProcessSQLCreateIndex( const char * ); 00615 OGRErr ProcessSQLDropIndex( const char * ); 00616 OGRErr ProcessSQLDropTable( const char * ); 00617 OGRErr ProcessSQLAlterTableAddColumn( const char * ); 00618 OGRErr ProcessSQLAlterTableDropColumn( const char * ); 00619 OGRErr ProcessSQLAlterTableAlterColumn( const char * ); 00620 OGRErr ProcessSQLAlterTableRenameColumn( const char * ); 00621 00622 OGRStyleTable *m_poStyleTable; 00624 00625 private: 00626 CPL_DISALLOW_COPY_ASSIGN(GDALDataset) 00627 }; 00628 00629 /* ******************************************************************** */ 00630 /* GDALRasterBlock */ 00631 /* ******************************************************************** */ 00632 00637 class CPL_DLL GDALRasterBlock 00638 { 00639 friend class GDALAbstractBandBlockCache; 00640 00641 GDALDataType eType; 00642 00643 bool bDirty; 00644 volatile int nLockCount; 00645 00646 int nXOff; 00647 int nYOff; 00648 00649 int nXSize; 00650 int nYSize; 00651 00652 void *pData; 00653 00654 GDALRasterBand *poBand; 00655 00656 GDALRasterBlock *poNext; 00657 GDALRasterBlock *poPrevious; 00658 00659 bool bMustDetach; 00660 00661 void Detach_unlocked( void ); 00662 void Touch_unlocked( void ); 00663 00664 void RecycleFor( int nXOffIn, int nYOffIn ); 00665 00666 public: 00667 GDALRasterBlock( GDALRasterBand *, int, int ); 00668 GDALRasterBlock( int nXOffIn, int nYOffIn ); /* only for lookup purpose */ 00669 virtual ~GDALRasterBlock(); 00670 00671 CPLErr Internalize( void ); 00672 void Touch( void ); 00673 void MarkDirty( void ); 00674 void MarkClean( void ); 00676 int AddLock( void ) { return CPLAtomicInc(&nLockCount); } 00678 int DropLock( void ) { return CPLAtomicDec(&nLockCount); } 00679 void Detach(); 00680 00681 CPLErr Write(); 00682 00686 GDALDataType GetDataType() const { return eType; } 00690 int GetXOff() const { return nXOff; } 00694 int GetYOff() const { return nYOff; } 00698 int GetXSize() const { return nXSize; } 00702 int GetYSize() const { return nYSize; } 00706 int GetDirty() const { return bDirty; } 00710 void *GetDataRef( void ) { return pData; } 00714 int GetBlockSize() const { 00715 return nXSize * nYSize * GDALGetDataTypeSizeBytes(eType); } 00716 00717 int TakeLock(); 00718 int DropLockForRemovalFromStorage(); 00719 00722 GDALRasterBand *GetBand() { return poBand; } 00723 00724 static void FlushDirtyBlocks(); 00725 static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE); 00726 static void Verify(); 00727 00728 static void EnterDisableDirtyBlockFlush(); 00729 static void LeaveDisableDirtyBlockFlush(); 00730 00731 #ifdef notdef 00732 static void CheckNonOrphanedBlocks(GDALRasterBand* poBand); 00733 void DumpBlock(); 00734 static void DumpAll(); 00735 #endif 00736 00737 /* Should only be called by GDALDestroyDriverManager() */ 00739 static void DestroyRBMutex(); 00741 00742 private: 00743 CPL_DISALLOW_COPY_ASSIGN(GDALRasterBlock) 00744 }; 00745 00746 /* ******************************************************************** */ 00747 /* GDALColorTable */ 00748 /* ******************************************************************** */ 00749 00752 class CPL_DLL GDALColorTable 00753 { 00754 GDALPaletteInterp eInterp; 00755 00756 std::vector<GDALColorEntry> aoEntries; 00757 00758 public: 00759 explicit GDALColorTable( GDALPaletteInterp = GPI_RGB ); 00760 ~GDALColorTable(); 00761 00762 GDALColorTable *Clone() const; 00763 int IsSame(const GDALColorTable* poOtherCT) const; 00764 00765 GDALPaletteInterp GetPaletteInterpretation() const; 00766 00767 int GetColorEntryCount() const; 00768 const GDALColorEntry *GetColorEntry( int ) const; 00769 int GetColorEntryAsRGB( int, GDALColorEntry * ) const; 00770 void SetColorEntry( int, const GDALColorEntry * ); 00771 int CreateColorRamp( int, const GDALColorEntry * , 00772 int, const GDALColorEntry * ); 00773 }; 00774 00775 /* ******************************************************************** */ 00776 /* GDALAbstractBandBlockCache */ 00777 /* ******************************************************************** */ 00778 00780 00782 // CPL_DLL is just technical here. This is really a private concept 00783 // only used by GDALRasterBand implementation. 00784 00785 class CPL_DLL GDALAbstractBandBlockCache 00786 { 00787 // List of blocks that can be freed or recycled, and its lock 00788 CPLLock *hSpinLock; 00789 GDALRasterBlock *psListBlocksToFree; 00790 00791 // Band keep alive counter, and its lock & condition 00792 CPLCond *hCond; 00793 CPLMutex *hCondMutex; 00794 volatile int nKeepAliveCounter; 00795 00796 protected: 00797 GDALRasterBand *poBand; 00798 00799 void FreeDanglingBlocks(); 00800 void UnreferenceBlockBase(); 00801 void WaitKeepAliveCounter(); 00802 00803 public: 00804 explicit GDALAbstractBandBlockCache(GDALRasterBand* poBand); 00805 virtual ~GDALAbstractBandBlockCache(); 00806 00807 GDALRasterBlock* CreateBlock(int nXBlockOff, int nYBlockOff); 00808 void AddBlockToFreeList( GDALRasterBlock * ); 00809 00810 virtual bool Init() = 0; 00811 virtual bool IsInitOK() = 0; 00812 virtual CPLErr FlushCache() = 0; 00813 virtual CPLErr AdoptBlock( GDALRasterBlock* poBlock ) = 0; 00814 virtual GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, 00815 int nYBlockYOff ) = 0; 00816 virtual CPLErr UnreferenceBlock( GDALRasterBlock* poBlock ) = 0; 00817 virtual CPLErr FlushBlock( int nXBlockOff, int nYBlockOff, 00818 int bWriteDirtyBlock ) = 0; 00819 }; 00820 00821 GDALAbstractBandBlockCache* GDALArrayBandBlockCacheCreate(GDALRasterBand* poBand); 00822 GDALAbstractBandBlockCache* GDALHashSetBandBlockCacheCreate(GDALRasterBand* poBand); 00823 00825 00826 /* ******************************************************************** */ 00827 /* GDALRasterBand */ 00828 /* ******************************************************************** */ 00829 00832 class CPL_DLL GDALRasterBand : public GDALMajorObject 00833 { 00834 private: 00835 friend class GDALArrayBandBlockCache; 00836 friend class GDALHashSetBandBlockCache; 00837 friend class GDALRasterBlock; 00838 00839 CPLErr eFlushBlockErr; 00840 GDALAbstractBandBlockCache* poBandBlockCache; 00841 00842 void SetFlushBlockErr( CPLErr eErr ); 00843 CPLErr UnreferenceBlock( GDALRasterBlock* poBlock ); 00844 00845 void Init(int bForceCachedIO); 00846 00847 protected: 00849 GDALDataset *poDS; 00850 int nBand; /* 1 based */ 00851 00852 int nRasterXSize; 00853 int nRasterYSize; 00854 00855 GDALDataType eDataType; 00856 GDALAccess eAccess; 00857 00858 /* stuff related to blocking, and raster cache */ 00859 int nBlockXSize; 00860 int nBlockYSize; 00861 int nBlocksPerRow; 00862 int nBlocksPerColumn; 00863 00864 int nBlockReads; 00865 int bForceCachedIO; 00866 00867 GDALRasterBand *poMask; 00868 bool bOwnMask; 00869 int nMaskFlags; 00870 00871 void InvalidateMaskBand(); 00872 00873 friend class GDALDataset; 00874 friend class GDALProxyRasterBand; 00875 friend class GDALDefaultOverviews; 00876 00877 CPLErr RasterIOResampled( GDALRWFlag, int, int, int, int, 00878 void *, int, int, GDALDataType, 00879 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; 00880 00881 int EnterReadWrite(GDALRWFlag eRWFlag); 00882 void LeaveReadWrite(); 00883 void InitRWLock(); 00885 00886 protected: 00887 virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void * pData ) = 0; 00888 virtual CPLErr IWriteBlock( int nBlockXOff, int nBlockYOff, void * pData ); 00889 00890 #ifdef DETECT_OLD_IRASTERIO 00891 virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int, 00892 void *, int, int, GDALDataType, 00893 int, int ) {}; 00894 #endif 00895 00896 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, 00897 void *, int, int, GDALDataType, 00898 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; 00899 00900 virtual int IGetDataCoverageStatus( int nXOff, int nYOff, 00901 int nXSize, int nYSize, 00902 int nMaskFlagStop, 00903 double* pdfDataPct); 00905 CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int, 00906 void *, int, int, GDALDataType, 00907 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT; 00908 00909 CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag, 00910 int nXOff, int nYOff, int nXSize, int nYSize, 00911 void * pData, int nBufXSize, int nBufYSize, 00912 GDALDataType eBufType, 00913 GSpacing nPixelSpace, GSpacing nLineSpace, 00914 GDALRasterIOExtraArg* psExtraArg, 00915 int* pbTried ); 00916 00917 int InitBlockInfo(); 00918 00919 void AddBlockToFreeList( GDALRasterBlock * ); 00921 00922 GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff ); 00923 00924 public: 00925 GDALRasterBand(); 00926 explicit GDALRasterBand(int bForceCachedIO); 00927 00928 virtual ~GDALRasterBand(); 00929 00930 int GetXSize(); 00931 int GetYSize(); 00932 int GetBand(); 00933 GDALDataset*GetDataset(); 00934 00935 GDALDataType GetRasterDataType( void ); 00936 void GetBlockSize( int *, int * ); 00937 CPLErr GetActualBlockSize ( int, int, int *, int * ); 00938 GDALAccess GetAccess(); 00939 00940 CPLErr RasterIO( GDALRWFlag, int, int, int, int, 00941 void *, int, int, GDALDataType, 00942 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg 00943 #ifndef DOXYGEN_SKIP 00944 OPTIONAL_OUTSIDE_GDAL(NULL) 00945 #endif 00946 ) CPL_WARN_UNUSED_RESULT; 00947 CPLErr ReadBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT; 00948 00949 CPLErr WriteBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT; 00950 00951 GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff, 00952 int bJustInitialize = FALSE ) CPL_WARN_UNUSED_RESULT; 00953 CPLErr FlushBlock( int, int, int bWriteDirtyBlock = TRUE ); 00954 00955 unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand, 00956 unsigned char* pTranslationTable = NULL, 00957 int* pApproximateMatching = NULL); 00958 00959 // New OpengIS CV_SampleDimension stuff. 00960 00961 virtual CPLErr FlushCache(); 00962 virtual char **GetCategoryNames(); 00963 virtual double GetNoDataValue( int *pbSuccess = NULL ); 00964 virtual double GetMinimum( int *pbSuccess = NULL ); 00965 virtual double GetMaximum(int *pbSuccess = NULL ); 00966 virtual double GetOffset( int *pbSuccess = NULL ); 00967 virtual double GetScale( int *pbSuccess = NULL ); 00968 virtual const char *GetUnitType(); 00969 virtual GDALColorInterp GetColorInterpretation(); 00970 virtual GDALColorTable *GetColorTable(); 00971 virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0); 00972 00973 virtual CPLErr SetCategoryNames( char ** papszNames ); 00974 virtual CPLErr SetNoDataValue( double dfNoData ); 00975 virtual CPLErr DeleteNoDataValue(); 00976 virtual CPLErr SetColorTable( GDALColorTable * poCT ); 00977 virtual CPLErr SetColorInterpretation( GDALColorInterp eColorInterp ); 00978 virtual CPLErr SetOffset( double dfNewOffset ); 00979 virtual CPLErr SetScale( double dfNewScale ); 00980 virtual CPLErr SetUnitType( const char * pszNewValue ); 00981 00982 virtual CPLErr GetStatistics( int bApproxOK, int bForce, 00983 double *pdfMin, double *pdfMax, 00984 double *pdfMean, double *padfStdDev ); 00985 virtual CPLErr ComputeStatistics( int bApproxOK, 00986 double *pdfMin, double *pdfMax, 00987 double *pdfMean, double *pdfStdDev, 00988 GDALProgressFunc, void *pProgressData ); 00989 virtual CPLErr SetStatistics( double dfMin, double dfMax, 00990 double dfMean, double dfStdDev ); 00991 virtual CPLErr ComputeRasterMinMax( int, double* ); 00992 00993 // Only defined when Doxygen enabled 00994 #ifdef DOXYGEN_SKIP 00995 virtual char **GetMetadata( const char * pszDomain = "" ) CPL_OVERRIDE; 00996 virtual CPLErr SetMetadata( char ** papszMetadata, 00997 const char * pszDomain ) CPL_OVERRIDE; 00998 virtual const char *GetMetadataItem( const char * pszName, 00999 const char * pszDomain ) CPL_OVERRIDE; 01000 virtual CPLErr SetMetadataItem( const char * pszName, 01001 const char * pszValue, 01002 const char * pszDomain ) CPL_OVERRIDE; 01003 #endif 01004 01005 virtual int HasArbitraryOverviews(); 01006 virtual int GetOverviewCount(); 01007 virtual GDALRasterBand *GetOverview(int); 01008 virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig ); 01009 virtual CPLErr BuildOverviews( const char * pszResampling, 01010 int nOverviews, 01011 int * panOverviewList, 01012 GDALProgressFunc pfnProgress, 01013 void * pProgressData ); 01014 01015 virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize, 01016 int nBufXSize, int nBufYSize, 01017 GDALDataType eBufType, char **papszOptions ); 01018 01019 virtual CPLErr GetHistogram( double dfMin, double dfMax, 01020 int nBuckets, GUIntBig * panHistogram, 01021 int bIncludeOutOfRange, int bApproxOK, 01022 GDALProgressFunc, void *pProgressData ); 01023 01024 virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax, 01025 int *pnBuckets, GUIntBig ** ppanHistogram, 01026 int bForce, 01027 GDALProgressFunc, void *pProgressData); 01028 virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax, 01029 int nBuckets, GUIntBig *panHistogram ); 01030 01031 virtual GDALRasterAttributeTable *GetDefaultRAT(); 01032 virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * poRAT ); 01033 01034 virtual GDALRasterBand *GetMaskBand(); 01035 virtual int GetMaskFlags(); 01036 virtual CPLErr CreateMaskBand( int nFlagsIn ); 01037 01038 virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag, 01039 int *pnPixelSpace, 01040 GIntBig *pnLineSpace, 01041 char **papszOptions ) CPL_WARN_UNUSED_RESULT; 01042 01043 int GetDataCoverageStatus( int nXOff, int nYOff, 01044 int nXSize, int nYSize, 01045 int nMaskFlagStop = 0, 01046 double* pdfDataPct = NULL ); 01047 01048 void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5); 01049 01050 private: 01051 CPL_DISALLOW_COPY_ASSIGN(GDALRasterBand) 01052 }; 01053 01055 /* ******************************************************************** */ 01056 /* GDALAllValidMaskBand */ 01057 /* ******************************************************************** */ 01058 01059 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand 01060 { 01061 protected: 01062 virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE; 01063 01064 public: 01065 explicit GDALAllValidMaskBand( GDALRasterBand * ); 01066 virtual ~GDALAllValidMaskBand(); 01067 01068 virtual GDALRasterBand *GetMaskBand() CPL_OVERRIDE; 01069 virtual int GetMaskFlags() CPL_OVERRIDE; 01070 }; 01071 01072 /* ******************************************************************** */ 01073 /* GDALNoDataMaskBand */ 01074 /* ******************************************************************** */ 01075 01076 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand 01077 { 01078 double dfNoDataValue; 01079 GDALRasterBand *poParent; 01080 01081 protected: 01082 virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE; 01083 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, 01084 void *, int, int, GDALDataType, 01085 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_OVERRIDE; 01086 01087 public: 01088 explicit GDALNoDataMaskBand( GDALRasterBand * ); 01089 virtual ~GDALNoDataMaskBand(); 01090 }; 01091 01092 /* ******************************************************************** */ 01093 /* GDALNoDataValuesMaskBand */ 01094 /* ******************************************************************** */ 01095 01096 class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand 01097 { 01098 double *padfNodataValues; 01099 01100 protected: 01101 virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE; 01102 01103 public: 01104 explicit GDALNoDataValuesMaskBand( GDALDataset * ); 01105 virtual ~GDALNoDataValuesMaskBand(); 01106 }; 01107 01108 /* ******************************************************************** */ 01109 /* GDALRescaledAlphaBand */ 01110 /* ******************************************************************** */ 01111 01112 class GDALRescaledAlphaBand : public GDALRasterBand 01113 { 01114 GDALRasterBand *poParent; 01115 void *pTemp; 01116 01117 protected: 01118 virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE; 01119 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, 01120 void *, int, int, GDALDataType, 01121 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_OVERRIDE; 01122 01123 public: 01124 explicit GDALRescaledAlphaBand( GDALRasterBand * ); 01125 virtual ~GDALRescaledAlphaBand(); 01126 }; 01128 01129 /* ******************************************************************** */ 01130 /* GDALIdentifyEnum */ 01131 /* ******************************************************************** */ 01132 01138 typedef enum 01139 { 01141 GDAL_IDENTIFY_UNKNOWN = -1, 01143 GDAL_IDENTIFY_FALSE = 0, 01145 GDAL_IDENTIFY_TRUE = 1 01146 } GDALIdentifyEnum; 01147 01148 /* ******************************************************************** */ 01149 /* GDALDriver */ 01150 /* ******************************************************************** */ 01151 01163 class CPL_DLL GDALDriver : public GDALMajorObject 01164 { 01165 public: 01166 GDALDriver(); 01167 virtual ~GDALDriver(); 01168 01169 virtual CPLErr SetMetadataItem( const char * pszName, 01170 const char * pszValue, 01171 const char * pszDomain = "" ) CPL_OVERRIDE; 01172 01173 /* -------------------------------------------------------------------- */ 01174 /* Public C++ methods. */ 01175 /* -------------------------------------------------------------------- */ 01176 GDALDataset *Create( const char * pszName, 01177 int nXSize, int nYSize, int nBands, 01178 GDALDataType eType, char ** papszOptions ) CPL_WARN_UNUSED_RESULT; 01179 01180 CPLErr Delete( const char * pszName ); 01181 CPLErr Rename( const char * pszNewName, 01182 const char * pszOldName ); 01183 CPLErr CopyFiles( const char * pszNewName, 01184 const char * pszOldName ); 01185 01186 GDALDataset *CreateCopy( const char *, GDALDataset *, 01187 int, char **, 01188 GDALProgressFunc pfnProgress, 01189 void * pProgressData ) CPL_WARN_UNUSED_RESULT; 01190 01191 /* -------------------------------------------------------------------- */ 01192 /* The following are semiprivate, not intended to be accessed */ 01193 /* by anyone but the formats instantiating and populating the */ 01194 /* drivers. */ 01195 /* -------------------------------------------------------------------- */ 01197 GDALDataset *(*pfnOpen)( GDALOpenInfo * ); 01198 01199 GDALDataset *(*pfnCreate)( const char * pszName, 01200 int nXSize, int nYSize, int nBands, 01201 GDALDataType eType, 01202 char ** papszOptions ); 01203 01204 CPLErr (*pfnDelete)( const char * pszName ); 01205 01206 GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *, 01207 int, char **, 01208 GDALProgressFunc pfnProgress, 01209 void * pProgressData ); 01210 01211 void *pDriverData; 01212 01213 void (*pfnUnloadDriver)(GDALDriver *); 01214 01222 int (*pfnIdentify)( GDALOpenInfo * ); 01223 01224 CPLErr (*pfnRename)( const char * pszNewName, 01225 const char * pszOldName ); 01226 CPLErr (*pfnCopyFiles)( const char * pszNewName, 01227 const char * pszOldName ); 01228 01229 /* For legacy OGR drivers */ 01230 GDALDataset *(*pfnOpenWithDriverArg)( GDALDriver*, GDALOpenInfo * ); 01231 GDALDataset *(*pfnCreateVectorOnly)( GDALDriver*, 01232 const char * pszName, 01233 char ** papszOptions ); 01234 CPLErr (*pfnDeleteDataSource)( GDALDriver*, 01235 const char * pszName ); 01237 01238 /* -------------------------------------------------------------------- */ 01239 /* Helper methods. */ 01240 /* -------------------------------------------------------------------- */ 01242 GDALDataset *DefaultCreateCopy( const char *, GDALDataset *, 01243 int, char **, 01244 GDALProgressFunc pfnProgress, 01245 void * pProgressData ) CPL_WARN_UNUSED_RESULT; 01246 static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS, 01247 GDALDataset *poDstDS, 01248 int bStrict ); 01250 static CPLErr QuietDelete( const char * pszName ); 01251 01253 static CPLErr DefaultRename( const char * pszNewName, 01254 const char * pszOldName ); 01255 static CPLErr DefaultCopyFiles( const char * pszNewName, 01256 const char * pszOldName ); 01258 private: 01259 CPL_DISALLOW_COPY_ASSIGN(GDALDriver) 01260 }; 01261 01262 /* ******************************************************************** */ 01263 /* GDALDriverManager */ 01264 /* ******************************************************************** */ 01265 01273 class CPL_DLL GDALDriverManager : public GDALMajorObject 01274 { 01275 int nDrivers; 01276 GDALDriver **papoDrivers; 01277 std::map<CPLString, GDALDriver*> oMapNameToDrivers; 01278 01279 GDALDriver *GetDriver_unlocked( int iDriver ) 01280 { return (iDriver >= 0 && iDriver < nDrivers) ? 01281 papoDrivers[iDriver] : NULL; } 01282 01283 GDALDriver *GetDriverByName_unlocked( const char * pszName ) 01284 { return oMapNameToDrivers[CPLString(pszName).toupper()]; } 01285 01286 public: 01287 GDALDriverManager(); 01288 ~GDALDriverManager(); 01289 01290 int GetDriverCount( void ) const; 01291 GDALDriver *GetDriver( int ); 01292 GDALDriver *GetDriverByName( const char * ); 01293 01294 int RegisterDriver( GDALDriver * ); 01295 void DeregisterDriver( GDALDriver * ); 01296 01297 // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined. 01298 static void AutoLoadDrivers(); 01299 void AutoSkipDrivers(); 01300 }; 01301 01302 CPL_C_START 01303 GDALDriverManager CPL_DLL * GetGDALDriverManager( void ); 01304 CPL_C_END 01305 01306 /* ******************************************************************** */ 01307 /* GDALAsyncReader */ 01308 /* ******************************************************************** */ 01309 01315 class CPL_DLL GDALAsyncReader 01316 { 01317 protected: 01319 GDALDataset* poDS; 01320 int nXOff; 01321 int nYOff; 01322 int nXSize; 01323 int nYSize; 01324 void * pBuf; 01325 int nBufXSize; 01326 int nBufYSize; 01327 GDALDataType eBufType; 01328 int nBandCount; 01329 int* panBandMap; 01330 int nPixelSpace; 01331 int nLineSpace; 01332 int nBandSpace; 01334 01335 public: 01336 GDALAsyncReader(); 01337 virtual ~GDALAsyncReader(); 01338 01342 GDALDataset* GetGDALDataset() {return poDS;} 01346 int GetXOffset() const { return nXOff; } 01350 int GetYOffset() const { return nYOff; } 01354 int GetXSize() const { return nXSize; } 01358 int GetYSize() const { return nYSize; } 01362 void * GetBuffer() {return pBuf;} 01366 int GetBufferXSize() const { return nBufXSize; } 01370 int GetBufferYSize() const { return nBufYSize; } 01374 GDALDataType GetBufferType() const { return eBufType; } 01378 int GetBandCount() const { return nBandCount; } 01382 int* GetBandMap() { return panBandMap; } 01386 int GetPixelSpace() const { return nPixelSpace; } 01390 int GetLineSpace() const { return nLineSpace; } 01394 int GetBandSpace() const { return nBandSpace; } 01395 01396 virtual GDALAsyncStatusType 01397 GetNextUpdatedRegion(double dfTimeout, 01398 int* pnBufXOff, int* pnBufYOff, 01399 int* pnBufXSize, int* pnBufYSize) = 0; 01400 virtual int LockBuffer( double dfTimeout = -1.0 ); 01401 virtual void UnlockBuffer(); 01402 }; 01403 01404 /* ==================================================================== */ 01405 /* An assortment of overview related stuff. */ 01406 /* ==================================================================== */ 01407 01409 /* Only exported for drivers as plugin. Signature may change */ 01410 CPLErr CPL_DLL 01411 GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands, 01412 int nOverviews, 01413 GDALRasterBand*** papapoOverviewBands, 01414 const char * pszResampling, 01415 GDALProgressFunc pfnProgress, void * pProgressData ); 01416 01417 typedef CPLErr (*GDALResampleFunction) 01418 ( double dfXRatioDstToSrc, 01419 double dfYRatioDstToSrc, 01420 double dfSrcXDelta, 01421 double dfSrcYDelta, 01422 GDALDataType eWrkDataType, 01423 void * pChunk, 01424 GByte * pabyChunkNodataMask, 01425 int nChunkXOff, int nChunkXSize, 01426 int nChunkYOff, int nChunkYSize, 01427 int nDstXOff, int nDstXOff2, 01428 int nDstYOff, int nDstYOff2, 01429 GDALRasterBand * poOverview, 01430 const char * pszResampling, 01431 int bHasNoData, float fNoDataValue, 01432 GDALColorTable* poColorTable, 01433 GDALDataType eSrcDataType, 01434 bool bPropagateNoData ); 01435 01436 GDALResampleFunction GDALGetResampleFunction(const char* pszResampling, 01437 int* pnRadius); 01438 01439 #ifdef GDAL_ENABLE_RESAMPLING_MULTIBAND 01440 typedef CPLErr (*GDALResampleFunctionMultiBands) 01441 ( double dfXRatioDstToSrc, 01442 double dfYRatioDstToSrc, 01443 double dfSrcXDelta, 01444 double dfSrcYDelta, 01445 GDALDataType eWrkDataType, 01446 void * pChunk, int nBands, 01447 GByte * pabyChunkNodataMask, 01448 int nChunkXOff, int nChunkXSize, 01449 int nChunkYOff, int nChunkYSize, 01450 int nDstXOff, int nDstXOff2, 01451 int nDstYOff, int nDstYOff2, 01452 GDALRasterBand ** papoDstBands, 01453 const char * pszResampling, 01454 int bHasNoData, float fNoDataValue, 01455 GDALColorTable* poColorTable, 01456 GDALDataType eSrcDataType); 01457 01458 GDALResampleFunctionMultiBands GDALGetResampleFunctionMultiBands(const char* pszResampling, 01459 int* pnRadius); 01460 #endif 01461 01462 GDALDataType GDALGetOvrWorkDataType(const char* pszResampling, 01463 GDALDataType eSrcDataType); 01464 01465 CPL_C_START 01466 01467 CPLErr CPL_DLL 01468 HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS, 01469 GDALDataset **ppoDS, 01470 int nBands, int *panBandList, 01471 int nNewOverviews, int *panNewOverviewList, 01472 const char *pszResampling, 01473 GDALProgressFunc pfnProgress, 01474 void *pProgressData ); 01475 01476 CPLErr CPL_DLL 01477 GTIFFBuildOverviews( const char * pszFilename, 01478 int nBands, GDALRasterBand **papoBandList, 01479 int nOverviews, int * panOverviewList, 01480 const char * pszResampling, 01481 GDALProgressFunc pfnProgress, void * pProgressData ); 01482 01483 CPLErr CPL_DLL 01484 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename, 01485 const char * pszResampling, 01486 int nOverviews, int * panOverviewList, 01487 int nBands, int * panBandList, 01488 GDALProgressFunc pfnProgress, void * pProgressData); 01489 01490 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand, 01491 int &nXOff, int &nYOff, 01492 int &nXSize, int &nYSize, 01493 int nBufXSize, int nBufYSize) CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead"); 01494 int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand* poBand, 01495 int &nXOff, int &nYOff, 01496 int &nXSize, int &nYSize, 01497 int nBufXSize, int nBufYSize, 01498 GDALRasterIOExtraArg* psExtraArg); 01499 01500 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize ) CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead"); 01501 int CPL_DLL GDALOvLevelAdjust2( int nOvLevel, int nXSize, int nYSize ); 01502 int CPL_DLL GDALComputeOvFactor( int nOvrXSize, int nRasterXSize, 01503 int nOvrYSize, int nRasterYSize ); 01504 01505 GDALDataset CPL_DLL * 01506 GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess, 01507 GDALDataset *poDependentDS ); 01508 01509 /* ==================================================================== */ 01510 /* Misc functions. */ 01511 /* ==================================================================== */ 01512 01513 CPLErr CPL_DLL GDALParseGMLCoverage( CPLXMLNode *psTree, 01514 int *pnXSize, int *pnYSize, 01515 double *padfGeoTransform, 01516 char **ppszProjection ); 01517 01518 /* ==================================================================== */ 01519 /* Infrastructure to check that dataset characteristics are valid */ 01520 /* ==================================================================== */ 01521 01522 int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize ); 01523 int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed ); 01524 01525 // Test if 2 floating point values match. Useful when comparing values 01526 // stored as a string at some point. See #3573, #4183, #4506 01527 #define ARE_REAL_EQUAL(dfVal1, dfVal2) \ 01528 /* Is it FLT_MIN ? Cf #6578 */ \ 01529 (((float)dfVal2 == (float)1.17549435e-38) ? ((float)dfVal1 == (float)dfVal2) : \ 01530 /* Or DBL_MIN ? */ \ 01531 (dfVal2 == 2.2250738585072014e-308) ? (dfVal1 == dfVal2) : \ 01532 /* General case */ \ 01533 (dfVal1 == dfVal2 || fabs(dfVal1 - dfVal2) < 1e-10 || (dfVal2 != 0 && fabs(1 - dfVal1 / dfVal2) < 1e-10 ))) 01534 01535 /* Internal use only */ 01536 01537 /* CPL_DLL exported, but only for in-tree drivers that can be built as plugins */ 01538 int CPL_DLL GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension, 01539 double *padfGeoTransform, char** papszSiblingFiles, 01540 char** ppszWorldFileNameOut); 01541 int GDALReadTabFile2( const char * pszBaseFilename, 01542 double *padfGeoTransform, char **ppszWKT, 01543 int *pnGCPCount, GDAL_GCP **ppasGCPs, 01544 char** papszSiblingFiles, char** ppszTabFileNameOut ); 01545 01546 void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg* psDestArg, 01547 GDALRasterIOExtraArg* psSrcArg); 01548 01549 CPL_C_END 01550 01551 void GDALNullifyOpenDatasetsList(); 01552 CPLMutex** GDALGetphDMMutex(); 01553 CPLMutex** GDALGetphDLMutex(); 01554 void GDALNullifyProxyPoolSingleton(); 01555 GDALDriver* GDALGetAPIPROXYDriver(); 01556 void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID); 01557 GIntBig GDALGetResponsiblePIDForCurrentThread(); 01558 01559 CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt, 01560 char **papszSiblingFiles, int nFlags ); 01561 01562 CPLErr EXIFExtractMetadata(char**& papszMetadata, 01563 void *fpL, int nOffset, 01564 int bSwabflag, int nTIFFHEADER, 01565 int& nExifOffset, int& nInterOffset, int& nGPSOffset); 01566 01567 int GDALValidateOpenOptions( GDALDriverH hDriver, 01568 const char* const* papszOptionOptions); 01569 int GDALValidateOptions( const char* pszOptionList, 01570 const char* const* papszOptionsToValidate, 01571 const char* pszErrorMessageOptionType, 01572 const char* pszErrorMessageContainerName); 01573 01574 GDALRIOResampleAlg GDALRasterIOGetResampleAlg(const char* pszResampling); 01575 const char* GDALRasterIOGetResampleAlg(GDALRIOResampleAlg eResampleAlg); 01576 01577 void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg* psExtraArg, 01578 int nXSize, int nYSize, 01579 int nBufXSize, int nBufYSize); 01580 01581 01582 GDALDataset* GDALCreateOverviewDataset(GDALDataset* poDS, int nOvrLevel, 01583 int bThisLevelOnly); 01584 01585 #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) ) 01586 01587 // Number of data samples that will be used to compute approximate statistics 01588 // (minimum value, maximum value, etc.) 01589 #define GDALSTAT_APPROX_NUMSAMPLES 2500 01590 01591 CPL_C_START 01592 /* Caution: for technical reason this declaration is duplicated in gdal_crs.c */ 01593 /* so any signature change should be reflected there too */ 01594 void GDALSerializeGCPListToXML( CPLXMLNode* psParentNode, 01595 GDAL_GCP* pasGCPList, 01596 int nGCPCount, 01597 const char* pszGCPProjection ); 01598 void GDALDeserializeGCPListFromXML( CPLXMLNode* psGCPList, 01599 GDAL_GCP** ppasGCPList, 01600 int* pnGCPCount, 01601 char** ppszGCPProjection ); 01602 CPL_C_END 01603 01604 void GDALSerializeOpenOptionsToXML( CPLXMLNode* psParentNode, char** papszOpenOptions); 01605 char** GDALDeserializeOpenOptionsFromXML( CPLXMLNode* psParentNode ); 01606 01607 int GDALCanFileAcceptSidecarFile(const char* pszFilename); 01609 01610 #endif /* ndef GDAL_PRIV_H_INCLUDED */
1.7.6.1.