GDAL
gdal_priv.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: gdal_priv.h 39324 2017-06-27 14:28:10Z 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 <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 #ifdef notdef
731  static void CheckNonOrphanedBlocks(GDALRasterBand* poBand);
732  void DumpBlock();
733  static void DumpAll();
734 #endif
735 
736  /* Should only be called by GDALDestroyDriverManager() */
738  static void DestroyRBMutex();
740 
741  private:
742  CPL_DISALLOW_COPY_ASSIGN(GDALRasterBlock)
743 };
744 
745 /* ******************************************************************** */
746 /* GDALColorTable */
747 /* ******************************************************************** */
748 
751 class CPL_DLL GDALColorTable
752 {
753  GDALPaletteInterp eInterp;
754 
755  std::vector<GDALColorEntry> aoEntries;
756 
757 public:
759  ~GDALColorTable();
760 
761  GDALColorTable *Clone() const;
762  int IsSame(const GDALColorTable* poOtherCT) const;
763 
764  GDALPaletteInterp GetPaletteInterpretation() const;
765 
766  int GetColorEntryCount() const;
767  const GDALColorEntry *GetColorEntry( int ) const;
768  int GetColorEntryAsRGB( int, GDALColorEntry * ) const;
769  void SetColorEntry( int, const GDALColorEntry * );
770  int CreateColorRamp( int, const GDALColorEntry * ,
771  int, const GDALColorEntry * );
772 };
773 
774 /* ******************************************************************** */
775 /* GDALAbstractBandBlockCache */
776 /* ******************************************************************** */
777 
779 
781 // CPL_DLL is just technical here. This is really a private concept
782 // only used by GDALRasterBand implementation.
783 
784 class CPL_DLL GDALAbstractBandBlockCache
785 {
786  // List of blocks that can be freed or recycled, and its lock
787  CPLLock *hSpinLock;
788  GDALRasterBlock *psListBlocksToFree;
789 
790  // Band keep alive counter, and its lock & condition
791  CPLCond *hCond;
792  CPLMutex *hCondMutex;
793  volatile int nKeepAliveCounter;
794 
795  protected:
796  GDALRasterBand *poBand;
797 
798  void FreeDanglingBlocks();
799  void UnreferenceBlockBase();
800  void WaitKeepAliveCounter();
801 
802  public:
803  explicit GDALAbstractBandBlockCache(GDALRasterBand* poBand);
804  virtual ~GDALAbstractBandBlockCache();
805 
806  GDALRasterBlock* CreateBlock(int nXBlockOff, int nYBlockOff);
807  void AddBlockToFreeList( GDALRasterBlock * );
808 
809  virtual bool Init() = 0;
810  virtual bool IsInitOK() = 0;
811  virtual CPLErr FlushCache() = 0;
812  virtual CPLErr AdoptBlock( GDALRasterBlock* poBlock ) = 0;
813  virtual GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff,
814  int nYBlockYOff ) = 0;
815  virtual CPLErr UnreferenceBlock( GDALRasterBlock* poBlock ) = 0;
816  virtual CPLErr FlushBlock( int nXBlockOff, int nYBlockOff,
817  int bWriteDirtyBlock ) = 0;
818 };
819 
820 GDALAbstractBandBlockCache* GDALArrayBandBlockCacheCreate(GDALRasterBand* poBand);
821 GDALAbstractBandBlockCache* GDALHashSetBandBlockCacheCreate(GDALRasterBand* poBand);
822 
824 
825 /* ******************************************************************** */
826 /* GDALRasterBand */
827 /* ******************************************************************** */
828 
831 class CPL_DLL GDALRasterBand : public GDALMajorObject
832 {
833  private:
834  friend class GDALArrayBandBlockCache;
835  friend class GDALHashSetBandBlockCache;
836  friend class GDALRasterBlock;
837 
838  CPLErr eFlushBlockErr;
839  GDALAbstractBandBlockCache* poBandBlockCache;
840 
841  void SetFlushBlockErr( CPLErr eErr );
842  CPLErr UnreferenceBlock( GDALRasterBlock* poBlock );
843 
844  void Init(int bForceCachedIO);
845 
846  protected:
848  GDALDataset *poDS;
849  int nBand; /* 1 based */
850 
851  int nRasterXSize;
852  int nRasterYSize;
853 
854  GDALDataType eDataType;
855  GDALAccess eAccess;
856 
857  /* stuff related to blocking, and raster cache */
858  int nBlockXSize;
859  int nBlockYSize;
860  int nBlocksPerRow;
861  int nBlocksPerColumn;
862 
863  int nBlockReads;
864  int bForceCachedIO;
865 
866  GDALRasterBand *poMask;
867  bool bOwnMask;
868  int nMaskFlags;
869 
870  void InvalidateMaskBand();
871 
872  friend class GDALDataset;
873  friend class GDALProxyRasterBand;
874  friend class GDALDefaultOverviews;
875 
876  CPLErr RasterIOResampled( GDALRWFlag, int, int, int, int,
877  void *, int, int, GDALDataType,
879 
880  int EnterReadWrite(GDALRWFlag eRWFlag);
881  void LeaveReadWrite();
882  void InitRWLock();
884 
885  protected:
886  virtual CPLErr IReadBlock( int nBlockXOff, int nBlockYOff, void * pData ) = 0;
887  virtual CPLErr IWriteBlock( int nBlockXOff, int nBlockYOff, void * pData );
888 
889 #ifdef DETECT_OLD_IRASTERIO
890  virtual signature_changed IRasterIO( GDALRWFlag, int, int, int, int,
891  void *, int, int, GDALDataType,
892  int, int ) {};
893 #endif
894 
895  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
896  void *, int, int, GDALDataType,
898 
899  virtual int IGetDataCoverageStatus( int nXOff, int nYOff,
900  int nXSize, int nYSize,
901  int nMaskFlagStop,
902  double* pdfDataPct);
904  CPLErr OverviewRasterIO( GDALRWFlag, int, int, int, int,
905  void *, int, int, GDALDataType,
907 
908  CPLErr TryOverviewRasterIO( GDALRWFlag eRWFlag,
909  int nXOff, int nYOff, int nXSize, int nYSize,
910  void * pData, int nBufXSize, int nBufYSize,
911  GDALDataType eBufType,
912  GSpacing nPixelSpace, GSpacing nLineSpace,
913  GDALRasterIOExtraArg* psExtraArg,
914  int* pbTried );
915 
916  int InitBlockInfo();
917 
918  void AddBlockToFreeList( GDALRasterBlock * );
920 
921  GDALRasterBlock *TryGetLockedBlockRef( int nXBlockOff, int nYBlockYOff );
922 
923  public:
924  GDALRasterBand();
925  explicit GDALRasterBand(int bForceCachedIO);
926 
927  virtual ~GDALRasterBand();
928 
929  int GetXSize();
930  int GetYSize();
931  int GetBand();
932  GDALDataset*GetDataset();
933 
934  GDALDataType GetRasterDataType( void );
935  void GetBlockSize( int *, int * );
936  CPLErr GetActualBlockSize ( int, int, int *, int * );
937  GDALAccess GetAccess();
938 
939  CPLErr RasterIO( GDALRWFlag, int, int, int, int,
940  void *, int, int, GDALDataType,
942 #ifndef DOXYGEN_SKIP
943  OPTIONAL_OUTSIDE_GDAL(NULL)
944 #endif
946  CPLErr ReadBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
947 
948  CPLErr WriteBlock( int, int, void * ) CPL_WARN_UNUSED_RESULT;
949 
950  GDALRasterBlock *GetLockedBlockRef( int nXBlockOff, int nYBlockOff,
951  int bJustInitialize = FALSE ) CPL_WARN_UNUSED_RESULT;
952  CPLErr FlushBlock( int, int, int bWriteDirtyBlock = TRUE );
953 
954  unsigned char* GetIndexColorTranslationTo(/* const */ GDALRasterBand* poReferenceBand,
955  unsigned char* pTranslationTable = NULL,
956  int* pApproximateMatching = NULL);
957 
958  // New OpengIS CV_SampleDimension stuff.
959 
960  virtual CPLErr FlushCache();
961  virtual char **GetCategoryNames();
962  virtual double GetNoDataValue( int *pbSuccess = NULL );
963  virtual double GetMinimum( int *pbSuccess = NULL );
964  virtual double GetMaximum(int *pbSuccess = NULL );
965  virtual double GetOffset( int *pbSuccess = NULL );
966  virtual double GetScale( int *pbSuccess = NULL );
967  virtual const char *GetUnitType();
968  virtual GDALColorInterp GetColorInterpretation();
969  virtual GDALColorTable *GetColorTable();
970  virtual CPLErr Fill(double dfRealValue, double dfImaginaryValue = 0);
971 
972  virtual CPLErr SetCategoryNames( char ** papszNames );
973  virtual CPLErr SetNoDataValue( double dfNoData );
974  virtual CPLErr DeleteNoDataValue();
975  virtual CPLErr SetColorTable( GDALColorTable * poCT );
976  virtual CPLErr SetColorInterpretation( GDALColorInterp eColorInterp );
977  virtual CPLErr SetOffset( double dfNewOffset );
978  virtual CPLErr SetScale( double dfNewScale );
979  virtual CPLErr SetUnitType( const char * pszNewValue );
980 
981  virtual CPLErr GetStatistics( int bApproxOK, int bForce,
982  double *pdfMin, double *pdfMax,
983  double *pdfMean, double *padfStdDev );
984  virtual CPLErr ComputeStatistics( int bApproxOK,
985  double *pdfMin, double *pdfMax,
986  double *pdfMean, double *pdfStdDev,
987  GDALProgressFunc, void *pProgressData );
988  virtual CPLErr SetStatistics( double dfMin, double dfMax,
989  double dfMean, double dfStdDev );
990  virtual CPLErr ComputeRasterMinMax( int, double* );
991 
992 // Only defined when Doxygen enabled
993 #ifdef DOXYGEN_SKIP
994  virtual char **GetMetadata( const char * pszDomain = "" ) CPL_OVERRIDE;
995  virtual CPLErr SetMetadata( char ** papszMetadata,
996  const char * pszDomain ) CPL_OVERRIDE;
997  virtual const char *GetMetadataItem( const char * pszName,
998  const char * pszDomain ) CPL_OVERRIDE;
999  virtual CPLErr SetMetadataItem( const char * pszName,
1000  const char * pszValue,
1001  const char * pszDomain ) CPL_OVERRIDE;
1002 #endif
1003 
1004  virtual int HasArbitraryOverviews();
1005  virtual int GetOverviewCount();
1006  virtual GDALRasterBand *GetOverview(int);
1007  virtual GDALRasterBand *GetRasterSampleOverview( GUIntBig );
1008  virtual CPLErr BuildOverviews( const char * pszResampling,
1009  int nOverviews,
1010  int * panOverviewList,
1011  GDALProgressFunc pfnProgress,
1012  void * pProgressData );
1013 
1014  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
1015  int nBufXSize, int nBufYSize,
1016  GDALDataType eBufType, char **papszOptions );
1017 
1018  virtual CPLErr GetHistogram( double dfMin, double dfMax,
1019  int nBuckets, GUIntBig * panHistogram,
1020  int bIncludeOutOfRange, int bApproxOK,
1021  GDALProgressFunc, void *pProgressData );
1022 
1023  virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
1024  int *pnBuckets, GUIntBig ** ppanHistogram,
1025  int bForce,
1026  GDALProgressFunc, void *pProgressData);
1027  virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
1028  int nBuckets, GUIntBig *panHistogram );
1029 
1030  virtual GDALRasterAttributeTable *GetDefaultRAT();
1031  virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * poRAT );
1032 
1033  virtual GDALRasterBand *GetMaskBand();
1034  virtual int GetMaskFlags();
1035  virtual CPLErr CreateMaskBand( int nFlagsIn );
1036 
1037  virtual CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
1038  int *pnPixelSpace,
1039  GIntBig *pnLineSpace,
1040  char **papszOptions ) CPL_WARN_UNUSED_RESULT;
1041 
1042  int GetDataCoverageStatus( int nXOff, int nYOff,
1043  int nXSize, int nYSize,
1044  int nMaskFlagStop = 0,
1045  double* pdfDataPct = NULL );
1046 
1047  void ReportError(CPLErr eErrClass, CPLErrorNum err_no, const char *fmt, ...) CPL_PRINT_FUNC_FORMAT (4, 5);
1048 
1049 private:
1051 };
1052 
1054 /* ******************************************************************** */
1055 /* GDALAllValidMaskBand */
1056 /* ******************************************************************** */
1057 
1058 class CPL_DLL GDALAllValidMaskBand : public GDALRasterBand
1059 {
1060  protected:
1061  virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE;
1062 
1063  public:
1064  explicit GDALAllValidMaskBand( GDALRasterBand * );
1065  virtual ~GDALAllValidMaskBand();
1066 
1067  virtual GDALRasterBand *GetMaskBand() CPL_OVERRIDE;
1068  virtual int GetMaskFlags() CPL_OVERRIDE;
1069 };
1070 
1071 /* ******************************************************************** */
1072 /* GDALNoDataMaskBand */
1073 /* ******************************************************************** */
1074 
1075 class CPL_DLL GDALNoDataMaskBand : public GDALRasterBand
1076 {
1077  double dfNoDataValue;
1078  GDALRasterBand *poParent;
1079 
1080  protected:
1081  virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE;
1082  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1083  void *, int, int, GDALDataType,
1084  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_OVERRIDE;
1085 
1086  public:
1087  explicit GDALNoDataMaskBand( GDALRasterBand * );
1088  virtual ~GDALNoDataMaskBand();
1089 };
1090 
1091 /* ******************************************************************** */
1092 /* GDALNoDataValuesMaskBand */
1093 /* ******************************************************************** */
1094 
1095 class CPL_DLL GDALNoDataValuesMaskBand : public GDALRasterBand
1096 {
1097  double *padfNodataValues;
1098 
1099  protected:
1100  virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE;
1101 
1102  public:
1103  explicit GDALNoDataValuesMaskBand( GDALDataset * );
1104  virtual ~GDALNoDataValuesMaskBand();
1105 };
1106 
1107 /* ******************************************************************** */
1108 /* GDALRescaledAlphaBand */
1109 /* ******************************************************************** */
1110 
1111 class GDALRescaledAlphaBand : public GDALRasterBand
1112 {
1113  GDALRasterBand *poParent;
1114  void *pTemp;
1115 
1116  protected:
1117  virtual CPLErr IReadBlock( int, int, void * ) CPL_OVERRIDE;
1118  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
1119  void *, int, int, GDALDataType,
1120  GSpacing, GSpacing, GDALRasterIOExtraArg* psExtraArg ) CPL_OVERRIDE;
1121 
1122  public:
1123  explicit GDALRescaledAlphaBand( GDALRasterBand * );
1124  virtual ~GDALRescaledAlphaBand();
1125 };
1127 
1128 /* ******************************************************************** */
1129 /* GDALIdentifyEnum */
1130 /* ******************************************************************** */
1131 
1137 typedef enum
1138 {
1146 
1147 /* ******************************************************************** */
1148 /* GDALDriver */
1149 /* ******************************************************************** */
1150 
1162 class CPL_DLL GDALDriver : public GDALMajorObject
1163 {
1164  public:
1165  GDALDriver();
1166  virtual ~GDALDriver();
1167 
1168  virtual CPLErr SetMetadataItem( const char * pszName,
1169  const char * pszValue,
1170  const char * pszDomain = "" ) CPL_OVERRIDE;
1171 
1172 /* -------------------------------------------------------------------- */
1173 /* Public C++ methods. */
1174 /* -------------------------------------------------------------------- */
1175  GDALDataset *Create( const char * pszName,
1176  int nXSize, int nYSize, int nBands,
1177  GDALDataType eType, char ** papszOptions ) CPL_WARN_UNUSED_RESULT;
1178 
1179  CPLErr Delete( const char * pszName );
1180  CPLErr Rename( const char * pszNewName,
1181  const char * pszOldName );
1182  CPLErr CopyFiles( const char * pszNewName,
1183  const char * pszOldName );
1184 
1185  GDALDataset *CreateCopy( const char *, GDALDataset *,
1186  int, char **,
1187  GDALProgressFunc pfnProgress,
1188  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
1189 
1190 /* -------------------------------------------------------------------- */
1191 /* The following are semiprivate, not intended to be accessed */
1192 /* by anyone but the formats instantiating and populating the */
1193 /* drivers. */
1194 /* -------------------------------------------------------------------- */
1196  GDALDataset *(*pfnOpen)( GDALOpenInfo * );
1197 
1198  GDALDataset *(*pfnCreate)( const char * pszName,
1199  int nXSize, int nYSize, int nBands,
1200  GDALDataType eType,
1201  char ** papszOptions );
1202 
1203  CPLErr (*pfnDelete)( const char * pszName );
1204 
1205  GDALDataset *(*pfnCreateCopy)( const char *, GDALDataset *,
1206  int, char **,
1207  GDALProgressFunc pfnProgress,
1208  void * pProgressData );
1209 
1210  void *pDriverData;
1211 
1212  void (*pfnUnloadDriver)(GDALDriver *);
1213 
1221  int (*pfnIdentify)( GDALOpenInfo * );
1222 
1223  CPLErr (*pfnRename)( const char * pszNewName,
1224  const char * pszOldName );
1225  CPLErr (*pfnCopyFiles)( const char * pszNewName,
1226  const char * pszOldName );
1227 
1228  /* For legacy OGR drivers */
1229  GDALDataset *(*pfnOpenWithDriverArg)( GDALDriver*, GDALOpenInfo * );
1230  GDALDataset *(*pfnCreateVectorOnly)( GDALDriver*,
1231  const char * pszName,
1232  char ** papszOptions );
1233  CPLErr (*pfnDeleteDataSource)( GDALDriver*,
1234  const char * pszName );
1236 
1237 /* -------------------------------------------------------------------- */
1238 /* Helper methods. */
1239 /* -------------------------------------------------------------------- */
1241  GDALDataset *DefaultCreateCopy( const char *, GDALDataset *,
1242  int, char **,
1243  GDALProgressFunc pfnProgress,
1244  void * pProgressData ) CPL_WARN_UNUSED_RESULT;
1245  static CPLErr DefaultCopyMasks( GDALDataset *poSrcDS,
1246  GDALDataset *poDstDS,
1247  int bStrict );
1249  static CPLErr QuietDelete( const char * pszName );
1250 
1252  static CPLErr DefaultRename( const char * pszNewName,
1253  const char * pszOldName );
1254  static CPLErr DefaultCopyFiles( const char * pszNewName,
1255  const char * pszOldName );
1257 private:
1258  CPL_DISALLOW_COPY_ASSIGN(GDALDriver)
1259 };
1260 
1261 /* ******************************************************************** */
1262 /* GDALDriverManager */
1263 /* ******************************************************************** */
1264 
1272 class CPL_DLL GDALDriverManager : public GDALMajorObject
1273 {
1274  int nDrivers;
1275  GDALDriver **papoDrivers;
1276  std::map<CPLString, GDALDriver*> oMapNameToDrivers;
1277 
1278  GDALDriver *GetDriver_unlocked( int iDriver )
1279  { return (iDriver >= 0 && iDriver < nDrivers) ?
1280  papoDrivers[iDriver] : NULL; }
1281 
1282  GDALDriver *GetDriverByName_unlocked( const char * pszName )
1283  { return oMapNameToDrivers[CPLString(pszName).toupper()]; }
1284 
1285  public:
1287  ~GDALDriverManager();
1288 
1289  int GetDriverCount( void ) const;
1290  GDALDriver *GetDriver( int );
1291  GDALDriver *GetDriverByName( const char * );
1292 
1293  int RegisterDriver( GDALDriver * );
1294  void DeregisterDriver( GDALDriver * );
1295 
1296  // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
1297  static void AutoLoadDrivers();
1298  void AutoSkipDrivers();
1299 };
1300 
1302 GDALDriverManager CPL_DLL * GetGDALDriverManager( void );
1303 CPL_C_END
1304 
1305 /* ******************************************************************** */
1306 /* GDALAsyncReader */
1307 /* ******************************************************************** */
1308 
1314 class CPL_DLL GDALAsyncReader
1315 {
1316  protected:
1318  GDALDataset* poDS;
1319  int nXOff;
1320  int nYOff;
1321  int nXSize;
1322  int nYSize;
1323  void * pBuf;
1324  int nBufXSize;
1325  int nBufYSize;
1326  GDALDataType eBufType;
1327  int nBandCount;
1328  int* panBandMap;
1329  int nPixelSpace;
1330  int nLineSpace;
1331  int nBandSpace;
1333 
1334  public:
1335  GDALAsyncReader();
1336  virtual ~GDALAsyncReader();
1337 
1341  GDALDataset* GetGDALDataset() {return poDS;}
1345  int GetXOffset() const { return nXOff; }
1349  int GetYOffset() const { return nYOff; }
1353  int GetXSize() const { return nXSize; }
1357  int GetYSize() const { return nYSize; }
1361  void * GetBuffer() {return pBuf;}
1365  int GetBufferXSize() const { return nBufXSize; }
1369  int GetBufferYSize() const { return nBufYSize; }
1373  GDALDataType GetBufferType() const { return eBufType; }
1377  int GetBandCount() const { return nBandCount; }
1381  int* GetBandMap() { return panBandMap; }
1385  int GetPixelSpace() const { return nPixelSpace; }
1389  int GetLineSpace() const { return nLineSpace; }
1393  int GetBandSpace() const { return nBandSpace; }
1394 
1395  virtual GDALAsyncStatusType
1396  GetNextUpdatedRegion(double dfTimeout,
1397  int* pnBufXOff, int* pnBufYOff,
1398  int* pnBufXSize, int* pnBufYSize) = 0;
1399  virtual int LockBuffer( double dfTimeout = -1.0 );
1400  virtual void UnlockBuffer();
1401 };
1402 
1403 /* ==================================================================== */
1404 /* An assortment of overview related stuff. */
1405 /* ==================================================================== */
1406 
1408 /* Only exported for drivers as plugin. Signature may change */
1409 CPLErr CPL_DLL
1410 GDALRegenerateOverviewsMultiBand(int nBands, GDALRasterBand** papoSrcBands,
1411  int nOverviews,
1412  GDALRasterBand*** papapoOverviewBands,
1413  const char * pszResampling,
1414  GDALProgressFunc pfnProgress, void * pProgressData );
1415 
1416 typedef CPLErr (*GDALResampleFunction)
1417  ( double dfXRatioDstToSrc,
1418  double dfYRatioDstToSrc,
1419  double dfSrcXDelta,
1420  double dfSrcYDelta,
1421  GDALDataType eWrkDataType,
1422  void * pChunk,
1423  GByte * pabyChunkNodataMask,
1424  int nChunkXOff, int nChunkXSize,
1425  int nChunkYOff, int nChunkYSize,
1426  int nDstXOff, int nDstXOff2,
1427  int nDstYOff, int nDstYOff2,
1428  GDALRasterBand * poOverview,
1429  const char * pszResampling,
1430  int bHasNoData, float fNoDataValue,
1431  GDALColorTable* poColorTable,
1432  GDALDataType eSrcDataType,
1433  bool bPropagateNoData );
1434 
1435 GDALResampleFunction GDALGetResampleFunction(const char* pszResampling,
1436  int* pnRadius);
1437 
1438 #ifdef GDAL_ENABLE_RESAMPLING_MULTIBAND
1439 typedef CPLErr (*GDALResampleFunctionMultiBands)
1440  ( double dfXRatioDstToSrc,
1441  double dfYRatioDstToSrc,
1442  double dfSrcXDelta,
1443  double dfSrcYDelta,
1444  GDALDataType eWrkDataType,
1445  void * pChunk, int nBands,
1446  GByte * pabyChunkNodataMask,
1447  int nChunkXOff, int nChunkXSize,
1448  int nChunkYOff, int nChunkYSize,
1449  int nDstXOff, int nDstXOff2,
1450  int nDstYOff, int nDstYOff2,
1451  GDALRasterBand ** papoDstBands,
1452  const char * pszResampling,
1453  int bHasNoData, float fNoDataValue,
1454  GDALColorTable* poColorTable,
1455  GDALDataType eSrcDataType);
1456 
1457 GDALResampleFunctionMultiBands GDALGetResampleFunctionMultiBands(const char* pszResampling,
1458  int* pnRadius);
1459 #endif
1460 
1461 GDALDataType GDALGetOvrWorkDataType(const char* pszResampling,
1462  GDALDataType eSrcDataType);
1463 
1465 
1466 CPLErr CPL_DLL
1467 HFAAuxBuildOverviews( const char *pszOvrFilename, GDALDataset *poParentDS,
1468  GDALDataset **ppoDS,
1469  int nBands, int *panBandList,
1470  int nNewOverviews, int *panNewOverviewList,
1471  const char *pszResampling,
1472  GDALProgressFunc pfnProgress,
1473  void *pProgressData );
1474 
1475 CPLErr CPL_DLL
1476 GTIFFBuildOverviews( const char * pszFilename,
1477  int nBands, GDALRasterBand **papoBandList,
1478  int nOverviews, int * panOverviewList,
1479  const char * pszResampling,
1480  GDALProgressFunc pfnProgress, void * pProgressData );
1481 
1482 CPLErr CPL_DLL
1483 GDALDefaultBuildOverviews( GDALDataset *hSrcDS, const char * pszBasename,
1484  const char * pszResampling,
1485  int nOverviews, int * panOverviewList,
1486  int nBands, int * panBandList,
1487  GDALProgressFunc pfnProgress, void * pProgressData);
1488 
1489 int CPL_DLL GDALBandGetBestOverviewLevel(GDALRasterBand* poBand,
1490  int &nXOff, int &nYOff,
1491  int &nXSize, int &nYSize,
1492  int nBufXSize, int nBufYSize) CPL_WARN_DEPRECATED("Use GDALBandGetBestOverviewLevel2 instead");
1493 int CPL_DLL GDALBandGetBestOverviewLevel2(GDALRasterBand* poBand,
1494  int &nXOff, int &nYOff,
1495  int &nXSize, int &nYSize,
1496  int nBufXSize, int nBufYSize,
1497  GDALRasterIOExtraArg* psExtraArg);
1498 
1499 int CPL_DLL GDALOvLevelAdjust( int nOvLevel, int nXSize ) CPL_WARN_DEPRECATED("Use GDALOvLevelAdjust2 instead");
1500 int CPL_DLL GDALOvLevelAdjust2( int nOvLevel, int nXSize, int nYSize );
1501 int CPL_DLL GDALComputeOvFactor( int nOvrXSize, int nRasterXSize,
1502  int nOvrYSize, int nRasterYSize );
1503 
1504 GDALDataset CPL_DLL *
1505 GDALFindAssociatedAuxFile( const char *pszBasefile, GDALAccess eAccess,
1506  GDALDataset *poDependentDS );
1507 
1508 /* ==================================================================== */
1509 /* Misc functions. */
1510 /* ==================================================================== */
1511 
1512 CPLErr CPL_DLL GDALParseGMLCoverage( CPLXMLNode *psTree,
1513  int *pnXSize, int *pnYSize,
1514  double *padfGeoTransform,
1515  char **ppszProjection );
1516 
1517 /* ==================================================================== */
1518 /* Infrastructure to check that dataset characteristics are valid */
1519 /* ==================================================================== */
1520 
1521 int CPL_DLL GDALCheckDatasetDimensions( int nXSize, int nYSize );
1522 int CPL_DLL GDALCheckBandCount( int nBands, int bIsZeroAllowed );
1523 
1524 /* Internal use only */
1525 
1526 /* CPL_DLL exported, but only for in-tree drivers that can be built as plugins */
1527 int CPL_DLL GDALReadWorldFile2( const char *pszBaseFilename, const char *pszExtension,
1528  double *padfGeoTransform, char** papszSiblingFiles,
1529  char** ppszWorldFileNameOut);
1530 int GDALReadTabFile2( const char * pszBaseFilename,
1531  double *padfGeoTransform, char **ppszWKT,
1532  int *pnGCPCount, GDAL_GCP **ppasGCPs,
1533  char** papszSiblingFiles, char** ppszTabFileNameOut );
1534 
1535 void CPL_DLL GDALCopyRasterIOExtraArg(GDALRasterIOExtraArg* psDestArg,
1536  GDALRasterIOExtraArg* psSrcArg);
1537 
1538 CPL_C_END
1539 
1540 void GDALNullifyOpenDatasetsList();
1541 CPLMutex** GDALGetphDMMutex();
1542 CPLMutex** GDALGetphDLMutex();
1543 void GDALNullifyProxyPoolSingleton();
1544 GDALDriver* GDALGetAPIPROXYDriver();
1545 void GDALSetResponsiblePIDForCurrentThread(GIntBig responsiblePID);
1546 GIntBig GDALGetResponsiblePIDForCurrentThread();
1547 
1548 CPLString GDALFindAssociatedFile( const char *pszBasename, const char *pszExt,
1549  char **papszSiblingFiles, int nFlags );
1550 
1551 CPLErr EXIFExtractMetadata(char**& papszMetadata,
1552  void *fpL, int nOffset,
1553  int bSwabflag, int nTIFFHEADER,
1554  int& nExifOffset, int& nInterOffset, int& nGPSOffset);
1555 
1556 int GDALValidateOpenOptions( GDALDriverH hDriver,
1557  const char* const* papszOptionOptions);
1558 int GDALValidateOptions( const char* pszOptionList,
1559  const char* const* papszOptionsToValidate,
1560  const char* pszErrorMessageOptionType,
1561  const char* pszErrorMessageContainerName);
1562 
1563 GDALRIOResampleAlg GDALRasterIOGetResampleAlg(const char* pszResampling);
1564 const char* GDALRasterIOGetResampleAlg(GDALRIOResampleAlg eResampleAlg);
1565 
1566 void GDALRasterIOExtraArgSetResampleAlg(GDALRasterIOExtraArg* psExtraArg,
1567  int nXSize, int nYSize,
1568  int nBufXSize, int nBufYSize);
1569 
1570 
1571 GDALDataset* GDALCreateOverviewDataset(GDALDataset* poDS, int nOvrLevel,
1572  int bThisLevelOnly);
1573 
1574 // Should cover particular cases of #3573, #4183, #4506, #6578
1575 // Behaviour is undefined if fVal1 or fVal2 are NaN (should be tested before
1576 // calling this function)
1577 template<class T> inline bool ARE_REAL_EQUAL(T fVal1, T fVal2, int ulp = 2)
1578 {
1579  return fVal1 == fVal2 || /* Should cover infinity */
1580  std::abs(fVal1 - fVal2) < std::numeric_limits<float>::epsilon() * std::abs(fVal1+fVal2) * ulp;
1581 }
1582 
1583 #define DIV_ROUND_UP(a, b) ( ((a) % (b)) == 0 ? ((a) / (b)) : (((a) / (b)) + 1) )
1584 
1585 // Number of data samples that will be used to compute approximate statistics
1586 // (minimum value, maximum value, etc.)
1587 #define GDALSTAT_APPROX_NUMSAMPLES 2500
1588 
1590 /* Caution: for technical reason this declaration is duplicated in gdal_crs.c */
1591 /* so any signature change should be reflected there too */
1592 void GDALSerializeGCPListToXML( CPLXMLNode* psParentNode,
1593  GDAL_GCP* pasGCPList,
1594  int nGCPCount,
1595  const char* pszGCPProjection );
1596 void GDALDeserializeGCPListFromXML( CPLXMLNode* psGCPList,
1597  GDAL_GCP** ppasGCPList,
1598  int* pnGCPCount,
1599  char** ppszGCPProjection );
1600 CPL_C_END
1601 
1602 void GDALSerializeOpenOptionsToXML( CPLXMLNode* psParentNode, char** papszOpenOptions);
1603 char** GDALDeserializeOpenOptionsFromXML( CPLXMLNode* psParentNode );
1604 
1605 int GDALCanFileAcceptSidecarFile(const char* pszFilename);
1607 
1608 #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
GDALDataType
Definition: gdal.h:57
GDALDataType GetBufferType() const
Return buffer data type.
Definition: gdal_priv.h:1373
Identify could not determine if the file is recognized or not by the probed driver.
Definition: gdal_priv.h:1140
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:1341
#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:1055
const char *const * papszAllowedDrivers
Allowed drivers (NULL for all)
Definition: gdal_priv.h:283
int * GetBandMap()
Return band map.
Definition: gdal_priv.h:1381
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:6514
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:1353
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:1020
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:2391
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:967
unknown type, non-standard
Definition: ogr_core.h:316
int GetLineSpace() const
Return line spacing.
Definition: gdal_priv.h:1389
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:1027
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:3670
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:1361
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:1349
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:1144
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:3429
void * GetDataRef(void)
Return the data buffer.
Definition: gdal_priv.h:712
int GetYSize() const
Return height.
Definition: gdal_priv.h:1357
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:94
Various convenience functions for CPL.
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:132
int GetBufferXSize() const
Return buffer width.
Definition: gdal_priv.h:1365
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:3056
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:1369
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:831
GDALAccess
Definition: gdal.h:107
int GetPixelSpace() const
Return pixel spacing.
Definition: gdal_priv.h:1385
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:6278
int GetBandSpace() const
Return band spacing.
Definition: gdal_priv.h:1393
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:354
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:250
int GetXOffset() const
Return x offset.
Definition: gdal_priv.h:1345
Class for managing the registration of file format drivers.
Definition: gdal_priv.h:1272
#define CPL_NULL_TERMINATED
Null terminated variadic.
Definition: cpl_port.h:957
CPLString & toupper(void)
Convert to upper case in place.
Definition: cplstring.cpp:316
GDALIdentifyEnum
Enumeration used by GDALDriver::pfnIdentify().
Definition: gdal_priv.h:1137
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:1142
int GetBandCount() const
Return band count.
Definition: gdal_priv.h:1377
Format specific driver.
Definition: gdal_priv.h:1162
int GetBlockSize() const
Return the block size in bytes.
Definition: gdal_priv.h:716
A color table / palette.
Definition: gdal_priv.h:751
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:536
CPLErr
Error category.
Definition: cpl_error.h:52
GDALDriverManager * GetGDALDriverManager(void)
Fetch the global GDAL driver manager.
Definition: gdaldrivermanager.cpp:98
#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:1085
#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:1314

Generated for GDAL by doxygen 1.8.8.