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

Generated for GDAL by doxygen 1.8.8.