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