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