00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef GDAL_PRIV_H_INCLUDED
00033 #define GDAL_PRIV_H_INCLUDED
00034
00035
00036
00037
00038
00039 class GDALMajorObject;
00040 class GDALDataset;
00041 class GDALRasterBand;
00042 class GDALDriver;
00043 class GDALRasterAttributeTable;
00044 class GDALProxyDataset;
00045 class GDALProxyRasterBand;
00046 class GDALAsyncReader;
00047
00048
00049
00050
00051
00052
00053
00054 #include "gdal.h"
00055 #include "gdal_frmts.h"
00056 #include "cpl_vsi.h"
00057 #include "cpl_conv.h"
00058 #include "cpl_string.h"
00059 #include "cpl_minixml.h"
00060 #include "cpl_multiproc.h"
00061 #include <vector>
00062 #include <map>
00063 #include "ogr_core.h"
00064
00065 #define GMO_VALID 0x0001
00066 #define GMO_IGNORE_UNIMPLEMENTED 0x0002
00067 #define GMO_SUPPORT_MD 0x0004
00068 #define GMO_SUPPORT_MDMD 0x0008
00069 #define GMO_MD_DIRTY 0x0010
00070 #define GMO_PAM_CLASS 0x0020
00071
00072
00073
00074
00075
00076 class CPL_DLL GDALMultiDomainMetadata
00077 {
00078 private:
00079 char **papszDomainList;
00080 CPLStringList **papoMetadataLists;
00081
00082 public:
00083 GDALMultiDomainMetadata();
00084 ~GDALMultiDomainMetadata();
00085
00086 int XMLInit( CPLXMLNode *psMetadata, int bMerge );
00087 CPLXMLNode *Serialize();
00088
00089 char **GetDomainList() { return papszDomainList; }
00090
00091 char **GetMetadata( const char * pszDomain = "" );
00092 CPLErr SetMetadata( char ** papszMetadata,
00093 const char * pszDomain = "" );
00094 const char *GetMetadataItem( const char * pszName,
00095 const char * pszDomain = "" );
00096 CPLErr SetMetadataItem( const char * pszName,
00097 const char * pszValue,
00098 const char * pszDomain = "" );
00099
00100 void Clear();
00101 };
00102
00103
00104
00105
00106
00107
00108
00109
00111
00112 class CPL_DLL GDALMajorObject
00113 {
00114 protected:
00115 int nFlags;
00116 CPLString sDescription;
00117 GDALMultiDomainMetadata oMDMD;
00118
00119 char **BuildMetadataDomainList(char** papszList, int bCheckNonEmpty, ...) CPL_NULL_TERMINATED;
00120
00121 public:
00122 GDALMajorObject();
00123 virtual ~GDALMajorObject();
00124
00125 int GetMOFlags();
00126 void SetMOFlags(int nFlagsIn);
00127
00128 virtual const char *GetDescription() const;
00129 virtual void SetDescription( const char * );
00130
00131 virtual char **GetMetadataDomainList();
00132
00133 virtual char **GetMetadata( const char * pszDomain = "" );
00134 virtual CPLErr SetMetadata( char ** papszMetadata,
00135 const char * pszDomain = "" );
00136 virtual const char *GetMetadataItem( const char * pszName,
00137 const char * pszDomain = "" );
00138 virtual CPLErr SetMetadataItem( const char * pszName,
00139 const char * pszValue,
00140 const char * pszDomain = "" );
00141 };
00142
00143
00144
00145
00146 class CPL_DLL GDALDefaultOverviews
00147 {
00148 friend class GDALDataset;
00149
00150 GDALDataset *poDS;
00151 GDALDataset *poODS;
00152
00153 CPLString osOvrFilename;
00154
00155 int bOvrIsAux;
00156
00157 int bCheckedForMask;
00158 int bOwnMaskDS;
00159 GDALDataset *poMaskDS;
00160
00161
00162
00163 GDALDataset *poBaseDS;
00164
00165
00166 bool bCheckedForOverviews;
00167 void OverviewScan();
00168 char *pszInitName;
00169 int bInitNameIsOVR;
00170 char **papszInitSiblingFiles;
00171
00172 public:
00173 GDALDefaultOverviews();
00174 ~GDALDefaultOverviews();
00175
00176 void Initialize( GDALDataset *poDSIn, const char *pszName = NULL,
00177 char **papszSiblingFiles = NULL,
00178 int bNameIsOVR = FALSE );
00179
00180 int IsInitialized();
00181
00182 int CloseDependentDatasets();
00183
00184
00185
00186 int GetOverviewCount(int);
00187 GDALRasterBand *GetOverview(int,int);
00188
00189 CPLErr BuildOverviews( const char * pszBasename,
00190 const char * pszResampling,
00191 int nOverviews, int * panOverviewList,
00192 int nBands, int * panBandList,
00193 GDALProgressFunc pfnProgress,
00194 void *pProgressData );
00195
00196 CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile,
00197 const char * pszResampling,
00198 int nOverviews, int * panOverviewList,
00199 int nBands, int * panBandList,
00200 GDALProgressFunc pfnProgress,
00201 void *pProgressData );
00202
00203 CPLErr CleanOverviews();
00204
00205
00206
00207 CPLErr CreateMaskBand( int nFlags, int nBand = -1 );
00208 GDALRasterBand *GetMaskBand( int nBand );
00209 int GetMaskFlags( int nBand );
00210
00211 int HaveMaskFile( char **papszSiblings = NULL,
00212 const char *pszBasename = NULL );
00213
00214 char** GetSiblingFiles() { return papszInitSiblingFiles; }
00215 };
00216
00217
00218
00219
00220
00221
00222
00223 class CPL_DLL GDALOpenInfo
00224 {
00225 int bHasGotSiblingFiles;
00226 char **papszSiblingFiles;
00227 int nHeaderBytesTried;
00228
00229 public:
00230 GDALOpenInfo( const char * pszFile, int nOpenFlagsIn,
00231 char **papszSiblingFiles = NULL );
00232 ~GDALOpenInfo( void );
00233
00234 char *pszFilename;
00235 char** papszOpenOptions;
00236
00237 GDALAccess eAccess;
00238 int nOpenFlags;
00239
00240 int bStatOK;
00241 int bIsDirectory;
00242
00243 VSILFILE *fpL;
00244
00245 int nHeaderBytes;
00246 GByte *pabyHeader;
00247
00248 int TryToIngest(int nBytes);
00249 char **GetSiblingFiles();
00250 };
00251
00252
00253
00254
00255
00256 class OGRLayer;
00257 class OGRGeometry;
00258 class OGRSpatialReference;
00259 class OGRStyleTable;
00260 class swq_select;
00261 class swq_select_parse_options;
00262 typedef struct GDALSQLParseInfo GDALSQLParseInfo;
00263
00264 #ifdef DETECT_OLD_IRASTERIO
00265 typedef void signature_changed;
00266 #endif
00267
00268 #ifdef GDAL_COMPILATION
00269 #define OPTIONAL_OUTSIDE_GDAL(val)
00270 #else
00271 #define OPTIONAL_OUTSIDE_GDAL(val) = val
00272 #endif
00273
00275
00276 class CPL_DLL GDALDataset : public GDALMajorObject
00277 {
00278 friend GDALDatasetH CPL_STDCALL GDALOpenEx( const char* pszFilename,
00279 unsigned int nOpenFlags,
00280 const char* const* papszAllowedDrivers,
00281 const char* const* papszOpenOptions,
00282 const char* const* papszSiblingFiles );
00283 friend void CPL_STDCALL GDALClose( GDALDatasetH hDS );
00284
00285 friend class GDALDriver;
00286 friend class GDALDefaultOverviews;
00287 friend class GDALProxyDataset;
00288 friend class GDALDriverManager;
00289
00290 void AddToDatasetOpenList();
00291
00292 protected:
00293 GDALDriver *poDriver;
00294 GDALAccess eAccess;
00295
00296
00297 int nRasterXSize;
00298 int nRasterYSize;
00299 int nBands;
00300 GDALRasterBand **papoBands;
00301
00302 int bForceCachedIO;
00303
00304 int nRefCount;
00305 int bShared;
00306 GByte bIsInternal;
00307 GByte bSuppressOnClose;
00308 GByte bReserved1;
00309 GByte bReserved2;
00310
00311 GDALDataset(void);
00312
00313 void RasterInitialize( int, int );
00314 void SetBand( int, GDALRasterBand * );
00315
00316 GDALDefaultOverviews oOvManager;
00317
00318 virtual CPLErr IBuildOverviews( const char *, int, int *,
00319 int, int *, GDALProgressFunc, void * );
00320
00321 #ifdef DETECT_OLD_IRASTERIO
00322 virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int,
00323 void *, int, int, GDALDataType,
00324 int, int *, int, int, int ) {};
00325 #endif
00326
00327 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00328 void *, int, int, GDALDataType,
00329 int, int *, GSpacing, GSpacing, GSpacing,
00330 GDALRasterIOExtraArg* psExtraArg );
00331
00332 CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
00333 void *, int, int, GDALDataType,
00334 int, int *, GSpacing, GSpacing, GSpacing,
00335 GDALRasterIOExtraArg* psExtraArg );
00336 void BlockBasedFlushCache();
00337
00338 CPLErr ValidateRasterIOOrAdviseReadParameters(
00339 const char* pszCallingFunc,
00340 int* pbStopProcessingOnCENone,
00341 int nXOff, int nYOff, int nXSize, int nYSize,
00342 int nBufXSize, int nBufYSize,
00343 int nBandCount, int *panBandMap);
00344
00345 virtual int CloseDependentDatasets();
00346
00347 int ValidateLayerCreationOptions( const char* const* papszLCO );
00348
00349 char **papszOpenOptions;
00350
00351 friend class GDALRasterBand;
00352
00353 int EnterReadWrite(GDALRWFlag eRWFlag);
00354 void LeaveReadWrite();
00355
00356
00357 public:
00358 virtual ~GDALDataset();
00359
00360 int GetRasterXSize( void );
00361 int GetRasterYSize( void );
00362 int GetRasterCount( void );
00363 GDALRasterBand *GetRasterBand( int );
00364
00365 virtual void FlushCache(void);
00366
00367 virtual const char *GetProjectionRef(void);
00368 virtual CPLErr SetProjection( const char * );
00369
00370 virtual CPLErr GetGeoTransform( double * );
00371 virtual CPLErr SetGeoTransform( double * );
00372
00373 virtual CPLErr AddBand( GDALDataType eType,
00374 char **papszOptions=NULL );
00375
00376 virtual void *GetInternalHandle( const char * );
00377 virtual GDALDriver *GetDriver(void);
00378 virtual char **GetFileList(void);
00379
00380 virtual const char* GetDriverName();
00381
00382 virtual int GetGCPCount();
00383 virtual const char *GetGCPProjection();
00384 virtual const GDAL_GCP *GetGCPs();
00385 virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
00386 const char *pszGCPProjection );
00387
00388 virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
00389 int nBufXSize, int nBufYSize,
00390 GDALDataType eDT,
00391 int nBandCount, int *panBandList,
00392 char **papszOptions );
00393
00394 virtual CPLErr CreateMaskBand( int nFlagsIn );
00395
00396 virtual GDALAsyncReader*
00397 BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize,
00398 void *pBuf, int nBufXSize, int nBufYSize,
00399 GDALDataType eBufType,
00400 int nBandCount, int* panBandMap,
00401 int nPixelSpace, int nLineSpace, int nBandSpace,
00402 char **papszOptions);
00403 virtual void EndAsyncReader(GDALAsyncReader *);
00404
00405 CPLErr RasterIO( GDALRWFlag, int, int, int, int,
00406 void *, int, int, GDALDataType,
00407 int, int *, GSpacing, GSpacing, GSpacing,
00408 GDALRasterIOExtraArg* psExtraArg
00409 #ifndef DOXYGEN_SKIP
00410 OPTIONAL_OUTSIDE_GDAL(NULL)
00411 #endif
00412 );
00413
00414 int Reference();
00415 int Dereference();
00416 GDALAccess GetAccess() { return eAccess; }
00417
00418 int GetShared();
00419 void MarkAsShared();
00420
00421 void MarkSuppressOnClose() { bSuppressOnClose = TRUE; }
00422
00423 char **GetOpenOptions() { return papszOpenOptions; }
00424
00425 static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
00426
00427 CPLErr BuildOverviews( const char *, int, int *,
00428 int, int *, GDALProgressFunc, void * );
00429
00430 void ReportError(CPLErr eErrClass, int err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
00431
00432 private:
00433 CPLMutex *m_hMutex;
00434
00435 OGRLayer* BuildLayerFromSelectInfo(swq_select* psSelectInfo,
00436 OGRGeometry *poSpatialFilter,
00437 const char *pszDialect,
00438 swq_select_parse_options* poSelectParseOptions);
00439
00440 public:
00441
00442 virtual int GetLayerCount();
00443 virtual OGRLayer *GetLayer(int);
00444 virtual OGRLayer *GetLayerByName(const char *);
00445 virtual OGRErr DeleteLayer(int);
00446
00447 virtual int TestCapability( const char * );
00448
00449 virtual OGRLayer *CreateLayer( const char *pszName,
00450 OGRSpatialReference *poSpatialRef = NULL,
00451 OGRwkbGeometryType eGType = wkbUnknown,
00452 char ** papszOptions = NULL );
00453 virtual OGRLayer *CopyLayer( OGRLayer *poSrcLayer,
00454 const char *pszNewName,
00455 char **papszOptions = NULL );
00456
00457 virtual OGRStyleTable *GetStyleTable();
00458 virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
00459
00460 virtual void SetStyleTable(OGRStyleTable *poStyleTable);
00461
00462 virtual OGRLayer * ExecuteSQL( const char *pszStatement,
00463 OGRGeometry *poSpatialFilter,
00464 const char *pszDialect );
00465 virtual void ReleaseResultSet( OGRLayer * poResultsSet );
00466
00467 int GetRefCount() const;
00468 int GetSummaryRefCount() const;
00469 OGRErr Release();
00470
00471 virtual OGRErr StartTransaction(int bForce=FALSE);
00472 virtual OGRErr CommitTransaction();
00473 virtual OGRErr RollbackTransaction();
00474
00475 static int IsGenericSQLDialect(const char* pszDialect);
00476
00477
00478 GDALSQLParseInfo* BuildParseInfo(swq_select* psSelectInfo,
00479 swq_select_parse_options* poSelectParseOptions);
00480 void DestroyParseInfo(GDALSQLParseInfo* psParseInfo );
00481 OGRLayer * ExecuteSQL( const char *pszStatement,
00482 OGRGeometry *poSpatialFilter,
00483 const char *pszDialect,
00484 swq_select_parse_options* poSelectParseOptions);
00485
00486 protected:
00487
00488 virtual OGRLayer *ICreateLayer( const char *pszName,
00489 OGRSpatialReference *poSpatialRef = NULL,
00490 OGRwkbGeometryType eGType = wkbUnknown,
00491 char ** papszOptions = NULL );
00492
00493 OGRErr ProcessSQLCreateIndex( const char * );
00494 OGRErr ProcessSQLDropIndex( const char * );
00495 OGRErr ProcessSQLDropTable( const char * );
00496 OGRErr ProcessSQLAlterTableAddColumn( const char * );
00497 OGRErr ProcessSQLAlterTableDropColumn( const char * );
00498 OGRErr ProcessSQLAlterTableAlterColumn( const char * );
00499 OGRErr ProcessSQLAlterTableRenameColumn( const char * );
00500
00501 OGRStyleTable *m_poStyleTable;
00502 };
00503
00504
00505
00506
00507
00509
00510 class CPL_DLL GDALRasterBlock
00511 {
00512 GDALDataType eType;
00513
00514 int bDirty;
00515 int nLockCount;
00516
00517 int nXOff;
00518 int nYOff;
00519
00520 int nXSize;
00521 int nYSize;
00522
00523 void *pData;
00524
00525 GDALRasterBand *poBand;
00526
00527 GDALRasterBlock *poNext;
00528 GDALRasterBlock *poPrevious;
00529
00530 int bMustDetach;
00531
00532 void Touch_unlocked( void );
00533 void Detach_unlocked( void );
00534
00535 public:
00536 GDALRasterBlock( GDALRasterBand *, int, int );
00537 virtual ~GDALRasterBlock();
00538
00539 CPLErr Internalize( void );
00540 void Touch( void );
00541 void MarkDirty( void );
00542 void MarkClean( void );
00543 void AddLock( void ) { nLockCount++; }
00544 void DropLock( void ) { nLockCount--; }
00545 void Detach();
00546
00547 CPLErr Write();
00548
00549 GDALDataType GetDataType() { return eType; }
00550 int GetXOff() { return nXOff; }
00551 int GetYOff() { return nYOff; }
00552 int GetXSize() { return nXSize; }
00553 int GetYSize() { return nYSize; }
00554 int GetDirty() { return bDirty; }
00555 int GetLockCount() { return nLockCount; }
00556
00557 void *GetDataRef( void ) { return pData; }
00558 int GetBlockSize() { return nXSize * nYSize * (GDALGetDataTypeSize(eType) / 8); }
00559
00562 GDALRasterBand *GetBand() { return poBand; }
00563
00564 static void FlushDirtyBlocks();
00565 static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE);
00566 static void Verify();
00567
00568 static int SafeLockBlock( GDALRasterBlock ** );
00569
00570
00571 static void DestroyRBMutex();
00572 };
00573
00574
00575
00576
00577
00580 class CPL_DLL GDALColorTable
00581 {
00582 GDALPaletteInterp eInterp;
00583
00584 std::vector<GDALColorEntry> aoEntries;
00585
00586 public:
00587 GDALColorTable( GDALPaletteInterp = GPI_RGB );
00588 ~GDALColorTable();
00589
00590 GDALColorTable *Clone() const;
00591 int IsSame(const GDALColorTable* poOtherCT) const;
00592
00593 GDALPaletteInterp GetPaletteInterpretation() const;
00594
00595 int GetColorEntryCount() const;
00596 const GDALColorEntry *GetColorEntry( int ) const;
00597 int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
00598 void SetColorEntry( int, const GDALColorEntry * );
00599 int CreateColorRamp( int, const GDALColorEntry * ,
00600 int, const GDALColorEntry * );
00601 };
00602
00603
00604
00605
00606
00608
00609 class CPL_DLL GDALRasterBand : public GDALMajorObject
00610 {
00611 private:
00612 CPLErr eFlushBlockErr;
00613
00614 void SetFlushBlockErr( CPLErr eErr );
00615
00616 friend class GDALRasterBlock;
00617 CPLErr UnreferenceBlock( int nXBlockOff, int nYBlockOff );
00618
00619 protected:
00620 GDALDataset *poDS;
00621 int nBand;
00622
00623 int nRasterXSize;
00624 int nRasterYSize;
00625
00626 GDALDataType eDataType;
00627 GDALAccess eAccess;
00628
00629
00630 int nBlockXSize;
00631 int nBlockYSize;
00632 int nBlocksPerRow;
00633 int nBlocksPerColumn;
00634
00635 int bSubBlockingActive;
00636 int nSubBlocksPerRow;
00637 int nSubBlocksPerColumn;
00638 GDALRasterBlock **papoBlocks;
00639
00640 int nBlockReads;
00641 int bForceCachedIO;
00642
00643 GDALRasterBand *poMask;
00644 bool bOwnMask;
00645 int nMaskFlags;
00646
00647 void InvalidateMaskBand();
00648
00649 friend class GDALDataset;
00650 friend class GDALProxyRasterBand;
00651 friend class GDALDefaultOverviews;
00652
00653 CPLErr RasterIOResampled( GDALRWFlag, int, int, int, int,
00654 void *, int, int, GDALDataType,
00655 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg );
00656
00657 int EnterReadWrite(GDALRWFlag eRWFlag);
00658 void LeaveReadWrite();
00659
00660 protected:
00661 virtual CPLErr IReadBlock( int, int, void * ) = 0;
00662 virtual CPLErr IWriteBlock( int, int, void * );
00663
00664 #ifdef DETECT_OLD_IRASTERIO
00665 virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int,
00666 void *, int, int, GDALDataType,
00667 int, int ) {};
00668 #endif
00669
00670 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00671 void *, int, int, GDALDataType,
00672 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg );
00673 CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
00674 void *, int, int, GDALDataType,
00675 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg );
00676
00677 int InitBlockInfo();
00678
00679 CPLErr AdoptBlock( int, int, GDALRasterBlock * );
00680 GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
00681
00682 public:
00683 GDALRasterBand();
00684
00685 virtual ~GDALRasterBand();
00686
00687 int GetXSize();
00688 int GetYSize();
00689 int GetBand();
00690 GDALDataset*GetDataset();
00691
00692 GDALDataType GetRasterDataType( void );
00693 void GetBlockSize( int *, int * );
00694 GDALAccess GetAccess();
00695
00696 CPLErr RasterIO( GDALRWFlag, int, int, int, int,
00697 void *, int, int, GDALDataType,
00698 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg
00699 #ifndef DOXYGEN_SKIP
00700 OPTIONAL_OUTSIDE_GDAL(NULL)
00701 #endif
00702 );
00703 CPLErr ReadBlock( int, int, void * );
00704
00705 CPLErr WriteBlock( int, int, void * );
00706
00707 GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
00708 int bJustInitialize = FALSE );
00709 CPLErr FlushBlock( int = -1, int = -1, int bWriteDirtyBlock = TRUE );
00710
00711 unsigned char* GetIndexColorTranslationTo( GDALRasterBand* poReferenceBand,
00712 unsigned char* pTranslationTable = NULL,
00713 int* pApproximateMatching = NULL);
00714
00715
00716
00717 virtual CPLErr FlushCache();
00718 virtual char **GetCategoryNames();
00719 virtual double GetNoDataValue( int *pbSuccess = NULL );
00720 virtual double GetMinimum( int *pbSuccess = NULL );
00721 virtual double GetMaximum(int *pbSuccess = NULL );
00722 virtual double GetOffset( int *pbSuccess = NULL );
00723 virtual double GetScale( int *pbSuccess = NULL );
00724 virtual const char *GetUnitType();
00725 virtual GDALColorInterp GetColorInterpretation();
00726 virtual GDALColorTable *GetColorTable();
00727 virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
00728
00729 virtual CPLErr SetCategoryNames( char ** );
00730 virtual CPLErr SetNoDataValue( double );
00731 virtual CPLErr SetColorTable( GDALColorTable * );
00732 virtual CPLErr SetColorInterpretation( GDALColorInterp );
00733 virtual CPLErr SetOffset( double );
00734 virtual CPLErr SetScale( double );
00735 virtual CPLErr SetUnitType( const char * );
00736
00737 virtual CPLErr GetStatistics( int bApproxOK, int bForce,
00738 double *pdfMin, double *pdfMax,
00739 double *pdfMean, double *padfStdDev );
00740 virtual CPLErr ComputeStatistics( int bApproxOK,
00741 double *pdfMin, double *pdfMax,
00742 double *pdfMean, double *pdfStdDev,
00743 GDALProgressFunc, void *pProgressData );
00744 virtual CPLErr SetStatistics( double dfMin, double dfMax,
00745 double dfMean, double dfStdDev );
00746 virtual CPLErr ComputeRasterMinMax( int, double* );
00747
00748 virtual int HasArbitraryOverviews();
00749 virtual int GetOverviewCount();
00750 virtual GDALRasterBand *GetOverview(int);
00751 virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig );
00752 virtual CPLErr BuildOverviews( const char *, int, int *,
00753 GDALProgressFunc, void * );
00754
00755 virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
00756 int nBufXSize, int nBufYSize,
00757 GDALDataType eDT, char **papszOptions );
00758
00759 virtual CPLErr GetHistogram( double dfMin, double dfMax,
00760 int nBuckets, GUIntBig * panHistogram,
00761 int bIncludeOutOfRange, int bApproxOK,
00762 GDALProgressFunc, void *pProgressData );
00763
00764 virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
00765 int *pnBuckets, GUIntBig ** ppanHistogram,
00766 int bForce,
00767 GDALProgressFunc, void *pProgressData);
00768 virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
00769 int nBuckets, GUIntBig *panHistogram );
00770
00771 virtual GDALRasterAttributeTable *GetDefaultRAT();
00772 virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
00773
00774 virtual GDALRasterBand *GetMaskBand();
00775 virtual int GetMaskFlags();
00776 virtual CPLErr CreateMaskBand( int nFlagsIn );
00777
00778 virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
00779 int *pnPixelSpace,
00780 GIntBig *pnLineSpace,
00781 char **papszOptions );
00782
00783 void ReportError(CPLErr eErrClass, int err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
00784 };
00785
00786
00787
00788
00789
00790 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
00791 {
00792 protected:
00793 virtual CPLErr IReadBlock( int, int, void * );
00794
00795 public:
00796 GDALAllValidMaskBand( GDALRasterBand * );
00797 virtual ~GDALAllValidMaskBand();
00798
00799 virtual GDALRasterBand *GetMaskBand();
00800 virtual int GetMaskFlags();
00801 };
00802
00803
00804
00805
00806
00807 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
00808 {
00809 double dfNoDataValue;
00810 GDALRasterBand *poParent;
00811
00812 protected:
00813 virtual CPLErr IReadBlock( int, int, void * );
00814 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00815 void *, int, int, GDALDataType,
00816 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg );
00817
00818 public:
00819 GDALNoDataMaskBand( GDALRasterBand * );
00820 virtual ~GDALNoDataMaskBand();
00821 };
00822
00823
00824
00825
00826
00827 class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
00828 {
00829 double *padfNodataValues;
00830
00831 protected:
00832 virtual CPLErr IReadBlock( int, int, void * );
00833
00834 public:
00835 GDALNoDataValuesMaskBand( GDALDataset * );
00836 virtual ~GDALNoDataValuesMaskBand();
00837 };
00838
00839
00840
00841
00842
00843 class GDALRescaledAlphaBand : public GDALRasterBand
00844 {
00845 GDALRasterBand *poParent;
00846 void *pTemp;
00847
00848 protected:
00849 virtual CPLErr IReadBlock( int, int, void * );
00850 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00851 void *, int, int, GDALDataType,
00852 GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg );
00853
00854 public:
00855 GDALRescaledAlphaBand( GDALRasterBand * );
00856 virtual ~GDALRescaledAlphaBand();
00857 };
00858
00859
00860
00861
00862
00863
00875 class CPL_DLL GDALDriver : public GDALMajorObject
00876 {
00877 public:
00878 GDALDriver();
00879 ~GDALDriver();
00880
00881 virtual CPLErr SetMetadataItem( const char * pszName,
00882 const char * pszValue,
00883 const char * pszDomain = "" );
00884
00885
00886
00887
00888 GDALDataset *Create( const char * pszName,
00889 int nXSize, int nYSize, int nBands,
00890 GDALDataType eType, char ** papszOptions ) CPL_WARN_UNUSED_RESULT;
00891
00892 CPLErr Delete( const char * pszName );
00893 CPLErr Rename( const char * pszNewName,
00894 const char * pszOldName );
00895 CPLErr CopyFiles( const char * pszNewName,
00896 const char * pszOldName );
00897
00898 GDALDataset *CreateCopy( const char *, GDALDataset *,
00899 int, char **,
00900 GDALProgressFunc pfnProgress,
00901 void * pProgressData ) CPL_WARN_UNUSED_RESULT;
00902
00903
00904
00905
00906
00907
00908 GDALDataset *(*pfnOpen)( GDALOpenInfo * );
00909
00910 GDALDataset *(*pfnCreate)( const char * pszName,
00911 int nXSize, int nYSize, int nBands,
00912 GDALDataType eType,
00913 char ** papszOptions );
00914
00915 CPLErr (*pfnDelete)( const char * pszName );
00916
00917 GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
00918 int, char **,
00919 GDALProgressFunc pfnProgress,
00920 void * pProgressData );
00921
00922 void *pDriverData;
00923
00924 void (*pfnUnloadDriver)(GDALDriver *);
00925
00926
00927
00928
00929
00930 int (*pfnIdentify)( GDALOpenInfo * );
00931
00932 CPLErr (*pfnRename)( const char * pszNewName,
00933 const char * pszOldName );
00934 CPLErr (*pfnCopyFiles)( const char * pszNewName,
00935 const char * pszOldName );
00936
00937
00938 GDALDataset *(*pfnOpenWithDriverArg)( GDALDriver*, GDALOpenInfo * );
00939 GDALDataset *(*pfnCreateVectorOnly)( GDALDriver*,
00940 const char * pszName,
00941 char ** papszOptions );
00942 CPLErr (*pfnDeleteDataSource)( GDALDriver*,
00943 const char * pszName );
00944
00945
00946
00947
00948 GDALDataset *DefaultCreateCopy( const char *, GDALDataset *,
00949 int, char **,
00950 GDALProgressFunc pfnProgress,
00951 void * pProgressData ) CPL_WARN_UNUSED_RESULT;
00952 static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
00953 GDALDataset *poDstDS,
00954 int bStrict );
00955 static CPLErr QuietDelete( const char * pszName );
00956
00957 CPLErr DefaultRename( const char * pszNewName,
00958 const char * pszOldName );
00959 CPLErr DefaultCopyFiles( const char * pszNewName,
00960 const char * pszOldName );
00961 };
00962
00963
00964
00965
00966
00974 class CPL_DLL GDALDriverManager : public GDALMajorObject
00975 {
00976 int nDrivers;
00977 GDALDriver **papoDrivers;
00978 std::map<CPLString, GDALDriver*> oMapNameToDrivers;
00979
00980 GDALDriver *GetDriver_unlocked( int iDriver )
00981 { return (iDriver >= 0 && iDriver < nDrivers) ? papoDrivers[iDriver] : NULL; }
00982
00983 GDALDriver *GetDriverByName_unlocked( const char * pszName )
00984 { return oMapNameToDrivers[CPLString(pszName).toupper()]; }
00985
00986 public:
00987 GDALDriverManager();
00988 ~GDALDriverManager();
00989
00990 int GetDriverCount( void );
00991 GDALDriver *GetDriver( int );
00992 GDALDriver *GetDriverByName( const char * );
00993
00994 int RegisterDriver( GDALDriver * );
00995 void DeregisterDriver( GDALDriver * );
00996
00997 void AutoLoadDrivers();
00998 void AutoSkipDrivers();
00999 };
01000
01001 CPL_C_START
01002 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
01003 CPL_C_END
01004
01005
01006
01007
01008
01014 class CPL_DLL GDALAsyncReader
01015 {
01016 protected:
01017 GDALDataset* poDS;
01018 int nXOff;
01019 int nYOff;
01020 int nXSize;
01021 int nYSize;
01022 void * pBuf;
01023 int nBufXSize;
01024 int nBufYSize;
01025 GDALDataType eBufType;
01026 int nBandCount;
01027 int* panBandMap;
01028 int nPixelSpace;
01029 int nLineSpace;
01030 int nBandSpace;
01031
01032 public:
01033 GDALAsyncReader();
01034 virtual ~GDALAsyncReader();
01035
01036 GDALDataset* GetGDALDataset() {return poDS;}
01037 int GetXOffset() {return nXOff;}
01038 int GetYOffset() {return nYOff;}
01039 int GetXSize() {return nXSize;}
01040 int GetYSize() {return nYSize;}
01041 void * GetBuffer() {return pBuf;}
01042 int GetBufferXSize() {return nBufXSize;}
01043 int GetBufferYSize() {return nBufYSize;}
01044 GDALDataType GetBufferType() {return eBufType;}
01045 int GetBandCount() {return nBandCount;}
01046 int* GetBandMap() {return panBandMap;}
01047 int GetPixelSpace() {return nPixelSpace;}
01048 int GetLineSpace() {return nLineSpace;}
01049 int GetBandSpace() {return nBandSpace;}
01050
01051 virtual GDALAsyncStatusType
01052 GetNextUpdatedRegion(double dfTimeout,
01053 int* pnBufXOff, int* pnBufYOff,
01054 int* pnBufXSize, int* pnBufYSize) = 0;
01055 virtual int LockBuffer( double dfTimeout = -1.0 );
01056 virtual void UnlockBuffer();
01057 };
01058
01059
01060
01061
01062
01063
01064 CPLErr
01065 GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands,
01066 int nOverviews,
01067 GDALRasterBand*** papapoOverviewBands,
01068 const char * pszResampling,
01069 GDALProgressFunc pfnProgress, void * pProgressData );
01070
01071 typedef CPLErr (*GDALResampleFunction)
01072 ( double dfXRatioDstToSrc,
01073 double dfYRatioDstToSrc,
01074 double dfSrcXDelta,
01075 double dfSrcYDelta,
01076 GDALDataType eWrkDataType,
01077 void * pChunk,
01078 GByte * pabyChunkNodataMask,
01079 int nChunkXOff, int nChunkXSize,
01080 int nChunkYOff, int nChunkYSize,
01081 int nDstXOff, int nDstXOff2,
01082 int nDstYOff, int nDstYOff2,
01083 GDALRasterBand * poOverview,
01084 const char * pszResampling,
01085 int bHasNoData, float fNoDataValue,
01086 GDALColorTable* poColorTable,
01087 GDALDataType eSrcDataType);
01088
01089 GDALResampleFunction GDALGetResampleFunction(const char* pszResampling,
01090 int* pnRadius);
01091 GDALDataType GDALGetOvrWorkDataType(const char* pszResampling,
01092 GDALDataType eSrcDataType);
01093
01094 CPL_C_START
01095
01096 #ifndef WIN32CE
01097
01098 CPLErr CPL_DLL
01099 HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
01100 GDALDataset **ppoDS,
01101 int nBands, int *panBandList,
01102 int nNewOverviews, int *panNewOverviewList,
01103 const char *pszResampling,
01104 GDALProgressFunc pfnProgress,
01105 void *pProgressData );
01106
01107 #endif
01108
01109 CPLErr CPL_DLL
01110 GTIFFBuildOverviews( const char * pszFilename,
01111 int nBands, GDALRasterBand **papoBandList,
01112 int nOverviews, int * panOverviewList,
01113 const char * pszResampling,
01114 GDALProgressFunc pfnProgress, void * pProgressData );
01115
01116 CPLErr CPL_DLL
01117 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
01118 const char * pszResampling,
01119 int nOverviews, int * panOverviewList,
01120 int nBands, int * panBandList,
01121 GDALProgressFunc pfnProgress, void * pProgressData);
01122
01123 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
01124 int &nXOff, int &nYOff,
01125 int &nXSize, int &nYSize,
01126 int nBufXSize, int nBufYSize) CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead");
01127 int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand* poBand,
01128 int &nXOff, int &nYOff,
01129 int &nXSize, int &nYSize,
01130 int nBufXSize, int nBufYSize,
01131 GDALRasterIOExtraArg* psExtraArg);
01132
01133 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize ) CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead");
01134 int CPL_DLL GDALOvLevelAdjust2( int nOvLevel, int nXSize, int nYSize );
01135 int CPL_DLL GDALComputeOvFactor( int nOvrXSize, int nRasterXSize,
01136 int nOvrYSize, int nRasterYSize );
01137
01138 GDALDataset CPL_DLL *
01139 GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
01140 GDALDataset *poDependentDS );
01141
01142
01143
01144
01145
01146 CPLErr CPL_DLL GDALParseGMLCoverage( CPLXMLNode *psTree,
01147 int *pnXSize, int *pnYSize,
01148 double *padfGeoTransform,
01149 char **ppszProjection );
01150
01151
01152
01153
01154
01155 int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize );
01156 int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed );
01157
01158
01159
01160
01161 #define ARE_REAL_EQUAL(dfVal1, dfVal2) \
01162 (dfVal1 == dfVal2 || fabs(dfVal1 - dfVal2) < 1e-10 || (dfVal2 != 0 && fabs(1 - dfVal1 / dfVal2) < 1e-10 ))
01163
01164
01165
01166
01167 int CPL_DLL GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension,
01168 double *padfGeoTransform, char** papszSiblingFiles,
01169 char** ppszWorldFileNameOut);
01170 int GDALReadTabFile2( const char * pszBaseFilename,
01171 double *padfGeoTransform, char **ppszWKT,
01172 int *pnGCPCount, GDAL_GCP **ppasGCPs,
01173 char** papszSiblingFiles, char** ppszTabFileNameOut );
01174
01175 void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg* psDestArg,
01176 GDALRasterIOExtraArg* psSrcArg);
01177
01178 CPL_C_END
01179
01180 void GDALNullifyOpenDatasetsList();
01181 CPLMutex** GDALGetphDMMutex();
01182 CPLMutex** GDALGetphDLMutex();
01183 void GDALNullifyProxyPoolSingleton();
01184 GDALDriver* GDALGetAPIPROXYDriver();
01185 void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
01186 GIntBig GDALGetResponsiblePIDForCurrentThread();
01187
01188 CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt,
01189 char **papszSiblingFiles, int nFlags );
01190
01191 CPLErr EXIFExtractMetadata(char**& papszMetadata,
01192 void *fpL, int nOffset,
01193 int bSwabflag, int nTIFFHEADER,
01194 int& nExifOffset, int& nInterOffset, int& nGPSOffset);
01195
01196 int GDALValidateOpenOptions( GDALDriverH hDriver,
01197 const char* const* papszOptionOptions);
01198 int GDALValidateOptions( const char* pszOptionList,
01199 const char* const* papszOptionsToValidate,
01200 const char* pszErrorMessageOptionType,
01201 const char* pszErrorMessageContainerName);
01202
01203 GDALRIOResampleAlg GDALRasterIOGetResampleAlg(const char* pszResampling);
01204
01205 void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg* psExtraArg,
01206 int nXSize, int nYSize,
01207 int nBufXSize, int nBufYSize);
01208
01209
01210 GDALDataset CPL_DLL* GDALCreateOverviewDataset(GDALDataset* poDS, int nOvrLevel,
01211 int bThisLevelOnly, int bOwnDS);
01212
01213 #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) )
01214
01215
01216
01217 #define GDALSTAT_APPROX_NUMSAMPLES 2500
01218
01219 CPL_C_START
01220
01221
01222 void GDALSerializeGCPListToXML( CPLXMLNode* psParentNode,
01223 GDAL_GCP* pasGCPList,
01224 int nGCPCount,
01225 const char* pszGCPProjection );
01226 void GDALDeserializeGCPListFromXML( CPLXMLNode* psGCPList,
01227 GDAL_GCP** ppasGCPList,
01228 int* pnGCPCount,
01229 char** ppszGCPProjection );
01230 CPL_C_END
01231
01232 void GDALSerializeOpenOptionsToXML( CPLXMLNode* psParentNode, char** papszOpenOptions);
01233 char** GDALDeserializeOpenOptionsFromXML( CPLXMLNode* psParentNode );
01234
01235 int GDALCanFileAcceptSidecarFile(const char* pszFilename);
01236
01237 #endif