GDAL
vrtdataset.h
1 /******************************************************************************
2  * $Id$
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 spatialys.com>
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 #ifndef DOXYGEN_SKIP
35 
36 #include "cpl_hash_set.h"
37 #include "cpl_minixml.h"
38 #include "gdal_pam.h"
39 #include "gdal_priv.h"
40 #include "gdal_rat.h"
41 #include "gdal_vrt.h"
42 #include "gdal_rat.h"
43 
44 #include <functional>
45 #include <map>
46 #include <memory>
47 #include <vector>
48 
49 int VRTApplyMetadata( CPLXMLNode *, GDALMajorObject * );
50 CPLXMLNode *VRTSerializeMetadata( GDALMajorObject * );
51 CPLErr GDALRegisterDefaultPixelFunc();
52 CPLString VRTSerializeNoData(double dfVal, GDALDataType eDataType, int nPrecision);
53 #if 0
54 int VRTWarpedOverviewTransform( void *pTransformArg, int bDstToSrc,
55  int nPointCount,
56  double *padfX, double *padfY, double *padfZ,
57  int *panSuccess );
58 void* VRTDeserializeWarpedOverviewTransformer( CPLXMLNode *psTree );
59 #endif
60 
61 /************************************************************************/
62 /* VRTOverviewInfo() */
63 /************************************************************************/
64 class VRTOverviewInfo
65 {
66  CPL_DISALLOW_COPY_ASSIGN(VRTOverviewInfo)
67 
68 public:
69  CPLString osFilename{};
70  int nBand = 0;
71  GDALRasterBand *poBand = nullptr;
72  int bTriedToOpen = FALSE;
73 
74  VRTOverviewInfo() = default;
75  VRTOverviewInfo(VRTOverviewInfo&& oOther) noexcept:
76  osFilename(std::move(oOther.osFilename)),
77  nBand(oOther.nBand),
78  poBand(oOther.poBand),
79  bTriedToOpen(oOther.bTriedToOpen)
80  {
81  oOther.poBand = nullptr;
82  }
83 
84  ~VRTOverviewInfo() {
85  CloseDataset();
86  }
87 
88  bool CloseDataset()
89  {
90  if( poBand == nullptr )
91  return false;
92 
93  GDALDataset* poDS = poBand->GetDataset();
94  // Nullify now, to prevent recursion in some cases !
95  poBand = nullptr;
96  if( poDS->GetShared() )
97  GDALClose( /* (GDALDatasetH) */ poDS );
98  else
99  poDS->Dereference();
100 
101  return true;
102  }
103 };
104 
105 /************************************************************************/
106 /* VRTSource */
107 /************************************************************************/
108 
109 class CPL_DLL VRTSource
110 {
111 public:
112  virtual ~VRTSource();
113 
114  virtual CPLErr RasterIO( GDALDataType eBandDataType,
115  int nXOff, int nYOff, int nXSize, int nYSize,
116  void *pData, int nBufXSize, int nBufYSize,
117  GDALDataType eBufType,
118  GSpacing nPixelSpace, GSpacing nLineSpace,
119  GDALRasterIOExtraArg* psExtraArg ) = 0;
120 
121  virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) = 0;
122  virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) = 0;
123  virtual CPLErr GetHistogram( int nXSize, int nYSize,
124  double dfMin, double dfMax,
125  int nBuckets, GUIntBig * panHistogram,
126  int bIncludeOutOfRange, int bApproxOK,
127  GDALProgressFunc pfnProgress,
128  void *pProgressData ) = 0;
129 
130  virtual CPLErr XMLInit( CPLXMLNode *psTree, const char *,
131  std::map<CPLString, GDALDataset*>& ) = 0;
132  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) = 0;
133 
134  virtual void GetFileList(char*** ppapszFileList, int *pnSize,
135  int *pnMaxSize, CPLHashSet* hSetFiles);
136 
137  virtual int IsSimpleSource() { return FALSE; }
138  virtual CPLErr FlushCache(bool /*bAtClosing*/) { return CE_None; }
139 };
140 
141 typedef VRTSource *(*VRTSourceParser)(CPLXMLNode *, const char *,
142  std::map<CPLString, GDALDataset*>& oMapSharedSources);
143 
144 VRTSource *VRTParseCoreSources( CPLXMLNode *psTree, const char *,
145  std::map<CPLString, GDALDataset*>& oMapSharedSources);
146 VRTSource *VRTParseFilterSources( CPLXMLNode *psTree, const char *,
147  std::map<CPLString, GDALDataset*>& oMapSharedSources );
148 
149 /************************************************************************/
150 /* VRTDataset */
151 /************************************************************************/
152 
153 class VRTRasterBand;
154 
155 template<class T> struct VRTFlushCacheStruct
156 {
157  static void FlushCache(T& obj, bool bAtClosing);
158 };
159 
160 class VRTWarpedDataset;
161 class VRTPansharpenedDataset;
162 class VRTGroup;
163 
164 class CPL_DLL VRTDataset CPL_NON_FINAL: public GDALDataset
165 {
166  friend class VRTRasterBand;
167  friend struct VRTFlushCacheStruct<VRTDataset>;
168  friend struct VRTFlushCacheStruct<VRTWarpedDataset>;
169  friend struct VRTFlushCacheStruct<VRTPansharpenedDataset>;
170  friend class VRTSourcedRasterBand;
171  friend VRTDatasetH CPL_STDCALL VRTCreate(int nXSize, int nYSize);
172 
173  OGRSpatialReference* m_poSRS = nullptr;
174 
175  int m_bGeoTransformSet = false;
176  double m_adfGeoTransform[6];
177 
178  int m_nGCPCount = 0;
179  GDAL_GCP *m_pasGCPList = nullptr;
180  OGRSpatialReference *m_poGCP_SRS = nullptr;
181 
182  bool m_bNeedsFlush = false;
183  bool m_bWritable = true;
184  bool m_bCanTakeRef = true;
185 
186  char *m_pszVRTPath = nullptr;
187 
188  VRTRasterBand *m_poMaskBand = nullptr;
189 
190  int m_bCompatibleForDatasetIO = -1;
191  int CheckCompatibleForDatasetIO();
192 
193  // Virtual (ie not materialized) overviews, created either implicitly
194  // when it is cheap to do it, or explicitly.
195  std::vector<GDALDataset*> m_apoOverviews{};
196  std::vector<GDALDataset*> m_apoOverviewsBak{};
197  CPLString m_osOverviewResampling{};
198  std::vector<int> m_anOverviewFactors{};
199 
200  char **m_papszXMLVRTMetadata = nullptr;
201 
202  std::map<CPLString, GDALDataset*> m_oMapSharedSources{};
203  std::shared_ptr<VRTGroup> m_poRootGroup{};
204 
205  VRTRasterBand* InitBand(const char* pszSubclass, int nBand,
206  bool bAllowPansharpened);
207  static GDALDataset *OpenVRTProtocol( const char* pszSpec );
208  bool AddVirtualOverview(int nOvFactor,
209  const char* pszResampling);
210 
211  CPL_DISALLOW_COPY_ASSIGN(VRTDataset)
212 
213  protected:
214  virtual int CloseDependentDatasets() override;
215 
216  public:
217  VRTDataset(int nXSize, int nYSize);
218  virtual ~VRTDataset();
219 
220  void SetNeedsFlush() { m_bNeedsFlush = true; }
221  virtual void FlushCache(bool bAtClosing) override;
222 
223  void SetWritable(int bWritableIn) { m_bWritable = CPL_TO_BOOL(bWritableIn); }
224 
225  virtual CPLErr CreateMaskBand( int nFlags ) override;
226  void SetMaskBand(VRTRasterBand* poMaskBand);
227 
228  const OGRSpatialReference* GetSpatialRef() const override { return m_poSRS; }
229  CPLErr SetSpatialRef(const OGRSpatialReference* poSRS) override;
230 
231  virtual CPLErr GetGeoTransform( double * ) override;
232  virtual CPLErr SetGeoTransform( double * ) override;
233 
234  virtual CPLErr SetMetadata( char **papszMetadata,
235  const char *pszDomain = "" ) override;
236  virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue,
237  const char *pszDomain = "" ) override;
238 
239  virtual char** GetMetadata( const char *pszDomain = "" ) override;
240 
241  virtual int GetGCPCount() override;
242  const OGRSpatialReference* GetGCPSpatialRef() const override { return m_poGCP_SRS; }
243  virtual const GDAL_GCP *GetGCPs() override;
244  using GDALDataset::SetGCPs;
245  CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
246  const OGRSpatialReference* poSRS ) override;
247 
248  virtual CPLErr AddBand( GDALDataType eType,
249  char **papszOptions=nullptr ) override;
250 
251  virtual char **GetFileList() override;
252 
253  virtual CPLErr IRasterIO( GDALRWFlag eRWFlag,
254  int nXOff, int nYOff, int nXSize, int nYSize,
255  void * pData, int nBufXSize, int nBufYSize,
256  GDALDataType eBufType,
257  int nBandCount, int *panBandMap,
258  GSpacing nPixelSpace, GSpacing nLineSpace,
259  GSpacing nBandSpace,
260  GDALRasterIOExtraArg* psExtraArg) override;
261 
262  virtual CPLErr AdviseRead( int nXOff, int nYOff, int nXSize, int nYSize,
263  int nBufXSize, int nBufYSize,
264  GDALDataType eDT,
265  int nBandCount, int *panBandList,
266  char **papszOptions ) override;
267 
268  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath);
269  virtual CPLErr XMLInit( CPLXMLNode *, const char * );
270 
271  virtual CPLErr IBuildOverviews( const char *,
272  int, const int *,
273  int, const int *,
274  GDALProgressFunc, void *,
275  CSLConstList papszOptions ) override;
276 
277  std::shared_ptr<GDALGroup> GetRootGroup() const override;
278 
279  /* Used by PDF driver for example */
280  GDALDataset* GetSingleSimpleSource();
281  void BuildVirtualOverviews();
282 
283  void UnsetPreservedRelativeFilenames();
284 
285  static int Identify( GDALOpenInfo * );
286  static GDALDataset *Open( GDALOpenInfo * );
287  static GDALDataset *OpenXML( const char *, const char * = nullptr,
288  GDALAccess eAccess = GA_ReadOnly );
289  static GDALDataset *Create( const char * pszName,
290  int nXSize, int nYSize, int nBands,
291  GDALDataType eType, char ** papszOptions );
292  static GDALDataset *CreateMultiDimensional( const char * pszFilename,
293  CSLConstList papszRootGroupOptions,
294  CSLConstList papszOptions );
295  static CPLErr Delete( const char * pszFilename );
296 };
297 
298 /************************************************************************/
299 /* VRTWarpedDataset */
300 /************************************************************************/
301 
302 class GDALWarpOperation;
303 class VRTWarpedRasterBand;
304 
305 class CPL_DLL VRTWarpedDataset final: public VRTDataset
306 {
307  int m_nBlockXSize;
308  int m_nBlockYSize;
309  GDALWarpOperation *m_poWarper;
310 
311  int m_nOverviewCount;
312  VRTWarpedDataset **m_papoOverviews;
313  int m_nSrcOvrLevel;
314 
315  void CreateImplicitOverviews();
316 
317  friend class VRTWarpedRasterBand;
318 
319  CPL_DISALLOW_COPY_ASSIGN(VRTWarpedDataset)
320 
321  protected:
322  virtual int CloseDependentDatasets() override;
323 
324 public:
325  VRTWarpedDataset( int nXSize, int nYSize );
326  virtual ~VRTWarpedDataset();
327 
328  virtual void FlushCache(bool bAtClosing) override;
329 
330  CPLErr Initialize( /* GDALWarpOptions */ void * );
331 
332  virtual CPLErr IBuildOverviews( const char *,
333  int, const int *,
334  int, const int *,
335  GDALProgressFunc, void *,
336  CSLConstList papszOptions ) override;
337 
338  virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue,
339  const char *pszDomain = "" ) override;
340 
341  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) override;
342  virtual CPLErr XMLInit( CPLXMLNode *, const char * ) override;
343 
344  virtual CPLErr AddBand( GDALDataType eType,
345  char **papszOptions=nullptr ) override;
346 
347  virtual char **GetFileList() override;
348 
349  CPLErr ProcessBlock( int iBlockX, int iBlockY );
350 
351  void GetBlockSize( int *, int * ) const;
352 };
353 
354 /************************************************************************/
355 /* VRTPansharpenedDataset */
356 /************************************************************************/
357 
359 
360 typedef enum
361 {
362  GTAdjust_Union,
363  GTAdjust_Intersection,
364  GTAdjust_None,
365  GTAdjust_NoneWithoutWarning
366 } GTAdjustment;
367 
368 class VRTPansharpenedDataset final: public VRTDataset
369 {
370  friend class VRTPansharpenedRasterBand;
371 
372  int m_nBlockXSize;
373  int m_nBlockYSize;
374  GDALPansharpenOperation* m_poPansharpener;
375  VRTPansharpenedDataset* m_poMainDataset;
376  std::vector<VRTPansharpenedDataset*> m_apoOverviewDatasets{};
377  // Map from absolute to relative.
378  std::map<CPLString,CPLString> m_oMapToRelativeFilenames{};
379 
380  int m_bLoadingOtherBands;
381 
382  GByte *m_pabyLastBufferBandRasterIO;
383  int m_nLastBandRasterIOXOff;
384  int m_nLastBandRasterIOYOff;
385  int m_nLastBandRasterIOXSize;
386  int m_nLastBandRasterIOYSize;
387  GDALDataType m_eLastBandRasterIODataType;
388 
389  GTAdjustment m_eGTAdjustment;
390  int m_bNoDataDisabled;
391 
392  std::vector<GDALDataset*> m_apoDatasetsToClose{};
393 
394  CPL_DISALLOW_COPY_ASSIGN(VRTPansharpenedDataset)
395 
396  protected:
397  virtual int CloseDependentDatasets() override;
398 
399 public:
400  VRTPansharpenedDataset( int nXSize, int nYSize );
401  virtual ~VRTPansharpenedDataset();
402 
403  virtual void FlushCache(bool bAtClosing) override;
404 
405  virtual CPLErr XMLInit( CPLXMLNode *, const char * ) override;
406  virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ) override;
407 
408  CPLErr XMLInit( CPLXMLNode *psTree, const char *pszVRTPath,
409  GDALRasterBandH hPanchroBandIn,
410  int nInputSpectralBandsIn,
411  GDALRasterBandH* pahInputSpectralBandsIn );
412 
413  virtual CPLErr AddBand( GDALDataType eType,
414  char **papszOptions=nullptr ) override;
415 
416  virtual char **GetFileList() override;
417 
418  virtual CPLErr IRasterIO( GDALRWFlag eRWFlag,
419  int nXOff, int nYOff, int nXSize, int nYSize,
420  void * pData, int nBufXSize, int nBufYSize,
421  GDALDataType eBufType,
422  int nBandCount, int *panBandMap,
423  GSpacing nPixelSpace, GSpacing nLineSpace,
424  GSpacing nBandSpace,
425  GDALRasterIOExtraArg* psExtraArg) override;
426 
427  void GetBlockSize( int *, int * ) const;
428 
429  GDALPansharpenOperation* GetPansharpener() { return m_poPansharpener; }
430 };
431 
432 /************************************************************************/
433 /* VRTRasterBand */
434 /* */
435 /* Provides support for all the various kinds of metadata but */
436 /* no raster access. That is handled by derived classes. */
437 /************************************************************************/
438 
439 constexpr double VRT_DEFAULT_NODATA_VALUE = -10000.0;
440 
441 class CPL_DLL VRTRasterBand CPL_NON_FINAL: public GDALRasterBand
442 {
443  private:
444 
445  void ResetNoDataValues();
446 
447  protected:
448  friend class VRTDataset;
449 
450  int m_bIsMaskBand = FALSE;
451 
452  int m_bNoDataValueSet = FALSE;
453  // If set to true, will not report the existence of nodata.
454  int m_bHideNoDataValue = FALSE;
455  double m_dfNoDataValue = VRT_DEFAULT_NODATA_VALUE;
456 
457  bool m_bNoDataSetAsInt64 = false;
458  int64_t m_nNoDataValueInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_INT64;
459 
460  bool m_bNoDataSetAsUInt64 = false;
461  uint64_t m_nNoDataValueUInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64;
462 
463  std::unique_ptr<GDALColorTable> m_poColorTable{};
464 
465  GDALColorInterp m_eColorInterp = GCI_Undefined;
466 
467  char *m_pszUnitType = nullptr;
468  char **m_papszCategoryNames = nullptr;
469 
470  double m_dfOffset = 0.0;
471  double m_dfScale = 1.0;
472 
473  CPLXMLNode *m_psSavedHistograms = nullptr;
474 
475  void Initialize( int nXSize, int nYSize );
476 
477  std::vector<VRTOverviewInfo> m_aoOverviewInfos{};
478 
479  VRTRasterBand *m_poMaskBand = nullptr;
480 
481  std::unique_ptr<GDALRasterAttributeTable> m_poRAT{};
482 
483  CPL_DISALLOW_COPY_ASSIGN(VRTRasterBand)
484 
485  bool IsNoDataValueInDataTypeRange() const;
486 
487  public:
488 
489  VRTRasterBand();
490  virtual ~VRTRasterBand();
491 
492  virtual CPLErr XMLInit( CPLXMLNode *, const char *,
493  std::map<CPLString, GDALDataset*>& );
494  virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath );
495 
496  CPLErr SetNoDataValue( double ) override;
497  CPLErr SetNoDataValueAsInt64( int64_t nNoData ) override;
498  CPLErr SetNoDataValueAsUInt64( uint64_t nNoData ) override;
499  double GetNoDataValue( int *pbSuccess = nullptr ) override;
500  int64_t GetNoDataValueAsInt64( int *pbSuccess = nullptr ) override;
501  uint64_t GetNoDataValueAsUInt64( int *pbSuccess = nullptr ) override;
502  CPLErr DeleteNoDataValue() override;
503 
504  virtual CPLErr SetColorTable( GDALColorTable * ) override;
505  virtual GDALColorTable *GetColorTable() override;
506 
507  virtual GDALRasterAttributeTable *GetDefaultRAT() override;
508  virtual CPLErr SetDefaultRAT( const GDALRasterAttributeTable * poRAT ) override;
509 
510  virtual CPLErr SetColorInterpretation( GDALColorInterp ) override;
511  virtual GDALColorInterp GetColorInterpretation() override;
512 
513  virtual const char *GetUnitType() override;
514  CPLErr SetUnitType( const char * ) override;
515 
516  virtual char **GetCategoryNames() override;
517  virtual CPLErr SetCategoryNames( char ** ) override;
518 
519  virtual CPLErr SetMetadata( char **papszMD, const char *pszDomain = "" ) override;
520  virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue,
521  const char *pszDomain = "" ) override;
522 
523  virtual double GetOffset( int *pbSuccess = nullptr ) override;
524  CPLErr SetOffset( double ) override;
525  virtual double GetScale( int *pbSuccess = nullptr ) override;
526  CPLErr SetScale( double ) override;
527 
528  virtual int GetOverviewCount() override;
529  virtual GDALRasterBand *GetOverview(int) override;
530 
531  virtual CPLErr GetHistogram( double dfMin, double dfMax,
532  int nBuckets, GUIntBig * panHistogram,
533  int bIncludeOutOfRange, int bApproxOK,
534  GDALProgressFunc, void *pProgressData ) override;
535 
536  virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
537  int *pnBuckets, GUIntBig ** ppanHistogram,
538  int bForce,
539  GDALProgressFunc, void *pProgressData) override;
540 
541  virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
542  int nBuckets, GUIntBig *panHistogram ) override;
543 
544  CPLErr CopyCommonInfoFrom( GDALRasterBand * );
545 
546  virtual void GetFileList(char*** ppapszFileList, int *pnSize,
547  int *pnMaxSize, CPLHashSet* hSetFiles);
548 
549  virtual void SetDescription( const char * ) override;
550 
551  virtual GDALRasterBand *GetMaskBand() override;
552  virtual int GetMaskFlags() override;
553 
554  virtual CPLErr CreateMaskBand( int nFlagsIn ) override;
555 
556  void SetMaskBand(VRTRasterBand* poMaskBand);
557 
558  void SetIsMaskBand();
559 
560  virtual bool IsMaskBand() const override;
561 
562  CPLErr UnsetNoDataValue();
563 
564  virtual int CloseDependentDatasets();
565 
566  virtual int IsSourcedRasterBand() { return FALSE; }
567  virtual int IsPansharpenRasterBand() { return FALSE; }
568 };
569 
570 /************************************************************************/
571 /* VRTSourcedRasterBand */
572 /************************************************************************/
573 
574 class VRTSimpleSource;
575 
576 class CPL_DLL VRTSourcedRasterBand CPL_NON_FINAL: public VRTRasterBand
577 {
578  private:
579  CPLString m_osLastLocationInfo{};
580  char **m_papszSourceList = nullptr;
581  int m_nSkipBufferInitialization = -1;
582 
583  bool CanUseSourcesMinMaxImplementations();
584 
585  bool IsMosaicOfNonOverlappingSimpleSourcesOfFullRasterNoResAndTypeChange(bool bAllowMaxValAdjustment) const;
586 
587  CPL_DISALLOW_COPY_ASSIGN(VRTSourcedRasterBand)
588 
589  protected:
590  bool SkipBufferInitialization();
591 
592  public:
593  int nSources = 0;
594  VRTSource **papoSources = nullptr;
595 
596  VRTSourcedRasterBand( GDALDataset *poDS, int nBand );
597  VRTSourcedRasterBand( GDALDataType eType,
598  int nXSize, int nYSize );
599  VRTSourcedRasterBand( GDALDataset *poDS, int nBand,
600  GDALDataType eType,
601  int nXSize, int nYSize );
602  VRTSourcedRasterBand( GDALDataset *poDS, int nBand,
603  GDALDataType eType,
604  int nXSize, int nYSize,
605  int nBlockXSizeIn, int nBlockYSizeIn );
606  virtual ~VRTSourcedRasterBand();
607 
608  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
609  void *, int, int, GDALDataType,
610  GSpacing nPixelSpace, GSpacing nLineSpace,
611  GDALRasterIOExtraArg* psExtraArg) override;
612 
613  virtual int IGetDataCoverageStatus( int nXOff, int nYOff,
614  int nXSize, int nYSize,
615  int nMaskFlagStop,
616  double* pdfDataPct) override;
617 
618  virtual char **GetMetadataDomainList() override;
619  virtual const char *GetMetadataItem( const char * pszName,
620  const char * pszDomain = "" ) override;
621  virtual char **GetMetadata( const char * pszDomain = "" ) override;
622  virtual CPLErr SetMetadata( char ** papszMetadata,
623  const char * pszDomain = "" ) override;
624  virtual CPLErr SetMetadataItem( const char * pszName,
625  const char * pszValue,
626  const char * pszDomain = "" ) override;
627 
628  virtual CPLErr XMLInit( CPLXMLNode *, const char *,
629  std::map<CPLString, GDALDataset*>& ) override;
630  virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ) override;
631 
632  virtual double GetMinimum( int *pbSuccess = nullptr ) override;
633  virtual double GetMaximum(int *pbSuccess = nullptr ) override;
634  virtual CPLErr ComputeRasterMinMax( int bApproxOK, double* adfMinMax ) override;
635  virtual CPLErr ComputeStatistics( int bApproxOK,
636  double *pdfMin, double *pdfMax,
637  double *pdfMean, double *pdfStdDev,
638  GDALProgressFunc pfnProgress,
639  void *pProgressData ) override;
640  virtual CPLErr GetHistogram( double dfMin, double dfMax,
641  int nBuckets, GUIntBig * panHistogram,
642  int bIncludeOutOfRange, int bApproxOK,
643  GDALProgressFunc pfnProgress,
644  void *pProgressData ) override;
645 
646  CPLErr AddSource( VRTSource * );
647 
648  CPLErr AddSimpleSource( const char* pszFilename,
649  int nBand,
650  double dfSrcXOff=-1, double dfSrcYOff=-1,
651  double dfSrcXSize=-1, double dfSrcYSize=-1,
652  double dfDstXOff=-1, double dfDstYOff=-1,
653  double dfDstXSize=-1, double dfDstYSize=-1,
654  const char *pszResampling = "near",
655  double dfNoDataValue = VRT_NODATA_UNSET);
656 
657  CPLErr AddSimpleSource( GDALRasterBand *poSrcBand,
658  double dfSrcXOff=-1, double dfSrcYOff=-1,
659  double dfSrcXSize=-1, double dfSrcYSize=-1,
660  double dfDstXOff=-1, double dfDstYOff=-1,
661  double dfDstXSize=-1, double dfDstYSize=-1,
662  const char *pszResampling = "near",
663  double dfNoDataValue = VRT_NODATA_UNSET);
664 
665  CPLErr AddComplexSource( const char* pszFilename,
666  int nBand,
667  double dfSrcXOff=-1, double dfSrcYOff=-1,
668  double dfSrcXSize=-1, double dfSrcYSize=-1,
669  double dfDstXOff=-1, double dfDstYOff=-1,
670  double dfDstXSize=-1, double dfDstYSize=-1,
671  double dfScaleOff=0.0,
672  double dfScaleRatio=1.0,
673  double dfNoDataValue = VRT_NODATA_UNSET,
674  int nColorTableComponent = 0);
675 
676  CPLErr AddComplexSource( GDALRasterBand *poSrcBand,
677  double dfSrcXOff=-1, double dfSrcYOff=-1,
678  double dfSrcXSize=-1, double dfSrcYSize=-1,
679  double dfDstXOff=-1, double dfDstYOff=-1,
680  double dfDstXSize=-1, double dfDstYSize=-1,
681  double dfScaleOff=0.0,
682  double dfScaleRatio=1.0,
683  double dfNoDataValue = VRT_NODATA_UNSET,
684  int nColorTableComponent = 0);
685 
686  CPLErr AddMaskBandSource( GDALRasterBand *poSrcBand,
687  double dfSrcXOff=-1, double dfSrcYOff=-1,
688  double dfSrcXSize=-1,
689  double dfSrcYSize=-1,
690  double dfDstXOff=-1, double dfDstYOff=-1,
691  double dfDstXSize=-1,
692  double dfDstYSize=-1 );
693 
694  CPLErr AddFuncSource( VRTImageReadFunc pfnReadFunc, void *hCBData,
695  double dfNoDataValue = VRT_NODATA_UNSET );
696 
697  void ConfigureSource(VRTSimpleSource *poSimpleSource,
698  GDALRasterBand *poSrcBand,
699  int bAddAsMaskBand,
700  double dfSrcXOff, double dfSrcYOff,
701  double dfSrcXSize, double dfSrcYSize,
702  double dfDstXOff, double dfDstYOff,
703  double dfDstXSize, double dfDstYSize );
704 
705  void RemoveCoveredSources(CSLConstList papszOptions = nullptr);
706 
707  virtual CPLErr IReadBlock( int, int, void * ) override;
708 
709  virtual void GetFileList(char*** ppapszFileList, int *pnSize,
710  int *pnMaxSize, CPLHashSet* hSetFiles) override;
711 
712  virtual int CloseDependentDatasets() override;
713 
714  virtual int IsSourcedRasterBand() override { return TRUE; }
715 
716  virtual CPLErr FlushCache(bool bAtClosing) override;
717 };
718 
719 /************************************************************************/
720 /* VRTWarpedRasterBand */
721 /************************************************************************/
722 
723 class CPL_DLL VRTWarpedRasterBand final: public VRTRasterBand
724 {
725  public:
726  VRTWarpedRasterBand( GDALDataset *poDS, int nBand,
727  GDALDataType eType = GDT_Unknown );
728  virtual ~VRTWarpedRasterBand();
729 
730  virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ) override;
731 
732  virtual CPLErr IReadBlock( int, int, void * ) override;
733  virtual CPLErr IWriteBlock( int, int, void * ) override;
734 
735  virtual int GetOverviewCount() override;
736  virtual GDALRasterBand *GetOverview(int) override;
737 };
738 /************************************************************************/
739 /* VRTPansharpenedRasterBand */
740 /************************************************************************/
741 
742 class VRTPansharpenedRasterBand final: public VRTRasterBand
743 {
744  int m_nIndexAsPansharpenedBand;
745 
746  public:
747  VRTPansharpenedRasterBand(
748  GDALDataset *poDS, int nBand,
749  GDALDataType eDataType = GDT_Unknown );
750  virtual ~VRTPansharpenedRasterBand();
751 
752  virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ) override;
753 
754  virtual CPLErr IReadBlock( int, int, void * ) override;
755 
756  virtual CPLErr IRasterIO( GDALRWFlag eRWFlag,
757  int nXOff, int nYOff, int nXSize, int nYSize,
758  void * pData, int nBufXSize, int nBufYSize,
759  GDALDataType eBufType,
760  GSpacing nPixelSpace, GSpacing nLineSpace,
761  GDALRasterIOExtraArg* psExtraArg) override;
762 
763  virtual int GetOverviewCount() override;
764  virtual GDALRasterBand *GetOverview(int) override;
765 
766  virtual int IsPansharpenRasterBand() override { return TRUE; }
767 
768  void SetIndexAsPansharpenedBand( int nIdx )
769  { m_nIndexAsPansharpenedBand = nIdx; }
770  int GetIndexAsPansharpenedBand() const
771  { return m_nIndexAsPansharpenedBand; }
772 };
773 
774 /************************************************************************/
775 /* VRTDerivedRasterBand */
776 /************************************************************************/
777 
778 class VRTDerivedRasterBandPrivateData;
779 
780 class CPL_DLL VRTDerivedRasterBand CPL_NON_FINAL: public VRTSourcedRasterBand
781 {
782  VRTDerivedRasterBandPrivateData* m_poPrivate;
783  bool InitializePython();
784  CPLErr GetPixelFunctionArguments(
785  const CPLString&,
786  std::vector<std::pair<CPLString, CPLString>> &);
787 
788  CPL_DISALLOW_COPY_ASSIGN(VRTDerivedRasterBand)
789 
790  public:
791  char *pszFuncName;
792  GDALDataType eSourceTransferType;
793 
794  using PixelFunc = std::function<CPLErr(void**, int, void*, int, int, GDALDataType, GDALDataType, int, int, CSLConstList)>;
795 
796  VRTDerivedRasterBand( GDALDataset *poDS, int nBand );
797  VRTDerivedRasterBand( GDALDataset *poDS, int nBand,
798  GDALDataType eType, int nXSize, int nYSize );
799  virtual ~VRTDerivedRasterBand();
800 
801  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
802  void *, int, int, GDALDataType,
803  GSpacing nPixelSpace, GSpacing nLineSpace,
804  GDALRasterIOExtraArg* psExtraArg ) override;
805 
806  virtual int IGetDataCoverageStatus( int nXOff, int nYOff,
807  int nXSize, int nYSize,
808  int nMaskFlagStop,
809  double* pdfDataPct) override;
810 
811  static CPLErr AddPixelFunction( const char *pszFuncNameIn,
812  GDALDerivedPixelFunc pfnPixelFunc );
813  static CPLErr AddPixelFunction( const char *pszFuncNameIn,
814  GDALDerivedPixelFuncWithArgs pfnPixelFunc,
815  const char *pszMetadata);
816 
817  static std::pair<PixelFunc, CPLString>* GetPixelFunction( const char *pszFuncNameIn );
818 
819  void SetPixelFunctionName( const char *pszFuncNameIn );
820  void SetSourceTransferType( GDALDataType eDataType );
821  void SetPixelFunctionLanguage( const char* pszLanguage );
822 
823  virtual CPLErr XMLInit( CPLXMLNode *, const char *,
824  std::map<CPLString, GDALDataset*>& ) override;
825  virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ) override;
826 
827  virtual double GetMinimum( int *pbSuccess = nullptr ) override;
828  virtual double GetMaximum(int *pbSuccess = nullptr ) override;
829  virtual CPLErr ComputeRasterMinMax( int bApproxOK, double* adfMinMax ) override;
830  virtual CPLErr ComputeStatistics( int bApproxOK,
831  double *pdfMin, double *pdfMax,
832  double *pdfMean, double *pdfStdDev,
833  GDALProgressFunc pfnProgress,
834  void *pProgressData ) override;
835  virtual CPLErr GetHistogram( double dfMin, double dfMax,
836  int nBuckets, GUIntBig * panHistogram,
837  int bIncludeOutOfRange, int bApproxOK,
838  GDALProgressFunc pfnProgress,
839  void *pProgressData ) override;
840 
841  static void Cleanup();
842 };
843 
844 /************************************************************************/
845 /* VRTRawRasterBand */
846 /************************************************************************/
847 
848 class RawRasterBand;
849 
850 class CPL_DLL VRTRawRasterBand CPL_NON_FINAL: public VRTRasterBand
851 {
852  RawRasterBand *m_poRawRaster;
853 
854  char *m_pszSourceFilename;
855  int m_bRelativeToVRT;
856 
857  CPL_DISALLOW_COPY_ASSIGN(VRTRawRasterBand)
858 
859  public:
860  VRTRawRasterBand( GDALDataset *poDS, int nBand,
861  GDALDataType eType = GDT_Unknown );
862  virtual ~VRTRawRasterBand();
863 
864  virtual CPLErr XMLInit( CPLXMLNode *, const char *,
865  std::map<CPLString, GDALDataset*>& ) override;
866  virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ) override;
867 
868  virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
869  void *, int, int, GDALDataType,
870  GSpacing nPixelSpace, GSpacing nLineSpace,
871  GDALRasterIOExtraArg* psExtraArg ) override;
872 
873  virtual CPLErr IReadBlock( int, int, void * ) override;
874  virtual CPLErr IWriteBlock( int, int, void * ) override;
875 
876  CPLErr SetRawLink( const char *pszFilename,
877  const char *pszVRTPath,
878  int bRelativeToVRT,
879  vsi_l_offset nImageOffset,
880  int nPixelOffset, int nLineOffset,
881  const char *pszByteOrder );
882 
883  void ClearRawLink();
884 
885  CPLVirtualMem *GetVirtualMemAuto( GDALRWFlag eRWFlag,
886  int *pnPixelSpace,
887  GIntBig *pnLineSpace,
888  char **papszOptions ) override;
889 
890  virtual void GetFileList( char*** ppapszFileList, int *pnSize,
891  int *pnMaxSize, CPLHashSet* hSetFiles ) override;
892 };
893 
894 /************************************************************************/
895 /* VRTDriver */
896 /************************************************************************/
897 
898 class VRTDriver final: public GDALDriver
899 {
900  CPL_DISALLOW_COPY_ASSIGN(VRTDriver)
901 
902  std::map<std::string, VRTSourceParser> m_oMapSourceParser{};
903 
904  public:
905  VRTDriver();
906  virtual ~VRTDriver();
907 
908  char **papszSourceParsers;
909 
910  virtual char **GetMetadataDomainList() override;
911  virtual char **GetMetadata( const char * pszDomain = "" ) override;
912  virtual CPLErr SetMetadata( char ** papszMetadata,
913  const char * pszDomain = "" ) override;
914 
915  VRTSource *ParseSource( CPLXMLNode *psSrc, const char *pszVRTPath,
916  std::map<CPLString, GDALDataset*>& oMapSharedSources );
917  void AddSourceParser( const char *pszElementName,
918  VRTSourceParser pfnParser );
919 };
920 
921 /************************************************************************/
922 /* VRTSimpleSource */
923 /************************************************************************/
924 
925 class CPL_DLL VRTSimpleSource CPL_NON_FINAL: public VRTSource
926 {
927  CPL_DISALLOW_COPY_ASSIGN(VRTSimpleSource)
928 
929 private:
930  // Owned by the VRTDataset
931  std::map<CPLString, GDALDataset*>* m_poMapSharedSources = nullptr;
932 
933  mutable GDALRasterBand *m_poRasterBand = nullptr;
934 
935  // When poRasterBand is a mask band, poMaskBandMainBand is the band
936  // from which the mask band is taken.
937  mutable GDALRasterBand *m_poMaskBandMainBand = nullptr;
938 
939  CPLStringList m_aosOpenOptions{};
940 
941  void OpenSource() const;
942 
943 protected:
944  friend class VRTSourcedRasterBand;
945  friend class VRTDataset;
946 
947  int m_nBand = 0;
948  bool m_bGetMaskBand = false;
949 
950  double m_dfSrcXOff = 0;
951  double m_dfSrcYOff = 0;
952  double m_dfSrcXSize = 0;
953  double m_dfSrcYSize = 0;
954 
955  double m_dfDstXOff = 0;
956  double m_dfDstYOff = 0;
957  double m_dfDstXSize = 0;
958  double m_dfDstYSize = 0;
959 
960  CPLString m_osResampling{};
961 
962  int m_nMaxValue = 0;
963 
964  int m_bRelativeToVRTOri = -1;
965  CPLString m_osSourceFileNameOri{};
966  int m_nExplicitSharedStatus = -1; // -1 unknown, 0 = unshared, 1 = shared
967  CPLString m_osSrcDSName{};
968 
969  bool m_bDropRefOnSrcBand = true;
970 
971  int NeedMaxValAdjustment() const;
972 
973  GDALRasterBand* GetRasterBandNoOpen() const { return m_poRasterBand; }
974 
975  virtual bool ValidateOpenedBand(GDALRasterBand* /*poBand*/) const { return true; }
976 
977 public:
978  VRTSimpleSource();
979  VRTSimpleSource( const VRTSimpleSource* poSrcSource,
980  double dfXDstRatio, double dfYDstRatio );
981  virtual ~VRTSimpleSource();
982 
983  virtual CPLErr XMLInit( CPLXMLNode *psTree, const char *,
984  std::map<CPLString, GDALDataset*>& ) override;
985  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) override;
986 
987  void SetSrcBand( const char* pszFilename, int nBand );
988  void SetSrcBand( GDALRasterBand * );
989  void SetSrcMaskBand( GDALRasterBand * );
990  void SetSrcWindow( double, double, double, double );
991  void SetDstWindow( double, double, double, double );
992  const CPLString& GetResampling() const { return m_osResampling; }
993  void SetResampling( const char* pszResampling );
994 
995  int GetSrcDstWindow( double, double, double, double,
996  int, int,
997  double *pdfReqXOff, double *pdfReqYOff,
998  double *pdfReqXSize, double *pdfReqYSize,
999  int *, int *, int *, int *,
1000  int *, int *, int *, int *,
1001  bool& bErrorOut );
1002 
1003  virtual CPLErr RasterIO( GDALDataType eBandDataType,
1004  int nXOff, int nYOff, int nXSize, int nYSize,
1005  void *pData, int nBufXSize, int nBufYSize,
1006  GDALDataType eBufType,
1007  GSpacing nPixelSpace, GSpacing nLineSpace,
1008  GDALRasterIOExtraArg* psExtraArgIn ) override;
1009 
1010  virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) override;
1011  virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) override;
1012  virtual CPLErr GetHistogram( int nXSize, int nYSize,
1013  double dfMin, double dfMax,
1014  int nBuckets, GUIntBig * panHistogram,
1015  int bIncludeOutOfRange, int bApproxOK,
1016  GDALProgressFunc pfnProgress,
1017  void *pProgressData ) override;
1018 
1019  void DstToSrc( double dfX, double dfY,
1020  double &dfXOut, double &dfYOut ) const;
1021  void SrcToDst( double dfX, double dfY,
1022  double &dfXOut, double &dfYOut ) const;
1023 
1024  virtual void GetFileList( char*** ppapszFileList, int *pnSize,
1025  int *pnMaxSize, CPLHashSet* hSetFiles ) override;
1026 
1027  virtual int IsSimpleSource() override { return TRUE; }
1028  virtual const char* GetType() { return "SimpleSource"; }
1029  virtual CPLErr FlushCache(bool bAtClosing) override;
1030 
1031  GDALRasterBand* GetRasterBand() const;
1032  GDALRasterBand* GetMaskBandMainBand();
1033  int IsSameExceptBandNumber( VRTSimpleSource* poOtherSource );
1034  CPLErr DatasetRasterIO(
1035  GDALDataType eBandDataType,
1036  int nXOff, int nYOff, int nXSize, int nYSize,
1037  void * pData, int nBufXSize, int nBufYSize,
1038  GDALDataType eBufType,
1039  int nBandCount, int *panBandMap,
1040  GSpacing nPixelSpace, GSpacing nLineSpace,
1041  GSpacing nBandSpace,
1042  GDALRasterIOExtraArg* psExtraArg );
1043 
1044  void UnsetPreservedRelativeFilenames();
1045 
1046  void SetMaxValue( int nVal ) { m_nMaxValue = nVal; }
1047 };
1048 
1049 /************************************************************************/
1050 /* VRTAveragedSource */
1051 /************************************************************************/
1052 
1053 class VRTAveragedSource final: public VRTSimpleSource
1054 {
1055  CPL_DISALLOW_COPY_ASSIGN(VRTAveragedSource)
1056 
1057  int m_bNoDataSet = false;
1058  double m_dfNoDataValue = VRT_NODATA_UNSET;
1059 
1060 public:
1061  VRTAveragedSource();
1062  virtual CPLErr RasterIO( GDALDataType eBandDataType,
1063  int nXOff, int nYOff, int nXSize, int nYSize,
1064  void *pData, int nBufXSize, int nBufYSize,
1065  GDALDataType eBufType,
1066  GSpacing nPixelSpace, GSpacing nLineSpace,
1067  GDALRasterIOExtraArg* psExtraArgIn ) override;
1068 
1069  virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) override;
1070  virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) override;
1071  virtual CPLErr GetHistogram( int nXSize, int nYSize,
1072  double dfMin, double dfMax,
1073  int nBuckets, GUIntBig * panHistogram,
1074  int bIncludeOutOfRange, int bApproxOK,
1075  GDALProgressFunc pfnProgress,
1076  void *pProgressData ) override;
1077 
1078  void SetNoDataValue( double dfNoDataValue );
1079 
1080  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) override;
1081  virtual const char* GetType() override { return "AveragedSource"; }
1082 };
1083 
1084 /************************************************************************/
1085 /* VRTComplexSource */
1086 /************************************************************************/
1087 
1088 typedef enum
1089 {
1090  VRT_SCALING_NONE,
1091  VRT_SCALING_LINEAR,
1092  VRT_SCALING_EXPONENTIAL,
1093 } VRTComplexSourceScaling;
1094 
1095 class CPL_DLL VRTComplexSource CPL_NON_FINAL: public VRTSimpleSource
1096 {
1097  CPL_DISALLOW_COPY_ASSIGN(VRTComplexSource)
1098 
1099 protected:
1100 
1101  int m_bNoDataSet = false;
1102  // adjusted value should be read with GetAdjustedNoDataValue()
1103  double m_dfNoDataValue = VRT_NODATA_UNSET;
1104  std::string m_osNoDataValueOri{}; // string value read in XML deserialization
1105 
1106  VRTComplexSourceScaling m_eScalingType = VRT_SCALING_NONE;
1107  double m_dfScaleOff = 0; // For linear scaling.
1108  double m_dfScaleRatio = 1; // For linear scaling.
1109 
1110  // For non-linear scaling with a power function.
1111  int m_bSrcMinMaxDefined = FALSE;
1112  double m_dfSrcMin = 0;
1113  double m_dfSrcMax = 0;
1114  double m_dfDstMin = 0;
1115  double m_dfDstMax = 0;
1116  double m_dfExponent = 1;
1117 
1118  int m_nColorTableComponent = 0;
1119 
1120  bool m_bUseMaskBand = false;
1121 
1122  double *m_padfLUTInputs = nullptr;
1123  double *m_padfLUTOutputs = nullptr;
1124  int m_nLUTItemCount = 0;
1125 
1126  double GetAdjustedNoDataValue() const;
1127 
1128  template <class WorkingDT>
1129  CPLErr RasterIOInternal( int nReqXOff, int nReqYOff,
1130  int nReqXSize, int nReqYSize,
1131  void *pData, int nOutXSize, int nOutYSize,
1132  GDALDataType eBufType,
1133  GSpacing nPixelSpace, GSpacing nLineSpace,
1134  GDALRasterIOExtraArg* psExtraArg,
1135  GDALDataType eWrkDataType );
1136 
1137 public:
1138  VRTComplexSource();
1139  VRTComplexSource(const VRTComplexSource* poSrcSource,
1140  double dfXDstRatio, double dfYDstRatio);
1141  virtual ~VRTComplexSource();
1142 
1143  virtual CPLErr RasterIO( GDALDataType eBandDataType,
1144  int nXOff, int nYOff, int nXSize, int nYSize,
1145  void *pData, int nBufXSize, int nBufYSize,
1146  GDALDataType eBufType,
1147  GSpacing nPixelSpace, GSpacing nLineSpace,
1148  GDALRasterIOExtraArg* psExtraArgIn ) override;
1149 
1150  virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) override;
1151  virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) override;
1152  virtual CPLErr GetHistogram( int nXSize, int nYSize,
1153  double dfMin, double dfMax,
1154  int nBuckets, GUIntBig * panHistogram,
1155  int bIncludeOutOfRange, int bApproxOK,
1156  GDALProgressFunc pfnProgress,
1157  void *pProgressData ) override;
1158 
1159  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) override;
1160  virtual CPLErr XMLInit( CPLXMLNode *, const char *,
1161  std::map<CPLString, GDALDataset*>& ) override;
1162  virtual const char* GetType() override { return "ComplexSource"; }
1163 
1164  bool AreValuesUnchanged() const;
1165 
1166  double LookupValue( double dfInput );
1167 
1168  void SetNoDataValue( double dfNoDataValue );
1169 
1170  void SetUseMaskBand(bool bUseMaskBand) { m_bUseMaskBand = bUseMaskBand; }
1171 
1172  void SetLinearScaling( double dfOffset, double dfScale );
1173  void SetPowerScaling( double dfExponent,
1174  double dfSrcMin,
1175  double dfSrcMax,
1176  double dfDstMin,
1177  double dfDstMax );
1178  void SetColorTableComponent( int nComponent );
1179 };
1180 
1181 /************************************************************************/
1182 /* VRTFilteredSource */
1183 /************************************************************************/
1184 
1185 class VRTFilteredSource CPL_NON_FINAL: public VRTComplexSource
1186 {
1187 private:
1188  int IsTypeSupported( GDALDataType eTestType ) const;
1189 
1190  CPL_DISALLOW_COPY_ASSIGN(VRTFilteredSource)
1191 
1192 protected:
1193  int m_nSupportedTypesCount;
1194  GDALDataType m_aeSupportedTypes[20];
1195 
1196  int m_nExtraEdgePixels;
1197 
1198 public:
1199  VRTFilteredSource();
1200  virtual ~VRTFilteredSource();
1201 
1202  void SetExtraEdgePixels( int );
1203  void SetFilteringDataTypesSupported( int, GDALDataType * );
1204 
1205  virtual CPLErr FilterData( int nXSize, int nYSize, GDALDataType eType,
1206  GByte *pabySrcData, GByte *pabyDstData ) = 0;
1207 
1208  virtual CPLErr RasterIO( GDALDataType eBandDataType,
1209  int nXOff, int nYOff, int nXSize, int nYSize,
1210  void *pData, int nBufXSize, int nBufYSize,
1211  GDALDataType eBufType,
1212  GSpacing nPixelSpace, GSpacing nLineSpace,
1213  GDALRasterIOExtraArg* psExtraArg ) override;
1214 };
1215 
1216 /************************************************************************/
1217 /* VRTKernelFilteredSource */
1218 /************************************************************************/
1219 
1220 class VRTKernelFilteredSource CPL_NON_FINAL: public VRTFilteredSource
1221 {
1222  CPL_DISALLOW_COPY_ASSIGN(VRTKernelFilteredSource)
1223 
1224 protected:
1225  int m_nKernelSize;
1226 
1227  bool m_bSeparable;
1228 
1229  double *m_padfKernelCoefs;
1230 
1231  int m_bNormalized;
1232 
1233 public:
1234  VRTKernelFilteredSource();
1235  virtual ~VRTKernelFilteredSource();
1236 
1237  virtual CPLErr XMLInit( CPLXMLNode *psTree, const char *,
1238  std::map<CPLString, GDALDataset*>& ) override;
1239  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) override;
1240 
1241  virtual CPLErr FilterData( int nXSize, int nYSize, GDALDataType eType,
1242  GByte *pabySrcData, GByte *pabyDstData ) override;
1243 
1244  CPLErr SetKernel( int nKernelSize, bool bSeparable, double *padfCoefs );
1245  void SetNormalized( int );
1246 };
1247 
1248 /************************************************************************/
1249 /* VRTAverageFilteredSource */
1250 /************************************************************************/
1251 
1252 class VRTAverageFilteredSource final: public VRTKernelFilteredSource
1253 {
1254  CPL_DISALLOW_COPY_ASSIGN(VRTAverageFilteredSource)
1255 
1256 public:
1257  explicit VRTAverageFilteredSource( int nKernelSize );
1258  virtual ~VRTAverageFilteredSource();
1259 
1260  virtual CPLErr XMLInit( CPLXMLNode *psTree, const char *,
1261  std::map<CPLString, GDALDataset*>& ) override;
1262  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) override;
1263 };
1264 
1265 /************************************************************************/
1266 /* VRTFuncSource */
1267 /************************************************************************/
1268 class VRTFuncSource final: public VRTSource
1269 {
1270  CPL_DISALLOW_COPY_ASSIGN(VRTFuncSource)
1271 
1272 public:
1273  VRTFuncSource();
1274  virtual ~VRTFuncSource();
1275 
1276  virtual CPLErr XMLInit( CPLXMLNode *, const char *,
1277  std::map<CPLString, GDALDataset*>& ) override { return CE_Failure; }
1278  virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) override;
1279 
1280  virtual CPLErr RasterIO( GDALDataType eBandDataType,
1281  int nXOff, int nYOff, int nXSize, int nYSize,
1282  void *pData, int nBufXSize, int nBufYSize,
1283  GDALDataType eBufType,
1284  GSpacing nPixelSpace, GSpacing nLineSpace,
1285  GDALRasterIOExtraArg* psExtraArg ) override;
1286 
1287  virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) override;
1288  virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) override;
1289  virtual CPLErr GetHistogram( int nXSize, int nYSize,
1290  double dfMin, double dfMax,
1291  int nBuckets, GUIntBig * panHistogram,
1292  int bIncludeOutOfRange, int bApproxOK,
1293  GDALProgressFunc pfnProgress,
1294  void *pProgressData ) override;
1295 
1296  VRTImageReadFunc pfnReadFunc;
1297  void *pCBData;
1298  GDALDataType eType;
1299 
1300  float fNoDataValue;
1301 };
1302 
1303 /************************************************************************/
1304 /* VRTGroup */
1305 /************************************************************************/
1306 
1307 #ifdef TMPEXPORT
1308 #define TMP_CPL_DLL CPL_DLL
1309 #else
1310 #define TMP_CPL_DLL
1311 #endif
1312 
1313 class VRTMDArray;
1314 class VRTAttribute;
1315 class VRTDimension;
1316 
1317 class VRTGroup final: public GDALGroup
1318 {
1319 public:
1320  struct Ref
1321  {
1322  VRTGroup* m_ptr;
1323  explicit Ref(VRTGroup* ptr): m_ptr(ptr) {}
1324  Ref(const Ref&) = delete;
1325  Ref& operator=(const Ref&) = delete;
1326  };
1327 
1328 private:
1329  std::shared_ptr<Ref> m_poSharedRefRootGroup{};
1330  std::weak_ptr<Ref> m_poWeakRefRootGroup{};
1331  std::shared_ptr<Ref> m_poRefSelf{};
1332 
1333  std::string m_osFilename{};
1334  mutable bool m_bDirty = false;
1335  std::string m_osVRTPath{};
1336  std::map<std::string, std::shared_ptr<VRTGroup>> m_oMapGroups{};
1337  std::map<std::string, std::shared_ptr<VRTMDArray>> m_oMapMDArrays{};
1338  std::map<std::string, std::shared_ptr<VRTAttribute>> m_oMapAttributes{};
1339  std::map<std::string, std::shared_ptr<VRTDimension>> m_oMapDimensions{};
1340 
1341  std::shared_ptr<VRTGroup> OpenGroupInternal(const std::string& osName) const;
1342  void SetRootGroupRef(const std::weak_ptr<Ref>& rgRef);
1343  std::weak_ptr<Ref> GetRootGroupRef() const;
1344 
1345 public:
1346 
1347  VRTGroup(const std::string& osParentName, const std::string& osName);
1348  ~VRTGroup();
1349 
1350  bool XMLInit(const std::shared_ptr<VRTGroup>& poRoot,
1351  const std::shared_ptr<VRTGroup>& poThisGroup,
1352  const CPLXMLNode* psNode,
1353  const char* pszVRTPath);
1354 
1355  std::vector<std::string> GetMDArrayNames(CSLConstList papszOptions) const override;
1356  std::shared_ptr<GDALMDArray> OpenMDArray(const std::string& osName,
1357  CSLConstList papszOptions = nullptr) const override;
1358 
1359  std::vector<std::string> GetGroupNames(CSLConstList papszOptions) const override;
1360  std::shared_ptr<GDALGroup> OpenGroup(const std::string& osName,
1361  CSLConstList) const override
1362  {
1363  return OpenGroupInternal(osName);
1364  }
1365 
1366  std::vector<std::shared_ptr<GDALDimension>> GetDimensions(CSLConstList) const override;
1367 
1368  std::vector<std::shared_ptr<GDALAttribute>> GetAttributes(CSLConstList) const override;
1369 
1370  std::shared_ptr<VRTDimension> GetDimension(const std::string& name) const {
1371  auto oIter = m_oMapDimensions.find(name);
1372  return oIter == m_oMapDimensions.end() ? nullptr : oIter->second;
1373  }
1374  std::shared_ptr<VRTDimension> GetDimensionFromFullName(const std::string& name,
1375  bool bEmitError) const;
1376 
1377  std::shared_ptr<GDALGroup> CreateGroup(const std::string& osName,
1378  CSLConstList papszOptions = nullptr) override;
1379 
1380  std::shared_ptr<GDALDimension> CreateDimension(const std::string& osName,
1381  const std::string& osType,
1382  const std::string& osDirection,
1383  GUInt64 nSize,
1384  CSLConstList papszOptions = nullptr) override;
1385 
1386  std::shared_ptr<GDALAttribute> CreateAttribute(
1387  const std::string& osName,
1388  const std::vector<GUInt64>& anDimensions,
1389  const GDALExtendedDataType& oDataType,
1390  CSLConstList papszOptions = nullptr) override;
1391 
1392  std::shared_ptr<GDALMDArray> CreateMDArray(const std::string& osName,
1393  const std::vector<std::shared_ptr<GDALDimension>>& aoDimensions,
1394  const GDALExtendedDataType& oDataType,
1395  CSLConstList papszOptions) override;
1396 
1397  void SetIsRootGroup();
1398 
1399  const std::shared_ptr<Ref>& GetRef() const { return m_poRefSelf; }
1400  VRTGroup* GetRootGroup() const;
1401 
1402  const std::string& GetVRTPath() const { return m_osVRTPath; }
1403  void SetDirty();
1404  void SetFilename(const std::string& osFilename) { m_osFilename = osFilename; }
1405  const std::string& GetFilename() const { return m_osFilename; }
1406  void Serialize() const;
1407  CPLXMLNode* SerializeToXML( const char *pszVRTPathIn ) const;
1408  void Serialize(CPLXMLNode* psParent, const char *pszVRTPathIn) const;
1409 };
1410 
1411 /************************************************************************/
1412 /* VRTDimension */
1413 /************************************************************************/
1414 
1415 class VRTDimension final: public GDALDimension
1416 {
1417  std::weak_ptr<VRTGroup::Ref> m_poGroupRef;
1418  std::string m_osIndexingVariableName;
1419 
1420 public:
1421  VRTDimension(const std::shared_ptr<VRTGroup::Ref>& poGroupRef,
1422  const std::string& osParentName,
1423  const std::string& osName,
1424  const std::string& osType,
1425  const std::string& osDirection,
1426  GUInt64 nSize,
1427  const std::string& osIndexingVariableName):
1428  GDALDimension(osParentName, osName, osType, osDirection, nSize),
1429  m_poGroupRef(poGroupRef),
1430  m_osIndexingVariableName(osIndexingVariableName)
1431  {}
1432 
1433  VRTGroup* GetGroup() const;
1434 
1435  static std::shared_ptr<VRTDimension> Create(const std::shared_ptr<VRTGroup>& poThisGroup,
1436  const std::string& osParentName,
1437  const CPLXMLNode* psNode);
1438 
1439  std::shared_ptr<GDALMDArray> GetIndexingVariable() const override;
1440 
1441  bool SetIndexingVariable(std::shared_ptr<GDALMDArray> poIndexingVariable) override;
1442 
1443  void Serialize(CPLXMLNode* psParent) const;
1444 };
1445 
1446 /************************************************************************/
1447 /* VRTAttribute */
1448 /************************************************************************/
1449 
1450 class VRTAttribute final: public GDALAttribute
1451 {
1452  GDALExtendedDataType m_dt;
1453  std::vector<std::string> m_aosList{};
1454  std::vector<std::shared_ptr<GDALDimension>> m_dims{};
1455 
1456 protected:
1457 
1458  bool IRead(const GUInt64* arrayStartIdx,
1459  const size_t* count,
1460  const GInt64* arrayStep,
1461  const GPtrDiff_t* bufferStride,
1462  const GDALExtendedDataType& bufferDataType,
1463  void* pDstBuffer) const override;
1464 
1465  bool IWrite(const GUInt64* arrayStartIdx,
1466  const size_t* count,
1467  const GInt64* arrayStep,
1468  const GPtrDiff_t* bufferStride,
1469  const GDALExtendedDataType& bufferDataType,
1470  const void* pSrcBuffer) override;
1471 
1472 
1473 public:
1474  VRTAttribute(const std::string& osParentName,
1475  const std::string& osName,
1476  const GDALExtendedDataType& dt,
1477  std::vector<std::string>&& aosList):
1478  GDALAbstractMDArray(osParentName, osName),
1479  GDALAttribute(osParentName, osName),
1480  m_dt(dt),
1481  m_aosList(std::move(aosList))
1482  {
1483  if( m_aosList.size() > 1 )
1484  {
1485  m_dims.emplace_back(std::make_shared<GDALDimension>(
1486  std::string(), "dim",
1487  std::string(), std::string(), m_aosList.size()));
1488  }
1489  }
1490 
1491  VRTAttribute(const std::string& osParentName,
1492  const std::string& osName,
1493  GUInt64 nDim,
1494  const GDALExtendedDataType& dt):
1495  GDALAbstractMDArray(osParentName, osName),
1496  GDALAttribute(osParentName, osName),
1497  m_dt(dt)
1498  {
1499  if( nDim != 0 )
1500  {
1501  m_dims.emplace_back(std::make_shared<GDALDimension>(
1502  std::string(), "dim",
1503  std::string(), std::string(), nDim));
1504  }
1505  }
1506 
1507  static bool CreationCommonChecks(const std::string& osName,
1508  const std::vector<GUInt64>& anDimensions,
1509  const std::map<std::string, std::shared_ptr<VRTAttribute>>& oMapAttributes);
1510 
1511  static std::shared_ptr<VRTAttribute> Create(const std::string& osParentName,
1512  const CPLXMLNode* psNode);
1513 
1514  const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const override { return m_dims; }
1515 
1516  const GDALExtendedDataType &GetDataType() const override { return m_dt; }
1517 
1518  void Serialize(CPLXMLNode* psParent) const;
1519 };
1520 
1521 /************************************************************************/
1522 /* VRTMDArraySource */
1523 /************************************************************************/
1524 
1525 class VRTMDArraySource
1526 {
1527 public:
1528  virtual ~VRTMDArraySource() = default;
1529 
1530  virtual bool Read(const GUInt64* arrayStartIdx,
1531  const size_t* count,
1532  const GInt64* arrayStep,
1533  const GPtrDiff_t* bufferStride,
1534  const GDALExtendedDataType& bufferDataType,
1535  void* pDstBuffer) const = 0;
1536 
1537  virtual void Serialize(CPLXMLNode* psParent, const char* pszVRTPath) const = 0;
1538 };
1539 
1540 /************************************************************************/
1541 /* VRTMDArray */
1542 /************************************************************************/
1543 
1544 class VRTMDArray final: public GDALMDArray
1545 {
1546 protected:
1547  friend class VRTGroup; // for access to SetSelf()
1548 
1549  std::weak_ptr<VRTGroup::Ref> m_poGroupRef;
1550  std::string m_osVRTPath{};
1551 
1552  GDALExtendedDataType m_dt;
1553  std::vector<std::shared_ptr<GDALDimension>> m_dims;
1554  std::map<std::string, std::shared_ptr<VRTAttribute>> m_oMapAttributes{};
1555  std::vector<std::unique_ptr<VRTMDArraySource>> m_sources{};
1556  std::shared_ptr<OGRSpatialReference> m_poSRS{};
1557  std::vector<GByte> m_abyNoData{};
1558  std::string m_osUnit{};
1559  double m_dfScale = 1.0;
1560  double m_dfOffset = 0.0;
1561  bool m_bHasScale = false;
1562  bool m_bHasOffset = false;
1563  std::string m_osFilename{};
1564 
1565  bool IRead(const GUInt64* arrayStartIdx,
1566  const size_t* count,
1567  const GInt64* arrayStep,
1568  const GPtrDiff_t* bufferStride,
1569  const GDALExtendedDataType& bufferDataType,
1570  void* pDstBuffer) const override;
1571 
1572  void SetDirty();
1573 
1574 public:
1575  VRTMDArray(const std::shared_ptr<VRTGroup::Ref>& poGroupRef,
1576  const std::string& osParentName,
1577  const std::string& osName,
1578  const GDALExtendedDataType& dt,
1579  std::vector<std::shared_ptr<GDALDimension>>&& dims,
1580  std::map<std::string, std::shared_ptr<VRTAttribute>>&& oMapAttributes) :
1581  GDALAbstractMDArray(osParentName, osName),
1582  GDALMDArray(osParentName, osName),
1583  m_poGroupRef(poGroupRef),
1584  m_osVRTPath(poGroupRef->m_ptr->GetVRTPath()),
1585  m_dt(dt),
1586  m_dims(std::move(dims)),
1587  m_oMapAttributes(std::move(oMapAttributes)),
1588  m_osFilename(poGroupRef->m_ptr->GetFilename())
1589  {
1590  }
1591 
1592  VRTMDArray(const std::shared_ptr<VRTGroup::Ref>& poGroupRef,
1593  const std::string& osParentName,
1594  const std::string& osName,
1595  const std::vector<std::shared_ptr<GDALDimension>>& dims,
1596  const GDALExtendedDataType& dt) :
1597  GDALAbstractMDArray(osParentName, osName),
1598  GDALMDArray(osParentName, osName),
1599  m_poGroupRef(poGroupRef),
1600  m_osVRTPath(poGroupRef->m_ptr->GetVRTPath()),
1601  m_dt(dt),
1602  m_dims(dims),
1603  m_osFilename(poGroupRef->m_ptr->GetFilename())
1604  {
1605  }
1606 
1607  bool IsWritable() const override { return false; }
1608 
1609  const std::string& GetFilename() const override { return m_osFilename; }
1610 
1611  static std::shared_ptr<VRTMDArray> Create(const std::shared_ptr<VRTGroup>& poThisGroup,
1612  const std::string& osParentName,
1613  const CPLXMLNode* psNode);
1614 
1615  const std::vector<std::shared_ptr<GDALDimension>>& GetDimensions() const override { return m_dims; }
1616 
1617  std::vector<std::shared_ptr<GDALAttribute>> GetAttributes(CSLConstList) const override;
1618 
1619  const GDALExtendedDataType &GetDataType() const override { return m_dt; }
1620 
1621  bool SetSpatialRef(const OGRSpatialReference* poSRS) override;
1622 
1623  std::shared_ptr<OGRSpatialReference> GetSpatialRef() const override { return m_poSRS; }
1624 
1625  const void* GetRawNoDataValue() const override;
1626 
1627  bool SetRawNoDataValue(const void* pRawNoData) override;
1628 
1629  const std::string& GetUnit() const override { return m_osUnit; }
1630 
1631  bool SetUnit(const std::string& osUnit) override {
1632  m_osUnit = osUnit; return true; }
1633 
1634  double GetOffset(bool* pbHasOffset, GDALDataType* peStorageType) const override
1635  {
1636  if( pbHasOffset) *pbHasOffset = m_bHasOffset;
1637  if( peStorageType ) *peStorageType = GDT_Unknown;
1638  return m_dfOffset;
1639  }
1640 
1641  double GetScale(bool* pbHasScale, GDALDataType* peStorageType) const override
1642  {
1643  if( pbHasScale) *pbHasScale = m_bHasScale;
1644  if( peStorageType ) *peStorageType = GDT_Unknown;
1645  return m_dfScale;
1646  }
1647 
1648  bool SetOffset(double dfOffset, GDALDataType /* eStorageType */ = GDT_Unknown) override
1649  { SetDirty(); m_bHasOffset = true; m_dfOffset = dfOffset; return true; }
1650 
1651  bool SetScale(double dfScale, GDALDataType /* eStorageType */ = GDT_Unknown) override
1652  { SetDirty(); m_bHasScale = true; m_dfScale = dfScale; return true; }
1653 
1654  void AddSource(std::unique_ptr<VRTMDArraySource>&& poSource);
1655 
1656  std::shared_ptr<GDALAttribute> CreateAttribute(
1657  const std::string& osName,
1658  const std::vector<GUInt64>& anDimensions,
1659  const GDALExtendedDataType& oDataType,
1660  CSLConstList papszOptions = nullptr) override;
1661 
1662  bool CopyFrom(GDALDataset* poSrcDS,
1663  const GDALMDArray* poSrcArray,
1664  bool bStrict,
1665  GUInt64& nCurCost,
1666  const GUInt64 nTotalCost,
1667  GDALProgressFunc pfnProgress,
1668  void * pProgressData) override;
1669 
1670  void Serialize(CPLXMLNode* psParent, const char *pszVRTPathIn ) const;
1671 
1672  VRTGroup* GetGroup() const;
1673 
1674  const std::string& GetVRTPath() const { return m_osVRTPath; }
1675 };
1676 
1677 /************************************************************************/
1678 /* VRTMDArraySourceInlinedValues */
1679 /************************************************************************/
1680 
1681 class VRTMDArraySourceInlinedValues final: public VRTMDArraySource
1682 {
1683  const VRTMDArray* m_poDstArray = nullptr;
1684  bool m_bIsConstantValue;
1685  std::vector<GUInt64> m_anOffset{};
1686  std::vector<size_t> m_anCount{};
1687  std::vector<GByte> m_abyValues{};
1688  std::vector<size_t> m_anInlinedArrayStrideInBytes{};
1689  GDALExtendedDataType m_dt;
1690 
1691  VRTMDArraySourceInlinedValues(const VRTMDArraySourceInlinedValues&) = delete;
1692  VRTMDArraySourceInlinedValues& operator=(const VRTMDArraySourceInlinedValues&) = delete;
1693 
1694 public:
1695  VRTMDArraySourceInlinedValues(const VRTMDArray* poDstArray,
1696  bool bIsConstantValue,
1697  std::vector<GUInt64>&& anOffset,
1698  std::vector<size_t>&& anCount,
1699  std::vector<GByte>&& abyValues):
1700  m_poDstArray(poDstArray),
1701  m_bIsConstantValue(bIsConstantValue),
1702  m_anOffset(std::move(anOffset)),
1703  m_anCount(std::move(anCount)),
1704  m_abyValues(std::move(abyValues)),
1705  m_dt(poDstArray->GetDataType())
1706  {
1707  const auto nDims(poDstArray->GetDimensionCount());
1708  m_anInlinedArrayStrideInBytes.resize(nDims);
1709  if( !bIsConstantValue && nDims > 0 )
1710  {
1711  m_anInlinedArrayStrideInBytes.back() = poDstArray->GetDataType().GetSize();
1712  for(size_t i = nDims - 1; i > 0; )
1713  {
1714  --i;
1715  m_anInlinedArrayStrideInBytes[i] =
1716  m_anInlinedArrayStrideInBytes[i+1] * m_anCount[i+1];
1717  }
1718  }
1719  }
1720 
1721  ~VRTMDArraySourceInlinedValues();
1722 
1723  static std::unique_ptr<VRTMDArraySourceInlinedValues> Create(
1724  const VRTMDArray* poDstArray,
1725  const CPLXMLNode* psNode);
1726 
1727  bool Read(const GUInt64* arrayStartIdx,
1728  const size_t* count,
1729  const GInt64* arrayStep,
1730  const GPtrDiff_t* bufferStride,
1731  const GDALExtendedDataType& bufferDataType,
1732  void* pDstBuffer) const override;
1733 
1734  void Serialize(CPLXMLNode* psParent, const char* pszVRTPath) const override;
1735 };
1736 
1737 /************************************************************************/
1738 /* VRTMDArraySourceRegularlySpaced */
1739 /************************************************************************/
1740 
1741 class VRTMDArraySourceRegularlySpaced final: public VRTMDArraySource
1742 {
1743  double m_dfStart;
1744  double m_dfIncrement;
1745 
1746 public:
1747  VRTMDArraySourceRegularlySpaced(
1748  double dfStart, double dfIncrement):
1749  m_dfStart(dfStart),
1750  m_dfIncrement(dfIncrement)
1751  {
1752  }
1753 
1754  bool Read(const GUInt64* arrayStartIdx,
1755  const size_t* count,
1756  const GInt64* arrayStep,
1757  const GPtrDiff_t* bufferStride,
1758  const GDALExtendedDataType& bufferDataType,
1759  void* pDstBuffer) const override;
1760 
1761  void Serialize(CPLXMLNode* psParent, const char* pszVRTPath) const override;
1762 };
1763 
1764 /************************************************************************/
1765 /* VRTMDArraySourceFromArray */
1766 /************************************************************************/
1767 
1768 class VRTMDArraySourceFromArray final: public VRTMDArraySource
1769 {
1770  const VRTMDArray* m_poDstArray = nullptr;
1771  bool m_bRelativeToVRTSet = false;
1772  bool m_bRelativeToVRT = false;
1773  std::string m_osFilename{};
1774  std::string m_osArray{};
1775  std::string m_osBand{};
1776  std::vector<int> m_anTransposedAxis{};
1777  std::string m_osViewExpr{};
1778  std::vector<GUInt64> m_anSrcOffset{};
1779  mutable std::vector<GUInt64> m_anCount{};
1780  std::vector<GUInt64> m_anStep{};
1781  std::vector<GUInt64> m_anDstOffset{};
1782 
1783  VRTMDArraySourceFromArray(const VRTMDArraySourceFromArray&) = delete;
1784  VRTMDArraySourceFromArray& operator=(const VRTMDArraySourceFromArray&) = delete;
1785 
1786 public:
1787  VRTMDArraySourceFromArray(const VRTMDArray* poDstArray,
1788  bool bRelativeToVRTSet,
1789  bool bRelativeToVRT,
1790  const std::string& osFilename,
1791  const std::string& osArray,
1792  const std::string& osBand,
1793  std::vector<int>&& anTransposedAxis,
1794  const std::string& osViewExpr,
1795  std::vector<GUInt64>&& anSrcOffset,
1796  std::vector<GUInt64>&& anCount,
1797  std::vector<GUInt64>&& anStep,
1798  std::vector<GUInt64>&& anDstOffset):
1799  m_poDstArray(poDstArray),
1800  m_bRelativeToVRTSet(bRelativeToVRTSet),
1801  m_bRelativeToVRT(bRelativeToVRT),
1802  m_osFilename(osFilename),
1803  m_osArray(osArray),
1804  m_osBand(osBand),
1805  m_anTransposedAxis(std::move(anTransposedAxis)),
1806  m_osViewExpr(osViewExpr),
1807  m_anSrcOffset(std::move(anSrcOffset)),
1808  m_anCount(std::move(anCount)),
1809  m_anStep(std::move(anStep)),
1810  m_anDstOffset(std::move(anDstOffset))
1811  {
1812  }
1813 
1814  ~VRTMDArraySourceFromArray() override;
1815 
1816  static std::unique_ptr<VRTMDArraySourceFromArray> Create(
1817  const VRTMDArray* poDstArray,
1818  const CPLXMLNode* psNode);
1819 
1820  bool Read(const GUInt64* arrayStartIdx,
1821  const size_t* count,
1822  const GInt64* arrayStep,
1823  const GPtrDiff_t* bufferStride,
1824  const GDALExtendedDataType& bufferDataType,
1825  void* pDstBuffer) const override;
1826 
1827  void Serialize(CPLXMLNode* psParent, const char* pszVRTPath) const override;
1828 };
1829 
1830 #endif /* #ifndef DOXYGEN_SKIP */
1831 
1832 #endif /* ndef VIRTUALDATASET_H_INCLUDED */
GDALGroup::CreateMDArray
virtual std::shared_ptr< GDALMDArray > CreateMDArray(const std::string &osName, const std::vector< std::shared_ptr< GDALDimension >> &aoDimensions, const GDALExtendedDataType &oDataType, CSLConstList papszOptions=nullptr)
Create a multidimensional array within a group.
Definition: gdalmultidim.cpp:566
GDALDataset::GetShared
int GetShared() const
Returns shared flag.
Definition: gdaldataset.cpp:1376
GDALRasterBand::SetNoDataValue
virtual CPLErr SetNoDataValue(double dfNoData)
Set the no data value for this band.
Definition: gdalrasterband.cpp:1850
GDALDimension::SetIndexingVariable
virtual bool SetIndexingVariable(std::shared_ptr< GDALMDArray > poIndexingVariable)
Set the variable that is used to index the dimension.
Definition: gdalmultidim.cpp:8648
GDALMDArray::GetUnit
virtual const std::string & GetUnit() const
Return the array unit.
Definition: gdalmultidim.cpp:2155
GDALMDArray::GetSpatialRef
virtual std::shared_ptr< OGRSpatialReference > GetSpatialRef() const
Return the spatial reference system object associated with the array.
Definition: gdalmultidim.cpp:2183
GDALRasterBand::GetColorTable
virtual GDALColorTable * GetColorTable()
Fetch the color table associated with band.
Definition: gdalrasterband.cpp:2374
GByte
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:203
GDALExtendedDataType
Class used to represent potentially complex data types.
Definition: gdal_priv.h:1879
GUInt64
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition: cpl_port.h:251
GDALOpenInfo
Class for dataset open functions.
Definition: gdal_priv.h:271
GDALRasterBand::GetUnitType
virtual const char * GetUnitType()
Return raster unit type.
Definition: gdalrasterband.cpp:2954
GDALRasterBand::DeleteNoDataValue
virtual CPLErr DeleteNoDataValue()
Remove the no data value for this band.
Definition: gdalrasterband.cpp:2052
GDALRasterBand::GetOffset
virtual double GetOffset(int *pbSuccess=nullptr)
Fetch the raster value offset.
Definition: gdalrasterband.cpp:2752
GDALRasterBand::SetColorTable
virtual CPLErr SetColorTable(GDALColorTable *poCT)
Set the raster color table.
Definition: gdalrasterband.cpp:2423
VRT_NODATA_UNSET
#define VRT_NODATA_UNSET
Special value to indicate that nodata is not set.
Definition: gdal_vrt.h:45
GDALRasterBand::GetDefaultHistogram
virtual CPLErr GetDefaultHistogram(double *pdfMin, double *pdfMax, int *pnBuckets, GUIntBig **ppanHistogram, int bForce, GDALProgressFunc, void *pProgressData)
Fetch default raster histogram.
Definition: gdalrasterband.cpp:3825
GDALRasterBand::IsMaskBand
virtual bool IsMaskBand() const
Returns whether a band is a mask band.
Definition: gdalrasterband.cpp:7182
VRTDatasetH
void * VRTDatasetH
Opaque type for a VRT dataset.
Definition: gdal_vrt.h:76
GDALRasterBand::GetDataset
GDALDataset * GetDataset()
Fetch the owning dataset handle.
Definition: gdalrasterband.cpp:3164
GDALMDArray::SetUnit
virtual bool SetUnit(const std::string &osUnit)
Set the variable unit.
Definition: gdalmultidim.cpp:2133
GDALDataset::AddBand
virtual CPLErr AddBand(GDALDataType eType, char **papszOptions=nullptr)
Add a band to a dataset.
Definition: gdaldataset.cpp:586
GDALMDArray::IsWritable
virtual bool IsWritable() const =0
Return whether an array is writable.
GDALDataset::GetRootGroup
virtual std::shared_ptr< GDALGroup > GetRootGroup() const
Return the root GDALGroup of this dataset.
Definition: gdaldataset.cpp:8280
cpl_hash_set.h
CPLStringList
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:429
GDT_Unknown
@ GDT_Unknown
Definition: gdal.h:64
cpl_minixml.h
GDALDriver
Format specific driver.
Definition: gdal_priv.h:1558
OGRSpatialReference
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition: ogr_spatialref.h:157
GDALAbstractMDArray
Abstract class, implemented by GDALAttribute and GDALMDArray.
Definition: gdal_priv.h:2162
GDALRasterBand::SetDefaultHistogram
virtual CPLErr SetDefaultHistogram(double dfMin, double dfMax, int nBuckets, GUIntBig *panHistogram)
Set default histogram.
Definition: gdalrasterband.cpp:6488
GDALMDArray::GetScale
virtual double GetScale(bool *pbHasScale=nullptr, GDALDataType *peStorageType=nullptr) const
Get the scale value to apply to raw values.
Definition: gdalmultidim.cpp:2498
GDALClose
void GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition: gdaldataset.cpp:3641
GDALRasterBand::SetUnitType
virtual CPLErr SetUnitType(const char *pszNewValue)
Set unit type.
Definition: gdalrasterband.cpp:3002
GDALRasterBand::GetColorInterpretation
virtual GDALColorInterp GetColorInterpretation()
How should this band be interpreted as color?
Definition: gdalrasterband.cpp:2282
gdal_vrt.h
GDALGroup::CreateDimension
virtual std::shared_ptr< GDALDimension > CreateDimension(const std::string &osName, const std::string &osType, const std::string &osDirection, GUInt64 nSize, CSLConstList papszOptions=nullptr)
Create a dimension within a group.
Definition: gdalmultidim.cpp:526
GDALRasterBand::GetCategoryNames
virtual char ** GetCategoryNames()
Fetch the list of category names for this raster.
Definition: gdalrasterband.cpp:1561
GDALAbstractMDArray::GetDimensions
virtual const std::vector< std::shared_ptr< GDALDimension > > & GetDimensions() const =0
Return the dimensions of an attribute/array.
GDALColorInterp
GDALColorInterp
Definition: gdal.h:204
GDALMajorObject::SetDescription
virtual void SetDescription(const char *)
Set object description.
Definition: gdalmajorobject.cpp:119
CPLString
Convenient string class based on std::string.
Definition: cpl_string.h:320
GDALRasterBand
A single raster band (or channel).
Definition: gdal_priv.h:1179
GInt64
GIntBig GInt64
Signed 64 bit integer type.
Definition: cpl_port.h:249
GDALIHasAttribute::GetAttributes
virtual std::vector< std::shared_ptr< GDALAttribute > > GetAttributes(CSLConstList papszOptions=nullptr) const
Return the list of attributes contained in a GDALMDArray or GDALGroup.
Definition: gdalmultidim.cpp:223
GPtrDiff_t
int GPtrDiff_t
Integer type large enough to hold the difference between 2 addresses.
Definition: cpl_port.h:269
CPL_NON_FINAL
#define CPL_NON_FINAL
Mark that a class is explicitly recognized as non-final.
Definition: cpl_port.h:923
GDALDataset::AdviseRead
virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, GDALDataType eDT, int nBandCount, int *panBandList, char **papszOptions)
Advise driver of upcoming read requests.
Definition: gdaldataset.cpp:2722
GDALDataset::GetMetadata
void static void char ** GetMetadata(const char *pszDomain="") override
Fetch metadata.
Definition: gdaldataset.cpp:4113
GDALDataType
GDALDataType
Definition: gdal.h:63
CPLXMLNode
Document node structure.
Definition: cpl_minixml.h:69
GDALWarpOperation
Definition: gdalwarper.h:463
GDALDataset::SetGCPs
virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList, const OGRSpatialReference *poGCP_SRS)
Assign GCPs.
Definition: gdaldataset.cpp:1714
GDALDataset::GetGCPs
virtual const GDAL_GCP * GetGCPs()
Fetch GCPs.
Definition: gdaldataset.cpp:1609
GDALGroup
Class modeling a named container of GDALAttribute, GDALMDArray, OGRLayer or other GDALGroup.
Definition: gdal_priv.h:2060
GDALDataset
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:342
GDALGroup::GetGroupNames
virtual std::vector< std::string > GetGroupNames(CSLConstList papszOptions=nullptr) const
Return the list of sub-groups contained in this group.
Definition: gdalmultidim.cpp:348
CPLHashSet
struct _CPLHashSet CPLHashSet
Opaque type for a hash set.
Definition: cpl_hash_set.h:52
GDALRasterBand::SetNoDataValueAsInt64
virtual CPLErr SetNoDataValueAsInt64(int64_t nNoData)
Set the no data value for this band.
Definition: gdalrasterband.cpp:1922
GDALRasterBand::GetOverviewCount
virtual int GetOverviewCount()
Return the number of overview layers available.
Definition: gdalrasterband.cpp:2508
GDALMDArray
Class modeling a multi-dimensional array.
Definition: gdal_priv.h:2456
GDALRasterBand::SetDefaultRAT
virtual CPLErr SetDefaultRAT(const GDALRasterAttributeTable *poRAT)
Set default Raster Attribute Table.
Definition: gdalrasterband.cpp:6635
GDALMDArray::SetSpatialRef
virtual bool SetSpatialRef(const OGRSpatialReference *poSRS)
Assign a spatial reference system object to the the array.
Definition: gdalmultidim.cpp:2169
GDALRasterBand::GetMaskBand
virtual GDALRasterBand * GetMaskBand()
Return the mask band associated with the band.
Definition: gdalrasterband.cpp:6720
GDALMajorObject::GetMetadata
virtual char ** GetMetadata(const char *pszDomain="")
Fetch metadata.
Definition: gdalmajorobject.cpp:248
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1056
GUIntBig
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:233
GDALDataset::Open
static GDALDataset * Open(const char *pszFilename, unsigned int nOpenFlags=0, const char *const *papszAllowedDrivers=nullptr, const char *const *papszOpenOptions=nullptr, const char *const *papszSiblingFiles=nullptr)
Definition: gdal_priv.h:668
GDALGroup::CreateGroup
virtual std::shared_ptr< GDALGroup > CreateGroup(const std::string &osName, CSLConstList papszOptions=nullptr)
Create a sub-group within a group.
Definition: gdalmultidim.cpp:497
GDALDataset::GetGCPSpatialRef
virtual const OGRSpatialReference * GetGCPSpatialRef() const
Get output spatial reference system for GCPs.
Definition: gdaldataset.cpp:1551
GDALDataset::SetSpatialRef
virtual CPLErr SetSpatialRef(const OGRSpatialReference *poSRS)
Set the spatial reference system for this dataset.
Definition: gdaldataset.cpp:1017
GDALDataset::Dereference
int Dereference()
Subtract one from dataset reference count.
Definition: gdaldataset.cpp:1304
GDAL_GCP
Ground Control Point.
Definition: gdal.h:892
GDALDerivedPixelFuncWithArgs
CPLErr(* GDALDerivedPixelFuncWithArgs)(void **papoSources, int nSources, void *pData, int nBufXSize, int nBufYSize, GDALDataType eSrcType, GDALDataType eBufType, int nPixelSpace, int nLineSpace, CSLConstList papszFunctionArgs)
Type of functions to pass to GDALAddDerivedBandPixelFuncWithArgs.
Definition: gdal.h:1159
GDALDimension
Class modeling a a dimension / axis used to index multidimensional arrays.
Definition: gdal_priv.h:2763
GDALDataset::GetGCPCount
virtual int GetGCPCount()
Get number of GCPs.
Definition: gdaldataset.cpp:1468
GCI_Undefined
@ GCI_Undefined
Definition: gdal.h:206
GDALMDArray::SetOffset
virtual bool SetOffset(double dfOffset, GDALDataType eStorageType=GDT_Unknown)
Set the offset value to apply to raw values.
Definition: gdalmultidim.cpp:2469
GDALRasterBand::GetOverview
virtual GDALRasterBand * GetOverview(int)
Fetch overview raster band object.
Definition: gdalrasterband.cpp:2550
GDALAbstractMDArray::GetDataType
virtual const GDALExtendedDataType & GetDataType() const =0
Return the data type of an attribute/array.
GDALMajorObject::GetMetadataDomainList
virtual char ** GetMetadataDomainList()
Fetch list of metadata domains.
Definition: gdalmajorobject.cpp:160
CPLVirtualMem
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition: cpl_virtualmem.h:62
GDALMDArray::SetRawNoDataValue
virtual bool SetRawNoDataValue(const void *pRawNoData)
Set the nodata value as a "raw" value.
Definition: gdalmultidim.cpp:2327
GDALRasterBand::SetScale
virtual CPLErr SetScale(double dfNewScale)
Set scaling ratio.
Definition: gdalrasterband.cpp:2907
GDALMajorObject::SetMetadata
virtual CPLErr SetMetadata(char **papszMetadata, const char *pszDomain="")
Set metadata.
Definition: gdalmajorobject.cpp:291
GDALDataset::CloseDependentDatasets
virtual int CloseDependentDatasets()
Drop references to any other datasets referenced by this dataset.
Definition: gdaldataset.cpp:4028
GDALDataset::CreateMaskBand
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the dataset.
Definition: gdaldataset.cpp:3028
VRTImageReadFunc
CPLErr(* VRTImageReadFunc)(void *hCBData, int nXOff, int nYOff, int nXSize, int nYSize, void *pData)
Type for a function that returns the pixel data in a provided window.
Definition: gdal_vrt.h:51
GSpacing
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:292
vsi_l_offset
GUIntBig vsi_l_offset
Type for a file offset.
Definition: cpl_vsi.h:142
GDALRasterBand::GetNoDataValue
virtual double GetNoDataValue(int *pbSuccess=nullptr)
Fetch the no data value for this band.
Definition: gdalrasterband.cpp:1665
GDALAccess
GDALAccess
Definition: gdal.h:116
GDALRasterBand::GetNoDataValueAsInt64
virtual int64_t GetNoDataValueAsInt64(int *pbSuccess=nullptr)
Fetch the no data value for this band.
Definition: gdalrasterband.cpp:1721
gdal_priv.h
GDALRasterBand::SetNoDataValueAsUInt64
virtual CPLErr SetNoDataValueAsUInt64(uint64_t nNoData)
Set the no data value for this band.
Definition: gdalrasterband.cpp:1994
GA_ReadOnly
@ GA_ReadOnly
Definition: gdal.h:117
GDALDimension::GetIndexingVariable
virtual std::shared_ptr< GDALMDArray > GetIndexingVariable() const
Return the variable that is used to index the dimension (if there is one).
Definition: gdalmultidim.cpp:8627
GDALDataset::GetSpatialRef
virtual const OGRSpatialReference * GetSpatialRef() const
Fetch the spatial reference for this dataset.
Definition: gdaldataset.cpp:911
GIntBig
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition: cpl_port.h:230
GDALDataset::SetGeoTransform
virtual CPLErr SetGeoTransform(double *padfTransform)
Set the affine transformation coefficients.
Definition: gdaldataset.cpp:1151
GDALMDArray::SetScale
virtual bool SetScale(double dfScale, GDALDataType eStorageType=GDT_Unknown)
Set the scale value to apply to raw values.
Definition: gdalmultidim.cpp:2440
GDALIHasAttribute::CreateAttribute
virtual std::shared_ptr< GDALAttribute > CreateAttribute(const std::string &osName, const std::vector< GUInt64 > &anDimensions, const GDALExtendedDataType &oDataType, CSLConstList papszOptions=nullptr)
Create an attribute within a GDALMDArray or GDALGroup.
Definition: gdalmultidim.cpp:254
GDALDataset::GetFileList
virtual char ** GetFileList(void)
Fetch files forming dataset.
Definition: gdaldataset.cpp:2907
GDALRasterBand::GetDefaultRAT
virtual GDALRasterAttributeTable * GetDefaultRAT()
Fetch default Raster Attribute Table.
Definition: gdalrasterband.cpp:6587
GDALRasterIOExtraArg
Structure to pass extra arguments to RasterIO() method, must be initialized with INIT_RASTERIO_EXTRA_...
Definition: gdal.h:161
GDALDataset::FlushCache
virtual void FlushCache(bool bAtClosing=false)
Flush all write cached data to disk.
Definition: gdaldataset.cpp:434
GDALMDArray::GetFilename
virtual const std::string & GetFilename() const =0
Return the filename that contains that array.
GDALRasterBand::GetScale
virtual double GetScale(int *pbSuccess=nullptr)
Fetch the raster value scale.
Definition: gdalrasterband.cpp:2858
GDALRWFlag
GDALRWFlag
Definition: gdal.h:122
GDALMDArray::CopyFrom
virtual bool CopyFrom(GDALDataset *poSrcDS, const GDALMDArray *poSrcArray, bool bStrict, GUInt64 &nCurCost, const GUInt64 nTotalCost, GDALProgressFunc pfnProgress, void *pProgressData)
Copy the content of an array into a new (generally empty) array.
Definition: gdalmultidim.cpp:3364
GDALRasterBand::SetColorInterpretation
virtual CPLErr SetColorInterpretation(GDALColorInterp eColorInterp)
Set color interpretation of a band.
Definition: gdalrasterband.cpp:2327
GDALGroup::GetDimensions
virtual std::vector< std::shared_ptr< GDALDimension > > GetDimensions(CSLConstList papszOptions=nullptr) const
Return the list of dimensions contained in this group and used by its arrays.
Definition: gdalmultidim.cpp:455
GDALMajorObject
Object with metadata.
Definition: gdal_priv.h:136
GDALPansharpenOperation
Pansharpening operation class.
Definition: gdalpansharpen.h:188
GDALDataset::SetMetadataItem
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
CPLErr
CPLErr
Error category.
Definition: cpl_error.h:52
GDALAttribute
Class modeling an attribute that has a name, a value and a type, and is typically used to describe a ...
Definition: gdal_priv.h:2338
GDALDataset::SetMetadata
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
GDALDerivedPixelFunc
CPLErr(* GDALDerivedPixelFunc)(void **papoSources, int nSources, void *pData, int nBufXSize, int nBufYSize, GDALDataType eSrcType, GDALDataType eBufType, int nPixelSpace, int nLineSpace)
Type of functions to pass to GDALAddDerivedBandPixelFunc.
Definition: gdal.h:1151
GDALRasterBand::SetCategoryNames
virtual CPLErr SetCategoryNames(char **papszNames)
Set the category names for this band.
Definition: gdalrasterband.cpp:1609
GDALRasterBand::GetHistogram
virtual CPLErr GetHistogram(double dfMin, double dfMax, int nBuckets, GUIntBig *panHistogram, int bIncludeOutOfRange, int bApproxOK, GDALProgressFunc, void *pProgressData)
Compute raster histogram.
Definition: gdalrasterband.cpp:3254
GDALGroup::GetMDArrayNames
virtual std::vector< std::string > GetMDArrayNames(CSLConstList papszOptions=nullptr) const
Return the list of multidimensional array names contained in this group.
Definition: gdalmultidim.cpp:300
GDALRasterBand::GetMaskFlags
virtual int GetMaskFlags()
Return the status flags of the mask band associated with the band.
Definition: gdalrasterband.cpp:7041
GDALDataset::GetGeoTransform
virtual CPLErr GetGeoTransform(double *padfTransform)
Fetch the affine transformation coefficients.
Definition: gdaldataset.cpp:1096
GDALGroup::OpenGroup
virtual std::shared_ptr< GDALGroup > OpenGroup(const std::string &osName, CSLConstList papszOptions=nullptr) const
Open and return a sub-group.
Definition: gdalmultidim.cpp:372
GDALRasterBand::CreateMaskBand
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the current band.
Definition: gdalrasterband.cpp:7122
GDALRasterBand::SetMetadata
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
GDALRasterAttributeTable
Definition: gdal_rat.h:47
GDALMDArray::GetRawNoDataValue
virtual const void * GetRawNoDataValue() const
Return the nodata value as a "raw" value.
Definition: gdalmultidim.cpp:2209
GDALGroup::OpenMDArray
virtual std::shared_ptr< GDALMDArray > OpenMDArray(const std::string &osName, CSLConstList papszOptions=nullptr) const
Open and return a multidimensional array.
Definition: gdalmultidim.cpp:324
GDALRasterBand::SetMetadataItem
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
GDALRasterBand::SetOffset
virtual CPLErr SetOffset(double dfNewOffset)
Set scaling offset.
Definition: gdalrasterband.cpp:2801
GDALRasterBandH
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:272
GDALMDArray::GetOffset
virtual double GetOffset(bool *pbHasOffset=nullptr, GDALDataType *peStorageType=nullptr) const
Get the offset value to apply to raw values.
Definition: gdalmultidim.cpp:2528
VRTCreate
VRTDatasetH VRTCreate(int, int)
Definition: vrtdataset.cpp:78
CPL_DISALLOW_COPY_ASSIGN
#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:930
GDALRasterBand::GetNoDataValueAsUInt64
virtual uint64_t GetNoDataValueAsUInt64(int *pbSuccess=nullptr)
Fetch the no data value for this band.
Definition: gdalrasterband.cpp:1782
GDALColorTable
A color table / palette.
Definition: gdal_priv.h:1044