GDAL
gdal_priv.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: gdal_priv.h 37354 2017-02-12 15:27:47Z 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;
51 class GDALProxyRasterBand;
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 
73 #define GMO_VALID 0x0001
74 #define GMO_IGNORE_UNIMPLEMENTED 0x0002
75 #define GMO_SUPPORT_MD 0x0004
76 #define GMO_SUPPORT_MDMD 0x0008
77 #define GMO_MD_DIRTY 0x0010
78 #define GMO_PAM_CLASS 0x0020
79 
81 /************************************************************************/
82 /* GDALMultiDomainMetadata */
83 /************************************************************************/
84 
86 class CPL_DLL GDALMultiDomainMetadata
87 {
88 private:
89  char **papszDomainList;
90  CPLStringList **papoMetadataLists;
91 
92 public:
93  GDALMultiDomainMetadata();
94  ~GDALMultiDomainMetadata();
95 
96  int XMLInit( CPLXMLNode *psMetadata, int bMerge );
97  CPLXMLNode *Serialize();
98 
99  char **GetDomainList() { return papszDomainList; }
100 
101  char **GetMetadata( const char * pszDomain = "" );
102  CPLErr SetMetadata( char ** papszMetadata,
103  const char * pszDomain = "" );
104  const char *GetMetadataItem( const char * pszName,
105  const char * pszDomain = "" );
106  CPLErr SetMetadataItem( const char * pszName,
107  const char * pszValue,
108  const char * pszDomain = "" );
109 
110  void Clear();
111 
112  private:
113  CPL_DISALLOW_COPY_ASSIGN(GDALMultiDomainMetadata)
114 };
116 
117 /* ******************************************************************** */
118 /* GDALMajorObject */
119 /* */
120 /* Base class providing metadata, description and other */
121 /* services shared by major objects. */
122 /* ******************************************************************** */
123 
125 class CPL_DLL GDALMajorObject
126 {
127  protected:
129  int nFlags; // GMO_* flags.
130  CPLString sDescription;
131  GDALMultiDomainMetadata oMDMD;
132 
134 
135  char **BuildMetadataDomainList( char** papszList,
136  int bCheckNonEmpty, ... ) CPL_NULL_TERMINATED;
137  public:
138  GDALMajorObject();
139  virtual ~GDALMajorObject();
140 
141  int GetMOFlags() const;
142  void SetMOFlags( int nFlagsIn );
143 
144  virtual const char *GetDescription() const;
145  virtual void SetDescription( const char * );
146 
147  virtual char **GetMetadataDomainList();
148 
149  virtual char **GetMetadata( const char * pszDomain = "" );
150  virtual CPLErr SetMetadata( char ** papszMetadata,
151  const char * pszDomain = "" );
152  virtual const char *GetMetadataItem( const char * pszName,
153  const char * pszDomain = "" );
154  virtual CPLErr SetMetadataItem( const char * pszName,
155  const char * pszValue,
156  const char * pszDomain = "" );
157 };
158 
159 /* ******************************************************************** */
160 /* GDALDefaultOverviews */
161 /* ******************************************************************** */
162 
164 class CPL_DLL GDALDefaultOverviews
165 {
166  friend class GDALDataset;
167 
168  GDALDataset *poDS;
169  GDALDataset *poODS;
170 
171  CPLString osOvrFilename;
172 
173  bool bOvrIsAux;
174 
175  bool bCheckedForMask;
176  bool bOwnMaskDS;
177  GDALDataset *poMaskDS;
178 
179  // For "overview datasets" we record base level info so we can
180  // find our way back to get overview masks.
181  GDALDataset *poBaseDS;
182 
183  // Stuff for deferred initialize/overviewscans.
184  bool bCheckedForOverviews;
185  void OverviewScan();
186  char *pszInitName;
187  bool bInitNameIsOVR;
188  char **papszInitSiblingFiles;
189 
190  public:
191  GDALDefaultOverviews();
192  ~GDALDefaultOverviews();
193 
194  void Initialize( GDALDataset *poDSIn, const char *pszName = NULL,
195  char **papszSiblingFiles = NULL,
196  int bNameIsOVR = FALSE );
197 
198  void TransferSiblingFiles( char** papszSiblingFiles );
199 
200  int IsInitialized();
201 
203 
204  // Overview Related
205 
206  int GetOverviewCount( int nBand );
207  GDALRasterBand *GetOverview( int nBand, int iOverview );
208 
209  CPLErr BuildOverviews( const char * pszBasename,
210  const char * pszResampling,
211  int nOverviews, int * panOverviewList,
212  int nBands, int * panBandList,
213  GDALProgressFunc pfnProgress,
214  void *pProgressData );
215 
216  CPLErr BuildOverviewsSubDataset( const char * pszPhysicalFile,
217  const char * pszResampling,
218  int nOverviews, int * panOverviewList,
219  int nBands, int * panBandList,
220  GDALProgressFunc pfnProgress,
221  void *pProgressData );
222 
223  CPLErr CleanOverviews();
224 
225  // Mask Related
226 
227  CPLErr CreateMaskBand( int nFlags, int nBand = -1 );
228  GDALRasterBand *GetMaskBand( int nBand );
229  int GetMaskFlags( int nBand );
230 
231  int HaveMaskFile( char **papszSiblings = NULL,
232  const char *pszBasename = NULL );
233 
234  char** GetSiblingFiles() { return papszInitSiblingFiles; }
235 
236  private:
237  CPL_DISALLOW_COPY_ASSIGN(GDALDefaultOverviews)
238 };
240 
241 /* ******************************************************************** */
242 /* GDALOpenInfo */
243 /* ******************************************************************** */
244 
246 class CPL_DLL GDALOpenInfo
247 {
248  bool bHasGotSiblingFiles;
249  char **papszSiblingFiles;
250  int nHeaderBytesTried;
251 
252  public:
253  GDALOpenInfo( const char * pszFile, int nOpenFlagsIn,
254  char **papszSiblingFiles = NULL );
255  ~GDALOpenInfo( void );
256 
258  char *pszFilename;
261 
266 
268  int bStatOK;
271 
274 
279 
281  const char* const* papszAllowedDrivers;
282 
283  int TryToIngest(int nBytes);
284  char **GetSiblingFiles();
285  char **StealSiblingFiles();
286  bool AreSiblingFilesLoaded() const;
287 
288  private:
290 };
291 
292 /* ******************************************************************** */
293 /* GDALDataset */
294 /* ******************************************************************** */
295 
296 class OGRLayer;
297 class OGRGeometry;
298 class OGRSpatialReference;
299 class OGRStyleTable;
300 class swq_select;
301 class swq_select_parse_options;
302 
304 typedef struct GDALSQLParseInfo GDALSQLParseInfo;
306 
307 #ifdef DETECT_OLD_IRASTERIO
308 typedef void signature_changed;
309 #endif
310 
312 #ifdef GDAL_COMPILATION
313 #define OPTIONAL_OUTSIDE_GDAL(val)
314 #else
315 #define OPTIONAL_OUTSIDE_GDAL(val) = val
316 #endif
317 
319 class OGRFeature;
320 
322 class CPL_DLL GDALDataset : public GDALMajorObject
323 {
324  friend GDALDatasetH CPL_STDCALL GDALOpenEx( const char* pszFilename,
325  unsigned int nOpenFlags,
326  const char* const* papszAllowedDrivers,
327  const char* const* papszOpenOptions,
328  const char* const* papszSiblingFiles );
329  friend void CPL_STDCALL GDALClose( GDALDatasetH hDS );
330 
331  friend class GDALDriver;
332  friend class GDALDefaultOverviews;
333  friend class GDALProxyDataset;
334  friend class GDALDriverManager;
335 
336  void AddToDatasetOpenList();
337 
338  void Init( bool bForceCachedIO );
339 
340  protected:
342  GDALDriver *poDriver;
343  GDALAccess eAccess;
344 
345  // Stored raster information.
346  int nRasterXSize;
347  int nRasterYSize;
348  int nBands;
349  GDALRasterBand **papoBands;
350 
351  int nOpenFlags;
352 
353  int nRefCount;
354  bool bForceCachedIO;
355  bool bShared;
356  bool bIsInternal;
357  bool bSuppressOnClose;
358 
359  GDALDataset(void);
360  explicit GDALDataset(int bForceCachedIO);
361 
362  void RasterInitialize( int, int );
363  void SetBand( int, GDALRasterBand * );
364 
365  GDALDefaultOverviews oOvManager;
366 
367  virtual CPLErr IBuildOverviews( const char *, int, int *,
368  int, int *, GDALProgressFunc, void * );
369 
370 #ifdef DETECT_OLD_IRASTERIO
371  virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int,
372  void *, int, int, GDALDataType,
373  int, int *, int, int, int ) {};
374 #endif
375 
376  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
377  void *, int, int, GDALDataType,
378  int, int *, GSpacing, GSpacing, GSpacing,
380 
381  CPLErr BlockBasedRasterIO( GDALRWFlag, int, int, int, int,
382  void *, int, int, GDALDataType,
383  int, int *, GSpacing, GSpacing, GSpacing,
385  void BlockBasedFlushCache();
386 
387  CPLErr BandBasedRasterIO( GDALRWFlag eRWFlag,
388  int nXOff, int nYOff, int nXSize, int nYSize,
389  void * pData, int nBufXSize, int nBufYSize,
390  GDALDataType eBufType,
391  int nBandCount, int *panBandMap,
392  GSpacing nPixelSpace, GSpacing nLineSpace,
393  GSpacing nBandSpace,
395 
396  CPLErr RasterIOResampled( GDALRWFlag eRWFlag,
397  int nXOff, int nYOff, int nXSize, int nYSize,
398  void * pData, int nBufXSize, int nBufYSize,
399  GDALDataType eBufType,
400  int nBandCount, int *panBandMap,
401  GSpacing nPixelSpace, GSpacing nLineSpace,
402  GSpacing nBandSpace,
404 
405  CPLErr ValidateRasterIOOrAdviseReadParameters(
406  const char* pszCallingFunc,
407  int* pbStopProcessingOnCENone,
408  int nXOff, int nYOff, int nXSize, int nYSize,
409  int nBufXSize, int nBufYSize,
410  int nBandCount, int *panBandMap);
411 
412  CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
413  int nXOff, int nYOff, int nXSize, int nYSize,
414  void * pData, int nBufXSize, int nBufYSize,
415  GDALDataType eBufType,
416  int nBandCount, int *panBandMap,
417  GSpacing nPixelSpace, GSpacing nLineSpace,
418  GSpacing nBandSpace,
419  GDALRasterIOExtraArg* psExtraArg,
420  int* pbTried);
421 
423  virtual int CloseDependentDatasets();
425  int ValidateLayerCreationOptions( const char* const* papszLCO );
426 
427  char **papszOpenOptions;
428 
429  friend class GDALRasterBand;
430 
431  // The below methods related to read write mutex are fragile logic, and
432  // should not be used by out-of-tree code if possible.
433  int EnterReadWrite(GDALRWFlag eRWFlag);
434  void LeaveReadWrite();
435  void InitRWLock();
436 
437  void TemporarilyDropReadWriteLock();
438  void ReacquireReadWriteLock();
439 
440  void DisableReadWriteMutex();
441 
442  int AcquireMutex();
443  void ReleaseMutex();
445 
446  public:
447  virtual ~GDALDataset();
448 
449  int GetRasterXSize( void );
450  int GetRasterYSize( void );
451  int GetRasterCount( void );
452  GDALRasterBand *GetRasterBand( int );
453 
454  virtual void FlushCache(void);
455 
456  virtual const char *GetProjectionRef(void);
457  virtual CPLErr SetProjection( const char * pszProjection );
458 
459  virtual CPLErr GetGeoTransform( double * padfTransform );
460  virtual CPLErr SetGeoTransform( double * padfTransform );
461 
462  virtual CPLErr AddBand( GDALDataType eType,
463  char **papszOptions=NULL );
464 
465  virtual void *GetInternalHandle( const char * pszHandleName );
466  virtual GDALDriver *GetDriver(void);
467  virtual char **GetFileList(void);
468 
469  virtual const char* GetDriverName();
470 
471  virtual int GetGCPCount();
472  virtual const char *GetGCPProjection();
473  virtual const GDAL_GCP *GetGCPs();
474  virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
475  const char *pszGCPProjection );
476 
477  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
478  int nBufXSize, int nBufYSize,
479  GDALDataType eDT,
480  int nBandCount, int *panBandList,
481  char **papszOptions );
482 
483  virtual CPLErr CreateMaskBand( int nFlagsIn );
484 
485  virtual GDALAsyncReader*
486  BeginAsyncReader(int nXOff, int nYOff, int nXSize, int nYSize,
487  void *pBuf, int nBufXSize, int nBufYSize,
488  GDALDataType eBufType,
489  int nBandCount, int* panBandMap,
490  int nPixelSpace, int nLineSpace, int nBandSpace,
491  char **papszOptions);
492  virtual void EndAsyncReader(GDALAsyncReader *);
493 
494  CPLErr RasterIO( GDALRWFlag, int, int, int, int,
495  void *, int, int, GDALDataType,
496  int, int *, GSpacing, GSpacing, GSpacing,
497  GDALRasterIOExtraArg* psExtraArg
498 #ifndef DOXYGEN_SKIP
499  OPTIONAL_OUTSIDE_GDAL(NULL)
500 #endif
502 
503  int Reference();
504  int Dereference();
508  GDALAccess GetAccess() const { return eAccess; }
509 
510  int GetShared() const;
511  void MarkAsShared();
512 
514  void MarkSuppressOnClose() { bSuppressOnClose = true; }
515 
519  char **GetOpenOptions() { return papszOpenOptions; }
520 
521  static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
522 
523  CPLErr BuildOverviews( const char *, int, int *,
524  int, int *, GDALProgressFunc, void * );
525 
526  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
527 
528  virtual char ** GetMetadata(const char * pszDomain = "") CPL_OVERRIDE;
529 
530 // Only defined when Doxygen enabled
531 #ifdef DOXYGEN_SKIP
532  virtual CPLErr SetMetadata( char ** papszMetadata,
533  const char * pszDomain ) CPL_OVERRIDE;
534  virtual const char *GetMetadataItem( const char * pszName,
535  const char * pszDomain ) CPL_OVERRIDE;
536  virtual CPLErr SetMetadataItem( const char * pszName,
537  const char * pszValue,
538  const char * pszDomain ) CPL_OVERRIDE;
539 #endif
540 
541  virtual char ** GetMetadataDomainList() CPL_OVERRIDE;
542 
543 private:
544  void *m_hPrivateData;
545 
546  OGRLayer* BuildLayerFromSelectInfo(swq_select* psSelectInfo,
547  OGRGeometry *poSpatialFilter,
548  const char *pszDialect,
549  swq_select_parse_options* poSelectParseOptions);
550  CPLStringList oDerivedMetadataList;
551  public:
552 
553  virtual int GetLayerCount();
554  virtual OGRLayer *GetLayer(int iLayer);
555  virtual OGRLayer *GetLayerByName(const char *);
556  virtual OGRErr DeleteLayer(int iLayer);
557 
558  virtual void ResetReading();
559  virtual OGRFeature* GetNextFeature( OGRLayer** ppoBelongingLayer,
560  double* pdfProgressPct,
561  GDALProgressFunc pfnProgress,
562  void* pProgressData );
563 
564  virtual int TestCapability( const char * );
565 
566  virtual OGRLayer *CreateLayer( const char *pszName,
567  OGRSpatialReference *poSpatialRef = NULL,
569  char ** papszOptions = NULL );
570  virtual OGRLayer *CopyLayer( OGRLayer *poSrcLayer,
571  const char *pszNewName,
572  char **papszOptions = NULL );
573 
574  virtual OGRStyleTable *GetStyleTable();
575  virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
576 
577  virtual void SetStyleTable(OGRStyleTable *poStyleTable);
578 
579  virtual OGRLayer * ExecuteSQL( const char *pszStatement,
580  OGRGeometry *poSpatialFilter,
581  const char *pszDialect );
582  virtual void ReleaseResultSet( OGRLayer * poResultsSet );
583 
584  int GetRefCount() const;
585  int GetSummaryRefCount() const;
586  OGRErr Release();
587 
588  virtual OGRErr StartTransaction(int bForce=FALSE);
589  virtual OGRErr CommitTransaction();
590  virtual OGRErr RollbackTransaction();
591 
593  static int IsGenericSQLDialect(const char* pszDialect);
594 
595  // Semi-public methods. Only to be used by in-tree drivers.
596  GDALSQLParseInfo* BuildParseInfo(swq_select* psSelectInfo,
597  swq_select_parse_options* poSelectParseOptions);
598  static void DestroyParseInfo(GDALSQLParseInfo* psParseInfo );
599  OGRLayer * ExecuteSQL( const char *pszStatement,
600  OGRGeometry *poSpatialFilter,
601  const char *pszDialect,
602  swq_select_parse_options* poSelectParseOptions);
604 
605  protected:
606  virtual OGRLayer *ICreateLayer( const char *pszName,
607  OGRSpatialReference *poSpatialRef = NULL,
608  OGRwkbGeometryType eGType = wkbUnknown,
609  char ** papszOptions = NULL );
610 
612  OGRErr ProcessSQLCreateIndex( const char * );
613  OGRErr ProcessSQLDropIndex( const char * );
614  OGRErr ProcessSQLDropTable( const char * );
615  OGRErr ProcessSQLAlterTableAddColumn( const char * );
616  OGRErr ProcessSQLAlterTableDropColumn( const char * );
617  OGRErr ProcessSQLAlterTableAlterColumn( const char * );
618  OGRErr ProcessSQLAlterTableRenameColumn( const char * );
619 
620  OGRStyleTable *m_poStyleTable;
622 
623  private:
625 };
626 
627 /* ******************************************************************** */
628 /* GDALRasterBlock */
629 /* ******************************************************************** */
630 
635 class CPL_DLL GDALRasterBlock
636 {
637  friend class GDALAbstractBandBlockCache;
638 
639  GDALDataType eType;
640 
641  bool bDirty;
642  volatile int nLockCount;
643 
644  int nXOff;
645  int nYOff;
646 
647  int nXSize;
648  int nYSize;
649 
650  void *pData;
651 
652  GDALRasterBand *poBand;
653 
654  GDALRasterBlock *poNext;
655  GDALRasterBlock *poPrevious;
656 
657  bool bMustDetach;
658 
659  void Detach_unlocked( void );
660  void Touch_unlocked( void );
661 
662  void RecycleFor( int nXOffIn, int nYOffIn );
663 
664  public:
665  GDALRasterBlock( GDALRasterBand *, int, int );
666  GDALRasterBlock( int nXOffIn, int nYOffIn ); /* only for lookup purpose */
667  virtual ~GDALRasterBlock();
668 
669  CPLErr Internalize( void );
670  void Touch( void );
671  void MarkDirty( void );
672  void MarkClean( void );
674  int AddLock( void ) { return CPLAtomicInc(&nLockCount); }
676  int DropLock( void ) { return CPLAtomicDec(&nLockCount); }
677  void Detach();
678 
679  CPLErr Write();
680 
684  GDALDataType GetDataType() const { return eType; }
688  int GetXOff() const { return nXOff; }
692  int GetYOff() const { return nYOff; }
696  int GetXSize() const { return nXSize; }
700  int GetYSize() const { return nYSize; }
704  int GetDirty() const { return bDirty; }
708  void *GetDataRef( void ) { return pData; }
712  int GetBlockSize() const {
713  return nXSize * nYSize * GDALGetDataTypeSizeBytes(eType); }
714 
715  int TakeLock();
716  int DropLockForRemovalFromStorage();
717 
720  GDALRasterBand *GetBand() { return poBand; }
721 
722  static void FlushDirtyBlocks();
723  static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE);
724  static void Verify();
725 
726 #ifdef notdef
727  static void CheckNonOrphanedBlocks(GDALRasterBand* poBand);
728  void DumpBlock();
729  static void DumpAll();
730 #endif
731 
732  /* Should only be called by GDALDestroyDriverManager() */
734  static void DestroyRBMutex();
736 
737  private:
738  CPL_DISALLOW_COPY_ASSIGN(GDALRasterBlock)
739 };
740 
741 /* ******************************************************************** */
742 /* GDALColorTable */
743 /* ******************************************************************** */
744 
747 class CPL_DLL GDALColorTable
748 {
749  GDALPaletteInterp eInterp;
750 
751  std::vector<GDALColorEntry> aoEntries;
752 
753 public:
755  ~GDALColorTable();
756 
757  GDALColorTable *Clone() const;
758  int IsSame(const GDALColorTable* poOtherCT) const;
759 
760  GDALPaletteInterp GetPaletteInterpretation() const;
761 
762  int GetColorEntryCount() const;
763  const GDALColorEntry *GetColorEntry( int ) const;
764  int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
765  void SetColorEntry( int, const GDALColorEntry * );
766  int CreateColorRamp( int, const GDALColorEntry * ,
767  int, const GDALColorEntry * );
768 };
769 
770 /* ******************************************************************** */
771 /* GDALAbstractBandBlockCache */
772 /* ******************************************************************** */
773 
775 
777 // CPL_DLL is just technical here. This is really a private concept
778 // only used by GDALRasterBand implementation.
779 
780 class CPL_DLL GDALAbstractBandBlockCache
781 {
782  // List of blocks that can be freed or recycled, and its lock
783  CPLLock *hSpinLock;
784  GDALRasterBlock *psListBlocksToFree;
785 
786  // Band keep alive counter, and its lock & condition
787  CPLCond *hCond;
788  CPLMutex *hCondMutex;
789  volatile int nKeepAliveCounter;
790 
791  protected:
792  GDALRasterBand *poBand;
793 
794  void FreeDanglingBlocks();
795  void UnreferenceBlockBase();
796  void WaitKeepAliveCounter();
797 
798  public:
799  explicit GDALAbstractBandBlockCache(GDALRasterBand* poBand);
800  virtual ~GDALAbstractBandBlockCache();
801 
802  GDALRasterBlock* CreateBlock(int nXBlockOff, int nYBlockOff);
803  void AddBlockToFreeList( GDALRasterBlock * );
804 
805  virtual bool Init() = 0;
806  virtual bool IsInitOK() = 0;
807  virtual CPLErr FlushCache() = 0;
808  virtual CPLErr AdoptBlock( GDALRasterBlock* poBlock ) = 0;
809  virtual GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff,
810  int nYBlockYOff ) = 0;
811  virtual CPLErr UnreferenceBlock( GDALRasterBlock* poBlock ) = 0;
812  virtual CPLErr FlushBlock( int nXBlockOff, int nYBlockOff,
813  int bWriteDirtyBlock ) = 0;
814 };
815 
816 GDALAbstractBandBlockCache* GDALArrayBandBlockCacheCreate(GDALRasterBand* poBand);
817 GDALAbstractBandBlockCache* GDALHashSetBandBlockCacheCreate(GDALRasterBand* poBand);
818 
820 
821 /* ******************************************************************** */
822 /* GDALRasterBand */
823 /* ******************************************************************** */
824 
827 class CPL_DLL GDALRasterBand : public GDALMajorObject
828 {
829  private:
830  friend class GDALArrayBandBlockCache;
831  friend class GDALHashSetBandBlockCache;
832  friend class GDALRasterBlock;
833 
834  CPLErr eFlushBlockErr;
835  GDALAbstractBandBlockCache* poBandBlockCache;
836 
837  void SetFlushBlockErr( CPLErr eErr );
838  CPLErr UnreferenceBlock( GDALRasterBlock* poBlock );
839 
840  void Init(int bForceCachedIO);
841 
842  protected:
844  GDALDataset *poDS;
845  int nBand; /* 1 based */
846 
847  int nRasterXSize;
848  int nRasterYSize;
849 
850  GDALDataType eDataType;
851  GDALAccess eAccess;
852 
853  /* stuff related to blocking, and raster cache */
854  int nBlockXSize;
855  int nBlockYSize;
856  int nBlocksPerRow;
857  int nBlocksPerColumn;
858 
859  int nBlockReads;
860  int bForceCachedIO;
861 
862  GDALRasterBand *poMask;
863  bool bOwnMask;
864  int nMaskFlags;
865 
866  void InvalidateMaskBand();
867 
868  friend class GDALDataset;
869  friend class GDALProxyRasterBand;
870  friend class GDALDefaultOverviews;
871 
872  CPLErr RasterIOResampled( GDALRWFlag, int, int, int, int,
873  void *, int, int, GDALDataType,
875 
876  int EnterReadWrite(GDALRWFlag eRWFlag);
877  void LeaveReadWrite();
878  void InitRWLock();
880 
881  protected:
882  virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void * pData ) = 0;
883  virtual CPLErr IWriteBlock( int nBlockXOff, int nBlockYOff, void * pData );
884 
885 #ifdef DETECT_OLD_IRASTERIO
886  virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int,
887  void *, int, int, GDALDataType,
888  int, int ) {};
889 #endif
890 
891  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
892  void *, int, int, GDALDataType,
894 
895  virtual int IGetDataCoverageStatus( int nXOff, int nYOff,
896  int nXSize, int nYSize,
897  int nMaskFlagStop,
898  double* pdfDataPct);
900  CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
901  void *, int, int, GDALDataType,
903 
904  CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
905  int nXOff, int nYOff, int nXSize, int nYSize,
906  void * pData, int nBufXSize, int nBufYSize,
907  GDALDataType eBufType,
908  GSpacing nPixelSpace, GSpacing nLineSpace,
909  GDALRasterIOExtraArg* psExtraArg,
910  int* pbTried );
911 
912  int InitBlockInfo();
913 
914  void AddBlockToFreeList( GDALRasterBlock * );
916 
917  GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
918 
919  public:
920  GDALRasterBand();
921  explicit GDALRasterBand(int bForceCachedIO);
922 
923  virtual ~GDALRasterBand();
924 
925  int GetXSize();
926  int GetYSize();
927  int GetBand();
928  GDALDataset*GetDataset();
929 
930  GDALDataType GetRasterDataType( void );
931  void GetBlockSize( int *, int * );
932  CPLErr GetActualBlockSize ( int, int, int *, int * );
933  GDALAccess GetAccess();
934 
935  CPLErr RasterIO( GDALRWFlag, int, int, int, int,
936  void *, int, int, GDALDataType,
938 #ifndef DOXYGEN_SKIP
939  OPTIONAL_OUTSIDE_GDAL(NULL)
940 #endif
942  CPLErr ReadBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
943 
944  CPLErr WriteBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
945 
946  GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
947  int bJustInitialize = FALSE ) CPL_WARN_UNUSED_RESULT;
948  CPLErr FlushBlock( int, int, int bWriteDirtyBlock = TRUE );
949 
950  unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand,
951  unsigned char* pTranslationTable = NULL,
952  int* pApproximateMatching = NULL);
953 
954  // New OpengIS CV_SampleDimension stuff.
955 
956  virtual CPLErr FlushCache();
957  virtual char **GetCategoryNames();
958  virtual double GetNoDataValue( int *pbSuccess = NULL );
959  virtual double GetMinimum( int *pbSuccess = NULL );
960  virtual double GetMaximum(int *pbSuccess = NULL );
961  virtual double GetOffset( int *pbSuccess = NULL );
962  virtual double GetScale( int *pbSuccess = NULL );
963  virtual const char *GetUnitType();
964  virtual GDALColorInterp GetColorInterpretation();
965  virtual GDALColorTable *GetColorTable();
966  virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
967 
968  virtual CPLErr SetCategoryNames( char ** papszNames );
969  virtual CPLErr SetNoDataValue( double dfNoData );
970  virtual CPLErr DeleteNoDataValue();
971  virtual CPLErr SetColorTable( GDALColorTable * poCT );
972  virtual CPLErr SetColorInterpretation( GDALColorInterp eColorInterp );
973  virtual CPLErr SetOffset( double dfNewOffset );
974  virtual CPLErr SetScale( double dfNewScale );
975  virtual CPLErr SetUnitType( const char * pszNewValue );
976 
977  virtual CPLErr GetStatistics( int bApproxOK, int bForce,
978  double *pdfMin, double *pdfMax,
979  double *pdfMean, double *padfStdDev );
980  virtual CPLErr ComputeStatistics( int bApproxOK,
981  double *pdfMin, double *pdfMax,
982  double *pdfMean, double *pdfStdDev,
983  GDALProgressFunc, void *pProgressData );
984  virtual CPLErr SetStatistics( double dfMin, double dfMax,
985  double dfMean, double dfStdDev );
986  virtual CPLErr ComputeRasterMinMax( int, double* );
987 
988 // Only defined when Doxygen enabled
989 #ifdef DOXYGEN_SKIP
990  virtual char **GetMetadata( const char * pszDomain = "" ) CPL_OVERRIDE;
991  virtual CPLErr SetMetadata( char ** papszMetadata,
992  const char * pszDomain ) CPL_OVERRIDE;
993  virtual const char *GetMetadataItem( const char * pszName,
994  const char * pszDomain ) CPL_OVERRIDE;
995  virtual CPLErr SetMetadataItem( const char * pszName,
996  const char * pszValue,
997  const char * pszDomain ) CPL_OVERRIDE;
998 #endif
999 
1000  virtual int HasArbitraryOverviews();
1001  virtual int GetOverviewCount();
1002  virtual GDALRasterBand *GetOverview(int);
1003  virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig );
1004  virtual CPLErr BuildOverviews( const char * pszResampling,
1005  int nOverviews,
1006  int * panOverviewList,
1007  GDALProgressFunc pfnProgress,
1008  void * pProgressData );
1009 
1010  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
1011  int nBufXSize, int nBufYSize,
1012  GDALDataType eBufType, char **papszOptions );
1013 
1014  virtual CPLErr GetHistogram( double dfMin, double dfMax,
1015  int nBuckets, GUIntBig * panHistogram,
1016  int bIncludeOutOfRange, int bApproxOK,
1017  GDALProgressFunc, void *pProgressData );
1018 
1019  virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
1020  int *pnBuckets, GUIntBig ** ppanHistogram,
1021  int bForce,
1022  GDALProgressFunc, void *pProgressData);
1023  virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
1024  int nBuckets, GUIntBig *panHistogram );
1025 
1026  virtual GDALRasterAttributeTable *GetDefaultRAT();
1027  virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * poRAT );
1028 
1029  virtual GDALRasterBand *GetMaskBand();
1030  virtual int GetMaskFlags();
1031  virtual CPLErr CreateMaskBand( int nFlagsIn );
1032 
1033  virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
1034  int *pnPixelSpace,
1035  GIntBig *pnLineSpace,
1036  char **papszOptions ) CPL_WARN_UNUSED_RESULT;
1037 
1038  int GetDataCoverageStatus( int nXOff, int nYOff,
1039  int nXSize, int nYSize,
1040  int nMaskFlagStop = 0,
1041  double* pdfDataPct = NULL );
1042 
1043  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
1044 
1045 private:
1047 };
1048 
1050 /* ******************************************************************** */
1051 /* GDALAllValidMaskBand */
1052 /* ******************************************************************** */
1053 
1054 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
1055 {
1056  protected:
1057  virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE;
1058 
1059  public:
1060  explicit GDALAllValidMaskBand( GDALRasterBand * );
1061  virtual ~GDALAllValidMaskBand();
1062 
1063  virtual GDALRasterBand *GetMaskBand() CPL_OVERRIDE;
1064  virtual int GetMaskFlags() CPL_OVERRIDE;
1065 };
1066 
1067 /* ******************************************************************** */
1068 /* GDALNoDataMaskBand */
1069 /* ******************************************************************** */
1070 
1071 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
1072 {
1073  double dfNoDataValue;
1074  GDALRasterBand *poParent;
1075 
1076  protected:
1077  virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE;
1078  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1079  void *, int, int, GDALDataType,
1080  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_OVERRIDE;
1081 
1082  public:
1083  explicit GDALNoDataMaskBand( GDALRasterBand * );
1084  virtual ~GDALNoDataMaskBand();
1085 };
1086 
1087 /* ******************************************************************** */
1088 /* GDALNoDataValuesMaskBand */
1089 /* ******************************************************************** */
1090 
1091 class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
1092 {
1093  double *padfNodataValues;
1094 
1095  protected:
1096  virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE;
1097 
1098  public:
1099  explicit GDALNoDataValuesMaskBand( GDALDataset * );
1100  virtual ~GDALNoDataValuesMaskBand();
1101 };
1102 
1103 /* ******************************************************************** */
1104 /* GDALRescaledAlphaBand */
1105 /* ******************************************************************** */
1106 
1107 class GDALRescaledAlphaBand : public GDALRasterBand
1108 {
1109  GDALRasterBand *poParent;
1110  void *pTemp;
1111 
1112  protected:
1113  virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE;
1114  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1115  void *, int, int, GDALDataType,
1116  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_OVERRIDE;
1117 
1118  public:
1119  explicit GDALRescaledAlphaBand( GDALRasterBand * );
1120  virtual ~GDALRescaledAlphaBand();
1121 };
1123 
1124 /* ******************************************************************** */
1125 /* GDALIdentifyEnum */
1126 /* ******************************************************************** */
1127 
1133 typedef enum
1134 {
1142 
1143 /* ******************************************************************** */
1144 /* GDALDriver */
1145 /* ******************************************************************** */
1146 
1158 class CPL_DLL GDALDriver : public GDALMajorObject
1159 {
1160  public:
1161  GDALDriver();
1162  virtual ~GDALDriver();
1163 
1164  virtual CPLErr SetMetadataItem( const char * pszName,
1165  const char * pszValue,
1166  const char * pszDomain = "" ) CPL_OVERRIDE;
1167 
1168 /* -------------------------------------------------------------------- */
1169 /* Public C++ methods. */
1170 /* -------------------------------------------------------------------- */
1171  GDALDataset *Create( const char * pszName,
1172  int nXSize, int nYSize, int nBands,
1173  GDALDataType eType, char ** papszOptions ) CPL_WARN_UNUSED_RESULT;
1174 
1175  CPLErr Delete( const char * pszName );
1176  CPLErr Rename( const char * pszNewName,
1177  const char * pszOldName );
1178  CPLErr CopyFiles( const char * pszNewName,
1179  const char * pszOldName );
1180 
1181  GDALDataset *CreateCopy( const char *, GDALDataset *,
1182  int, char **,
1183  GDALProgressFunc pfnProgress,
1184  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
1185 
1186 /* -------------------------------------------------------------------- */
1187 /* The following are semiprivate, not intended to be accessed */
1188 /* by anyone but the formats instantiating and populating the */
1189 /* drivers. */
1190 /* -------------------------------------------------------------------- */
1192  GDALDataset *(*pfnOpen)( GDALOpenInfo * );
1193 
1194  GDALDataset *(*pfnCreate)( const char * pszName,
1195  int nXSize, int nYSize, int nBands,
1196  GDALDataType eType,
1197  char ** papszOptions );
1198 
1199  CPLErr (*pfnDelete)( const char * pszName );
1200 
1201  GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
1202  int, char **,
1203  GDALProgressFunc pfnProgress,
1204  void * pProgressData );
1205 
1206  void *pDriverData;
1207 
1208  void (*pfnUnloadDriver)(GDALDriver *);
1209 
1217  int (*pfnIdentify)( GDALOpenInfo * );
1218 
1219  CPLErr (*pfnRename)( const char * pszNewName,
1220  const char * pszOldName );
1221  CPLErr (*pfnCopyFiles)( const char * pszNewName,
1222  const char * pszOldName );
1223 
1224  /* For legacy OGR drivers */
1225  GDALDataset *(*pfnOpenWithDriverArg)( GDALDriver*, GDALOpenInfo * );
1226  GDALDataset *(*pfnCreateVectorOnly)( GDALDriver*,
1227  const char * pszName,
1228  char ** papszOptions );
1229  CPLErr (*pfnDeleteDataSource)( GDALDriver*,
1230  const char * pszName );
1232 
1233 /* -------------------------------------------------------------------- */
1234 /* Helper methods. */
1235 /* -------------------------------------------------------------------- */
1237  GDALDataset *DefaultCreateCopy( const char *, GDALDataset *,
1238  int, char **,
1239  GDALProgressFunc pfnProgress,
1240  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
1241  static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
1242  GDALDataset *poDstDS,
1243  int bStrict );
1245  static CPLErr QuietDelete( const char * pszName );
1246 
1248  static CPLErr DefaultRename( const char * pszNewName,
1249  const char * pszOldName );
1250  static CPLErr DefaultCopyFiles( const char * pszNewName,
1251  const char * pszOldName );
1253 private:
1254  CPL_DISALLOW_COPY_ASSIGN(GDALDriver)
1255 };
1256 
1257 /* ******************************************************************** */
1258 /* GDALDriverManager */
1259 /* ******************************************************************** */
1260 
1268 class CPL_DLL GDALDriverManager : public GDALMajorObject
1269 {
1270  int nDrivers;
1271  GDALDriver **papoDrivers;
1272  std::map<CPLString, GDALDriver*> oMapNameToDrivers;
1273 
1274  GDALDriver *GetDriver_unlocked( int iDriver )
1275  { return (iDriver >= 0 && iDriver < nDrivers) ?
1276  papoDrivers[iDriver] : NULL; }
1277 
1278  GDALDriver *GetDriverByName_unlocked( const char * pszName )
1279  { return oMapNameToDrivers[CPLString(pszName).toupper()]; }
1280 
1281  public:
1283  ~GDALDriverManager();
1284 
1285  int GetDriverCount( void ) const;
1286  GDALDriver *GetDriver( int );
1287  GDALDriver *GetDriverByName( const char * );
1288 
1289  int RegisterDriver( GDALDriver * );
1290  void DeregisterDriver( GDALDriver * );
1291 
1292  // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
1293  static void AutoLoadDrivers();
1294  void AutoSkipDrivers();
1295 };
1296 
1298 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
1299 CPL_C_END
1300 
1301 /* ******************************************************************** */
1302 /* GDALAsyncReader */
1303 /* ******************************************************************** */
1304 
1310 class CPL_DLL GDALAsyncReader
1311 {
1312  protected:
1314  GDALDataset* poDS;
1315  int nXOff;
1316  int nYOff;
1317  int nXSize;
1318  int nYSize;
1319  void * pBuf;
1320  int nBufXSize;
1321  int nBufYSize;
1322  GDALDataType eBufType;
1323  int nBandCount;
1324  int* panBandMap;
1325  int nPixelSpace;
1326  int nLineSpace;
1327  int nBandSpace;
1329 
1330  public:
1331  GDALAsyncReader();
1332  virtual ~GDALAsyncReader();
1333 
1337  GDALDataset* GetGDALDataset() {return poDS;}
1341  int GetXOffset() const { return nXOff; }
1345  int GetYOffset() const { return nYOff; }
1349  int GetXSize() const { return nXSize; }
1353  int GetYSize() const { return nYSize; }
1357  void * GetBuffer() {return pBuf;}
1361  int GetBufferXSize() const { return nBufXSize; }
1365  int GetBufferYSize() const { return nBufYSize; }
1369  GDALDataType GetBufferType() const { return eBufType; }
1373  int GetBandCount() const { return nBandCount; }
1377  int* GetBandMap() { return panBandMap; }
1381  int GetPixelSpace() const { return nPixelSpace; }
1385  int GetLineSpace() const { return nLineSpace; }
1389  int GetBandSpace() const { return nBandSpace; }
1390 
1391  virtual GDALAsyncStatusType
1392  GetNextUpdatedRegion(double dfTimeout,
1393  int* pnBufXOff, int* pnBufYOff,
1394  int* pnBufXSize, int* pnBufYSize) = 0;
1395  virtual int LockBuffer( double dfTimeout = -1.0 );
1396  virtual void UnlockBuffer();
1397 };
1398 
1399 /* ==================================================================== */
1400 /* An assortment of overview related stuff. */
1401 /* ==================================================================== */
1402 
1404 /* Only exported for drivers as plugin. Signature may change */
1405 CPLErr CPL_DLL
1406 GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands,
1407  int nOverviews,
1408  GDALRasterBand*** papapoOverviewBands,
1409  const char * pszResampling,
1410  GDALProgressFunc pfnProgress, void * pProgressData );
1411 
1412 typedef CPLErr (*GDALResampleFunction)
1413  ( double dfXRatioDstToSrc,
1414  double dfYRatioDstToSrc,
1415  double dfSrcXDelta,
1416  double dfSrcYDelta,
1417  GDALDataType eWrkDataType,
1418  void * pChunk,
1419  GByte * pabyChunkNodataMask,
1420  int nChunkXOff, int nChunkXSize,
1421  int nChunkYOff, int nChunkYSize,
1422  int nDstXOff, int nDstXOff2,
1423  int nDstYOff, int nDstYOff2,
1424  GDALRasterBand * poOverview,
1425  const char * pszResampling,
1426  int bHasNoData, float fNoDataValue,
1427  GDALColorTable* poColorTable,
1428  GDALDataType eSrcDataType,
1429  bool bPropagateNoData );
1430 
1431 GDALResampleFunction GDALGetResampleFunction(const char* pszResampling,
1432  int* pnRadius);
1433 
1434 #ifdef GDAL_ENABLE_RESAMPLING_MULTIBAND
1435 typedef CPLErr (*GDALResampleFunctionMultiBands)
1436  ( double dfXRatioDstToSrc,
1437  double dfYRatioDstToSrc,
1438  double dfSrcXDelta,
1439  double dfSrcYDelta,
1440  GDALDataType eWrkDataType,
1441  void * pChunk, int nBands,
1442  GByte * pabyChunkNodataMask,
1443  int nChunkXOff, int nChunkXSize,
1444  int nChunkYOff, int nChunkYSize,
1445  int nDstXOff, int nDstXOff2,
1446  int nDstYOff, int nDstYOff2,
1447  GDALRasterBand ** papoDstBands,
1448  const char * pszResampling,
1449  int bHasNoData, float fNoDataValue,
1450  GDALColorTable* poColorTable,
1451  GDALDataType eSrcDataType);
1452 
1453 GDALResampleFunctionMultiBands GDALGetResampleFunctionMultiBands(const char* pszResampling,
1454  int* pnRadius);
1455 #endif
1456 
1457 GDALDataType GDALGetOvrWorkDataType(const char* pszResampling,
1458  GDALDataType eSrcDataType);
1459 
1461 
1462 CPLErr CPL_DLL
1463 HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
1464  GDALDataset **ppoDS,
1465  int nBands, int *panBandList,
1466  int nNewOverviews, int *panNewOverviewList,
1467  const char *pszResampling,
1468  GDALProgressFunc pfnProgress,
1469  void *pProgressData );
1470 
1471 CPLErr CPL_DLL
1472 GTIFFBuildOverviews( const char * pszFilename,
1473  int nBands, GDALRasterBand **papoBandList,
1474  int nOverviews, int * panOverviewList,
1475  const char * pszResampling,
1476  GDALProgressFunc pfnProgress, void * pProgressData );
1477 
1478 CPLErr CPL_DLL
1479 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
1480  const char * pszResampling,
1481  int nOverviews, int * panOverviewList,
1482  int nBands, int * panBandList,
1483  GDALProgressFunc pfnProgress, void * pProgressData);
1484 
1485 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
1486  int &nXOff, int &nYOff,
1487  int &nXSize, int &nYSize,
1488  int nBufXSize, int nBufYSize) CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead");
1489 int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand* poBand,
1490  int &nXOff, int &nYOff,
1491  int &nXSize, int &nYSize,
1492  int nBufXSize, int nBufYSize,
1493  GDALRasterIOExtraArg* psExtraArg);
1494 
1495 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize ) CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead");
1496 int CPL_DLL GDALOvLevelAdjust2( int nOvLevel, int nXSize, int nYSize );
1497 int CPL_DLL GDALComputeOvFactor( int nOvrXSize, int nRasterXSize,
1498  int nOvrYSize, int nRasterYSize );
1499 
1500 GDALDataset CPL_DLL *
1501 GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
1502  GDALDataset *poDependentDS );
1503 
1504 /* ==================================================================== */
1505 /* Misc functions. */
1506 /* ==================================================================== */
1507 
1508 CPLErr CPL_DLL GDALParseGMLCoverage( CPLXMLNode *psTree,
1509  int *pnXSize, int *pnYSize,
1510  double *padfGeoTransform,
1511  char **ppszProjection );
1512 
1513 /* ==================================================================== */
1514 /* Infrastructure to check that dataset characteristics are valid */
1515 /* ==================================================================== */
1516 
1517 int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize );
1518 int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed );
1519 
1520 // Test if 2 floating point values match. Useful when comparing values
1521 // stored as a string at some point. See #3573, #4183, #4506
1522 #define ARE_REAL_EQUAL(dfVal1, dfVal2) \
1523  /* Is it FLT_MIN ? Cf #6578 */ \
1524  (((float)dfVal2 == (float)1.17549435e-38) ? ((float)dfVal1 == (float)dfVal2) : \
1525  /* Or DBL_MIN ? */ \
1526  (dfVal2 == 2.2250738585072014e-308) ? (dfVal1 == dfVal2) : \
1527  /* General case */ \
1528  (dfVal1 == dfVal2 || fabs(dfVal1 - dfVal2) < 1e-10 || (dfVal2 != 0 && fabs(1 - dfVal1 / dfVal2) < 1e-10 )))
1529 
1530 /* Internal use only */
1531 
1532 /* CPL_DLL exported, but only for in-tree drivers that can be built as plugins */
1533 int CPL_DLL GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension,
1534  double *padfGeoTransform, char** papszSiblingFiles,
1535  char** ppszWorldFileNameOut);
1536 int GDALReadTabFile2( const char * pszBaseFilename,
1537  double *padfGeoTransform, char **ppszWKT,
1538  int *pnGCPCount, GDAL_GCP **ppasGCPs,
1539  char** papszSiblingFiles, char** ppszTabFileNameOut );
1540 
1541 void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg* psDestArg,
1542  GDALRasterIOExtraArg* psSrcArg);
1543 
1544 CPL_C_END
1545 
1546 void GDALNullifyOpenDatasetsList();
1547 CPLMutex** GDALGetphDMMutex();
1548 CPLMutex** GDALGetphDLMutex();
1549 void GDALNullifyProxyPoolSingleton();
1550 GDALDriver* GDALGetAPIPROXYDriver();
1551 void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
1552 GIntBig GDALGetResponsiblePIDForCurrentThread();
1553 
1554 CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt,
1555  char **papszSiblingFiles, int nFlags );
1556 
1557 CPLErr EXIFExtractMetadata(char**& papszMetadata,
1558  void *fpL, int nOffset,
1559  int bSwabflag, int nTIFFHEADER,
1560  int& nExifOffset, int& nInterOffset, int& nGPSOffset);
1561 
1562 int GDALValidateOpenOptions( GDALDriverH hDriver,
1563  const char* const* papszOptionOptions);
1564 int GDALValidateOptions( const char* pszOptionList,
1565  const char* const* papszOptionsToValidate,
1566  const char* pszErrorMessageOptionType,
1567  const char* pszErrorMessageContainerName);
1568 
1569 GDALRIOResampleAlg GDALRasterIOGetResampleAlg(const char* pszResampling);
1570 const char* GDALRasterIOGetResampleAlg(GDALRIOResampleAlg eResampleAlg);
1571 
1572 void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg* psExtraArg,
1573  int nXSize, int nYSize,
1574  int nBufXSize, int nBufYSize);
1575 
1576 /* CPL_DLL exported, but only for gdalwarp */
1577 GDALDataset CPL_DLL* GDALCreateOverviewDataset(GDALDataset* poDS, int nOvrLevel,
1578  int bThisLevelOnly, int bOwnDS);
1579 
1580 #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) )
1581 
1582 // Number of data samples that will be used to compute approximate statistics
1583 // (minimum value, maximum value, etc.)
1584 #define GDALSTAT_APPROX_NUMSAMPLES 2500
1585 
1587 /* Caution: for technical reason this declaration is duplicated in gdal_crs.c */
1588 /* so any signature change should be reflected there too */
1589 void GDALSerializeGCPListToXML( CPLXMLNode* psParentNode,
1590  GDAL_GCP* pasGCPList,
1591  int nGCPCount,
1592  const char* pszGCPProjection );
1593 void GDALDeserializeGCPListFromXML( CPLXMLNode* psGCPList,
1594  GDAL_GCP** ppasGCPList,
1595  int* pnGCPCount,
1596  char** ppszGCPProjection );
1597 CPL_C_END
1598 
1599 void GDALSerializeOpenOptionsToXML( CPLXMLNode* psParentNode, char** papszOpenOptions);
1600 char** GDALDeserializeOpenOptionsFromXML( CPLXMLNode* psParentNode );
1601 
1602 int GDALCanFileAcceptSidecarFile(const char* pszFilename);
1604 
1605 #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:2618
GDALDataType
Definition: gdal.h:57
GDALDataType GetBufferType() const
Return buffer data type.
Definition: gdal_priv.h:1369
Identify could not determine if the file is recognized or not by the probed driver.
Definition: gdal_priv.h:1136
Document node structure.
Definition: cpl_minixml.h:66
Standard C Covers.
Definitions for CPL mini XML Parser/Serializer.
int GetYOff() const
Return the y offset of the top-left corner of the block.
Definition: gdal_priv.h:692
Definition: gdal.h:205
GDALDataset * GetGDALDataset()
Return dataset.
Definition: gdal_priv.h:1337
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:352
#define CPL_OVERRIDE
To be used in public headers only.
Definition: cpl_port.h:1054
const char *const * papszAllowedDrivers
Allowed drivers (NULL for all)
Definition: gdal_priv.h:281
int * GetBandMap()
Return band map.
Definition: gdal_priv.h:1377
int DropLock(void)
Decrement the lock count.
Definition: gdal_priv.h:676
FILE VSILFILE
Opaque type for a FILE that implements the VSIVirtualHandle API.
Definition: cpl_vsi.h:154
char ** GetOpenOptions()
Return open options.
Definition: gdal_priv.h:519
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:6501
GByte * pabyHeader
Buffer with first bytes of the file.
Definition: gdal_priv.h:278
int GetXOff() const
Return the x offset of the top-left corner of the block.
Definition: gdal_priv.h:688
GDALAccess eAccess
Access flag.
Definition: gdal_priv.h:263
GDALRIOResampleAlg
RasterIO() resampling method.
Definition: gdal.h:114
VSILFILE * fpL
Pointer to the file.
Definition: gdal_priv.h:273
int GetXSize() const
Return width.
Definition: gdal_priv.h:1349
GDALRWFlag
Definition: gdal.h:105
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition: gdal.h:241
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:207
char * pszFilename
Filename.
Definition: gdal_priv.h:258
Color tuple.
Definition: gdal.h:997
int nOpenFlags
Open flags.
Definition: gdal_priv.h:265
A single raster block in the block cache.
Definition: gdal_priv.h:635
virtual char ** GetMetadata(const char *pszDomain="")
Fetch metadata.
Definition: gdalmajorobject.cpp:249
virtual CPLErr BuildOverviews(const char *pszResampling, int nOverviews, int *panOverviewList, GDALProgressFunc pfnProgress, void *pProgressData)
Build raster overview(s)
Definition: gdalrasterband.cpp:2387
int AddLock(void)
Increment the lock count.
Definition: gdal_priv.h:674
Convenient string class based on std::string.
Definition: cpl_string.h:363
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:282
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition: cpl_port.h:966
unknown type, non-standard
Definition: ogr_core.h:340
int GetLineSpace() const
Return line spacing.
Definition: gdal_priv.h:1385
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition: cpl_virtualmem.h:62
virtual CPLErr IReadBlock(int nBlockXOff, int nBlockYOff, void *pData)=0
Read a block of data.
CPLErr BuildOverviews(const char *, int, int *, int, int *, GDALProgressFunc, void *)
Build raster overview(s)
Definition: gdaldataset.cpp:1447
Various convenience functions for working with strings and string lists.
virtual CPLErr FlushCache()
Flush raster data cache.
Definition: gdalrasterband.cpp:1026
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:259
int bIsDirectory
Whether the file is a directory.
Definition: gdal_priv.h:270
virtual const char * GetMetadataItem(const char *pszName, const char *pszDomain="")
Fetch single metadata item.
Definition: gdalmajorobject.cpp:344
int GetYSize() const
Return the height of the block.
Definition: gdal_priv.h:700
int GetXSize() const
Return the width of the block.
Definition: gdal_priv.h:696
virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, GDALDataType eBufType, char **papszOptions)
Advise driver of upcoming read requests.
Definition: gdalrasterband.cpp:3666
OGRwkbGeometryType
List of well known binary geometry types.
Definition: ogr_core.h:338
virtual char ** GetMetadata(const char *pszDomain="") CPL_OVERRIDE
Fetch metadata.
Public (C callable) GDAL entry points.
GDALAsyncStatusType
status of the asynchronous stream
Definition: gdal.h:86
Abstract base class for all geometry classes.
Definition: ogr_geometry.h:118
virtual CPLErr SetMetadata(char **papszMetadata, const char *pszDomain="")
Set metadata.
Definition: gdalmajorobject.cpp:292
void * GetBuffer()
Return buffer.
Definition: gdal_priv.h:1357
GDALRasterBand * GetBand()
Accessor to source GDALRasterBand object.
Definition: gdal_priv.h:720
Class for dataset open functions.
Definition: gdal_priv.h:246
int GetYOffset() const
Return y offset.
Definition: gdal_priv.h:1345
void MarkSuppressOnClose()
Set that the dataset must be deleted on close.
Definition: gdal_priv.h:514
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:472
Structure to pass extra arguments to RasterIO() method.
Definition: gdal.h:133
Identify determined the file is recognized by the probed driver.
Definition: gdal_priv.h:1140
GDALPaletteInterp
Definition: gdal.h:202
Core portability services for cross-platform OGR code.
int bStatOK
Whether stat()'ing the file was successful.
Definition: gdal_priv.h:268
int nHeaderBytes
Number of bytes in pabyHeader.
Definition: gdal_priv.h:276
virtual int CloseDependentDatasets()
Drop references to any other datasets referenced by this dataset.
Definition: gdaldataset.cpp:3373
void * GetDataRef(void)
Return the data buffer.
Definition: gdal_priv.h:708
int GetYSize() const
Return height.
Definition: gdal_priv.h:1353
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the dataset.
Definition: gdaldataset.cpp:2430
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:253
int CPLErrorNum
Error number.
Definition: cpl_error.h:95
Various convenience functions for CPL.
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:132
int GetBufferXSize() const
Return buffer width.
Definition: gdal_priv.h:1361
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition: gdal.h:247
void GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition: gdaldataset.cpp:3000
char ** papszOpenOptions
Open options.
Definition: gdal_priv.h:260
Object with metadata.
Definition: gdal_priv.h:125
int GetBufferYSize() const
Return buffer height.
Definition: gdal_priv.h:1365
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:68
int GetDirty() const
Return the dirty flag.
Definition: gdal_priv.h:704
A single raster band (or channel).
Definition: gdal_priv.h:827
GDALAccess
Definition: gdal.h:99
int GetPixelSpace() const
Return pixel spacing.
Definition: gdal_priv.h:1381
A simple feature, including geometry and attributes.
Definition: ogr_feature.h:279
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the current band.
Definition: gdalrasterband.cpp:6265
int GetBandSpace() const
Return band spacing.
Definition: gdal_priv.h:1389
This class represents a style table.
Definition: ogr_featurestyle.h:83
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:322
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:354
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:250
int GetXOffset() const
Return x offset.
Definition: gdal_priv.h:1341
Class for managing the registration of file format drivers.
Definition: gdal_priv.h:1268
#define CPL_NULL_TERMINATED
Null terminated variadic.
Definition: cpl_port.h:956
CPLString & toupper(void)
Convert to upper case in place.
Definition: cplstring.cpp:312
GDALIdentifyEnum
Enumeration used by GDALDriver::pfnIdentify().
Definition: gdal_priv.h:1133
int OGRErr
Simple container for a bounding region.
Definition: ogr_core.h:311
GDALColorInterp
Definition: gdal.h:176
int GDALGetDataTypeSizeBytes(GDALDataType)
Get data type size in bytes.
Definition: gdal_misc.cpp:222
virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain="")
Set single metadata item.
Definition: gdalmajorobject.cpp:388
GDALDataType GetDataType() const
Return the data type.
Definition: gdal_priv.h:684
Identify determined the file is not recognized by the probed driver.
Definition: gdal_priv.h:1138
int GetBandCount() const
Return band count.
Definition: gdal_priv.h:1373
Format specific driver.
Definition: gdal_priv.h:1158
int GetBlockSize() const
Return the block size in bytes.
Definition: gdal_priv.h:712
A color table / palette.
Definition: gdal_priv.h:747
virtual char ** GetMetadataDomainList()
Fetch list of metadata domains.
Definition: gdalmajorobject.cpp:161
GDALAccess GetAccess() const
Return access mode.
Definition: gdal_priv.h:508
Ground Control Point.
Definition: gdal.h:514
CPLErr
Error category.
Definition: cpl_error.h:52
GDALDriverManager * GetGDALDriverManager(void)
Fetch the global GDAL driver manager.
Definition: gdaldrivermanager.cpp:96
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:1084
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:998
Class used as a session object for asynchronous requests.
Definition: gdal_priv.h:1310

Generated for GDAL by doxygen 1.8.8.