GDAL
vrtdataset.h
1 /******************************************************************************
2  * $Id: vrtdataset.h 27542 2014-07-22 21:25:37Z rouault $
3  *
4  * Project: Virtual GDAL Datasets
5  * Purpose: Declaration of virtual gdal dataset classes.
6  * Author: Frank Warmerdam, warmerdam@pobox.com
7  *
8  ******************************************************************************
9  * Copyright (c) 2001, Frank Warmerdam <warmerdam@pobox.com>
10  * Copyright (c) 2007-2013, Even Rouault <even dot rouault at mines-paris dot org>
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included
20  * in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28  * DEALINGS IN THE SOFTWARE.
29  ****************************************************************************/
30 
31 #ifndef VIRTUALDATASET_H_INCLUDED
32 #define VIRTUALDATASET_H_INCLUDED
33 
34 #include "gdal_priv.h"
35 #include "gdal_pam.h"
36 #include "gdal_vrt.h"
37 #include "cpl_hash_set.h"
38 
39 int VRTApplyMetadata( CPLXMLNode *, GDALMajorObject * );
40 CPLXMLNode *VRTSerializeMetadata( GDALMajorObject * );
41 
42 int VRTWarpedOverviewTransform( void *pTransformArg, int bDstToSrc,
43  int nPointCount,
44  double *padfX, double *padfY, double *padfZ,
45  int *panSuccess );
46 void* VRTDeserializeWarpedOverviewTransformer( CPLXMLNode *psTree );
47 
48 /************************************************************************/
49 /* VRTOverviewInfo() */
50 /************************************************************************/
52 {
53 public:
54  CPLString osFilename;
55  int nBand;
56  GDALRasterBand *poBand;
57  int bTriedToOpen;
58 
59  VRTOverviewInfo() : poBand(NULL), bTriedToOpen(FALSE) {}
60  ~VRTOverviewInfo() {
61  if( poBand == NULL )
62  /* do nothing */;
63  else if( poBand->GetDataset()->GetShared() )
64  GDALClose( (GDALDatasetH) poBand->GetDataset() );
65  else
66  poBand->GetDataset()->Dereference();
67  }
68 };
69 
70 
71 /************************************************************************/
72 /* VRTSource */
73 /************************************************************************/
74 
75 class CPL_DLL VRTSource
76 {
77 public:
78  virtual ~VRTSource();
79 
80  virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
81  void *pData, int nBufXSize, int nBufYSize,
82  GDALDataType eBufType,
83  int nPixelSpace, int nLineSpace ) = 0;
84 
85  virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) = 0;
86  virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) = 0;
87  virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax ) = 0;
88  virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
89  int bApproxOK,
90  double *pdfMin, double *pdfMax,
91  double *pdfMean, double *pdfStdDev,
92  GDALProgressFunc pfnProgress, void *pProgressData ) = 0;
93  virtual CPLErr GetHistogram( int nXSize, int nYSize,
94  double dfMin, double dfMax,
95  int nBuckets, int * panHistogram,
96  int bIncludeOutOfRange, int bApproxOK,
97  GDALProgressFunc pfnProgress, void *pProgressData ) = 0;
98 
99  virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * ) = 0;
100  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) = 0;
101 
102  virtual void GetFileList(char*** ppapszFileList, int *pnSize,
103  int *pnMaxSize, CPLHashSet* hSetFiles);
104 
105  virtual int IsSimpleSource() { return FALSE; }
106 };
107 
108 typedef VRTSource *(*VRTSourceParser)(CPLXMLNode *, const char *);
109 
110 VRTSource *VRTParseCoreSources( CPLXMLNode *psTree, const char * );
111 VRTSource *VRTParseFilterSources( CPLXMLNode *psTree, const char * );
112 
113 /************************************************************************/
114 /* VRTDataset */
115 /************************************************************************/
116 
117 class VRTRasterBand;
118 
119 class CPL_DLL VRTDataset : public GDALDataset
120 {
121  friend class VRTRasterBand;
122 
123  char *pszProjection;
124 
125  int bGeoTransformSet;
126  double adfGeoTransform[6];
127 
128  int nGCPCount;
129  GDAL_GCP *pasGCPList;
130  char *pszGCPProjection;
131 
132  int bNeedsFlush;
133  int bWritable;
134 
135  char *pszVRTPath;
136 
137  VRTRasterBand *poMaskBand;
138 
139  int bCompatibleForDatasetIO;
140  int CheckCompatibleForDatasetIO();
141 
142  protected:
143  virtual int CloseDependentDatasets();
144 
145  public:
146  VRTDataset(int nXSize, int nYSize);
147  ~VRTDataset();
148 
149  void SetNeedsFlush() { bNeedsFlush = TRUE; }
150  virtual void FlushCache();
151 
152  void SetWritable(int bWritable) { this->bWritable = bWritable; }
153 
154  virtual CPLErr CreateMaskBand( int nFlags );
155  void SetMaskBand(VRTRasterBand* poMaskBand);
156 
157  virtual const char *GetProjectionRef(void);
158  virtual CPLErr SetProjection( const char * );
159  virtual CPLErr GetGeoTransform( double * );
160  virtual CPLErr SetGeoTransform( double * );
161 
162  virtual CPLErr SetMetadata( char **papszMD, const char *pszDomain = "" );
163  virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue,
164  const char *pszDomain = "" );
165 
166  virtual int GetGCPCount();
167  virtual const char *GetGCPProjection();
168  virtual const GDAL_GCP *GetGCPs();
169  virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
170  const char *pszGCPProjection );
171 
172  virtual CPLErr AddBand( GDALDataType eType,
173  char **papszOptions=NULL );
174 
175  virtual char **GetFileList();
176 
177  virtual CPLErr IRasterIO( GDALRWFlag eRWFlag,
178  int nXOff, int nYOff, int nXSize, int nYSize,
179  void * pData, int nBufXSize, int nBufYSize,
180  GDALDataType eBufType,
181  int nBandCount, int *panBandMap,
182  int nPixelSpace, int nLineSpace, int nBandSpace);
183 
184  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath);
185  virtual CPLErr XMLInit( CPLXMLNode *, const char * );
186 
187  /* Used by PDF driver for example */
188  GDALDataset* GetSingleSimpleSource();
189 
190  static int Identify( GDALOpenInfo * );
191  static GDALDataset *Open( GDALOpenInfo * );
192  static GDALDataset *OpenXML( const char *, const char * = NULL, GDALAccess eAccess = GA_ReadOnly );
193  static GDALDataset *Create( const char * pszName,
194  int nXSize, int nYSize, int nBands,
195  GDALDataType eType, char ** papszOptions );
196  static CPLErr Delete( const char * pszFilename );
197 };
198 
199 /************************************************************************/
200 /* VRTWarpedDataset */
201 /************************************************************************/
202 
203 class GDALWarpOperation;
204 class VRTWarpedRasterBand;
205 
206 class CPL_DLL VRTWarpedDataset : public VRTDataset
207 {
208  int nBlockXSize;
209  int nBlockYSize;
210  GDALWarpOperation *poWarper;
211 
212  friend class VRTWarpedRasterBand;
213 
214  protected:
215  virtual int CloseDependentDatasets();
216 
217 public:
218  int nOverviewCount;
219  VRTWarpedDataset **papoOverviews;
220 
221 public:
222  VRTWarpedDataset( int nXSize, int nYSize );
223  ~VRTWarpedDataset();
224 
225  CPLErr Initialize( /* GDALWarpOptions */ void * );
226 
227  virtual CPLErr IBuildOverviews( const char *, int, int *,
228  int, int *, GDALProgressFunc, void * );
229 
230  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
231  virtual CPLErr XMLInit( CPLXMLNode *, const char * );
232 
233  virtual CPLErr AddBand( GDALDataType eType,
234  char **papszOptions=NULL );
235 
236  virtual char **GetFileList();
237 
238  CPLErr ProcessBlock( int iBlockX, int iBlockY );
239 
240  void GetBlockSize( int *, int * );
241 };
242 
243 /************************************************************************/
244 /* VRTRasterBand */
245 /* */
246 /* Provides support for all the various kinds of metadata but */
247 /* no raster access. That is handled by derived classes. */
248 /************************************************************************/
249 
250 class CPL_DLL VRTRasterBand : public GDALRasterBand
251 {
252  protected:
253  int bIsMaskBand;
254 
255  int bNoDataValueSet;
256  int bHideNoDataValue; // If set to true, will not report the existence of nodata
257  double dfNoDataValue;
258 
259  GDALColorTable *poColorTable;
260 
261  GDALColorInterp eColorInterp;
262 
263  char *pszUnitType;
264  char **papszCategoryNames;
265 
266  double dfOffset;
267  double dfScale;
268 
269  CPLXMLNode *psSavedHistograms;
270 
271  void Initialize( int nXSize, int nYSize );
272 
273  std::vector<VRTOverviewInfo> apoOverviews;
274 
275  VRTRasterBand *poMaskBand;
276 
277  public:
278 
279  VRTRasterBand();
280  virtual ~VRTRasterBand();
281 
282  virtual CPLErr XMLInit( CPLXMLNode *, const char * );
283  virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath );
284 
285  virtual CPLErr SetNoDataValue( double );
286  virtual double GetNoDataValue( int *pbSuccess = NULL );
287 
288  virtual CPLErr SetColorTable( GDALColorTable * );
289  virtual GDALColorTable *GetColorTable();
290 
291  virtual CPLErr SetColorInterpretation( GDALColorInterp );
292  virtual GDALColorInterp GetColorInterpretation();
293 
294  virtual const char *GetUnitType();
295  CPLErr SetUnitType( const char * );
296 
297  virtual char **GetCategoryNames();
298  virtual CPLErr SetCategoryNames( char ** );
299 
300  virtual CPLErr SetMetadata( char **papszMD, const char *pszDomain = "" );
301  virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue,
302  const char *pszDomain = "" );
303 
304  virtual double GetOffset( int *pbSuccess = NULL );
305  CPLErr SetOffset( double );
306  virtual double GetScale( int *pbSuccess = NULL );
307  CPLErr SetScale( double );
308 
309  virtual int GetOverviewCount();
310  virtual GDALRasterBand *GetOverview(int);
311 
312  virtual CPLErr GetHistogram( double dfMin, double dfMax,
313  int nBuckets, int * panHistogram,
314  int bIncludeOutOfRange, int bApproxOK,
315  GDALProgressFunc, void *pProgressData );
316 
317  virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
318  int *pnBuckets, int ** ppanHistogram,
319  int bForce,
320  GDALProgressFunc, void *pProgressData);
321 
322  virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
323  int nBuckets, int *panHistogram );
324 
325  CPLErr CopyCommonInfoFrom( GDALRasterBand * );
326 
327  virtual void GetFileList(char*** ppapszFileList, int *pnSize,
328  int *pnMaxSize, CPLHashSet* hSetFiles);
329 
330  virtual void SetDescription( const char * );
331 
332  virtual GDALRasterBand *GetMaskBand();
333  virtual int GetMaskFlags();
334 
335  virtual CPLErr CreateMaskBand( int nFlags );
336 
337  void SetMaskBand(VRTRasterBand* poMaskBand);
338 
339  void SetIsMaskBand();
340 
341  CPLErr UnsetNoDataValue();
342 
343  virtual int CloseDependentDatasets();
344 
345  virtual int IsSourcedRasterBand() { return FALSE; }
346 };
347 
348 /************************************************************************/
349 /* VRTSourcedRasterBand */
350 /************************************************************************/
351 
352 class VRTSimpleSource;
353 
354 class CPL_DLL VRTSourcedRasterBand : public VRTRasterBand
355 {
356  private:
357  int nRecursionCounter;
358  CPLString osLastLocationInfo;
359  char **papszSourceList;
360 
361  void Initialize( int nXSize, int nYSize );
362 
363  int CanUseSourcesMinMaxImplementations();
364 
365  public:
366  int nSources;
367  VRTSource **papoSources;
368  int bEqualAreas;
369 
370  VRTSourcedRasterBand( GDALDataset *poDS, int nBand );
372  int nXSize, int nYSize );
373  VRTSourcedRasterBand( GDALDataset *poDS, int nBand,
374  GDALDataType eType,
375  int nXSize, int nYSize );
376  virtual ~VRTSourcedRasterBand();
377 
378  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
379  void *, int, int, GDALDataType,
380  int, int );
381 
382  virtual char **GetMetadataDomainList();
383  virtual const char *GetMetadataItem( const char * pszName,
384  const char * pszDomain = "" );
385  virtual char **GetMetadata( const char * pszDomain = "" );
386  virtual CPLErr SetMetadata( char ** papszMetadata,
387  const char * pszDomain = "" );
388  virtual CPLErr SetMetadataItem( const char * pszName,
389  const char * pszValue,
390  const char * pszDomain = "" );
391 
392  virtual CPLErr XMLInit( CPLXMLNode *, const char * );
393  virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath );
394 
395  virtual double GetMinimum( int *pbSuccess = NULL );
396  virtual double GetMaximum(int *pbSuccess = NULL );
397  virtual CPLErr ComputeRasterMinMax( int bApproxOK, double* adfMinMax );
398  virtual CPLErr ComputeStatistics( int bApproxOK,
399  double *pdfMin, double *pdfMax,
400  double *pdfMean, double *pdfStdDev,
401  GDALProgressFunc pfnProgress, void *pProgressData );
402  virtual CPLErr GetHistogram( double dfMin, double dfMax,
403  int nBuckets, int * panHistogram,
404  int bIncludeOutOfRange, int bApproxOK,
405  GDALProgressFunc pfnProgress, void *pProgressData );
406 
407  CPLErr AddSource( VRTSource * );
408  CPLErr AddSimpleSource( GDALRasterBand *poSrcBand,
409  int nSrcXOff=-1, int nSrcYOff=-1,
410  int nSrcXSize=-1, int nSrcYSize=-1,
411  int nDstXOff=-1, int nDstYOff=-1,
412  int nDstXSize=-1, int nDstYSize=-1,
413  const char *pszResampling = "near",
414  double dfNoDataValue = VRT_NODATA_UNSET);
415  CPLErr AddComplexSource( GDALRasterBand *poSrcBand,
416  int nSrcXOff=-1, int nSrcYOff=-1,
417  int nSrcXSize=-1, int nSrcYSize=-1,
418  int nDstXOff=-1, int nDstYOff=-1,
419  int nDstXSize=-1, int nDstYSize=-1,
420  double dfScaleOff=0.0,
421  double dfScaleRatio=1.0,
422  double dfNoDataValue = VRT_NODATA_UNSET,
423  int nColorTableComponent = 0);
424 
425  CPLErr AddMaskBandSource( GDALRasterBand *poSrcBand,
426  int nSrcXOff=-1, int nSrcYOff=-1,
427  int nSrcXSize=-1, int nSrcYSize=-1,
428  int nDstXOff=-1, int nDstYOff=-1,
429  int nDstXSize=-1, int nDstYSize=-1 );
430 
431  CPLErr AddFuncSource( VRTImageReadFunc pfnReadFunc, void *hCBData,
432  double dfNoDataValue = VRT_NODATA_UNSET );
433 
434  void ConfigureSource(VRTSimpleSource *poSimpleSource,
435  GDALRasterBand *poSrcBand,
436  int bAddAsMaskBand,
437  int nSrcXOff, int nSrcYOff,
438  int nSrcXSize, int nSrcYSize,
439  int nDstXOff, int nDstYOff,
440  int nDstXSize, int nDstYSize);
441 
442  virtual CPLErr IReadBlock( int, int, void * );
443 
444  virtual void GetFileList(char*** ppapszFileList, int *pnSize,
445  int *pnMaxSize, CPLHashSet* hSetFiles);
446 
447  virtual int CloseDependentDatasets();
448 
449  virtual int IsSourcedRasterBand() { return TRUE; }
450 };
451 
452 /************************************************************************/
453 /* VRTWarpedRasterBand */
454 /************************************************************************/
455 
456 class CPL_DLL VRTWarpedRasterBand : public VRTRasterBand
457 {
458  public:
459  VRTWarpedRasterBand( GDALDataset *poDS, int nBand,
460  GDALDataType eType = GDT_Unknown );
461  virtual ~VRTWarpedRasterBand();
462 
463  virtual CPLErr XMLInit( CPLXMLNode *, const char * );
464  virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath );
465 
466  virtual CPLErr IReadBlock( int, int, void * );
467  virtual CPLErr IWriteBlock( int, int, void * );
468 
469  virtual int GetOverviewCount();
470  virtual GDALRasterBand *GetOverview(int);
471 };
472 
473 /************************************************************************/
474 /* VRTDerivedRasterBand */
475 /************************************************************************/
476 
478 {
479 
480  public:
481  char *pszFuncName;
482  GDALDataType eSourceTransferType;
483 
484  VRTDerivedRasterBand(GDALDataset *poDS, int nBand);
485  VRTDerivedRasterBand(GDALDataset *poDS, int nBand,
486  GDALDataType eType, int nXSize, int nYSize);
487  virtual ~VRTDerivedRasterBand();
488 
489  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
490  void *, int, int, GDALDataType,
491  int, int );
492 
493  static CPLErr AddPixelFunction
494  (const char *pszFuncName, GDALDerivedPixelFunc pfnPixelFunc);
495  static GDALDerivedPixelFunc GetPixelFunction(const char *pszFuncName);
496 
497  void SetPixelFunctionName(const char *pszFuncName);
498  void SetSourceTransferType(GDALDataType eDataType);
499 
500  virtual CPLErr XMLInit( CPLXMLNode *, const char * );
501  virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath );
502 
503 };
504 
505 /************************************************************************/
506 /* VRTRawRasterBand */
507 /************************************************************************/
508 
509 class RawRasterBand;
510 
511 class CPL_DLL VRTRawRasterBand : public VRTRasterBand
512 {
513  RawRasterBand *poRawRaster;
514 
515  char *pszSourceFilename;
516  int bRelativeToVRT;
517 
518  public:
519  VRTRawRasterBand( GDALDataset *poDS, int nBand,
520  GDALDataType eType = GDT_Unknown );
521  virtual ~VRTRawRasterBand();
522 
523  virtual CPLErr XMLInit( CPLXMLNode *, const char * );
524  virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath );
525 
526  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
527  void *, int, int, GDALDataType,
528  int, int );
529 
530  virtual CPLErr IReadBlock( int, int, void * );
531  virtual CPLErr IWriteBlock( int, int, void * );
532 
533  CPLErr SetRawLink( const char *pszFilename,
534  const char *pszVRTPath,
535  int bRelativeToVRT,
536  vsi_l_offset nImageOffset,
537  int nPixelOffset, int nLineOffset,
538  const char *pszByteOrder );
539 
540  void ClearRawLink();
541 
542  virtual void GetFileList(char*** ppapszFileList, int *pnSize,
543  int *pnMaxSize, CPLHashSet* hSetFiles);
544 };
545 
546 /************************************************************************/
547 /* VRTDriver */
548 /************************************************************************/
549 
550 class VRTDriver : public GDALDriver
551 {
552  void *pDeserializerData;
553 
554  public:
555  VRTDriver();
556  ~VRTDriver();
557 
558  char **papszSourceParsers;
559 
560  virtual char **GetMetadataDomainList();
561  virtual char **GetMetadata( const char * pszDomain = "" );
562  virtual CPLErr SetMetadata( char ** papszMetadata,
563  const char * pszDomain = "" );
564 
565  VRTSource *ParseSource( CPLXMLNode *psSrc, const char *pszVRTPath );
566  void AddSourceParser( const char *pszElementName,
567  VRTSourceParser pfnParser );
568 };
569 
570 /************************************************************************/
571 /* VRTSimpleSource */
572 /************************************************************************/
573 
574 class CPL_DLL VRTSimpleSource : public VRTSource
575 {
576 protected:
577  GDALRasterBand *poRasterBand;
578 
579  /* when poRasterBand is a mask band, poMaskBandMainBand is the band */
580  /* from which the mask band is taken */
581  GDALRasterBand *poMaskBandMainBand;
582 
583  int nSrcXOff;
584  int nSrcYOff;
585  int nSrcXSize;
586  int nSrcYSize;
587 
588  int nDstXOff;
589  int nDstYOff;
590  int nDstXSize;
591  int nDstYSize;
592 
593  int bNoDataSet;
594  double dfNoDataValue;
595 
596 public:
597  VRTSimpleSource();
598  virtual ~VRTSimpleSource();
599 
600  virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * );
601  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
602 
603  void SetSrcBand( GDALRasterBand * );
604  void SetSrcMaskBand( GDALRasterBand * );
605  void SetSrcWindow( int, int, int, int );
606  void SetDstWindow( int, int, int, int );
607  void SetNoDataValue( double dfNoDataValue );
608 
609  int GetSrcDstWindow( int, int, int, int, int, int,
610  int *, int *, int *, int *,
611  int *, int *, int *, int * );
612 
613  virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
614  void *pData, int nBufXSize, int nBufYSize,
615  GDALDataType eBufType,
616  int nPixelSpace, int nLineSpace );
617 
618  virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
619  virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
620  virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
621  virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
622  int bApproxOK,
623  double *pdfMin, double *pdfMax,
624  double *pdfMean, double *pdfStdDev,
625  GDALProgressFunc pfnProgress, void *pProgressData );
626  virtual CPLErr GetHistogram( int nXSize, int nYSize,
627  double dfMin, double dfMax,
628  int nBuckets, int * panHistogram,
629  int bIncludeOutOfRange, int bApproxOK,
630  GDALProgressFunc pfnProgress, void *pProgressData );
631 
632  void DstToSrc( double dfX, double dfY,
633  double &dfXOut, double &dfYOut );
634  void SrcToDst( double dfX, double dfY,
635  double &dfXOut, double &dfYOut );
636 
637  virtual void GetFileList(char*** ppapszFileList, int *pnSize,
638  int *pnMaxSize, CPLHashSet* hSetFiles);
639 
640  virtual int IsSimpleSource() { return TRUE; }
641  virtual const char* GetType() { return "SimpleSource"; }
642 
643  GDALRasterBand* GetBand();
644  int IsSameExceptBandNumber(VRTSimpleSource* poOtherSource);
645  CPLErr DatasetRasterIO(
646  int nXOff, int nYOff, int nXSize, int nYSize,
647  void * pData, int nBufXSize, int nBufYSize,
648  GDALDataType eBufType,
649  int nBandCount, int *panBandMap,
650  int nPixelSpace, int nLineSpace, int nBandSpace);
651 };
652 
653 /************************************************************************/
654 /* VRTAveragedSource */
655 /************************************************************************/
656 
658 {
659 public:
661  virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
662  void *pData, int nBufXSize, int nBufYSize,
663  GDALDataType eBufType,
664  int nPixelSpace, int nLineSpace );
665 
666  virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
667  virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
668  virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
669  virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
670  int bApproxOK,
671  double *pdfMin, double *pdfMax,
672  double *pdfMean, double *pdfStdDev,
673  GDALProgressFunc pfnProgress, void *pProgressData );
674  virtual CPLErr GetHistogram( int nXSize, int nYSize,
675  double dfMin, double dfMax,
676  int nBuckets, int * panHistogram,
677  int bIncludeOutOfRange, int bApproxOK,
678  GDALProgressFunc pfnProgress, void *pProgressData );
679 
680  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
681  virtual const char* GetType() { return "AveragedSource"; }
682 };
683 
684 /************************************************************************/
685 /* VRTComplexSource */
686 /************************************************************************/
687 
688 typedef enum
689 {
690  VRT_SCALING_NONE,
691  VRT_SCALING_LINEAR,
692  VRT_SCALING_EXPONENTIAL,
693 } VRTComplexSourceScaling;
694 
695 class CPL_DLL VRTComplexSource : public VRTSimpleSource
696 {
697 protected:
698  VRTComplexSourceScaling eScalingType;
699  double dfScaleOff; /* for linear scaling */
700  double dfScaleRatio; /* for linear scaling */
701 
702  /* For non-linear scaling with a power function. */
703  int bSrcMinMaxDefined;
704  double dfSrcMin;
705  double dfSrcMax;
706  double dfDstMin;
707  double dfDstMax;
708  double dfExponent;
709 
710  int nColorTableComponent;
711 
712  CPLErr RasterIOInternal( int nReqXOff, int nReqYOff,
713  int nReqXSize, int nReqYSize,
714  void *pData, int nOutXSize, int nOutYSize,
715  GDALDataType eBufType,
716  int nPixelSpace, int nLineSpace );
717 
718 public:
720  virtual ~VRTComplexSource();
721 
722  virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
723  void *pData, int nBufXSize, int nBufYSize,
724  GDALDataType eBufType,
725  int nPixelSpace, int nLineSpace );
726 
727  virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
728  virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
729  virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
730  virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
731  int bApproxOK,
732  double *pdfMin, double *pdfMax,
733  double *pdfMean, double *pdfStdDev,
734  GDALProgressFunc pfnProgress, void *pProgressData );
735  virtual CPLErr GetHistogram( int nXSize, int nYSize,
736  double dfMin, double dfMax,
737  int nBuckets, int * panHistogram,
738  int bIncludeOutOfRange, int bApproxOK,
739  GDALProgressFunc pfnProgress, void *pProgressData );
740 
741  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
742  virtual CPLErr XMLInit( CPLXMLNode *, const char * );
743  virtual const char* GetType() { return "ComplexSource"; }
744 
745  double LookupValue( double dfInput );
746 
747  void SetLinearScaling(double dfOffset, double dfScale);
748  void SetPowerScaling(double dfExponent,
749  double dfSrcMin,
750  double dfSrcMax,
751  double dfDstMin,
752  double dfDstMax);
753  void SetColorTableComponent(int nComponent);
754 
755  double *padfLUTInputs;
756  double *padfLUTOutputs;
757  int nLUTItemCount;
758 
759 };
760 
761 /************************************************************************/
762 /* VRTFilteredSource */
763 /************************************************************************/
764 
766 {
767 private:
768  int IsTypeSupported( GDALDataType eType );
769 
770 protected:
771  int nSupportedTypesCount;
772  GDALDataType aeSupportedTypes[20];
773 
774  int nExtraEdgePixels;
775 
776 public:
778  virtual ~VRTFilteredSource();
779 
780  void SetExtraEdgePixels( int );
781  void SetFilteringDataTypesSupported( int, GDALDataType * );
782 
783  virtual CPLErr FilterData( int nXSize, int nYSize, GDALDataType eType,
784  GByte *pabySrcData, GByte *pabyDstData ) = 0;
785 
786  virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
787  void *pData, int nBufXSize, int nBufYSize,
788  GDALDataType eBufType,
789  int nPixelSpace, int nLineSpace );
790 };
791 
792 /************************************************************************/
793 /* VRTKernelFilteredSource */
794 /************************************************************************/
795 
797 {
798 protected:
799  int nKernelSize;
800 
801  double *padfKernelCoefs;
802 
803  int bNormalized;
804 
805 public:
807  virtual ~VRTKernelFilteredSource();
808 
809  virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * );
810  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
811 
812  virtual CPLErr FilterData( int nXSize, int nYSize, GDALDataType eType,
813  GByte *pabySrcData, GByte *pabyDstData );
814 
815  CPLErr SetKernel( int nKernelSize, double *padfCoefs );
816  void SetNormalized( int );
817 };
818 
819 /************************************************************************/
820 /* VRTAverageFilteredSource */
821 /************************************************************************/
822 
824 {
825 public:
826  VRTAverageFilteredSource( int nKernelSize );
827  virtual ~VRTAverageFilteredSource();
828 
829  virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * );
830  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
831 };
832 
833 /************************************************************************/
834 /* VRTFuncSource */
835 /************************************************************************/
836 class VRTFuncSource : public VRTSource
837 {
838 public:
839  VRTFuncSource();
840  virtual ~VRTFuncSource();
841 
842  virtual CPLErr XMLInit( CPLXMLNode *, const char *) { return CE_Failure; }
843  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
844 
845  virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
846  void *pData, int nBufXSize, int nBufYSize,
847  GDALDataType eBufType,
848  int nPixelSpace, int nLineSpace );
849 
850  virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
851  virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
852  virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
853  virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
854  int bApproxOK,
855  double *pdfMin, double *pdfMax,
856  double *pdfMean, double *pdfStdDev,
857  GDALProgressFunc pfnProgress, void *pProgressData );
858  virtual CPLErr GetHistogram( int nXSize, int nYSize,
859  double dfMin, double dfMax,
860  int nBuckets, int * panHistogram,
861  int bIncludeOutOfRange, int bApproxOK,
862  GDALProgressFunc pfnProgress, void *pProgressData );
863 
864  VRTImageReadFunc pfnReadFunc;
865  void *pCBData;
866  GDALDataType eType;
867 
868  float fNoDataValue;
869 };
870 
871 #endif /* ndef VIRTUALDATASET_H_INCLUDED */
GDALDataType
Definition: gdal.h:55
Document node structure.
Definition: cpl_minixml.h:65
Definition: vrtdataset.h:796
Definition: vrtdataset.h:657
Definition: vrtdataset.h:250
virtual CPLErr SetMetadata(char **papszMD, const char *pszDomain="")
Set metadata.
Definition: vrtrasterband.cpp:142
Definition: vrtdataset.h:75
Definition: vrtdataset.h:765
GDALRWFlag
Definition: gdal.h:99
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition: gdal.h:162
Definition: vrtdataset.h:354
Definition: vrtdataset.h:119
void GetBlockSize(int *, int *)
Fetch the "natural" block size of this band.
Definition: gdalrasterband.cpp:621
int GetShared()
Returns shared flag.
Definition: gdaldataset.cpp:1092
Definition: vrtdataset.h:51
Convenient string class based on std::string.
Definition: cpl_string.h:226
Hash set implementation.
Definition: gdal.h:56
Definition: vrtdataset.h:823
virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain="")
Set single metadata item.
Definition: vrtrasterband.cpp:155
virtual CPLErr FlushCache()
Flush raster data cache.
Definition: gdalrasterband.cpp:850
Definition: vrtdataset.h:511
int Dereference()
Subtract one from dataset reference count.
Definition: gdaldataset.cpp:1058
Definition: vrtdataset.h:456
Definition: vrtdataset.h:477
Definition: gdal_priv.h:220
High level image warping class.
Definition: gdalwarper.h:326
Definition: vrtdataset.h:836
Definition: vrtdataset.h:695
void GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition: gdaldataset.cpp:2482
Definition: vrtdataset.h:574
Object with metadata.
Definition: gdal_priv.h:109
virtual CPLErr CreateMaskBand(int nFlags)
Adds a mask band to the current band.
Definition: vrtrasterband.cpp:1057
GDALDataset * GetDataset()
Fetch the owning dataset handle.
Definition: gdalrasterband.cpp:2634
A single raster band (or channel).
Definition: gdal_priv.h:475
GDALAccess
Definition: gdal.h:93
Definition: vrtdataset.h:550
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:254
Definition: vrtdataset.h:206
GDALColorInterp
Definition: gdal.h:105
Public (C callable) entry points for virtual GDAL dataset objects.
Definition: gdal.h:94
Format specific driver.
Definition: gdal_priv.h:722
Definition: gdal_priv.h:447
Ground Control Point.
Definition: gdal.h:255

Generated for GDAL by doxygen 1.8.11.