GDAL
gdal_priv.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: gdal_priv.h 39966 2017-08-30 15:28:52Z 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();
505  int ReleaseRef();
506 
510  GDALAccess GetAccess() const { return eAccess; }
511 
512  int GetShared() const;
513  void MarkAsShared();
514 
516  void MarkSuppressOnClose() { bSuppressOnClose = true; }
517 
521  char **GetOpenOptions() { return papszOpenOptions; }
522 
523  static GDALDataset **GetOpenDatasets( int *pnDatasetCount );
524 
525  CPLErr BuildOverviews( const char *, int, int *,
526  int, int *, GDALProgressFunc, void * );
527 
528  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
529 
530  virtual char ** GetMetadata(const char * pszDomain = "") CPL_OVERRIDE;
531 
532 // Only defined when Doxygen enabled
533 #ifdef DOXYGEN_SKIP
534  virtual CPLErr SetMetadata( char ** papszMetadata,
535  const char * pszDomain ) CPL_OVERRIDE;
536  virtual const char *GetMetadataItem( const char * pszName,
537  const char * pszDomain ) CPL_OVERRIDE;
538  virtual CPLErr SetMetadataItem( const char * pszName,
539  const char * pszValue,
540  const char * pszDomain ) CPL_OVERRIDE;
541 #endif
542 
543  virtual char ** GetMetadataDomainList() CPL_OVERRIDE;
544 
545 private:
546  void *m_hPrivateData;
547 
548  OGRLayer* BuildLayerFromSelectInfo(swq_select* psSelectInfo,
549  OGRGeometry *poSpatialFilter,
550  const char *pszDialect,
551  swq_select_parse_options* poSelectParseOptions);
552  CPLStringList oDerivedMetadataList;
553  public:
554 
555  virtual int GetLayerCount();
556  virtual OGRLayer *GetLayer(int iLayer);
557  virtual OGRLayer *GetLayerByName(const char *);
558  virtual OGRErr DeleteLayer(int iLayer);
559 
560  virtual void ResetReading();
561  virtual OGRFeature* GetNextFeature( OGRLayer** ppoBelongingLayer,
562  double* pdfProgressPct,
563  GDALProgressFunc pfnProgress,
564  void* pProgressData );
565 
566  virtual int TestCapability( const char * );
567 
568  virtual OGRLayer *CreateLayer( const char *pszName,
569  OGRSpatialReference *poSpatialRef = NULL,
571  char ** papszOptions = NULL );
572  virtual OGRLayer *CopyLayer( OGRLayer *poSrcLayer,
573  const char *pszNewName,
574  char **papszOptions = NULL );
575 
576  virtual OGRStyleTable *GetStyleTable();
577  virtual void SetStyleTableDirectly( OGRStyleTable *poStyleTable );
578 
579  virtual void SetStyleTable(OGRStyleTable *poStyleTable);
580 
581  virtual OGRLayer * ExecuteSQL( const char *pszStatement,
582  OGRGeometry *poSpatialFilter,
583  const char *pszDialect );
584  virtual void ReleaseResultSet( OGRLayer * poResultsSet );
585 
586  int GetRefCount() const;
587  int GetSummaryRefCount() const;
588  OGRErr Release();
589 
590  virtual OGRErr StartTransaction(int bForce=FALSE);
591  virtual OGRErr CommitTransaction();
592  virtual OGRErr RollbackTransaction();
593 
595  static int IsGenericSQLDialect(const char* pszDialect);
596 
597  // Semi-public methods. Only to be used by in-tree drivers.
598  GDALSQLParseInfo* BuildParseInfo(swq_select* psSelectInfo,
599  swq_select_parse_options* poSelectParseOptions);
600  static void DestroyParseInfo(GDALSQLParseInfo* psParseInfo );
601  OGRLayer * ExecuteSQL( const char *pszStatement,
602  OGRGeometry *poSpatialFilter,
603  const char *pszDialect,
604  swq_select_parse_options* poSelectParseOptions);
606 
607  protected:
608  virtual OGRLayer *ICreateLayer( const char *pszName,
609  OGRSpatialReference *poSpatialRef = NULL,
611  char ** papszOptions = NULL );
612 
614  OGRErr ProcessSQLCreateIndex( const char * );
615  OGRErr ProcessSQLDropIndex( const char * );
616  OGRErr ProcessSQLDropTable( const char * );
617  OGRErr ProcessSQLAlterTableAddColumn( const char * );
618  OGRErr ProcessSQLAlterTableDropColumn( const char * );
619  OGRErr ProcessSQLAlterTableAlterColumn( const char * );
620  OGRErr ProcessSQLAlterTableRenameColumn( const char * );
621 
622  OGRStyleTable *m_poStyleTable;
624 
625  private:
627 };
628 
629 /* ******************************************************************** */
630 /* GDALRasterBlock */
631 /* ******************************************************************** */
632 
637 class CPL_DLL GDALRasterBlock
638 {
639  friend class GDALAbstractBandBlockCache;
640 
641  GDALDataType eType;
642 
643  bool bDirty;
644  volatile int nLockCount;
645 
646  int nXOff;
647  int nYOff;
648 
649  int nXSize;
650  int nYSize;
651 
652  void *pData;
653 
654  GDALRasterBand *poBand;
655 
656  GDALRasterBlock *poNext;
657  GDALRasterBlock *poPrevious;
658 
659  bool bMustDetach;
660 
661  void Detach_unlocked( void );
662  void Touch_unlocked( void );
663 
664  void RecycleFor( int nXOffIn, int nYOffIn );
665 
666  public:
667  GDALRasterBlock( GDALRasterBand *, int, int );
668  GDALRasterBlock( int nXOffIn, int nYOffIn ); /* only for lookup purpose */
669  virtual ~GDALRasterBlock();
670 
671  CPLErr Internalize( void );
672  void Touch( void );
673  void MarkDirty( void );
674  void MarkClean( void );
676  int AddLock( void ) { return CPLAtomicInc(&nLockCount); }
678  int DropLock( void ) { return CPLAtomicDec(&nLockCount); }
679  void Detach();
680 
681  CPLErr Write();
682 
686  GDALDataType GetDataType() const { return eType; }
690  int GetXOff() const { return nXOff; }
694  int GetYOff() const { return nYOff; }
698  int GetXSize() const { return nXSize; }
702  int GetYSize() const { return nYSize; }
706  int GetDirty() const { return bDirty; }
710  void *GetDataRef( void ) { return pData; }
714  int GetBlockSize() const {
715  return nXSize * nYSize * GDALGetDataTypeSizeBytes(eType); }
716 
717  int TakeLock();
718  int DropLockForRemovalFromStorage();
719 
722  GDALRasterBand *GetBand() { return poBand; }
723 
724  static void FlushDirtyBlocks();
725  static int FlushCacheBlock(int bDirtyBlocksOnly = FALSE);
726  static void Verify();
727 
728  static void EnterDisableDirtyBlockFlush();
729  static void LeaveDisableDirtyBlockFlush();
730 
731 #ifdef notdef
732  static void CheckNonOrphanedBlocks(GDALRasterBand* poBand);
733  void DumpBlock();
734  static void DumpAll();
735 #endif
736 
737  /* Should only be called by GDALDestroyDriverManager() */
739  static void DestroyRBMutex();
741 
742  private:
744 };
745 
746 /* ******************************************************************** */
747 /* GDALColorTable */
748 /* ******************************************************************** */
749 
752 class CPL_DLL GDALColorTable
753 {
754  GDALPaletteInterp eInterp;
755 
756  std::vector<GDALColorEntry> aoEntries;
757 
758 public:
760  ~GDALColorTable();
761 
762  GDALColorTable *Clone() const;
763  int IsSame(const GDALColorTable* poOtherCT) const;
764 
765  GDALPaletteInterp GetPaletteInterpretation() const;
766 
767  int GetColorEntryCount() const;
768  const GDALColorEntry *GetColorEntry( int ) const;
769  int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
770  void SetColorEntry( int, const GDALColorEntry * );
771  int CreateColorRamp( int, const GDALColorEntry * ,
772  int, const GDALColorEntry * );
773 };
774 
775 /* ******************************************************************** */
776 /* GDALAbstractBandBlockCache */
777 /* ******************************************************************** */
778 
780 
782 // CPL_DLL is just technical here. This is really a private concept
783 // only used by GDALRasterBand implementation.
784 
785 class CPL_DLL GDALAbstractBandBlockCache
786 {
787  // List of blocks that can be freed or recycled, and its lock
788  CPLLock *hSpinLock;
789  GDALRasterBlock *psListBlocksToFree;
790 
791  // Band keep alive counter, and its lock & condition
792  CPLCond *hCond;
793  CPLMutex *hCondMutex;
794  volatile int nKeepAliveCounter;
795 
796  protected:
797  GDALRasterBand *poBand;
798 
799  void FreeDanglingBlocks();
800  void UnreferenceBlockBase();
801  void WaitKeepAliveCounter();
802 
803  public:
804  explicit GDALAbstractBandBlockCache(GDALRasterBand* poBand);
805  virtual ~GDALAbstractBandBlockCache();
806 
807  GDALRasterBlock* CreateBlock(int nXBlockOff, int nYBlockOff);
808  void AddBlockToFreeList( GDALRasterBlock * );
809 
810  virtual bool Init() = 0;
811  virtual bool IsInitOK() = 0;
812  virtual CPLErr FlushCache() = 0;
813  virtual CPLErr AdoptBlock( GDALRasterBlock* poBlock ) = 0;
814  virtual GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff,
815  int nYBlockYOff ) = 0;
816  virtual CPLErr UnreferenceBlock( GDALRasterBlock* poBlock ) = 0;
817  virtual CPLErr FlushBlock( int nXBlockOff, int nYBlockOff,
818  int bWriteDirtyBlock ) = 0;
819 };
820 
821 GDALAbstractBandBlockCache* GDALArrayBandBlockCacheCreate(GDALRasterBand* poBand);
822 GDALAbstractBandBlockCache* GDALHashSetBandBlockCacheCreate(GDALRasterBand* poBand);
823 
825 
826 /* ******************************************************************** */
827 /* GDALRasterBand */
828 /* ******************************************************************** */
829 
832 class CPL_DLL GDALRasterBand : public GDALMajorObject
833 {
834  private:
835  friend class GDALArrayBandBlockCache;
836  friend class GDALHashSetBandBlockCache;
837  friend class GDALRasterBlock;
838 
839  CPLErr eFlushBlockErr;
840  GDALAbstractBandBlockCache* poBandBlockCache;
841 
842  void SetFlushBlockErr( CPLErr eErr );
843  CPLErr UnreferenceBlock( GDALRasterBlock* poBlock );
844 
845  void Init(int bForceCachedIO);
846 
847  protected:
849  GDALDataset *poDS;
850  int nBand; /* 1 based */
851 
852  int nRasterXSize;
853  int nRasterYSize;
854 
855  GDALDataType eDataType;
856  GDALAccess eAccess;
857 
858  /* stuff related to blocking, and raster cache */
859  int nBlockXSize;
860  int nBlockYSize;
861  int nBlocksPerRow;
862  int nBlocksPerColumn;
863 
864  int nBlockReads;
865  int bForceCachedIO;
866 
867  GDALRasterBand *poMask;
868  bool bOwnMask;
869  int nMaskFlags;
870 
871  void InvalidateMaskBand();
872 
873  friend class GDALDataset;
874  friend class GDALProxyRasterBand;
875  friend class GDALDefaultOverviews;
876 
877  CPLErr RasterIOResampled( GDALRWFlag, int, int, int, int,
878  void *, int, int, GDALDataType,
880 
881  int EnterReadWrite(GDALRWFlag eRWFlag);
882  void LeaveReadWrite();
883  void InitRWLock();
885 
886  protected:
887  virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void * pData ) = 0;
888  virtual CPLErr IWriteBlock( int nBlockXOff, int nBlockYOff, void * pData );
889 
890 #ifdef DETECT_OLD_IRASTERIO
891  virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int,
892  void *, int, int, GDALDataType,
893  int, int ) {};
894 #endif
895 
896  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
897  void *, int, int, GDALDataType,
899 
900  virtual int IGetDataCoverageStatus( int nXOff, int nYOff,
901  int nXSize, int nYSize,
902  int nMaskFlagStop,
903  double* pdfDataPct);
905  CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
906  void *, int, int, GDALDataType,
908 
909  CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
910  int nXOff, int nYOff, int nXSize, int nYSize,
911  void * pData, int nBufXSize, int nBufYSize,
912  GDALDataType eBufType,
913  GSpacing nPixelSpace, GSpacing nLineSpace,
914  GDALRasterIOExtraArg* psExtraArg,
915  int* pbTried );
916 
917  int InitBlockInfo();
918 
919  void AddBlockToFreeList( GDALRasterBlock * );
921 
922  GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
923 
924  public:
925  GDALRasterBand();
926  explicit GDALRasterBand(int bForceCachedIO);
927 
928  virtual ~GDALRasterBand();
929 
930  int GetXSize();
931  int GetYSize();
932  int GetBand();
933  GDALDataset*GetDataset();
934 
935  GDALDataType GetRasterDataType( void );
936  void GetBlockSize( int *, int * );
937  CPLErr GetActualBlockSize ( int, int, int *, int * );
938  GDALAccess GetAccess();
939 
940  CPLErr RasterIO( GDALRWFlag, int, int, int, int,
941  void *, int, int, GDALDataType,
943 #ifndef DOXYGEN_SKIP
944  OPTIONAL_OUTSIDE_GDAL(NULL)
945 #endif
947  CPLErr ReadBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
948 
949  CPLErr WriteBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
950 
951  GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
952  int bJustInitialize = FALSE ) CPL_WARN_UNUSED_RESULT;
953  CPLErr FlushBlock( int, int, int bWriteDirtyBlock = TRUE );
954 
955  unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand,
956  unsigned char* pTranslationTable = NULL,
957  int* pApproximateMatching = NULL);
958 
959  // New OpengIS CV_SampleDimension stuff.
960 
961  virtual CPLErr FlushCache();
962  virtual char **GetCategoryNames();
963  virtual double GetNoDataValue( int *pbSuccess = NULL );
964  virtual double GetMinimum( int *pbSuccess = NULL );
965  virtual double GetMaximum(int *pbSuccess = NULL );
966  virtual double GetOffset( int *pbSuccess = NULL );
967  virtual double GetScale( int *pbSuccess = NULL );
968  virtual const char *GetUnitType();
969  virtual GDALColorInterp GetColorInterpretation();
970  virtual GDALColorTable *GetColorTable();
971  virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
972 
973  virtual CPLErr SetCategoryNames( char ** papszNames );
974  virtual CPLErr SetNoDataValue( double dfNoData );
975  virtual CPLErr DeleteNoDataValue();
976  virtual CPLErr SetColorTable( GDALColorTable * poCT );
977  virtual CPLErr SetColorInterpretation( GDALColorInterp eColorInterp );
978  virtual CPLErr SetOffset( double dfNewOffset );
979  virtual CPLErr SetScale( double dfNewScale );
980  virtual CPLErr SetUnitType( const char * pszNewValue );
981 
982  virtual CPLErr GetStatistics( int bApproxOK, int bForce,
983  double *pdfMin, double *pdfMax,
984  double *pdfMean, double *padfStdDev );
985  virtual CPLErr ComputeStatistics( int bApproxOK,
986  double *pdfMin, double *pdfMax,
987  double *pdfMean, double *pdfStdDev,
988  GDALProgressFunc, void *pProgressData );
989  virtual CPLErr SetStatistics( double dfMin, double dfMax,
990  double dfMean, double dfStdDev );
991  virtual CPLErr ComputeRasterMinMax( int, double* );
992 
993 // Only defined when Doxygen enabled
994 #ifdef DOXYGEN_SKIP
995  virtual char **GetMetadata( const char * pszDomain = "" ) CPL_OVERRIDE;
996  virtual CPLErr SetMetadata( char ** papszMetadata,
997  const char * pszDomain ) CPL_OVERRIDE;
998  virtual const char *GetMetadataItem( const char * pszName,
999  const char * pszDomain ) CPL_OVERRIDE;
1000  virtual CPLErr SetMetadataItem( const char * pszName,
1001  const char * pszValue,
1002  const char * pszDomain ) CPL_OVERRIDE;
1003 #endif
1004 
1005  virtual int HasArbitraryOverviews();
1006  virtual int GetOverviewCount();
1007  virtual GDALRasterBand *GetOverview(int);
1008  virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig );
1009  virtual CPLErr BuildOverviews( const char * pszResampling,
1010  int nOverviews,
1011  int * panOverviewList,
1012  GDALProgressFunc pfnProgress,
1013  void * pProgressData );
1014 
1015  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
1016  int nBufXSize, int nBufYSize,
1017  GDALDataType eBufType, char **papszOptions );
1018 
1019  virtual CPLErr GetHistogram( double dfMin, double dfMax,
1020  int nBuckets, GUIntBig * panHistogram,
1021  int bIncludeOutOfRange, int bApproxOK,
1022  GDALProgressFunc, void *pProgressData );
1023 
1024  virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
1025  int *pnBuckets, GUIntBig ** ppanHistogram,
1026  int bForce,
1027  GDALProgressFunc, void *pProgressData);
1028  virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
1029  int nBuckets, GUIntBig *panHistogram );
1030 
1031  virtual GDALRasterAttributeTable *GetDefaultRAT();
1032  virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * poRAT );
1033 
1034  virtual GDALRasterBand *GetMaskBand();
1035  virtual int GetMaskFlags();
1036  virtual CPLErr CreateMaskBand( int nFlagsIn );
1037 
1038  virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
1039  int *pnPixelSpace,
1040  GIntBig *pnLineSpace,
1041  char **papszOptions ) CPL_WARN_UNUSED_RESULT;
1042 
1043  int GetDataCoverageStatus( int nXOff, int nYOff,
1044  int nXSize, int nYSize,
1045  int nMaskFlagStop = 0,
1046  double* pdfDataPct = NULL );
1047 
1048  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
1049 
1050 private:
1052 };
1053 
1055 /* ******************************************************************** */
1056 /* GDALAllValidMaskBand */
1057 /* ******************************************************************** */
1058 
1059 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
1060 {
1061  protected:
1062  virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE;
1063 
1064  public:
1065  explicit GDALAllValidMaskBand( GDALRasterBand * );
1066  virtual ~GDALAllValidMaskBand();
1067 
1069  virtual int GetMaskFlags() CPL_OVERRIDE;
1070 };
1071 
1072 /* ******************************************************************** */
1073 /* GDALNoDataMaskBand */
1074 /* ******************************************************************** */
1075 
1076 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
1077 {
1078  double dfNoDataValue;
1079  GDALRasterBand *poParent;
1080 
1081  protected:
1082  virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE;
1083  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1084  void *, int, int, GDALDataType,
1086 
1087  public:
1088  explicit GDALNoDataMaskBand( GDALRasterBand * );
1089  virtual ~GDALNoDataMaskBand();
1090 };
1091 
1092 /* ******************************************************************** */
1093 /* GDALNoDataValuesMaskBand */
1094 /* ******************************************************************** */
1095 
1096 class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
1097 {
1098  double *padfNodataValues;
1099 
1100  protected:
1101  virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE;
1102 
1103  public:
1104  explicit GDALNoDataValuesMaskBand( GDALDataset * );
1105  virtual ~GDALNoDataValuesMaskBand();
1106 };
1107 
1108 /* ******************************************************************** */
1109 /* GDALRescaledAlphaBand */
1110 /* ******************************************************************** */
1111 
1112 class GDALRescaledAlphaBand : public GDALRasterBand
1113 {
1114  GDALRasterBand *poParent;
1115  void *pTemp;
1116 
1117  protected:
1118  virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE;
1119  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1120  void *, int, int, GDALDataType,
1122 
1123  public:
1124  explicit GDALRescaledAlphaBand( GDALRasterBand * );
1125  virtual ~GDALRescaledAlphaBand();
1126 };
1128 
1129 /* ******************************************************************** */
1130 /* GDALIdentifyEnum */
1131 /* ******************************************************************** */
1132 
1138 typedef enum
1139 {
1147 
1148 /* ******************************************************************** */
1149 /* GDALDriver */
1150 /* ******************************************************************** */
1151 
1163 class CPL_DLL GDALDriver : public GDALMajorObject
1164 {
1165  public:
1166  GDALDriver();
1167  virtual ~GDALDriver();
1168 
1169  virtual CPLErr SetMetadataItem( const char * pszName,
1170  const char * pszValue,
1171  const char * pszDomain = "" ) CPL_OVERRIDE;
1172 
1173 /* -------------------------------------------------------------------- */
1174 /* Public C++ methods. */
1175 /* -------------------------------------------------------------------- */
1176  GDALDataset *Create( const char * pszName,
1177  int nXSize, int nYSize, int nBands,
1178  GDALDataType eType, char ** papszOptions ) CPL_WARN_UNUSED_RESULT;
1179 
1180  CPLErr Delete( const char * pszName );
1181  CPLErr Rename( const char * pszNewName,
1182  const char * pszOldName );
1183  CPLErr CopyFiles( const char * pszNewName,
1184  const char * pszOldName );
1185 
1186  GDALDataset *CreateCopy( const char *, GDALDataset *,
1187  int, char **,
1188  GDALProgressFunc pfnProgress,
1189  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
1190 
1191 /* -------------------------------------------------------------------- */
1192 /* The following are semiprivate, not intended to be accessed */
1193 /* by anyone but the formats instantiating and populating the */
1194 /* drivers. */
1195 /* -------------------------------------------------------------------- */
1197  GDALDataset *(*pfnOpen)( GDALOpenInfo * );
1198 
1199  GDALDataset *(*pfnCreate)( const char * pszName,
1200  int nXSize, int nYSize, int nBands,
1201  GDALDataType eType,
1202  char ** papszOptions );
1203 
1204  CPLErr (*pfnDelete)( const char * pszName );
1205 
1206  GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
1207  int, char **,
1208  GDALProgressFunc pfnProgress,
1209  void * pProgressData );
1210 
1211  void *pDriverData;
1212 
1213  void (*pfnUnloadDriver)(GDALDriver *);
1214 
1222  int (*pfnIdentify)( GDALOpenInfo * );
1223 
1224  CPLErr (*pfnRename)( const char * pszNewName,
1225  const char * pszOldName );
1226  CPLErr (*pfnCopyFiles)( const char * pszNewName,
1227  const char * pszOldName );
1228 
1229  /* For legacy OGR drivers */
1230  GDALDataset *(*pfnOpenWithDriverArg)( GDALDriver*, GDALOpenInfo * );
1231  GDALDataset *(*pfnCreateVectorOnly)( GDALDriver*,
1232  const char * pszName,
1233  char ** papszOptions );
1234  CPLErr (*pfnDeleteDataSource)( GDALDriver*,
1235  const char * pszName );
1237 
1238 /* -------------------------------------------------------------------- */
1239 /* Helper methods. */
1240 /* -------------------------------------------------------------------- */
1242  GDALDataset *DefaultCreateCopy( const char *, GDALDataset *,
1243  int, char **,
1244  GDALProgressFunc pfnProgress,
1245  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
1246  static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
1247  GDALDataset *poDstDS,
1248  int bStrict );
1250  static CPLErr QuietDelete( const char * pszName );
1251 
1253  static CPLErr DefaultRename( const char * pszNewName,
1254  const char * pszOldName );
1255  static CPLErr DefaultCopyFiles( const char * pszNewName,
1256  const char * pszOldName );
1258 private:
1260 };
1261 
1262 /* ******************************************************************** */
1263 /* GDALDriverManager */
1264 /* ******************************************************************** */
1265 
1273 class CPL_DLL GDALDriverManager : public GDALMajorObject
1274 {
1275  int nDrivers;
1276  GDALDriver **papoDrivers;
1277  std::map<CPLString, GDALDriver*> oMapNameToDrivers;
1278 
1279  GDALDriver *GetDriver_unlocked( int iDriver )
1280  { return (iDriver >= 0 && iDriver < nDrivers) ?
1281  papoDrivers[iDriver] : NULL; }
1282 
1283  GDALDriver *GetDriverByName_unlocked( const char * pszName )
1284  { return oMapNameToDrivers[CPLString(pszName).toupper()]; }
1285 
1286  public:
1288  ~GDALDriverManager();
1289 
1290  int GetDriverCount( void ) const;
1291  GDALDriver *GetDriver( int );
1292  GDALDriver *GetDriverByName( const char * );
1293 
1294  int RegisterDriver( GDALDriver * );
1295  void DeregisterDriver( GDALDriver * );
1296 
1297  // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
1298  static void AutoLoadDrivers();
1299  void AutoSkipDrivers();
1300 };
1301 
1303 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
1304 CPL_C_END
1305 
1306 /* ******************************************************************** */
1307 /* GDALAsyncReader */
1308 /* ******************************************************************** */
1309 
1315 class CPL_DLL GDALAsyncReader
1316 {
1317  protected:
1319  GDALDataset* poDS;
1320  int nXOff;
1321  int nYOff;
1322  int nXSize;
1323  int nYSize;
1324  void * pBuf;
1325  int nBufXSize;
1326  int nBufYSize;
1327  GDALDataType eBufType;
1328  int nBandCount;
1329  int* panBandMap;
1330  int nPixelSpace;
1331  int nLineSpace;
1332  int nBandSpace;
1334 
1335  public:
1336  GDALAsyncReader();
1337  virtual ~GDALAsyncReader();
1338 
1342  GDALDataset* GetGDALDataset() {return poDS;}
1346  int GetXOffset() const { return nXOff; }
1350  int GetYOffset() const { return nYOff; }
1354  int GetXSize() const { return nXSize; }
1358  int GetYSize() const { return nYSize; }
1362  void * GetBuffer() {return pBuf;}
1366  int GetBufferXSize() const { return nBufXSize; }
1370  int GetBufferYSize() const { return nBufYSize; }
1374  GDALDataType GetBufferType() const { return eBufType; }
1378  int GetBandCount() const { return nBandCount; }
1382  int* GetBandMap() { return panBandMap; }
1386  int GetPixelSpace() const { return nPixelSpace; }
1390  int GetLineSpace() const { return nLineSpace; }
1394  int GetBandSpace() const { return nBandSpace; }
1395 
1396  virtual GDALAsyncStatusType
1397  GetNextUpdatedRegion(double dfTimeout,
1398  int* pnBufXOff, int* pnBufYOff,
1399  int* pnBufXSize, int* pnBufYSize) = 0;
1400  virtual int LockBuffer( double dfTimeout = -1.0 );
1401  virtual void UnlockBuffer();
1402 };
1403 
1404 /* ==================================================================== */
1405 /* An assortment of overview related stuff. */
1406 /* ==================================================================== */
1407 
1409 /* Only exported for drivers as plugin. Signature may change */
1410 CPLErr CPL_DLL
1411 GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands,
1412  int nOverviews,
1413  GDALRasterBand*** papapoOverviewBands,
1414  const char * pszResampling,
1415  GDALProgressFunc pfnProgress, void * pProgressData );
1416 
1417 typedef CPLErr (*GDALResampleFunction)
1418  ( double dfXRatioDstToSrc,
1419  double dfYRatioDstToSrc,
1420  double dfSrcXDelta,
1421  double dfSrcYDelta,
1422  GDALDataType eWrkDataType,
1423  void * pChunk,
1424  GByte * pabyChunkNodataMask,
1425  int nChunkXOff, int nChunkXSize,
1426  int nChunkYOff, int nChunkYSize,
1427  int nDstXOff, int nDstXOff2,
1428  int nDstYOff, int nDstYOff2,
1429  GDALRasterBand * poOverview,
1430  const char * pszResampling,
1431  int bHasNoData, float fNoDataValue,
1432  GDALColorTable* poColorTable,
1433  GDALDataType eSrcDataType,
1434  bool bPropagateNoData );
1435 
1436 GDALResampleFunction GDALGetResampleFunction(const char* pszResampling,
1437  int* pnRadius);
1438 
1439 #ifdef GDAL_ENABLE_RESAMPLING_MULTIBAND
1440 typedef CPLErr (*GDALResampleFunctionMultiBands)
1441  ( double dfXRatioDstToSrc,
1442  double dfYRatioDstToSrc,
1443  double dfSrcXDelta,
1444  double dfSrcYDelta,
1445  GDALDataType eWrkDataType,
1446  void * pChunk, int nBands,
1447  GByte * pabyChunkNodataMask,
1448  int nChunkXOff, int nChunkXSize,
1449  int nChunkYOff, int nChunkYSize,
1450  int nDstXOff, int nDstXOff2,
1451  int nDstYOff, int nDstYOff2,
1452  GDALRasterBand ** papoDstBands,
1453  const char * pszResampling,
1454  int bHasNoData, float fNoDataValue,
1455  GDALColorTable* poColorTable,
1456  GDALDataType eSrcDataType);
1457 
1458 GDALResampleFunctionMultiBands GDALGetResampleFunctionMultiBands(const char* pszResampling,
1459  int* pnRadius);
1460 #endif
1461 
1462 GDALDataType GDALGetOvrWorkDataType(const char* pszResampling,
1463  GDALDataType eSrcDataType);
1464 
1466 
1467 CPLErr CPL_DLL
1468 HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
1469  GDALDataset **ppoDS,
1470  int nBands, int *panBandList,
1471  int nNewOverviews, int *panNewOverviewList,
1472  const char *pszResampling,
1473  GDALProgressFunc pfnProgress,
1474  void *pProgressData );
1475 
1476 CPLErr CPL_DLL
1477 GTIFFBuildOverviews( const char * pszFilename,
1478  int nBands, GDALRasterBand **papoBandList,
1479  int nOverviews, int * panOverviewList,
1480  const char * pszResampling,
1481  GDALProgressFunc pfnProgress, void * pProgressData );
1482 
1483 CPLErr CPL_DLL
1484 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
1485  const char * pszResampling,
1486  int nOverviews, int * panOverviewList,
1487  int nBands, int * panBandList,
1488  GDALProgressFunc pfnProgress, void * pProgressData);
1489 
1490 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
1491  int &nXOff, int &nYOff,
1492  int &nXSize, int &nYSize,
1493  int nBufXSize, int nBufYSize) CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead");
1494 int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand* poBand,
1495  int &nXOff, int &nYOff,
1496  int &nXSize, int &nYSize,
1497  int nBufXSize, int nBufYSize,
1498  GDALRasterIOExtraArg* psExtraArg);
1499 
1500 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize ) CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead");
1501 int CPL_DLL GDALOvLevelAdjust2( int nOvLevel, int nXSize, int nYSize );
1502 int CPL_DLL GDALComputeOvFactor( int nOvrXSize, int nRasterXSize,
1503  int nOvrYSize, int nRasterYSize );
1504 
1505 GDALDataset CPL_DLL *
1506 GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
1507  GDALDataset *poDependentDS );
1508 
1509 /* ==================================================================== */
1510 /* Misc functions. */
1511 /* ==================================================================== */
1512 
1513 CPLErr CPL_DLL GDALParseGMLCoverage( CPLXMLNode *psTree,
1514  int *pnXSize, int *pnYSize,
1515  double *padfGeoTransform,
1516  char **ppszProjection );
1517 
1518 /* ==================================================================== */
1519 /* Infrastructure to check that dataset characteristics are valid */
1520 /* ==================================================================== */
1521 
1522 int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize );
1523 int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed );
1524 
1525 // Test if 2 floating point values match. Useful when comparing values
1526 // stored as a string at some point. See #3573, #4183, #4506
1527 #define ARE_REAL_EQUAL(dfVal1, dfVal2) \
1528  /* Is it FLT_MIN ? Cf #6578 */ \
1529  (((float)dfVal2 == (float)1.17549435e-38) ? ((float)dfVal1 == (float)dfVal2) : \
1530  /* Or DBL_MIN ? */ \
1531  (dfVal2 == 2.2250738585072014e-308) ? (dfVal1 == dfVal2) : \
1532  /* General case */ \
1533  (dfVal1 == dfVal2 || fabs(dfVal1 - dfVal2) < 1e-10 || (dfVal2 != 0 && fabs(1 - dfVal1 / dfVal2) < 1e-10 )))
1534 
1535 /* Internal use only */
1536 
1537 /* CPL_DLL exported, but only for in-tree drivers that can be built as plugins */
1538 int CPL_DLL GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension,
1539  double *padfGeoTransform, char** papszSiblingFiles,
1540  char** ppszWorldFileNameOut);
1541 int GDALReadTabFile2( const char * pszBaseFilename,
1542  double *padfGeoTransform, char **ppszWKT,
1543  int *pnGCPCount, GDAL_GCP **ppasGCPs,
1544  char** papszSiblingFiles, char** ppszTabFileNameOut );
1545 
1546 void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg* psDestArg,
1547  GDALRasterIOExtraArg* psSrcArg);
1548 
1549 CPL_C_END
1550 
1551 void GDALNullifyOpenDatasetsList();
1552 CPLMutex** GDALGetphDMMutex();
1553 CPLMutex** GDALGetphDLMutex();
1554 void GDALNullifyProxyPoolSingleton();
1555 GDALDriver* GDALGetAPIPROXYDriver();
1556 void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
1557 GIntBig GDALGetResponsiblePIDForCurrentThread();
1558 
1559 CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt,
1560  char **papszSiblingFiles, int nFlags );
1561 
1562 CPLErr EXIFExtractMetadata(char**& papszMetadata,
1563  void *fpL, int nOffset,
1564  int bSwabflag, int nTIFFHEADER,
1565  int& nExifOffset, int& nInterOffset, int& nGPSOffset);
1566 
1567 int GDALValidateOpenOptions( GDALDriverH hDriver,
1568  const char* const* papszOptionOptions);
1569 int GDALValidateOptions( const char* pszOptionList,
1570  const char* const* papszOptionsToValidate,
1571  const char* pszErrorMessageOptionType,
1572  const char* pszErrorMessageContainerName);
1573 
1574 GDALRIOResampleAlg GDALRasterIOGetResampleAlg(const char* pszResampling);
1575 const char* GDALRasterIOGetResampleAlg(GDALRIOResampleAlg eResampleAlg);
1576 
1577 void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg* psExtraArg,
1578  int nXSize, int nYSize,
1579  int nBufXSize, int nBufYSize);
1580 
1581 
1582 GDALDataset* GDALCreateOverviewDataset(GDALDataset* poDS, int nOvrLevel,
1583  int bThisLevelOnly);
1584 
1585 #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) )
1586 
1587 // Number of data samples that will be used to compute approximate statistics
1588 // (minimum value, maximum value, etc.)
1589 #define GDALSTAT_APPROX_NUMSAMPLES 2500
1590 
1592 /* Caution: for technical reason this declaration is duplicated in gdal_crs.c */
1593 /* so any signature change should be reflected there too */
1594 void GDALSerializeGCPListToXML( CPLXMLNode* psParentNode,
1595  GDAL_GCP* pasGCPList,
1596  int nGCPCount,
1597  const char* pszGCPProjection );
1598 void GDALDeserializeGCPListFromXML( CPLXMLNode* psGCPList,
1599  GDAL_GCP** ppasGCPList,
1600  int* pnGCPCount,
1601  char** ppszGCPProjection );
1602 CPL_C_END
1603 
1604 void GDALSerializeOpenOptionsToXML( CPLXMLNode* psParentNode, char** papszOpenOptions);
1605 char** GDALDeserializeOpenOptionsFromXML( CPLXMLNode* psParentNode );
1606 
1607 int GDALCanFileAcceptSidecarFile(const char* pszFilename);
1609 
1610 #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:2662
int GetBlockSize() const
Return the block size in bytes.
Definition: gdal_priv.h:714
int GetYSize() const
Return height.
Definition: gdal_priv.h:1358
GDALDataType
Definition: gdal.h:57
Identify could not determine if the file is recognized or not by the probed driver.
Definition: gdal_priv.h:1141
Document node structure.
Definition: cpl_minixml.h:66
Standard C Covers.
virtual GDALRasterBand * GetMaskBand()
Return the mask band associated with the band.
Definition: gdalrasterband.cpp:5937
Definitions for CPL mini XML Parser/Serializer.
Definition: gdal.h:205
GDALDataset * GetGDALDataset()
Return dataset.
Definition: gdal_priv.h:1342
int GetBandCount() const
Return band count.
Definition: gdal_priv.h:1378
#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:1049
const char *const * papszAllowedDrivers
Allowed drivers (NULL for all)
Definition: gdal_priv.h:281
int GetXOffset() const
Return x offset.
Definition: gdal_priv.h:1346
virtual CPLErr IRasterIO(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: rasterio.cpp:68
int * GetBandMap()
Return band map.
Definition: gdal_priv.h:1382
int DropLock(void)
Decrement the lock count.
Definition: gdal_priv.h:678
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:521
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 GetLineSpace() const
Return line spacing.
Definition: gdal_priv.h:1390
GDALAccess eAccess
Access flag.
Definition: gdal_priv.h:263
GDALDataType GetDataType() const
Return the data type.
Definition: gdal_priv.h:686
GDALRIOResampleAlg
RasterIO() resampling method.
Definition: gdal.h:114
VSILFILE * fpL
Pointer to the file.
Definition: gdal_priv.h:273
int GetBufferYSize() const
Return buffer height.
Definition: gdal_priv.h:1370
int GetBandSpace() const
Return band spacing.
Definition: gdal_priv.h:1394
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:999
int nOpenFlags
Open flags.
Definition: gdal_priv.h:265
A single raster block in the block cache.
Definition: gdal_priv.h:637
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:676
Convenient string class based on std::string.
Definition: cpl_string.h:338
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:967
unknown type, non-standard
Definition: ogr_core.h:314
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:1491
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
int GetDirty() const
Return the dirty flag.
Definition: gdal_priv.h:706
int GetXOff() const
Return the x offset of the top-left corner of the block.
Definition: gdal_priv.h:690
virtual const char * GetMetadataItem(const char *pszName, const char *pszDomain="")
Fetch single metadata item.
Definition: gdalmajorobject.cpp:344
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:312
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
int GetPixelSpace() const
Return pixel spacing.
Definition: gdal_priv.h:1386
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:1362
GDALRasterBand * GetBand()
Accessor to source GDALRasterBand object.
Definition: gdal_priv.h:722
Class for dataset open functions.
Definition: gdal_priv.h:246
GDALAccess GetAccess() const
Return access mode.
Definition: gdal_priv.h:510
void MarkSuppressOnClose()
Set that the dataset must be deleted on close.
Definition: gdal_priv.h:516
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:449
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:1145
GDALPaletteInterp
Definition: gdal.h:202
Core portability services for cross-platform OGR code.
int bStatOK
Whether stat()&#39;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:3413
void * GetDataRef(void)
Return the data buffer.
Definition: gdal_priv.h:710
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the dataset.
Definition: gdaldataset.cpp:2474
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 GetXSize() const
Return width.
Definition: gdal_priv.h:1354
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition: gdal.h:247
int GetXSize() const
Return the width of the block.
Definition: gdal_priv.h:698
void GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition: gdaldataset.cpp:3040
char ** papszOpenOptions
Open options.
Definition: gdal_priv.h:260
Object with metadata.
Definition: gdal_priv.h:125
int GetYSize() const
Return the height of the block.
Definition: gdal_priv.h:702
This class represents a layer of simple features, with access methods.
Definition: ogrsf_frmts.h:68
int GetYOffset() const
Return y offset.
Definition: gdal_priv.h:1350
A single raster band (or channel).
Definition: gdal_priv.h:832
GDALAccess
Definition: gdal.h:99
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
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
GDALDataType GetBufferType() const
Return buffer data type.
Definition: gdal_priv.h:1374
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:250
Class for managing the registration of file format drivers.
Definition: gdal_priv.h:1273
#define CPL_NULL_TERMINATED
Null terminated variadic.
Definition: cpl_port.h:957
int GetYOff() const
Return the y offset of the top-left corner of the block.
Definition: gdal_priv.h:694
CPLString & toupper(void)
Convert to upper case in place.
Definition: cplstring.cpp:316
GDALIdentifyEnum
Enumeration used by GDALDriver::pfnIdentify().
Definition: gdal_priv.h:1138
int OGRErr
Simple container for a bounding region.
Definition: ogr_core.h:285
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
Identify determined the file is not recognized by the probed driver.
Definition: gdal_priv.h:1143
Format specific driver.
Definition: gdal_priv.h:1163
A color table / palette.
Definition: gdal_priv.h:752
virtual char ** GetMetadataDomainList()
Fetch list of metadata domains.
Definition: gdalmajorobject.cpp:161
Ground Control Point.
Definition: gdal.h:515
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:1073
int GetBufferXSize() const
Return buffer width.
Definition: gdal_priv.h:1366
#define CPL_WARN_UNUSED_RESULT
Qualifier to warn when the return value of a function is not used.
Definition: cpl_port.h:999
Class used as a session object for asynchronous requests.
Definition: gdal_priv.h:1315

Generated for GDAL by doxygen 1.8.14.