GDAL
gdal_priv.h
1 /******************************************************************************
2  * $Id: gdal_priv.h 27657 2014-09-10 07:21:17Z 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 
35 /* -------------------------------------------------------------------- */
36 /* Predeclare various classes before pulling in gdal.h, the */
37 /* public declarations. */
38 /* -------------------------------------------------------------------- */
39 class GDALMajorObject;
40 class GDALDataset;
41 class GDALRasterBand;
42 class GDALDriver;
44 class GDALProxyDataset;
46 class GDALAsyncReader;
47 
48 /* -------------------------------------------------------------------- */
49 /* Pull in the public declarations. This gets the C apis, and */
50 /* also various constants. However, we will still get to */
51 /* provide the real class definitions for the GDAL classes. */
52 /* -------------------------------------------------------------------- */
53 
54 #include "gdal.h"
55 #include "gdal_frmts.h"
56 #include "cpl_vsi.h"
57 #include "cpl_conv.h"
58 #include "cpl_string.h"
59 #include "cpl_minixml.h"
60 #include <vector>
61 
62 #define GMO_VALID 0x0001
63 #define GMO_IGNORE_UNIMPLEMENTED 0x0002
64 #define GMO_SUPPORT_MD 0x0004
65 #define GMO_SUPPORT_MDMD 0x0008
66 #define GMO_MD_DIRTY 0x0010
67 #define GMO_PAM_CLASS 0x0020
68 
69 /************************************************************************/
70 /* GDALMultiDomainMetadata */
71 /************************************************************************/
72 
74 {
75 private:
76  char **papszDomainList;
77  CPLStringList **papoMetadataLists;
78 
79 public:
82 
83  int XMLInit( CPLXMLNode *psMetadata, int bMerge );
84  CPLXMLNode *Serialize();
85 
86  char **GetDomainList() { return papszDomainList; }
87 
88  char **GetMetadata( const char * pszDomain = "" );
89  CPLErr SetMetadata( char ** papszMetadata,
90  const char * pszDomain = "" );
91  const char *GetMetadataItem( const char * pszName,
92  const char * pszDomain = "" );
93  CPLErr SetMetadataItem( const char * pszName,
94  const char * pszValue,
95  const char * pszDomain = "" );
96 
97  void Clear();
98 };
99 
100 /* ******************************************************************** */
101 /* GDALMajorObject */
102 /* */
103 /* Base class providing metadata, description and other */
104 /* services shared by major objects. */
105 /* ******************************************************************** */
106 
108 
109 class CPL_DLL GDALMajorObject
110 {
111  protected:
112  int nFlags; // GMO_* flags.
113  CPLString sDescription;
115 
116  char **BuildMetadataDomainList(char** papszList, int bCheckNonEmpty, ...) CPL_NULL_TERMINATED;
117 
118  public:
119  GDALMajorObject();
120  virtual ~GDALMajorObject();
121 
122  int GetMOFlags();
123  void SetMOFlags(int nFlags);
124 
125  virtual const char *GetDescription() const;
126  virtual void SetDescription( const char * );
127 
128  virtual char **GetMetadataDomainList();
129 
130  virtual char **GetMetadata( const char * pszDomain = "" );
131  virtual CPLErr SetMetadata( char ** papszMetadata,
132  const char * pszDomain = "" );
133  virtual const char *GetMetadataItem( const char * pszName,
134  const char * pszDomain = "" );
135  virtual CPLErr SetMetadataItem( const char * pszName,
136  const char * pszValue,
137  const char * pszDomain = "" );
138 };
139 
140 /* ******************************************************************** */
141 /* GDALDefaultOverviews */
142 /* ******************************************************************** */
143 class CPL_DLL GDALDefaultOverviews
144 {
145  friend class GDALDataset;
146 
147  GDALDataset *poDS;
148  GDALDataset *poODS;
149 
150  CPLString osOvrFilename;
151 
152  int bOvrIsAux;
153 
154  int bCheckedForMask;
155  int bOwnMaskDS;
156  GDALDataset *poMaskDS;
157 
158  // for "overview datasets" we record base level info so we can
159  // find our way back to get overview masks.
160  GDALDataset *poBaseDS;
161 
162  // Stuff for deferred initialize/overviewscans...
163  bool bCheckedForOverviews;
164  void OverviewScan();
165  char *pszInitName;
166  int bInitNameIsOVR;
167  char **papszInitSiblingFiles;
168 
169  public:
172 
173  void Initialize( GDALDataset *poDS, const char *pszName = NULL,
174  char **papszSiblingFiles = NULL,
175  int bNameIsOVR = FALSE );
176 
177  int IsInitialized();
178 
180 
181  // Overview Related
182 
183  int GetOverviewCount(int);
184  GDALRasterBand *GetOverview(int,int);
185 
186  CPLErr BuildOverviews( const char * pszBasename,
187  const char * pszResampling,
188  int nOverviews, int * panOverviewList,
189  int nBands, int * panBandList,
190  GDALProgressFunc pfnProgress,
191  void *pProgressData );
192 
193  CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile,
194  const char * pszResampling,
195  int nOverviews, int * panOverviewList,
196  int nBands, int * panBandList,
197  GDALProgressFunc pfnProgress,
198  void *pProgressData );
199 
200  CPLErr CleanOverviews();
201 
202  // Mask Related
203 
204  CPLErr CreateMaskBand( int nFlags, int nBand = -1 );
205  GDALRasterBand *GetMaskBand( int nBand );
206  int GetMaskFlags( int nBand );
207 
208  int HaveMaskFile( char **papszSiblings = NULL,
209  const char *pszBasename = NULL );
210 
211  char** GetSiblingFiles() { return papszInitSiblingFiles; }
212 };
213 
214 /* ******************************************************************** */
215 /* GDALOpenInfo */
216 /* */
217 /* Structure of data about dataset for open functions. */
218 /* ******************************************************************** */
219 
220 class CPL_DLL GDALOpenInfo
221 {
222  public:
223  GDALOpenInfo( const char * pszFile, GDALAccess eAccessIn,
224  char **papszSiblingFiles = NULL );
225  ~GDALOpenInfo( void );
226 
227  char *pszFilename;
228  char **papszSiblingFiles;
229 
230  GDALAccess eAccess;
231 
232  int bStatOK;
233  int bIsDirectory;
234 
235  FILE *fp;
236 
237  int nHeaderBytes;
238  GByte *pabyHeader;
239 
240 };
241 
242 /* ******************************************************************** */
243 /* GDALDataset */
244 /* ******************************************************************** */
245 
246 /* Internal method for now. Might be subject to later revisions */
247 GDALDatasetH GDALOpenInternal( const char * pszFilename, GDALAccess eAccess,
248  const char* const * papszAllowedDrivers);
249 GDALDatasetH GDALOpenInternal( GDALOpenInfo& oOpenInfo,
250  const char* const * papszAllowedDrivers);
251 
253 
254 class CPL_DLL GDALDataset : public GDALMajorObject
255 {
256  friend GDALDatasetH CPL_STDCALL GDALOpen( const char *, GDALAccess);
257  friend GDALDatasetH CPL_STDCALL GDALOpenShared( const char *, GDALAccess);
258 
259  /* Internal method for now. Might be subject to later revisions */
260  friend GDALDatasetH GDALOpenInternal( const char *, GDALAccess, const char* const * papszAllowedDrivers);
261  friend GDALDatasetH GDALOpenInternal( GDALOpenInfo& oOpenInfo,
262  const char* const * papszAllowedDrivers);
263 
264  friend class GDALDriver;
265  friend class GDALDefaultOverviews;
266  friend class GDALProxyDataset;
267  friend class GDALDriverManager;
268 
269  protected:
270  GDALDriver *poDriver;
271  GDALAccess eAccess;
272 
273  // Stored raster information.
274  int nRasterXSize;
275  int nRasterYSize;
276  int nBands;
277  GDALRasterBand **papoBands;
278 
279  int bForceCachedIO;
280 
281  int nRefCount;
282  int bShared;
283 
284  GDALDataset(void);
285  void RasterInitialize( int, int );
286  void SetBand( int, GDALRasterBand * );
287 
288  GDALDefaultOverviews oOvManager;
289 
290  virtual CPLErr IBuildOverviews( const char *, int, int *,
291  int, int *, GDALProgressFunc, void * );
292 
293  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
294  void *, int, int, GDALDataType,
295  int, int *, int, int, int );
296 
297  CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
298  void *, int, int, GDALDataType,
299  int, int *, int, int, int );
300  void BlockBasedFlushCache();
301 
302  CPLErr ValidateRasterIOOrAdviseReadParameters(
303  const char* pszCallingFunc,
304  int* pbStopProcessingOnCENone,
305  int nXOff, int nYOff, int nXSize, int nYSize,
306  int nBufXSize, int nBufYSize,
307  int nBandCount, int *panBandMap);
308 
309  virtual int CloseDependentDatasets();
310 
311  friend class GDALRasterBand;
312 
313  public:
314  virtual ~GDALDataset();
315 
316  int GetRasterXSize( void );
317  int GetRasterYSize( void );
318  int GetRasterCount( void );
319  GDALRasterBand *GetRasterBand( int );
320 
321  virtual void FlushCache(void);
322 
323  virtual const char *GetProjectionRef(void);
324  virtual CPLErr SetProjection( const char * );
325 
326  virtual CPLErr GetGeoTransform( double * );
327  virtual CPLErr SetGeoTransform( double * );
328 
329  virtual CPLErr AddBand( GDALDataType eType,
330  char **papszOptions=NULL );
331 
332  virtual void *GetInternalHandle( const char * );
333  virtual GDALDriver *GetDriver(void);
334  virtual char **GetFileList(void);
335 
336  virtual int GetGCPCount();
337  virtual const char *GetGCPProjection();
338  virtual const GDAL_GCP *GetGCPs();
339  virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
340  const char *pszGCPProjection );
341 
342  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
343  int nBufXSize, int nBufYSize,
344  GDALDataType eDT,
345  int nBandCount, int *panBandList,
346  char **papszOptions );
347 
348  virtual CPLErr CreateMaskBand( int nFlags );
349 
350  virtual GDALAsyncReader*
351  BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize,
352  void *pBuf, int nBufXSize, int nBufYSize,
353  GDALDataType eBufType,
354  int nBandCount, int* panBandMap,
355  int nPixelSpace, int nLineSpace, int nBandSpace,
356  char **papszOptions);
357  virtual void EndAsyncReader(GDALAsyncReader *);
358 
359  CPLErr RasterIO( GDALRWFlag, int, int, int, int,
360  void *, int, int, GDALDataType,
361  int, int *, int, int, int );
362 
363  int Reference();
364  int Dereference();
365  GDALAccess GetAccess() { return eAccess; }
366 
367  int GetShared();
368  void MarkAsShared();
369 
370  static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
371 
372  CPLErr BuildOverviews( const char *, int, int *,
373  int, int *, GDALProgressFunc, void * );
374 
375  void ReportError(CPLErr eErrClass, int err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
376 };
377 
378 /* ******************************************************************** */
379 /* GDALRasterBlock */
380 /* ******************************************************************** */
381 
383 
384 class CPL_DLL GDALRasterBlock
385 {
386  GDALDataType eType;
387 
388  int bDirty;
389  int nLockCount;
390 
391  int nXOff;
392  int nYOff;
393 
394  int nXSize;
395  int nYSize;
396 
397  void *pData;
398 
399  GDALRasterBand *poBand;
400 
401  GDALRasterBlock *poNext;
402  GDALRasterBlock *poPrevious;
403 
404  public:
405  GDALRasterBlock( GDALRasterBand *, int, int );
406  virtual ~GDALRasterBlock();
407 
408  CPLErr Internalize( void );
409  void Touch( void );
410  void MarkDirty( void );
411  void MarkClean( void );
412  void AddLock( void ) { nLockCount++; }
413  void DropLock( void ) { nLockCount--; }
414  void Detach();
415 
416  CPLErr Write();
417 
418  GDALDataType GetDataType() { return eType; }
419  int GetXOff() { return nXOff; }
420  int GetYOff() { return nYOff; }
421  int GetXSize() { return nXSize; }
422  int GetYSize() { return nYSize; }
423  int GetDirty() { return bDirty; }
424  int GetLockCount() { return nLockCount; }
425 
426  void *GetDataRef( void ) { return pData; }
427 
430  GDALRasterBand *GetBand() { return poBand; }
431 
432  static int FlushCacheBlock();
433  static void Verify();
434 
435  static int SafeLockBlock( GDALRasterBlock ** );
436 
437  /* Should only be called by GDALDestroyDriverManager() */
438  static void DestroyRBMutex();
439 };
440 
441 /* ******************************************************************** */
442 /* GDALColorTable */
443 /* ******************************************************************** */
444 
447 class CPL_DLL GDALColorTable
448 {
449  GDALPaletteInterp eInterp;
450 
451  std::vector<GDALColorEntry> aoEntries;
452 
453 public:
455  ~GDALColorTable();
456 
457  GDALColorTable *Clone() const;
458 
459  GDALPaletteInterp GetPaletteInterpretation() const;
460 
461  int GetColorEntryCount() const;
462  const GDALColorEntry *GetColorEntry( int ) const;
463  int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
464  void SetColorEntry( int, const GDALColorEntry * );
465  int CreateColorRamp( int, const GDALColorEntry * ,
466  int, const GDALColorEntry * );
467 };
468 
469 /* ******************************************************************** */
470 /* GDALRasterBand */
471 /* ******************************************************************** */
472 
474 
475 class CPL_DLL GDALRasterBand : public GDALMajorObject
476 {
477  private:
478  CPLErr eFlushBlockErr;
479 
480  void SetFlushBlockErr( CPLErr eErr );
481 
482  friend class GDALRasterBlock;
483 
484  protected:
485  GDALDataset *poDS;
486  int nBand; /* 1 based */
487 
488  int nRasterXSize;
489  int nRasterYSize;
490 
491  GDALDataType eDataType;
492  GDALAccess eAccess;
493 
494  /* stuff related to blocking, and raster cache */
495  int nBlockXSize;
496  int nBlockYSize;
497  int nBlocksPerRow;
498  int nBlocksPerColumn;
499 
500  int bSubBlockingActive;
501  int nSubBlocksPerRow;
502  int nSubBlocksPerColumn;
503  GDALRasterBlock **papoBlocks;
504 
505  int nBlockReads;
506  int bForceCachedIO;
507 
508  GDALRasterBand *poMask;
509  bool bOwnMask;
510  int nMaskFlags;
511 
512  void InvalidateMaskBand();
513 
514  friend class GDALDataset;
515  friend class GDALProxyRasterBand;
516  friend class GDALDefaultOverviews;
517 
518  protected:
519  virtual CPLErr IReadBlock( int, int, void * ) = 0;
520  virtual CPLErr IWriteBlock( int, int, void * );
521  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
522  void *, int, int, GDALDataType,
523  int, int );
524  CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
525  void *, int, int, GDALDataType,
526  int, int );
527 
528  int InitBlockInfo();
529 
530  CPLErr AdoptBlock( int, int, GDALRasterBlock * );
531  GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
532 
533  public:
534  GDALRasterBand();
535 
536  virtual ~GDALRasterBand();
537 
538  int GetXSize();
539  int GetYSize();
540  int GetBand();
541  GDALDataset*GetDataset();
542 
543  GDALDataType GetRasterDataType( void );
544  void GetBlockSize( int *, int * );
545  GDALAccess GetAccess();
546 
547  CPLErr RasterIO( GDALRWFlag, int, int, int, int,
548  void *, int, int, GDALDataType,
549  int, int );
550  CPLErr ReadBlock( int, int, void * );
551 
552  CPLErr WriteBlock( int, int, void * );
553 
554  GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
555  int bJustInitialize = FALSE );
556  CPLErr FlushBlock( int = -1, int = -1, int bWriteDirtyBlock = TRUE );
557 
558  unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand,
559  unsigned char* pTranslationTable = NULL,
560  int* pApproximateMatching = NULL);
561 
562  // New OpengIS CV_SampleDimension stuff.
563 
564  virtual CPLErr FlushCache();
565  virtual char **GetCategoryNames();
566  virtual double GetNoDataValue( int *pbSuccess = NULL );
567  virtual double GetMinimum( int *pbSuccess = NULL );
568  virtual double GetMaximum(int *pbSuccess = NULL );
569  virtual double GetOffset( int *pbSuccess = NULL );
570  virtual double GetScale( int *pbSuccess = NULL );
571  virtual const char *GetUnitType();
572  virtual GDALColorInterp GetColorInterpretation();
573  virtual GDALColorTable *GetColorTable();
574  virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
575 
576  virtual CPLErr SetCategoryNames( char ** );
577  virtual CPLErr SetNoDataValue( double );
578  virtual CPLErr SetColorTable( GDALColorTable * );
579  virtual CPLErr SetColorInterpretation( GDALColorInterp );
580  virtual CPLErr SetOffset( double );
581  virtual CPLErr SetScale( double );
582  virtual CPLErr SetUnitType( const char * );
583 
584  virtual CPLErr GetStatistics( int bApproxOK, int bForce,
585  double *pdfMin, double *pdfMax,
586  double *pdfMean, double *padfStdDev );
587  virtual CPLErr ComputeStatistics( int bApproxOK,
588  double *pdfMin, double *pdfMax,
589  double *pdfMean, double *pdfStdDev,
590  GDALProgressFunc, void *pProgressData );
591  virtual CPLErr SetStatistics( double dfMin, double dfMax,
592  double dfMean, double dfStdDev );
593  virtual CPLErr ComputeRasterMinMax( int, double* );
594 
595  virtual int HasArbitraryOverviews();
596  virtual int GetOverviewCount();
597  virtual GDALRasterBand *GetOverview(int);
598  virtual GDALRasterBand *GetRasterSampleOverview( int );
599  virtual CPLErr BuildOverviews( const char *, int, int *,
600  GDALProgressFunc, void * );
601 
602  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
603  int nBufXSize, int nBufYSize,
604  GDALDataType eDT, char **papszOptions );
605 
606  virtual CPLErr GetHistogram( double dfMin, double dfMax,
607  int nBuckets, int * panHistogram,
608  int bIncludeOutOfRange, int bApproxOK,
609  GDALProgressFunc, void *pProgressData );
610 
611  virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
612  int *pnBuckets, int ** ppanHistogram,
613  int bForce,
614  GDALProgressFunc, void *pProgressData);
615  virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
616  int nBuckets, int *panHistogram );
617 
618  virtual GDALRasterAttributeTable *GetDefaultRAT();
619  virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * );
620 
621  virtual GDALRasterBand *GetMaskBand();
622  virtual int GetMaskFlags();
623  virtual CPLErr CreateMaskBand( int nFlags );
624 
625  virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
626  int *pnPixelSpace,
627  GIntBig *pnLineSpace,
628  char **papszOptions );
629 
630  void ReportError(CPLErr eErrClass, int err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
631 };
632 
633 /* ******************************************************************** */
634 /* GDALAllValidMaskBand */
635 /* ******************************************************************** */
636 
637 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
638 {
639  protected:
640  virtual CPLErr IReadBlock( int, int, void * );
641 
642  public:
644  virtual ~GDALAllValidMaskBand();
645 
646  virtual GDALRasterBand *GetMaskBand();
647  virtual int GetMaskFlags();
648 };
649 
650 /* ******************************************************************** */
651 /* GDALNoDataMaskBand */
652 /* ******************************************************************** */
653 
654 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
655 {
656  double dfNoDataValue;
657  GDALRasterBand *poParent;
658 
659  protected:
660  virtual CPLErr IReadBlock( int, int, void * );
661  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
662  void *, int, int, GDALDataType,
663  int, int );
664 
665  public:
667  virtual ~GDALNoDataMaskBand();
668 };
669 
670 /* ******************************************************************** */
671 /* GDALNoDataValuesMaskBand */
672 /* ******************************************************************** */
673 
675 {
676  double *padfNodataValues;
677 
678  protected:
679  virtual CPLErr IReadBlock( int, int, void * );
680 
681  public:
683  virtual ~GDALNoDataValuesMaskBand();
684 };
685 
686 /* ******************************************************************** */
687 /* GDALDriver */
688 /* ******************************************************************** */
689 
690 
702 class CPL_DLL GDALDriver : public GDALMajorObject
703 {
704  public:
705  GDALDriver();
706  ~GDALDriver();
707 
708 /* -------------------------------------------------------------------- */
709 /* Public C++ methods. */
710 /* -------------------------------------------------------------------- */
711  GDALDataset *Create( const char * pszName,
712  int nXSize, int nYSize, int nBands,
713  GDALDataType eType, char ** papszOptions ) CPL_WARN_UNUSED_RESULT;
714 
715  CPLErr Delete( const char * pszName );
716  CPLErr Rename( const char * pszNewName,
717  const char * pszOldName );
718  CPLErr CopyFiles( const char * pszNewName,
719  const char * pszOldName );
720 
721  GDALDataset *CreateCopy( const char *, GDALDataset *,
722  int, char **,
723  GDALProgressFunc pfnProgress,
724  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
725 
726 /* -------------------------------------------------------------------- */
727 /* The following are semiprivate, not intended to be accessed */
728 /* by anyone but the formats instantiating and populating the */
729 /* drivers. */
730 /* -------------------------------------------------------------------- */
731  GDALDataset *(*pfnOpen)( GDALOpenInfo * );
732 
733  GDALDataset *(*pfnCreate)( const char * pszName,
734  int nXSize, int nYSize, int nBands,
735  GDALDataType eType,
736  char ** papszOptions );
737 
738  CPLErr (*pfnDelete)( const char * pszName );
739 
740  GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
741  int, char **,
742  GDALProgressFunc pfnProgress,
743  void * pProgressData );
744 
745  void *pDriverData;
746 
747  void (*pfnUnloadDriver)(GDALDriver *);
748 
749  int (*pfnIdentify)( GDALOpenInfo * );
750 
751  CPLErr (*pfnRename)( const char * pszNewName,
752  const char * pszOldName );
753  CPLErr (*pfnCopyFiles)( const char * pszNewName,
754  const char * pszOldName );
755 
756 /* -------------------------------------------------------------------- */
757 /* Helper methods. */
758 /* -------------------------------------------------------------------- */
759  GDALDataset *DefaultCreateCopy( const char *, GDALDataset *,
760  int, char **,
761  GDALProgressFunc pfnProgress,
762  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
763  static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
764  GDALDataset *poDstDS,
765  int bStrict );
766  static CPLErr QuietDelete( const char * pszName );
767 
768  CPLErr DefaultRename( const char * pszNewName,
769  const char * pszOldName );
770  CPLErr DefaultCopyFiles( const char * pszNewName,
771  const char * pszOldName );
772 };
773 
774 /* ******************************************************************** */
775 /* GDALDriverManager */
776 /* ******************************************************************** */
777 
785 class CPL_DLL GDALDriverManager : public GDALMajorObject
786 {
787  int nDrivers;
788  GDALDriver **papoDrivers;
789 
790  char *pszHome;
791 
792  public:
795 
796  int GetDriverCount( void );
797  GDALDriver *GetDriver( int );
798  GDALDriver *GetDriverByName( const char * );
799 
800  int RegisterDriver( GDALDriver * );
801  void MoveDriver( GDALDriver *, int );
802  void DeregisterDriver( GDALDriver * );
803 
804  void AutoLoadDrivers();
805  void AutoSkipDrivers();
806 
807  const char *GetHome();
808  void SetHome( const char * );
809 };
810 
811 CPL_C_START
812 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
813 CPL_C_END
814 
815 /* ******************************************************************** */
816 /* GDALAsyncReader */
817 /* ******************************************************************** */
818 
824 class CPL_DLL GDALAsyncReader
825 {
826  protected:
827  GDALDataset* poDS;
828  int nXOff;
829  int nYOff;
830  int nXSize;
831  int nYSize;
832  void * pBuf;
833  int nBufXSize;
834  int nBufYSize;
835  GDALDataType eBufType;
836  int nBandCount;
837  int* panBandMap;
838  int nPixelSpace;
839  int nLineSpace;
840  int nBandSpace;
841 
842  public:
843  GDALAsyncReader();
844  virtual ~GDALAsyncReader();
845 
846  GDALDataset* GetGDALDataset() {return poDS;}
847  int GetXOffset() {return nXOff;}
848  int GetYOffset() {return nYOff;}
849  int GetXSize() {return nXSize;}
850  int GetYSize() {return nYSize;}
851  void * GetBuffer() {return pBuf;}
852  int GetBufferXSize() {return nBufXSize;}
853  int GetBufferYSize() {return nBufYSize;}
854  GDALDataType GetBufferType() {return eBufType;}
855  int GetBandCount() {return nBandCount;}
856  int* GetBandMap() {return panBandMap;}
857  int GetPixelSpace() {return nPixelSpace;}
858  int GetLineSpace() {return nLineSpace;}
859  int GetBandSpace() {return nBandSpace;}
860 
861  virtual GDALAsyncStatusType
862  GetNextUpdatedRegion(double dfTimeout,
863  int* pnBufXOff, int* pnBufYOff,
864  int* pnBufXSize, int* pnBufYSize) = 0;
865  virtual int LockBuffer( double dfTimeout = -1.0 );
866  virtual void UnlockBuffer();
867 };
868 
869 /* ==================================================================== */
870 /* An assortment of overview related stuff. */
871 /* ==================================================================== */
872 
873 /* Not a public symbol for the moment */
874 CPLErr
875 GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands,
876  int nOverviews,
877  GDALRasterBand*** papapoOverviewBands,
878  const char * pszResampling,
879  GDALProgressFunc pfnProgress, void * pProgressData );
880 
881 CPL_C_START
882 
883 #ifndef WIN32CE
884 
885 CPLErr CPL_DLL
886 HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
887  GDALDataset **ppoDS,
888  int nBands, int *panBandList,
889  int nNewOverviews, int *panNewOverviewList,
890  const char *pszResampling,
891  GDALProgressFunc pfnProgress,
892  void *pProgressData );
893 
894 #endif /* WIN32CE */
895 
896 CPLErr CPL_DLL
897 GTIFFBuildOverviews( const char * pszFilename,
898  int nBands, GDALRasterBand **papoBandList,
899  int nOverviews, int * panOverviewList,
900  const char * pszResampling,
901  GDALProgressFunc pfnProgress, void * pProgressData );
902 
903 CPLErr CPL_DLL
904 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
905  const char * pszResampling,
906  int nOverviews, int * panOverviewList,
907  int nBands, int * panBandList,
908  GDALProgressFunc pfnProgress, void * pProgressData);
909 
910 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
911  int &nXOff, int &nYOff,
912  int &nXSize, int &nYSize,
913  int nBufXSize, int nBufYSize);
914 
915 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize );
916 
917 GDALDataset CPL_DLL *
918 GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
919  GDALDataset *poDependentDS );
920 
921 /* ==================================================================== */
922 /* Misc functions. */
923 /* ==================================================================== */
924 
925 CPLErr CPL_DLL GDALParseGMLCoverage( CPLXMLNode *psTree,
926  int *pnXSize, int *pnYSize,
927  double *padfGeoTransform,
928  char **ppszProjection );
929 
930 /* ==================================================================== */
931 /* Infrastructure to check that dataset characteristics are valid */
932 /* ==================================================================== */
933 
934 int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize );
935 int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed );
936 
937 
938 // Test if 2 floating point values match. Usefull when comparing values
939 // stored as a string at some point. See #3573, #4183, #4506
940 #define ARE_REAL_EQUAL(dfVal1, dfVal2) \
941  (dfVal1 == dfVal2 || fabs(dfVal1 - dfVal2) < 1e-10 || (dfVal2 != 0 && fabs(1 - dfVal1 / dfVal2) < 1e-10 ))
942 
943 /* Internal use only */
944 
945 /* CPL_DLL exported, but only for in-tree drivers that can be built as plugins */
946 int CPL_DLL GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension,
947  double *padfGeoTransform, char** papszSiblingFiles,
948  char** ppszWorldFileNameOut);
949 int GDALReadTabFile2( const char * pszBaseFilename,
950  double *padfGeoTransform, char **ppszWKT,
951  int *pnGCPCount, GDAL_GCP **ppasGCPs,
952  char** papszSiblingFiles, char** ppszTabFileNameOut );
953 
954 CPL_C_END
955 
956 void GDALNullifyOpenDatasetsList();
957 void** GDALGetphDMMutex();
958 void** GDALGetphDLMutex();
959 void GDALNullifyProxyPoolSingleton();
960 GDALDriver* GDALGetAPIPROXYDriver();
961 void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
962 GIntBig GDALGetResponsiblePIDForCurrentThread();
963 
964 CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt,
965  char **papszSiblingFiles, int nFlags );
966 
967 CPLErr EXIFExtractMetadata(char**& papszMetadata,
968  void *fpL, int nOffset,
969  int bSwabflag, int nTIFFHEADER,
970  int& nExifOffset, int& nInterOffset, int& nGPSOffset);
971 
972 #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) )
973 
974 // Number of data samples that will be used to compute approximate statistics
975 // (minimum value, maximum value, etc.)
976 #define GDALSTAT_APPROX_NUMSAMPLES 2500
977 
978 CPL_C_START
979 /* Caution: for technical reason this declaration is duplicated in gdal_crs.c */
980 /* so any signature change should be reflected there too */
981 void GDALSerializeGCPListToXML( CPLXMLNode* psParentNode,
982  GDAL_GCP* pasGCPList,
983  int nGCPCount,
984  const char* pszGCPProjection );
985 void GDALDeserializeGCPListFromXML( CPLXMLNode* psGCPList,
986  GDAL_GCP** ppasGCPList,
987  int* pnGCPCount,
988  char** ppszGCPProjection );
989 CPL_C_END
990 
991 #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
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:3280
GDALDataType
Definition: gdal.h:55
Definition: gdal_priv.h:674
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:4450
Definitions for CPL mini XML Parser/Serializer.
Definition: gdal.h:134
Definition: gdal_proxy.h:99
GDALDatasetH GDALOpenShared(const char *, GDALAccess) CPL_WARN_UNUSED_RESULT
Open a raster file as a GDALDataset.
Definition: gdaldataset.cpp:2408
GDALRWFlag
Definition: gdal.h:99
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition: gdal.h:162
Definition: gdal_priv.h:654
Color tuple.
Definition: gdal.h:640
A single raster block in the block cache.
Definition: gdal_priv.h:384
virtual int GetMaskFlags()
Return the status flags of the mask band associated with the band.
Definition: gdalrasterband.cpp:4641
Convenient string class based on std::string.
Definition: cpl_string.h:226
virtual CPLErr BuildOverviews(const char *, int, int *, GDALProgressFunc, void *)
Build raster overview(s)
Definition: gdalrasterband.cpp:2194
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:1359
Various convenience functions for working with strings and string lists.
Definition: gdal_priv.h:143
virtual CPLErr FlushCache()
Flush raster data cache.
Definition: gdalrasterband.cpp:850
virtual CPLErr CreateMaskBand(int nFlags)
Adds a mask band to the current band.
Definition: gdalrasterband.cpp:4714
virtual CPLErr CreateMaskBand(int nFlags)
Adds a mask band to the dataset.
Definition: gdaldataset.cpp:2161
Public (C callable) GDAL entry points.
GDALAsyncStatusType
status of the asynchronous stream
Definition: gdal.h:80
Definition: gdal_proxy.h:44
GDALRasterBand * GetBand()
Accessor to source GDALRasterBand object.
Definition: gdal_priv.h:430
Definition: gdal_priv.h:220
Definition: gdal_priv.h:637
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:300
GDALDatasetH GDALOpen(const char *pszFilename, GDALAccess eAccess) CPL_WARN_UNUSED_RESULT
Open a raster file as a GDALDataset.
Definition: gdaldataset.cpp:2251
GDALPaletteInterp
Definition: gdal.h:131
virtual int CloseDependentDatasets()
Drop references to any other datasets referenced by this dataset.
Definition: gdaldataset.cpp:2789
Various convenience functions for CPL.
void ReportError(CPLErr eErrClass, int err_no, const char *fmt,...) CPL_PRINT_FUNC_FORMAT(4
Emits an error related to a raster band.
Definition: gdalrasterband.cpp:4931
Object with metadata.
Definition: gdal_priv.h:109
CPLErr RasterIO(GDALRWFlag, int, int, int, int, void *, int, int, GDALDataType, int, int)
Read/write a region of image data for this band.
Definition: gdalrasterband.cpp:170
A single raster band (or channel).
Definition: gdal_priv.h:475
GDALAccess
Definition: gdal.h:93
Definition: gdal_priv.h:73
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:254
GDALAccess GetAccess()
Find out if we have update permission for this band.
Definition: gdalrasterband.cpp:1395
Class for managing the registration of file format drivers.
Definition: gdal_priv.h:785
GDALColorInterp
Definition: gdal.h:105
Format specific driver.
Definition: gdal_priv.h:702
Definition: gdal_priv.h:447
Ground Control Point.
Definition: gdal.h:255
Class used as a session object for asynchronous requests.
Definition: gdal_priv.h:824

Generated for GDAL by doxygen 1.8.8.