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