GDAL
gdal_priv.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: gdal_priv.h 35549 2016-09-29 22:56:53Z rouault $
3  *
4  * Name: gdal_priv.h
5  * Project: GDAL Core
6  * Purpose: GDAL Core C++/Private declarations.
7  * Author: Frank Warmerdam, warmerdam@pobox.com
8  *
9  ******************************************************************************
10  * Copyright (c) 1998, Frank Warmerdam
11  * Copyright (c) 2007-2014, Even Rouault <even dot rouault at mines-paris dot org>
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a
14  * copy of this software and associated documentation files (the "Software"),
15  * to deal in the Software without restriction, including without limitation
16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  * and/or sell copies of the Software, and to permit persons to whom the
18  * Software is furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included
21  * in all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29  * DEALINGS IN THE SOFTWARE.
30  ****************************************************************************/
31 
32 #ifndef GDAL_PRIV_H_INCLUDED
33 #define GDAL_PRIV_H_INCLUDED
34 
41 /* -------------------------------------------------------------------- */
42 /* Predeclare various classes before pulling in gdal.h, the */
43 /* public declarations. */
44 /* -------------------------------------------------------------------- */
45 class GDALMajorObject;
46 class GDALDataset;
47 class GDALRasterBand;
48 class GDALDriver;
50 class GDALProxyDataset;
52 class GDALAsyncReader;
53 
54 /* -------------------------------------------------------------------- */
55 /* Pull in the public declarations. This gets the C apis, and */
56 /* also various constants. However, we will still get to */
57 /* provide the real class definitions for the GDAL classes. */
58 /* -------------------------------------------------------------------- */
59 
60 #include "gdal.h"
61 #include "gdal_frmts.h"
62 #include "cpl_vsi.h"
63 #include "cpl_conv.h"
64 #include "cpl_string.h"
65 #include "cpl_minixml.h"
66 #include "cpl_multiproc.h"
67 #include "cpl_atomic_ops.h"
68 #include <vector>
69 #include <map>
70 #include "ogr_core.h"
71 
72 #define GMO_VALID 0x0001
73 #define GMO_IGNORE_UNIMPLEMENTED 0x0002
74 #define GMO_SUPPORT_MD 0x0004
75 #define GMO_SUPPORT_MDMD 0x0008
76 #define GMO_MD_DIRTY 0x0010
77 #define GMO_PAM_CLASS 0x0020
78 
79 /************************************************************************/
80 /* GDALMultiDomainMetadata */
81 /************************************************************************/
82 
84 {
85 private:
86  char **papszDomainList;
87  CPLStringList **papoMetadataLists;
88 
89 public:
92 
93  int XMLInit( CPLXMLNode *psMetadata, int bMerge );
94  CPLXMLNode *Serialize();
95 
96  char **GetDomainList() { return papszDomainList; }
97 
98  char **GetMetadata( const char * pszDomain = "" );
99  CPLErr SetMetadata( char ** papszMetadata,
100  const char * pszDomain = "" );
101  const char *GetMetadataItem( const char * pszName,
102  const char * pszDomain = "" );
103  CPLErr SetMetadataItem( const char * pszName,
104  const char * pszValue,
105  const char * pszDomain = "" );
106 
107  void Clear();
108 
109  private:
110  CPL_DISALLOW_COPY_ASSIGN(GDALMultiDomainMetadata);
111 };
112 
113 /* ******************************************************************** */
114 /* GDALMajorObject */
115 /* */
116 /* Base class providing metadata, description and other */
117 /* services shared by major objects. */
118 /* ******************************************************************** */
119 
121 
122 class CPL_DLL GDALMajorObject
123 {
124  protected:
125  int nFlags; // GMO_* flags.
126  CPLString sDescription;
128 
129  char **BuildMetadataDomainList(char** papszList, int bCheckNonEmpty, ...) CPL_NULL_TERMINATED;
130 
131  public:
132  GDALMajorObject();
133  virtual ~GDALMajorObject();
134 
135  int GetMOFlags();
136  void SetMOFlags(int nFlagsIn);
137 
138  virtual const char *GetDescription() const;
139  virtual void SetDescription( const char * );
140 
141  virtual char **GetMetadataDomainList();
142 
143  virtual char **GetMetadata( const char * pszDomain = "" );
144  virtual CPLErr SetMetadata( char ** papszMetadata,
145  const char * pszDomain = "" );
146  virtual const char *GetMetadataItem( const char * pszName,
147  const char * pszDomain = "" );
148  virtual CPLErr SetMetadataItem( const char * pszName,
149  const char * pszValue,
150  const char * pszDomain = "" );
151 };
152 
153 /* ******************************************************************** */
154 /* GDALDefaultOverviews */
155 /* ******************************************************************** */
156 class CPL_DLL GDALDefaultOverviews
157 {
158  friend class GDALDataset;
159 
160  GDALDataset *poDS;
161  GDALDataset *poODS;
162 
163  CPLString osOvrFilename;
164 
165  int bOvrIsAux;
166 
167  int bCheckedForMask;
168  int bOwnMaskDS;
169  GDALDataset *poMaskDS;
170 
171  // for "overview datasets" we record base level info so we can
172  // find our way back to get overview masks.
173  GDALDataset *poBaseDS;
174 
175  // Stuff for deferred initialize/overviewscans...
176  bool bCheckedForOverviews;
177  void OverviewScan();
178  char *pszInitName;
179  int bInitNameIsOVR;
180  char **papszInitSiblingFiles;
181 
182  public:
185 
186  void Initialize( GDALDataset *poDSIn, const char *pszName = NULL,
187  char **papszSiblingFiles = NULL,
188  int bNameIsOVR = FALSE );
189 
190  void TransferSiblingFiles(char** papszSiblingFiles);
191 
192  int IsInitialized();
193 
195 
196  // Overview Related
197 
198  int GetOverviewCount(int);
199  GDALRasterBand *GetOverview(int,int);
200 
201  CPLErr BuildOverviews( const char * pszBasename,
202  const char * pszResampling,
203  int nOverviews, int * panOverviewList,
204  int nBands, int * panBandList,
205  GDALProgressFunc pfnProgress,
206  void *pProgressData );
207 
208  CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile,
209  const char * pszResampling,
210  int nOverviews, int * panOverviewList,
211  int nBands, int * panBandList,
212  GDALProgressFunc pfnProgress,
213  void *pProgressData );
214 
215  CPLErr CleanOverviews();
216 
217  // Mask Related
218 
219  CPLErr CreateMaskBand( int nFlags, int nBand = -1 );
220  GDALRasterBand *GetMaskBand( int nBand );
221  int GetMaskFlags( int nBand );
222 
223  int HaveMaskFile( char **papszSiblings = NULL,
224  const char *pszBasename = NULL );
225 
226  char** GetSiblingFiles() { return papszInitSiblingFiles; }
227 
228  private:
229  CPL_DISALLOW_COPY_ASSIGN(GDALDefaultOverviews);
230 };
231 
232 /* ******************************************************************** */
233 /* GDALOpenInfo */
234 /* */
235 /* Structure of data about dataset for open functions. */
236 /* ******************************************************************** */
237 
238 class CPL_DLL GDALOpenInfo
239 {
240  bool bHasGotSiblingFiles;
241  char **papszSiblingFiles;
242  int nHeaderBytesTried;
243 
244  public:
245  GDALOpenInfo( const char * pszFile, int nOpenFlagsIn,
246  char **papszSiblingFiles = NULL );
247  ~GDALOpenInfo( void );
248 
249  char *pszFilename;
250  char** papszOpenOptions;
251 
252  GDALAccess eAccess;
253  int nOpenFlags;
254 
255  int bStatOK;
256  int bIsDirectory;
257 
258  VSILFILE *fpL;
259 
260  int nHeaderBytes;
261  GByte *pabyHeader;
262 
263  int TryToIngest(int nBytes);
264  char **GetSiblingFiles();
265  char **StealSiblingFiles();
266  bool AreSiblingFilesLoaded() const;
267 
268  private:
269  CPL_DISALLOW_COPY_ASSIGN(GDALOpenInfo);
270 };
271 
272 /* ******************************************************************** */
273 /* GDALDataset */
274 /* ******************************************************************** */
275 
276 class OGRLayer;
277 class OGRGeometry;
278 class OGRSpatialReference;
279 class OGRStyleTable;
280 class swq_select;
282 typedef struct GDALSQLParseInfo GDALSQLParseInfo;
283 
284 #ifdef DETECT_OLD_IRASTERIO
285 typedef void signature_changed;
286 #endif
287 
288 #ifdef GDAL_COMPILATION
289 #define OPTIONAL_OUTSIDE_GDAL(val)
290 #else
291 #define OPTIONAL_OUTSIDE_GDAL(val) = val
292 #endif
293 
295 
296 class CPL_DLL GDALDataset : public GDALMajorObject
297 {
298  friend GDALDatasetH CPL_STDCALL GDALOpenEx( const char* pszFilename,
299  unsigned int nOpenFlags,
300  const char* const* papszAllowedDrivers,
301  const char* const* papszOpenOptions,
302  const char* const* papszSiblingFiles );
303  friend void CPL_STDCALL GDALClose( GDALDatasetH hDS );
304 
305  friend class GDALDriver;
306  friend class GDALDefaultOverviews;
307  friend class GDALProxyDataset;
308  friend class GDALDriverManager;
309 
310  void AddToDatasetOpenList();
311 
312  void Init(int bForceCachedIO);
313 
314  protected:
315  GDALDriver *poDriver;
316  GDALAccess eAccess;
317 
318  // Stored raster information.
319  int nRasterXSize;
320  int nRasterYSize;
321  int nBands;
322  GDALRasterBand **papoBands;
323 
324  int nOpenFlags;
325 
326  int nRefCount;
327  GByte bForceCachedIO;
328  GByte bShared;
329  GByte bIsInternal;
330  GByte bSuppressOnClose;
331 
332  GDALDataset(void);
333  GDALDataset(int bForceCachedIO);
334 
335  void RasterInitialize( int, int );
336  void SetBand( int, GDALRasterBand * );
337 
338  GDALDefaultOverviews oOvManager;
339 
340  virtual CPLErr IBuildOverviews( const char *, int, int *,
341  int, int *, GDALProgressFunc, void * );
342 
343 #ifdef DETECT_OLD_IRASTERIO
344  virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int,
345  void *, int, int, GDALDataType,
346  int, int *, int, int, int ) {};
347 #endif
348 
349  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
350  void *, int, int, GDALDataType,
351  int, int *, GSpacing, GSpacing, GSpacing,
352  GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
353 
354  CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
355  void *, int, int, GDALDataType,
356  int, int *, GSpacing, GSpacing, GSpacing,
357  GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
358  void BlockBasedFlushCache();
359 
360  CPLErr BandBasedRasterIO( GDALRWFlag eRWFlag,
361  int nXOff, int nYOff, int nXSize, int nYSize,
362  void * pData, int nBufXSize, int nBufYSize,
363  GDALDataType eBufType,
364  int nBandCount, int *panBandMap,
365  GSpacing nPixelSpace, GSpacing nLineSpace,
366  GSpacing nBandSpace,
367  GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
368 
369  CPLErr RasterIOResampled( GDALRWFlag eRWFlag,
370  int nXOff, int nYOff, int nXSize, int nYSize,
371  void * pData, int nBufXSize, int nBufYSize,
372  GDALDataType eBufType,
373  int nBandCount, int *panBandMap,
374  GSpacing nPixelSpace, GSpacing nLineSpace,
375  GSpacing nBandSpace,
376  GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
377 
378  CPLErr ValidateRasterIOOrAdviseReadParameters(
379  const char* pszCallingFunc,
380  int* pbStopProcessingOnCENone,
381  int nXOff, int nYOff, int nXSize, int nYSize,
382  int nBufXSize, int nBufYSize,
383  int nBandCount, int *panBandMap);
384 
385  CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
386  int nXOff, int nYOff, int nXSize, int nYSize,
387  void * pData, int nBufXSize, int nBufYSize,
388  GDALDataType eBufType,
389  int nBandCount, int *panBandMap,
390  GSpacing nPixelSpace, GSpacing nLineSpace,
391  GSpacing nBandSpace,
392  GDALRasterIOExtraArg* psExtraArg,
393  int* pbTried);
394 
395  virtual int CloseDependentDatasets();
396 
397  int ValidateLayerCreationOptions( const char* const* papszLCO );
398 
399  char **papszOpenOptions;
400 
401  friend class GDALRasterBand;
402 
403  // The below methods related to read write mutex are fragile logic, and
404  // should not be used by out-of-tree code if possible.
405  int EnterReadWrite(GDALRWFlag eRWFlag);
406  void LeaveReadWrite();
407  void InitRWLock();
408 
409  void TemporarilyDropReadWriteLock();
410  void ReacquireReadWriteLock();
411 
412  void DisableReadWriteMutex();
413 
414  int AcquireMutex();
415  void ReleaseMutex();
416 
417  public:
418  virtual ~GDALDataset();
419 
420  int GetRasterXSize( void );
421  int GetRasterYSize( void );
422  int GetRasterCount( void );
423  GDALRasterBand *GetRasterBand( int );
424 
425  virtual void FlushCache(void);
426 
427  virtual const char *GetProjectionRef(void);
428  virtual CPLErr SetProjection( const char * );
429 
430  virtual CPLErr GetGeoTransform( double * );
431  virtual CPLErr SetGeoTransform( double * );
432 
433  virtual CPLErr AddBand( GDALDataType eType,
434  char **papszOptions=NULL );
435 
436  virtual void *GetInternalHandle( const char * );
437  virtual GDALDriver *GetDriver(void);
438  virtual char **GetFileList(void);
439 
440  virtual const char* GetDriverName();
441 
442  virtual int GetGCPCount();
443  virtual const char *GetGCPProjection();
444  virtual const GDAL_GCP *GetGCPs();
445  virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
446  const char *pszGCPProjection );
447 
448  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
449  int nBufXSize, int nBufYSize,
450  GDALDataType eDT,
451  int nBandCount, int *panBandList,
452  char **papszOptions );
453 
454  virtual CPLErr CreateMaskBand( int nFlagsIn );
455 
456  virtual GDALAsyncReader*
457  BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize,
458  void *pBuf, int nBufXSize, int nBufYSize,
459  GDALDataType eBufType,
460  int nBandCount, int* panBandMap,
461  int nPixelSpace, int nLineSpace, int nBandSpace,
462  char **papszOptions);
463  virtual void EndAsyncReader(GDALAsyncReader *);
464 
465  CPLErr RasterIO( GDALRWFlag, int, int, int, int,
466  void *, int, int, GDALDataType,
467  int, int *, GSpacing, GSpacing, GSpacing,
468  GDALRasterIOExtraArg* psExtraArg
469 #ifndef DOXYGEN_SKIP
470  OPTIONAL_OUTSIDE_GDAL(NULL)
471 #endif
472  ) CPL_WARN_UNUSED_RESULT;
473 
474  int Reference();
475  int Dereference();
476  GDALAccess GetAccess() const { return eAccess; }
477 
478  int GetShared();
479  void MarkAsShared();
480 
481  void MarkSuppressOnClose() { bSuppressOnClose = TRUE; }
482 
483  char **GetOpenOptions() { return papszOpenOptions; }
484 
485  static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
486 
487  CPLErr BuildOverviews( const char *, int, int *,
488  int, int *, GDALProgressFunc, void * );
489 
490  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
491 
492 private:
493  void *m_hPrivateData;
494 
495  OGRLayer* BuildLayerFromSelectInfo(swq_select* psSelectInfo,
496  OGRGeometry *poSpatialFilter,
497  const char *pszDialect,
498  swq_select_parse_options* poSelectParseOptions);
499 
500  public:
501 
502  virtual int GetLayerCount();
503  virtual OGRLayer *GetLayer(int);
504  virtual OGRLayer *GetLayerByName(const char *);
505  virtual OGRErr DeleteLayer(int);
506 
507  virtual int TestCapability( const char * );
508 
509  virtual OGRLayer *CreateLayer( const char *pszName,
510  OGRSpatialReference *poSpatialRef = NULL,
512  char ** papszOptions = NULL );
513  virtual OGRLayer *CopyLayer( OGRLayer *poSrcLayer,
514  const char *pszNewName,
515  char **papszOptions = NULL );
516 
517  virtual OGRStyleTable *GetStyleTable();
518  virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
519 
520  virtual void SetStyleTable(OGRStyleTable *poStyleTable);
521 
522  virtual OGRLayer * ExecuteSQL( const char *pszStatement,
523  OGRGeometry *poSpatialFilter,
524  const char *pszDialect );
525  virtual void ReleaseResultSet( OGRLayer * poResultsSet );
526 
527  int GetRefCount() const;
528  int GetSummaryRefCount() const;
529  OGRErr Release();
530 
531  virtual OGRErr StartTransaction(int bForce=FALSE);
532  virtual OGRErr CommitTransaction();
533  virtual OGRErr RollbackTransaction();
534 
535  static int IsGenericSQLDialect(const char* pszDialect);
536 
537  // Semi-public methods. Only to be used by in-tree drivers.
538  GDALSQLParseInfo* BuildParseInfo(swq_select* psSelectInfo,
539  swq_select_parse_options* poSelectParseOptions);
540  void DestroyParseInfo(GDALSQLParseInfo* psParseInfo );
541  OGRLayer * ExecuteSQL( const char *pszStatement,
542  OGRGeometry *poSpatialFilter,
543  const char *pszDialect,
544  swq_select_parse_options* poSelectParseOptions);
545 
546  protected:
547 
548  virtual OGRLayer *ICreateLayer( const char *pszName,
549  OGRSpatialReference *poSpatialRef = NULL,
551  char ** papszOptions = NULL );
552 
553  OGRErr ProcessSQLCreateIndex( const char * );
554  OGRErr ProcessSQLDropIndex( const char * );
555  OGRErr ProcessSQLDropTable( const char * );
556  OGRErr ProcessSQLAlterTableAddColumn( const char * );
557  OGRErr ProcessSQLAlterTableDropColumn( const char * );
558  OGRErr ProcessSQLAlterTableAlterColumn( const char * );
559  OGRErr ProcessSQLAlterTableRenameColumn( const char * );
560 
561  OGRStyleTable *m_poStyleTable;
562 
563  private:
564  CPL_DISALLOW_COPY_ASSIGN(GDALDataset);
565 };
566 
567 /* ******************************************************************** */
568 /* GDALRasterBlock */
569 /* ******************************************************************** */
570 
572 // And the global block manager that manages a least-recently-used list of
573 // blocks from various datasets/bands
574 
575 class CPL_DLL GDALRasterBlock
576 {
577  friend class GDALAbstractBandBlockCache;
578 
579  GDALDataType eType;
580 
581  int bDirty;
582  volatile int nLockCount;
583 
584  int nXOff;
585  int nYOff;
586 
587  int nXSize;
588  int nYSize;
589 
590  void *pData;
591 
592  GDALRasterBand *poBand;
593 
594  GDALRasterBlock *poNext;
595  GDALRasterBlock *poPrevious;
596 
597  int bMustDetach;
598 
599  void Detach_unlocked( void );
600  void Touch_unlocked( void );
601 
602  void RecycleFor( int nXOffIn, int nYOffIn );
603 
604  public:
605  GDALRasterBlock( GDALRasterBand *, int, int );
606  GDALRasterBlock( int nXOffIn, int nYOffIn ); /* only for lookup purpose */
607  virtual ~GDALRasterBlock();
608 
609  CPLErr Internalize( void );
610  void Touch( void );
611  void MarkDirty( void );
612  void MarkClean( void );
613  int AddLock( void ) { return CPLAtomicInc(&nLockCount); }
614  int DropLock( void ) { return CPLAtomicDec(&nLockCount); }
615  void Detach();
616 
617  CPLErr Write();
618 
619  GDALDataType GetDataType() const { return eType; }
620  int GetXOff() const { return nXOff; }
621  int GetYOff() const { return nYOff; }
622  int GetXSize() const { return nXSize; }
623  int GetYSize() const { return nYSize; }
624  int GetDirty() const { return bDirty; }
625 
626  void *GetDataRef( void ) { return pData; }
627  int GetBlockSize() const {
628  return nXSize * nYSize * GDALGetDataTypeSizeBytes(eType); }
629 
630  int TakeLock();
631  int DropLockForRemovalFromStorage();
632 
635  GDALRasterBand *GetBand() { return poBand; }
636 
637  static void FlushDirtyBlocks();
638  static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE);
639  static void Verify();
640 
641 #ifdef notdef
642  static void CheckNonOrphanedBlocks(GDALRasterBand* poBand);
643  void DumpBlock();
644  static void DumpAll();
645 #endif
646 
647  /* Should only be called by GDALDestroyDriverManager() */
648  static void DestroyRBMutex();
649 
650  private:
651  CPL_DISALLOW_COPY_ASSIGN(GDALRasterBlock);
652 };
653 
654 /* ******************************************************************** */
655 /* GDALColorTable */
656 /* ******************************************************************** */
657 
660 class CPL_DLL GDALColorTable
661 {
662  GDALPaletteInterp eInterp;
663 
664  std::vector<GDALColorEntry> aoEntries;
665 
666 public:
668  ~GDALColorTable();
669 
670  GDALColorTable *Clone() const;
671  int IsSame(const GDALColorTable* poOtherCT) const;
672 
673  GDALPaletteInterp GetPaletteInterpretation() const;
674 
675  int GetColorEntryCount() const;
676  const GDALColorEntry *GetColorEntry( int ) const;
677  int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
678  void SetColorEntry( int, const GDALColorEntry * );
679  int CreateColorRamp( int, const GDALColorEntry * ,
680  int, const GDALColorEntry * );
681 };
682 
683 /* ******************************************************************** */
684 /* GDALAbstractBandBlockCache */
685 /* ******************************************************************** */
686 
688 // CPL_DLL is just technical here. This is really a private concept
689 // only used by GDALRasterBand implementation.
690 
692 {
693  // List of blocks that can be freed or recycled, and its lock
694  CPLLock *hSpinLock;
695  GDALRasterBlock *psListBlocksToFree;
696 
697  // Band keep alive counter, and its lock & condition
698  CPLCond *hCond;
699  CPLMutex *hCondMutex;
700  volatile int nKeepAliveCounter;
701 
702  protected:
703  GDALRasterBand *poBand;
704 
705  void FreeDanglingBlocks();
706  void UnreferenceBlockBase();
707  void WaitKeepAliveCounter();
708 
709  public:
711  virtual ~GDALAbstractBandBlockCache();
712 
713  GDALRasterBlock* CreateBlock(int nXBlockOff, int nYBlockOff);
714  void AddBlockToFreeList( GDALRasterBlock * );
715 
716  virtual bool Init() = 0;
717  virtual bool IsInitOK() = 0;
718  virtual CPLErr FlushCache() = 0;
719  virtual CPLErr AdoptBlock( GDALRasterBlock* poBlock ) = 0;
720  virtual GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff,
721  int nYBlockYOff ) = 0;
722  virtual CPLErr UnreferenceBlock( GDALRasterBlock* poBlock ) = 0;
723  virtual CPLErr FlushBlock( int nXBlockOff, int nYBlockOff,
724  int bWriteDirtyBlock ) = 0;
725 };
726 
727 GDALAbstractBandBlockCache* GDALArrayBandBlockCacheCreate(GDALRasterBand* poBand);
728 GDALAbstractBandBlockCache* GDALHashSetBandBlockCacheCreate(GDALRasterBand* poBand);
729 
730 /* ******************************************************************** */
731 /* GDALRasterBand */
732 /* ******************************************************************** */
733 
735 
736 class CPL_DLL GDALRasterBand : public GDALMajorObject
737 {
738  private:
739  friend class GDALArrayBandBlockCache;
740  friend class GDALHashSetBandBlockCache;
741  friend class GDALRasterBlock;
742 
743  CPLErr eFlushBlockErr;
744  GDALAbstractBandBlockCache* poBandBlockCache;
745 
746  void SetFlushBlockErr( CPLErr eErr );
747  CPLErr UnreferenceBlock( GDALRasterBlock* poBlock );
748 
749  void Init(int bForceCachedIO);
750 
751  protected:
752  GDALDataset *poDS;
753  int nBand; /* 1 based */
754 
755  int nRasterXSize;
756  int nRasterYSize;
757 
758  GDALDataType eDataType;
759  GDALAccess eAccess;
760 
761  /* stuff related to blocking, and raster cache */
762  int nBlockXSize;
763  int nBlockYSize;
764  int nBlocksPerRow;
765  int nBlocksPerColumn;
766 
767  int nBlockReads;
768  int bForceCachedIO;
769 
770  GDALRasterBand *poMask;
771  bool bOwnMask;
772  int nMaskFlags;
773 
774  void InvalidateMaskBand();
775 
776  friend class GDALDataset;
777  friend class GDALProxyRasterBand;
778  friend class GDALDefaultOverviews;
779 
780  CPLErr RasterIOResampled( GDALRWFlag, int, int, int, int,
781  void *, int, int, GDALDataType,
782  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
783 
784  int EnterReadWrite(GDALRWFlag eRWFlag);
785  void LeaveReadWrite();
786  void InitRWLock();
787 
788  protected:
789  virtual CPLErr IReadBlock( int, int, void * ) = 0;
790  virtual CPLErr IWriteBlock( int, int, void * );
791 
792 #ifdef DETECT_OLD_IRASTERIO
793  virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int,
794  void *, int, int, GDALDataType,
795  int, int ) {};
796 #endif
797 
798  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
799  void *, int, int, GDALDataType,
800  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
801  CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
802  void *, int, int, GDALDataType,
803  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_WARN_UNUSED_RESULT;
804 
805  CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
806  int nXOff, int nYOff, int nXSize, int nYSize,
807  void * pData, int nBufXSize, int nBufYSize,
808  GDALDataType eBufType,
809  GSpacing nPixelSpace, GSpacing nLineSpace,
810  GDALRasterIOExtraArg* psExtraArg,
811  int* pbTried );
812 
813  int InitBlockInfo();
814 
815  CPLErr AdoptBlock( GDALRasterBlock * );
816  GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
817  void AddBlockToFreeList( GDALRasterBlock * );
818 
819  public:
820  GDALRasterBand();
821  GDALRasterBand(int bForceCachedIO);
822 
823  virtual ~GDALRasterBand();
824 
825  int GetXSize();
826  int GetYSize();
827  int GetBand();
828  GDALDataset*GetDataset();
829 
830  GDALDataType GetRasterDataType( void );
831  void GetBlockSize( int *, int * );
832  GDALAccess GetAccess();
833 
834  CPLErr RasterIO( GDALRWFlag, int, int, int, int,
835  void *, int, int, GDALDataType,
837 #ifndef DOXYGEN_SKIP
838  OPTIONAL_OUTSIDE_GDAL(NULL)
839 #endif
840  ) CPL_WARN_UNUSED_RESULT;
841  CPLErr ReadBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
842 
843  CPLErr WriteBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
844 
845  GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
846  int bJustInitialize = FALSE ) CPL_WARN_UNUSED_RESULT;
847  CPLErr FlushBlock( int, int, int bWriteDirtyBlock = TRUE );
848 
849  unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand,
850  unsigned char* pTranslationTable = NULL,
851  int* pApproximateMatching = NULL);
852 
853  // New OpengIS CV_SampleDimension stuff.
854 
855  virtual CPLErr FlushCache();
856  virtual char **GetCategoryNames();
857  virtual double GetNoDataValue( int *pbSuccess = NULL );
858  virtual double GetMinimum( int *pbSuccess = NULL );
859  virtual double GetMaximum(int *pbSuccess = NULL );
860  virtual double GetOffset( int *pbSuccess = NULL );
861  virtual double GetScale( int *pbSuccess = NULL );
862  virtual const char *GetUnitType();
863  virtual GDALColorInterp GetColorInterpretation();
864  virtual GDALColorTable *GetColorTable();
865  virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
866 
867  virtual CPLErr SetCategoryNames( char ** );
868  virtual CPLErr SetNoDataValue( double );
869  virtual CPLErr DeleteNoDataValue();
870  virtual CPLErr SetColorTable( GDALColorTable * );
871  virtual CPLErr SetColorInterpretation( GDALColorInterp );
872  virtual CPLErr SetOffset( double );
873  virtual CPLErr SetScale( double );
874  virtual CPLErr SetUnitType( const char * );
875 
876  virtual CPLErr GetStatistics( int bApproxOK, int bForce,
877  double *pdfMin, double *pdfMax,
878  double *pdfMean, double *padfStdDev );
879  virtual CPLErr ComputeStatistics( int bApproxOK,
880  double *pdfMin, double *pdfMax,
881  double *pdfMean, double *pdfStdDev,
882  GDALProgressFunc, void *pProgressData );
883  virtual CPLErr SetStatistics( double dfMin, double dfMax,
884  double dfMean, double dfStdDev );
885  virtual CPLErr ComputeRasterMinMax( int, double* );
886 
887  virtual int HasArbitraryOverviews();
888  virtual int GetOverviewCount();
889  virtual GDALRasterBand *GetOverview(int);
890  virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig );
891  virtual CPLErr BuildOverviews( const char *, int, int *,
892  GDALProgressFunc, void * );
893 
894  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
895  int nBufXSize, int nBufYSize,
896  GDALDataType eDT, char **papszOptions );
897 
898  virtual CPLErr GetHistogram( double dfMin, double dfMax,
899  int nBuckets, GUIntBig * panHistogram,
900  int bIncludeOutOfRange, int bApproxOK,
901  GDALProgressFunc, void *pProgressData );
902 
903  virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
904  int *pnBuckets, GUIntBig ** ppanHistogram,
905  int bForce,
906  GDALProgressFunc, void *pProgressData);
907  virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
908  int nBuckets, GUIntBig *panHistogram );
909 
910  virtual GDALRasterAttributeTable *GetDefaultRAT();
911  virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
912 
913  virtual GDALRasterBand *GetMaskBand();
914  virtual int GetMaskFlags();
915  virtual CPLErr CreateMaskBand( int nFlagsIn );
916 
917  virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
918  int *pnPixelSpace,
919  GIntBig *pnLineSpace,
920  char **papszOptions ) CPL_WARN_UNUSED_RESULT;
921 
922  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
923 
924 private:
925  CPL_DISALLOW_COPY_ASSIGN(GDALRasterBand);
926 };
927 
928 /* ******************************************************************** */
929 /* GDALAllValidMaskBand */
930 /* ******************************************************************** */
931 
932 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
933 {
934  protected:
935  virtual CPLErr IReadBlock( int, int, void * );
936 
937  public:
939  virtual ~GDALAllValidMaskBand();
940 
941  virtual GDALRasterBand *GetMaskBand();
942  virtual int GetMaskFlags();
943 };
944 
945 /* ******************************************************************** */
946 /* GDALNoDataMaskBand */
947 /* ******************************************************************** */
948 
949 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
950 {
951  double dfNoDataValue;
952  GDALRasterBand *poParent;
953 
954  protected:
955  virtual CPLErr IReadBlock( int, int, void * );
956  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
957  void *, int, int, GDALDataType,
958  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg );
959 
960  public:
962  virtual ~GDALNoDataMaskBand();
963 };
964 
965 /* ******************************************************************** */
966 /* GDALNoDataValuesMaskBand */
967 /* ******************************************************************** */
968 
970 {
971  double *padfNodataValues;
972 
973  protected:
974  virtual CPLErr IReadBlock( int, int, void * );
975 
976  public:
978  virtual ~GDALNoDataValuesMaskBand();
979 };
980 
981 /* ******************************************************************** */
982 /* GDALRescaledAlphaBand */
983 /* ******************************************************************** */
984 
986 {
987  GDALRasterBand *poParent;
988  void *pTemp;
989 
990  protected:
991  virtual CPLErr IReadBlock( int, int, void * );
992  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
993  void *, int, int, GDALDataType,
994  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg );
995 
996  public:
998  virtual ~GDALRescaledAlphaBand();
999 };
1000 
1001 /* ******************************************************************** */
1002 /* GDALIdentifyEnum */
1003 /* ******************************************************************** */
1004 
1010 typedef enum
1011 {
1019 
1020 /* ******************************************************************** */
1021 /* GDALDriver */
1022 /* ******************************************************************** */
1023 
1024 
1036 class CPL_DLL GDALDriver : public GDALMajorObject
1037 {
1038  public:
1039  GDALDriver();
1040  ~GDALDriver();
1041 
1042  virtual CPLErr SetMetadataItem( const char * pszName,
1043  const char * pszValue,
1044  const char * pszDomain = "" );
1045 
1046 /* -------------------------------------------------------------------- */
1047 /* Public C++ methods. */
1048 /* -------------------------------------------------------------------- */
1049  GDALDataset *Create( const char * pszName,
1050  int nXSize, int nYSize, int nBands,
1051  GDALDataType eType, char ** papszOptions ) CPL_WARN_UNUSED_RESULT;
1052 
1053  CPLErr Delete( const char * pszName );
1054  CPLErr Rename( const char * pszNewName,
1055  const char * pszOldName );
1056  CPLErr CopyFiles( const char * pszNewName,
1057  const char * pszOldName );
1058 
1059  GDALDataset *CreateCopy( const char *, GDALDataset *,
1060  int, char **,
1061  GDALProgressFunc pfnProgress,
1062  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
1063 
1064 /* -------------------------------------------------------------------- */
1065 /* The following are semiprivate, not intended to be accessed */
1066 /* by anyone but the formats instantiating and populating the */
1067 /* drivers. */
1068 /* -------------------------------------------------------------------- */
1069  GDALDataset *(*pfnOpen)( GDALOpenInfo * );
1070 
1071  GDALDataset *(*pfnCreate)( const char * pszName,
1072  int nXSize, int nYSize, int nBands,
1073  GDALDataType eType,
1074  char ** papszOptions );
1075 
1076  CPLErr (*pfnDelete)( const char * pszName );
1077 
1078  GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
1079  int, char **,
1080  GDALProgressFunc pfnProgress,
1081  void * pProgressData );
1082 
1083  void *pDriverData;
1084 
1085  void (*pfnUnloadDriver)(GDALDriver *);
1086 
1094  int (*pfnIdentify)( GDALOpenInfo * );
1095 
1096  CPLErr (*pfnRename)( const char * pszNewName,
1097  const char * pszOldName );
1098  CPLErr (*pfnCopyFiles)( const char * pszNewName,
1099  const char * pszOldName );
1100 
1101  /* For legacy OGR drivers */
1102  GDALDataset *(*pfnOpenWithDriverArg)( GDALDriver*, GDALOpenInfo * );
1103  GDALDataset *(*pfnCreateVectorOnly)( GDALDriver*,
1104  const char * pszName,
1105  char ** papszOptions );
1106  CPLErr (*pfnDeleteDataSource)( GDALDriver*,
1107  const char * pszName );
1108 
1109 /* -------------------------------------------------------------------- */
1110 /* Helper methods. */
1111 /* -------------------------------------------------------------------- */
1112  GDALDataset *DefaultCreateCopy( const char *, GDALDataset *,
1113  int, char **,
1114  GDALProgressFunc pfnProgress,
1115  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
1116  static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
1117  GDALDataset *poDstDS,
1118  int bStrict );
1119  static CPLErr QuietDelete( const char * pszName );
1120 
1121  CPLErr DefaultRename( const char * pszNewName,
1122  const char * pszOldName );
1123  CPLErr DefaultCopyFiles( const char * pszNewName,
1124  const char * pszOldName );
1125 private:
1126  CPL_DISALLOW_COPY_ASSIGN(GDALDriver);
1127 };
1128 
1129 /* ******************************************************************** */
1130 /* GDALDriverManager */
1131 /* ******************************************************************** */
1132 
1140 class CPL_DLL GDALDriverManager : public GDALMajorObject
1141 {
1142  int nDrivers;
1143  GDALDriver **papoDrivers;
1144  std::map<CPLString, GDALDriver*> oMapNameToDrivers;
1145 
1146  GDALDriver *GetDriver_unlocked( int iDriver )
1147  { return (iDriver >= 0 && iDriver < nDrivers) ? papoDrivers[iDriver] : NULL; }
1148 
1149  GDALDriver *GetDriverByName_unlocked( const char * pszName )
1150  { return oMapNameToDrivers[CPLString(pszName).toupper()]; }
1151 
1152  public:
1154  ~GDALDriverManager();
1155 
1156  int GetDriverCount( void );
1157  GDALDriver *GetDriver( int );
1158  GDALDriver *GetDriverByName( const char * );
1159 
1160  int RegisterDriver( GDALDriver * );
1161  void DeregisterDriver( GDALDriver * );
1162 
1163  // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
1164  void AutoLoadDrivers();
1165  void AutoSkipDrivers();
1166 };
1167 
1168 CPL_C_START
1169 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
1170 CPL_C_END
1171 
1172 /* ******************************************************************** */
1173 /* GDALAsyncReader */
1174 /* ******************************************************************** */
1175 
1181 class CPL_DLL GDALAsyncReader
1182 {
1183  protected:
1184  GDALDataset* poDS;
1185  int nXOff;
1186  int nYOff;
1187  int nXSize;
1188  int nYSize;
1189  void * pBuf;
1190  int nBufXSize;
1191  int nBufYSize;
1192  GDALDataType eBufType;
1193  int nBandCount;
1194  int* panBandMap;
1195  int nPixelSpace;
1196  int nLineSpace;
1197  int nBandSpace;
1198 
1199  public:
1200  GDALAsyncReader();
1201  virtual ~GDALAsyncReader();
1202 
1203  GDALDataset* GetGDALDataset() {return poDS;}
1204  int GetXOffset() const { return nXOff; }
1205  int GetYOffset() const { return nYOff; }
1206  int GetXSize() const { return nXSize; }
1207  int GetYSize() const { return nYSize; }
1208  void * GetBuffer() {return pBuf;}
1209  int GetBufferXSize() const { return nBufXSize; }
1210  int GetBufferYSize() const { return nBufYSize; }
1211  GDALDataType GetBufferType() const { return eBufType; }
1212  int GetBandCount() const { return nBandCount; }
1213  int* GetBandMap() { return panBandMap; }
1214  int GetPixelSpace() const { return nPixelSpace; }
1215  int GetLineSpace() const { return nLineSpace; }
1216  int GetBandSpace() const { return nBandSpace; }
1217 
1218  virtual GDALAsyncStatusType
1219  GetNextUpdatedRegion(double dfTimeout,
1220  int* pnBufXOff, int* pnBufYOff,
1221  int* pnBufXSize, int* pnBufYSize) = 0;
1222  virtual int LockBuffer( double dfTimeout = -1.0 );
1223  virtual void UnlockBuffer();
1224 };
1225 
1226 /* ==================================================================== */
1227 /* An assortment of overview related stuff. */
1228 /* ==================================================================== */
1229 
1230 /* Only exported for drivers as plugin. Signature may change */
1231 CPLErr CPL_DLL
1232 GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands,
1233  int nOverviews,
1234  GDALRasterBand*** papapoOverviewBands,
1235  const char * pszResampling,
1236  GDALProgressFunc pfnProgress, void * pProgressData );
1237 
1238 typedef CPLErr (*GDALResampleFunction)
1239  ( double dfXRatioDstToSrc,
1240  double dfYRatioDstToSrc,
1241  double dfSrcXDelta,
1242  double dfSrcYDelta,
1243  GDALDataType eWrkDataType,
1244  void * pChunk,
1245  GByte * pabyChunkNodataMask,
1246  int nChunkXOff, int nChunkXSize,
1247  int nChunkYOff, int nChunkYSize,
1248  int nDstXOff, int nDstXOff2,
1249  int nDstYOff, int nDstYOff2,
1250  GDALRasterBand * poOverview,
1251  const char * pszResampling,
1252  int bHasNoData, float fNoDataValue,
1253  GDALColorTable* poColorTable,
1254  GDALDataType eSrcDataType);
1255 
1256 GDALResampleFunction GDALGetResampleFunction(const char* pszResampling,
1257  int* pnRadius);
1258 
1259 #ifdef GDAL_ENABLE_RESAMPLING_MULTIBAND
1260 typedef CPLErr (*GDALResampleFunctionMultiBands)
1261  ( double dfXRatioDstToSrc,
1262  double dfYRatioDstToSrc,
1263  double dfSrcXDelta,
1264  double dfSrcYDelta,
1265  GDALDataType eWrkDataType,
1266  void * pChunk, int nBands,
1267  GByte * pabyChunkNodataMask,
1268  int nChunkXOff, int nChunkXSize,
1269  int nChunkYOff, int nChunkYSize,
1270  int nDstXOff, int nDstXOff2,
1271  int nDstYOff, int nDstYOff2,
1272  GDALRasterBand ** papoDstBands,
1273  const char * pszResampling,
1274  int bHasNoData, float fNoDataValue,
1275  GDALColorTable* poColorTable,
1276  GDALDataType eSrcDataType);
1277 
1278 GDALResampleFunctionMultiBands GDALGetResampleFunctionMultiBands(const char* pszResampling,
1279  int* pnRadius);
1280 #endif
1281 
1282 GDALDataType GDALGetOvrWorkDataType(const char* pszResampling,
1283  GDALDataType eSrcDataType);
1284 
1285 CPL_C_START
1286 
1287 CPLErr CPL_DLL
1288 HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
1289  GDALDataset **ppoDS,
1290  int nBands, int *panBandList,
1291  int nNewOverviews, int *panNewOverviewList,
1292  const char *pszResampling,
1293  GDALProgressFunc pfnProgress,
1294  void *pProgressData );
1295 
1296 CPLErr CPL_DLL
1297 GTIFFBuildOverviews( const char * pszFilename,
1298  int nBands, GDALRasterBand **papoBandList,
1299  int nOverviews, int * panOverviewList,
1300  const char * pszResampling,
1301  GDALProgressFunc pfnProgress, void * pProgressData );
1302 
1303 CPLErr CPL_DLL
1304 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
1305  const char * pszResampling,
1306  int nOverviews, int * panOverviewList,
1307  int nBands, int * panBandList,
1308  GDALProgressFunc pfnProgress, void * pProgressData);
1309 
1310 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
1311  int &nXOff, int &nYOff,
1312  int &nXSize, int &nYSize,
1313  int nBufXSize, int nBufYSize) CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead");
1314 int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand* poBand,
1315  int &nXOff, int &nYOff,
1316  int &nXSize, int &nYSize,
1317  int nBufXSize, int nBufYSize,
1318  GDALRasterIOExtraArg* psExtraArg);
1319 
1320 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize ) CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead");
1321 int CPL_DLL GDALOvLevelAdjust2( int nOvLevel, int nXSize, int nYSize );
1322 int CPL_DLL GDALComputeOvFactor( int nOvrXSize, int nRasterXSize,
1323  int nOvrYSize, int nRasterYSize );
1324 
1325 GDALDataset CPL_DLL *
1326 GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
1327  GDALDataset *poDependentDS );
1328 
1329 /* ==================================================================== */
1330 /* Misc functions. */
1331 /* ==================================================================== */
1332 
1333 CPLErr CPL_DLL GDALParseGMLCoverage( CPLXMLNode *psTree,
1334  int *pnXSize, int *pnYSize,
1335  double *padfGeoTransform,
1336  char **ppszProjection );
1337 
1338 /* ==================================================================== */
1339 /* Infrastructure to check that dataset characteristics are valid */
1340 /* ==================================================================== */
1341 
1342 int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize );
1343 int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed );
1344 
1345 
1346 // Test if 2 floating point values match. Useful when comparing values
1347 // stored as a string at some point. See #3573, #4183, #4506
1348 #define ARE_REAL_EQUAL(dfVal1, dfVal2) \
1349  /* Is it FLT_MIN ? Cf #6578 */ \
1350  (((float)dfVal2 == (float)1.17549435e-38) ? ((float)dfVal1 == (float)dfVal2) : \
1351  /* Or DBL_MIN ? */ \
1352  (dfVal2 == 2.2250738585072014e-308) ? (dfVal1 == dfVal2) : \
1353  /* General case */ \
1354  (dfVal1 == dfVal2 || fabs(dfVal1 - dfVal2) < 1e-10 || (dfVal2 != 0 && fabs(1 - dfVal1 / dfVal2) < 1e-10 )))
1355 
1356 /* Internal use only */
1357 
1358 /* CPL_DLL exported, but only for in-tree drivers that can be built as plugins */
1359 int CPL_DLL GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension,
1360  double *padfGeoTransform, char** papszSiblingFiles,
1361  char** ppszWorldFileNameOut);
1362 int GDALReadTabFile2( const char * pszBaseFilename,
1363  double *padfGeoTransform, char **ppszWKT,
1364  int *pnGCPCount, GDAL_GCP **ppasGCPs,
1365  char** papszSiblingFiles, char** ppszTabFileNameOut );
1366 
1367 void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg* psDestArg,
1368  GDALRasterIOExtraArg* psSrcArg);
1369 
1370 CPL_C_END
1371 
1372 void GDALNullifyOpenDatasetsList();
1373 CPLMutex** GDALGetphDMMutex();
1374 CPLMutex** GDALGetphDLMutex();
1375 void GDALNullifyProxyPoolSingleton();
1376 GDALDriver* GDALGetAPIPROXYDriver();
1377 void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
1378 GIntBig GDALGetResponsiblePIDForCurrentThread();
1379 
1380 CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt,
1381  char **papszSiblingFiles, int nFlags );
1382 
1383 CPLErr EXIFExtractMetadata(char**& papszMetadata,
1384  void *fpL, int nOffset,
1385  int bSwabflag, int nTIFFHEADER,
1386  int& nExifOffset, int& nInterOffset, int& nGPSOffset);
1387 
1388 int GDALValidateOpenOptions( GDALDriverH hDriver,
1389  const char* const* papszOptionOptions);
1390 int GDALValidateOptions( const char* pszOptionList,
1391  const char* const* papszOptionsToValidate,
1392  const char* pszErrorMessageOptionType,
1393  const char* pszErrorMessageContainerName);
1394 
1395 GDALRIOResampleAlg GDALRasterIOGetResampleAlg(const char* pszResampling);
1396 const char* GDALRasterIOGetResampleAlg(GDALRIOResampleAlg eResampleAlg);
1397 
1398 void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg* psExtraArg,
1399  int nXSize, int nYSize,
1400  int nBufXSize, int nBufYSize);
1401 
1402 /* CPL_DLL exported, but only for gdalwarp */
1403 GDALDataset CPL_DLL* GDALCreateOverviewDataset(GDALDataset* poDS, int nOvrLevel,
1404  int bThisLevelOnly, int bOwnDS);
1405 
1406 #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) )
1407 
1408 // Number of data samples that will be used to compute approximate statistics
1409 // (minimum value, maximum value, etc.)
1410 #define GDALSTAT_APPROX_NUMSAMPLES 2500
1411 
1412 CPL_C_START
1413 /* Caution: for technical reason this declaration is duplicated in gdal_crs.c */
1414 /* so any signature change should be reflected there too */
1415 void GDALSerializeGCPListToXML( CPLXMLNode* psParentNode,
1416  GDAL_GCP* pasGCPList,
1417  int nGCPCount,
1418  const char* pszGCPProjection );
1419 void GDALDeserializeGCPListFromXML( CPLXMLNode* psGCPList,
1420  GDAL_GCP** ppasGCPList,
1421  int* pnGCPCount,
1422  char** ppszGCPProjection );
1423 CPL_C_END
1424 
1425 void GDALSerializeOpenOptionsToXML( CPLXMLNode* psParentNode, char** papszOpenOptions);
1426 char** GDALDeserializeOpenOptionsFromXML( CPLXMLNode* psParentNode );
1427 
1428 int GDALCanFileAcceptSidecarFile(const char* pszFilename);
1429 
1430 #endif /* ndef GDAL_PRIV_H_INCLUDED */
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition: gdal_rat.h:46
GDALDatasetH GDALOpenEx(const char *pszFilename, unsigned int nOpenFlags, const char *const *papszAllowedDrivers, const char *const *papszOpenOptions, const char *const *papszSiblingFiles) CPL_WARN_UNUSED_RESULT
Open a raster or vector file as a GDALDataset.
Definition: gdaldataset.cpp:2626
virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, GDALDataType eDT, char **papszOptions)
Advise driver of upcoming read requests.
Definition: gdalrasterband.cpp:3393
GDALDataType
Definition: gdal.h:57
Definition: gdal_priv.h:969
Definition: swq.h:328
Identify could not determine if the file is recognized or not by the probed driver.
Definition: gdal_priv.h:1013
Document node structure.
Definition: cpl_minixml.h:65
Standard C Covers.
virtual GDALRasterBand * GetMaskBand()
Return the mask band associated with the band.
Definition: gdalrasterband.cpp:4621
Definitions for CPL mini XML Parser/Serializer.
Definition: gdal.h:202
int GDALCheckBandCount(int nBands, int bIsZeroAllowed)
Return TRUE if the band count is valid.
Definition: gdal_misc.cpp:3178
Definition: gdal_proxy.h:104
int GDALCheckDatasetDimensions(int nXSize, int nYSize)
Return TRUE if the dataset dimensions are valid.
Definition: gdal_misc.cpp:3154
This manages how a raster band store its cached block.
Definition: gdal_priv.h:691
void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt,...) CPL_PRINT_FUNC_FORMAT(4
Emits an error related to a raster band.
Definition: gdalrasterband.cpp:5147
GDALRIOResampleAlg
RasterIO() resampling method.
Definition: gdal.h:113
GDALRWFlag
Definition: gdal.h:104
CPLErr GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand **papoSrcBands, int nOverviews, GDALRasterBand ***papapoOverviewBands, const char *pszResampling, GDALProgressFunc pfnProgress, void *pProgressData)
Variant of GDALRegenerateOverviews, specially dedicated for generating compressed pixel-interleaved o...
Definition: overview.cpp:2689
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition: gdal.h:230
Definition: gdal_priv.h:949
Color tuple.
Definition: gdal.h:925
A single raster block in the block cache.
Definition: gdal_priv.h:575
virtual int GetMaskFlags()
Return the status flags of the mask band associated with the band.
Definition: gdalrasterband.cpp:4855
Convenient string class based on std::string.
Definition: cpl_string.h:283
virtual CPLErr BuildOverviews(const char *, int, int *, GDALProgressFunc, void *)
Build raster overview(s)
Definition: gdalrasterband.cpp:2183
CPLErr RasterIO(GDALRWFlag, int, int, int, int, void *, int, int, GDALDataType, GSpacing, GSpacing, GDALRasterIOExtraArg *psExtraArg) CPL_WARN_UNUSED_RESULT
Read/write a region of image data for this band.
Definition: gdalrasterband.cpp:181
unknown type, non-standard
Definition: ogr_core.h:335
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition: cpl_virtualmem.h:60
CPLErr BuildOverviews(const char *, int, int *, int, int *, GDALProgressFunc, void *)
Build raster overview(s)
Definition: gdaldataset.cpp:1423
Various convenience functions for working with strings and string lists.
Definition: gdal_priv.h:156
virtual CPLErr FlushCache()
Flush raster data cache.
Definition: gdalrasterband.cpp:849
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:248
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:333
Public (C callable) GDAL entry points.
GDALAsyncStatusType
status of the asynchronous stream
Definition: gdal.h:85
Definition: gdal_proxy.h:44
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:104
GDALRasterBand * GetBand()
Accessor to source GDALRasterBand object.
Definition: gdal_priv.h:635
Definition: gdal_priv.h:238
Definition: gdal_priv.h:932
CPLString GDALFindAssociatedFile(const char *pszBasename, const char *pszExt, char **papszSiblingFiles, int nFlags)
Find file with alternate extension.
Definition: gdal_misc.cpp:967
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:362
Definition: swq.h:310
Structure to pass extra arguments to RasterIO() method.
Definition: gdal.h:132
Identify determined the file is recognized by the probed driver.
Definition: gdal_priv.h:1017
GDALPaletteInterp
Definition: gdal.h:199
Core portability services for cross-platform OGR code.
virtual int CloseDependentDatasets()
Drop references to any other datasets referenced by this dataset.
Definition: gdaldataset.cpp:3288
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the dataset.
Definition: gdaldataset.cpp:2439
Various convenience functions for CPL.
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:129
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition: gdal.h:236
void GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition: gdaldataset.cpp:2981
Object with metadata.
Definition: gdal_priv.h:122
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:66
A single raster band (or channel).
Definition: gdal_priv.h:736
GDALAccess
Definition: gdal.h:98
Definition: gdal_priv.h:83
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the current band.
Definition: gdalrasterband.cpp:4928
This class represents a style table.
Definition: ogr_featurestyle.h:82
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:296
GDALAccess GetAccess()
Find out if we have update permission for this band.
Definition: gdalrasterband.cpp:1292
Class for managing the registration of file format drivers.
Definition: gdal_priv.h:1140
Definition: gdal_priv.h:985
CPLString & toupper(void)
Convert to upper case in place.
Definition: cplstring.cpp:298
GDALIdentifyEnum
Enumeration used by GDALDriver::pfnIdentify().
Definition: gdal_priv.h:1010
GDALColorInterp
Definition: gdal.h:173
int GDALGetDataTypeSizeBytes(GDALDataType)
Get data type size in bytes.
Definition: gdal_misc.cpp:204
Identify determined the file is not recognized by the probed driver.
Definition: gdal_priv.h:1015
Format specific driver.
Definition: gdal_priv.h:1036
Definition: gdal_priv.h:660
Ground Control Point.
Definition: gdal.h:492
GDALDriverManager * GetGDALDriverManager(void)
Fetch the global GDAL driver manager.
Definition: gdaldrivermanager.cpp:75
Class used as a session object for asynchronous requests.
Definition: gdal_priv.h:1181

Generated for GDAL by doxygen 1.8.12.