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
49CPLErr GDALRegisterDefaultPixelFunc();
50void GDALVRTRegisterDefaultProcessedDatasetFuncs();
51CPLString VRTSerializeNoData(double dfVal, GDALDataType eDataType,
52 int nPrecision);
53
54#if 0
55int VRTWarpedOverviewTransform( void *pTransformArg, int bDstToSrc,
56 int nPointCount,
57 double *padfX, double *padfY, double *padfZ,
58 int *panSuccess );
59void* VRTDeserializeWarpedOverviewTransformer( CPLXMLNode *psTree );
60#endif
61
62/************************************************************************/
63/* VRTOverviewInfo() */
64/************************************************************************/
65class 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
77 VRTOverviewInfo(VRTOverviewInfo &&oOther) noexcept
78 : osFilename(std::move(oOther.osFilename)), nBand(oOther.nBand),
79 poBand(oOther.poBand), bTriedToOpen(oOther.bTriedToOpen)
80 {
81 oOther.poBand = nullptr;
82 }
83
84 ~VRTOverviewInfo()
85 {
86 CloseDataset();
87 }
88
89 bool CloseDataset()
90 {
91 if (poBand == nullptr)
92 return false;
93
94 GDALDataset *poDS = poBand->GetDataset();
95 // Nullify now, to prevent recursion in some cases !
96 poBand = nullptr;
97 if (poDS->GetShared())
98 GDALClose(/* (GDALDatasetH) */ poDS);
99 else
100 poDS->Dereference();
101
102 return true;
103 }
104};
105
106/************************************************************************/
107/* VRTSource */
108/************************************************************************/
109
110class CPL_DLL VRTSource
111{
112 public:
113 struct CPL_DLL WorkingState
114 {
115 // GByte whose initialization constructor does nothing
116#ifdef __GNUC__
117#pragma GCC diagnostic push
118#pragma GCC diagnostic ignored "-Weffc++"
119#endif
120 struct NoInitByte
121 {
122 GByte value;
123
124 // cppcheck-suppress uninitMemberVar
125 NoInitByte()
126 {
127 // do nothing
128 /* coverity[uninit_member] */
129 }
130
131 inline operator GByte() const
132 {
133 return value;
134 }
135 };
136#ifdef __GNUC__
137#pragma GCC diagnostic pop
138#endif
139
140 std::vector<NoInitByte> m_abyWrkBuffer{};
141 std::vector<NoInitByte> m_abyWrkBufferMask{};
142 };
143
144 virtual ~VRTSource();
145
146 virtual CPLErr RasterIO(GDALDataType eVRTBandDataType, int nXOff, int nYOff,
147 int nXSize, int nYSize, void *pData, int nBufXSize,
148 int nBufYSize, GDALDataType eBufType,
149 GSpacing nPixelSpace, GSpacing nLineSpace,
150 GDALRasterIOExtraArg *psExtraArg,
151 WorkingState &oWorkingState) = 0;
152
153 virtual double GetMinimum(int nXSize, int nYSize, int *pbSuccess) = 0;
154 virtual double GetMaximum(int nXSize, int nYSize, int *pbSuccess) = 0;
155 virtual CPLErr GetHistogram(int nXSize, int nYSize, double dfMin,
156 double dfMax, int nBuckets,
157 GUIntBig *panHistogram, int bIncludeOutOfRange,
158 int bApproxOK, GDALProgressFunc pfnProgress,
159 void *pProgressData) = 0;
160
161 virtual CPLErr XMLInit(const CPLXMLNode *psTree, const char *,
162 std::map<CPLString, GDALDataset *> &) = 0;
163 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath) = 0;
164
165 virtual void GetFileList(char ***ppapszFileList, int *pnSize,
166 int *pnMaxSize, CPLHashSet *hSetFiles);
167
168 virtual int IsSimpleSource()
169 {
170 return FALSE;
171 }
172
173 virtual CPLErr FlushCache(bool /*bAtClosing*/)
174 {
175 return CE_None;
176 }
177};
178
179typedef VRTSource *(*VRTSourceParser)(
180 const CPLXMLNode *, const char *,
181 std::map<CPLString, GDALDataset *> &oMapSharedSources);
182
183VRTSource *
184VRTParseCoreSources(const CPLXMLNode *psTree, const char *,
185 std::map<CPLString, GDALDataset *> &oMapSharedSources);
186VRTSource *
187VRTParseFilterSources(const CPLXMLNode *psTree, const char *,
188 std::map<CPLString, GDALDataset *> &oMapSharedSources);
189VRTSource *
190VRTParseArraySource(const CPLXMLNode *psTree, const char *,
191 std::map<CPLString, GDALDataset *> &oMapSharedSources);
192
193/************************************************************************/
194/* VRTDataset */
195/************************************************************************/
196
197class VRTRasterBand;
198
199template <class T> struct VRTFlushCacheStruct
200{
201 static CPLErr FlushCache(T &obj, bool bAtClosing);
202};
203
204class VRTWarpedDataset;
205class VRTPansharpenedDataset;
206class VRTProcessedDataset;
207class VRTGroup;
208
209class CPL_DLL VRTDataset CPL_NON_FINAL : public GDALDataset
210{
211 friend class VRTRasterBand;
212 friend struct VRTFlushCacheStruct<VRTDataset>;
213 friend struct VRTFlushCacheStruct<VRTWarpedDataset>;
214 friend struct VRTFlushCacheStruct<VRTPansharpenedDataset>;
215 friend struct VRTFlushCacheStruct<VRTProcessedDataset>;
216 friend class VRTSourcedRasterBand;
217 friend class VRTSimpleSource;
218 friend VRTDatasetH CPL_STDCALL VRTCreate(int nXSize, int nYSize);
219
220 std::vector<gdal::GCP> m_asGCPs{};
221 std::unique_ptr<OGRSpatialReference, OGRSpatialReferenceReleaser>
222 m_poGCP_SRS{};
223
224 bool m_bNeedsFlush = false;
225 bool m_bWritable = true;
226 bool m_bCanTakeRef = true;
227
228 char *m_pszVRTPath = nullptr;
229
230 VRTRasterBand *m_poMaskBand = nullptr;
231
232 int m_bCompatibleForDatasetIO = -1;
233 int CheckCompatibleForDatasetIO();
234
235 // Virtual (ie not materialized) overviews, created either implicitly
236 // when it is cheap to do it, or explicitly.
237 std::vector<GDALDataset *> m_apoOverviews{};
238 std::vector<GDALDataset *> m_apoOverviewsBak{};
239 CPLStringList m_aosOverviewList{}; // only temporarily set during Open()
240 CPLString m_osOverviewResampling{};
241 std::vector<int> m_anOverviewFactors{};
242
243 char **m_papszXMLVRTMetadata = nullptr;
244
245 std::map<CPLString, GDALDataset *> m_oMapSharedSources{};
246 std::shared_ptr<VRTGroup> m_poRootGroup{};
247
248 VRTSource::WorkingState m_oWorkingState{};
249
250 static constexpr const char *const apszSpecialSyntax[] = {
251 "NITF_IM:{ANY}:{FILENAME}", "PDF:{ANY}:{FILENAME}",
252 "RASTERLITE:{FILENAME},{ANY}", "TILEDB:\"{FILENAME}\":{ANY}",
253 "TILEDB:{FILENAME}:{ANY}"};
254
255 VRTRasterBand *InitBand(const char *pszSubclass, int nBand,
256 bool bAllowPansharpenedOrProcessed);
257 static GDALDataset *OpenVRTProtocol(const char *pszSpec);
258 bool AddVirtualOverview(int nOvFactor, const char *pszResampling);
259
260 bool GetShiftedDataset(int nXOff, int nYOff, int nXSize, int nYSize,
261 GDALDataset *&poSrcDataset, int &nSrcXOff,
262 int &nSrcYOff);
263
264 CPL_DISALLOW_COPY_ASSIGN(VRTDataset)
265
266 protected:
267 bool m_bBlockSizeSpecified = false;
268 int m_nBlockXSize = 0;
269 int m_nBlockYSize = 0;
270
271 std::unique_ptr<OGRSpatialReference, OGRSpatialReferenceReleaser> m_poSRS{};
272
273 int m_bGeoTransformSet = false;
274 double m_adfGeoTransform[6];
275
276 virtual int CloseDependentDatasets() override;
277
278 public:
279 VRTDataset(int nXSize, int nYSize, int nBlockXSize = 0,
280 int nBlockYSize = 0);
281 virtual ~VRTDataset();
282
283 void SetNeedsFlush()
284 {
285 m_bNeedsFlush = true;
286 }
287
288 virtual CPLErr FlushCache(bool bAtClosing) override;
289
290 void SetWritable(int bWritableIn)
291 {
292 m_bWritable = CPL_TO_BOOL(bWritableIn);
293 }
294
295 virtual CPLErr CreateMaskBand(int nFlags) override;
296 void SetMaskBand(VRTRasterBand *poMaskBand);
297
298 const OGRSpatialReference *GetSpatialRef() const override
299 {
300 return m_poSRS.get();
301 }
302
303 CPLErr SetSpatialRef(const OGRSpatialReference *poSRS) override;
304
305 virtual CPLErr GetGeoTransform(double *) override;
306 virtual CPLErr SetGeoTransform(double *) override;
307
308 virtual CPLErr SetMetadata(char **papszMetadata,
309 const char *pszDomain = "") override;
310 virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
311 const char *pszDomain = "") override;
312
313 virtual char **GetMetadata(const char *pszDomain = "") override;
314
315 virtual int GetGCPCount() override;
316
317 const OGRSpatialReference *GetGCPSpatialRef() const override
318 {
319 return m_poGCP_SRS.get();
320 }
321
322 virtual const GDAL_GCP *GetGCPs() override;
324 CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList,
325 const OGRSpatialReference *poSRS) override;
326
327 virtual CPLErr AddBand(GDALDataType eType,
328 char **papszOptions = nullptr) override;
329
330 virtual char **GetFileList() override;
331
332 virtual CPLErr IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
333 int nXSize, int nYSize, void *pData, int nBufXSize,
334 int nBufYSize, GDALDataType eBufType,
335 int nBandCount, int *panBandMap,
336 GSpacing nPixelSpace, GSpacing nLineSpace,
337 GSpacing nBandSpace,
338 GDALRasterIOExtraArg *psExtraArg) override;
339
340 virtual CPLStringList
341 GetCompressionFormats(int nXOff, int nYOff, int nXSize, int nYSize,
342 int nBandCount, const int *panBandList) override;
343 virtual CPLErr ReadCompressedData(const char *pszFormat, int nXOff,
344 int nYOff, int nXSize, int nYSize,
345 int nBandCount, const int *panBandList,
346 void **ppBuffer, size_t *pnBufferSize,
347 char **ppszDetailedFormat) override;
348
349 virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize,
350 int nBufXSize, int nBufYSize, GDALDataType eDT,
351 int nBandCount, int *panBandList,
352 char **papszOptions) override;
353
354 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath);
355 virtual CPLErr XMLInit(const CPLXMLNode *, const char *);
356
357 virtual CPLErr IBuildOverviews(const char *, int, const int *, int,
358 const int *, GDALProgressFunc, void *,
359 CSLConstList papszOptions) override;
360
361 std::shared_ptr<GDALGroup> GetRootGroup() const override;
362
363 void ClearStatistics() override;
364
365 /* Used by PDF driver for example */
366 GDALDataset *GetSingleSimpleSource();
367 void BuildVirtualOverviews();
368
369 void UnsetPreservedRelativeFilenames();
370
371 bool IsBlockSizeSpecified() const
372 {
373 return m_bBlockSizeSpecified;
374 }
375
376 int GetBlockXSize() const
377 {
378 return m_nBlockXSize;
379 }
380
381 int GetBlockYSize() const
382 {
383 return m_nBlockYSize;
384 }
385
386 static int Identify(GDALOpenInfo *);
387 static GDALDataset *Open(GDALOpenInfo *);
388 static VRTDataset *OpenXML(const char *, const char * = nullptr,
389 GDALAccess eAccess = GA_ReadOnly);
390 static GDALDataset *Create(const char *pszName, int nXSize, int nYSize,
391 int nBands, GDALDataType eType,
392 char **papszOptions);
393 static GDALDataset *
394 CreateMultiDimensional(const char *pszFilename,
395 CSLConstList papszRootGroupOptions,
396 CSLConstList papszOptions);
397 static CPLErr Delete(const char *pszFilename);
398
399 static std::string BuildSourceFilename(const char *pszFilename,
400 const char *pszVRTPath,
401 bool bRelativeToVRT);
402};
403
404/************************************************************************/
405/* VRTWarpedDataset */
406/************************************************************************/
407
409class VRTWarpedRasterBand;
410
411class CPL_DLL VRTWarpedDataset final : public VRTDataset
412{
413 GDALWarpOperation *m_poWarper;
414
415 int m_nOverviewCount;
416 VRTWarpedDataset **m_papoOverviews;
417 int m_nSrcOvrLevel;
418
419 void CreateImplicitOverviews();
420
421 friend class VRTWarpedRasterBand;
422
423 CPL_DISALLOW_COPY_ASSIGN(VRTWarpedDataset)
424
425 protected:
426 virtual int CloseDependentDatasets() override;
427
428 public:
429 VRTWarpedDataset(int nXSize, int nYSize, int nBlockXSize = 0,
430 int nBlockYSize = 0);
431 virtual ~VRTWarpedDataset();
432
433 virtual CPLErr FlushCache(bool bAtClosing) override;
434
435 CPLErr Initialize(/* GDALWarpOptions */ void *);
436
437 virtual CPLErr IBuildOverviews(const char *, int, const int *, int,
438 const int *, GDALProgressFunc, void *,
439 CSLConstList papszOptions) override;
440
441 virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
442 const char *pszDomain = "") override;
443
444 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath) override;
445 virtual CPLErr XMLInit(const CPLXMLNode *, const char *) override;
446
447 virtual CPLErr AddBand(GDALDataType eType,
448 char **papszOptions = nullptr) override;
449
450 virtual char **GetFileList() override;
451
452 virtual CPLErr IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
453 int nXSize, int nYSize, void *pData, int nBufXSize,
454 int nBufYSize, GDALDataType eBufType,
455 int nBandCount, int *panBandMap,
456 GSpacing nPixelSpace, GSpacing nLineSpace,
457 GSpacing nBandSpace,
458 GDALRasterIOExtraArg *psExtraArg) override;
459
460 CPLErr ProcessBlock(int iBlockX, int iBlockY);
461
462 void GetBlockSize(int *, int *) const;
463};
464
465/************************************************************************/
466/* VRTPansharpenedDataset */
467/************************************************************************/
468
470
471typedef enum
472{
473 GTAdjust_Union,
474 GTAdjust_Intersection,
475 GTAdjust_None,
476 GTAdjust_NoneWithoutWarning
477} GTAdjustment;
478
479class VRTPansharpenedDataset final : public VRTDataset
480{
481 friend class VRTPansharpenedRasterBand;
482
483 GDALPansharpenOperation *m_poPansharpener;
484 VRTPansharpenedDataset *m_poMainDataset;
485 std::vector<VRTPansharpenedDataset *> m_apoOverviewDatasets{};
486 // Map from absolute to relative.
487 std::map<CPLString, CPLString> m_oMapToRelativeFilenames{};
488
489 int m_bLoadingOtherBands;
490
491 GByte *m_pabyLastBufferBandRasterIO;
492 int m_nLastBandRasterIOXOff;
493 int m_nLastBandRasterIOYOff;
494 int m_nLastBandRasterIOXSize;
495 int m_nLastBandRasterIOYSize;
496 GDALDataType m_eLastBandRasterIODataType;
497
498 GTAdjustment m_eGTAdjustment;
499 int m_bNoDataDisabled;
500
501 std::vector<GDALDataset *> m_apoDatasetsToClose{};
502
503 CPL_DISALLOW_COPY_ASSIGN(VRTPansharpenedDataset)
504
505 protected:
506 virtual int CloseDependentDatasets() override;
507
508 public:
509 VRTPansharpenedDataset(int nXSize, int nYSize, int nBlockXSize = 0,
510 int nBlockYSize = 0);
511 virtual ~VRTPansharpenedDataset();
512
513 virtual CPLErr FlushCache(bool bAtClosing) override;
514
515 virtual CPLErr XMLInit(const CPLXMLNode *, const char *) override;
516 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath) override;
517
518 CPLErr XMLInit(const CPLXMLNode *psTree, const char *pszVRTPath,
519 GDALRasterBandH hPanchroBandIn, int nInputSpectralBandsIn,
520 GDALRasterBandH *pahInputSpectralBandsIn);
521
522 virtual CPLErr AddBand(GDALDataType eType,
523 char **papszOptions = nullptr) override;
524
525 virtual char **GetFileList() override;
526
527 virtual CPLErr IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
528 int nXSize, int nYSize, void *pData, int nBufXSize,
529 int nBufYSize, GDALDataType eBufType,
530 int nBandCount, int *panBandMap,
531 GSpacing nPixelSpace, GSpacing nLineSpace,
532 GSpacing nBandSpace,
533 GDALRasterIOExtraArg *psExtraArg) override;
534
535 void GetBlockSize(int *, int *) const;
536
537 GDALPansharpenOperation *GetPansharpener()
538 {
539 return m_poPansharpener;
540 }
541};
542
543/************************************************************************/
544/* VRTPansharpenedDataset */
545/************************************************************************/
546
552class VRTProcessedDataset final : public VRTDataset
553{
554 public:
555 VRTProcessedDataset(int nXSize, int nYSize);
556 ~VRTProcessedDataset() override;
557
558 virtual CPLErr FlushCache(bool bAtClosing) override;
559
560 virtual CPLErr XMLInit(const CPLXMLNode *, const char *) override;
561 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath) override;
562
563 void GetBlockSize(int *, int *) const;
564
565 // GByte whose initialization constructor does nothing
566#ifdef __GNUC__
567#pragma GCC diagnostic push
568#pragma GCC diagnostic ignored "-Weffc++"
569#endif
570 struct NoInitByte
571 {
572 GByte value;
573
574 // cppcheck-suppress uninitMemberVar
575 NoInitByte()
576 {
577 // do nothing
578 /* coverity[uninit_member] */
579 }
580
581 inline operator GByte() const
582 {
583 return value;
584 }
585 };
586#ifdef __GNUC__
587#pragma GCC diagnostic pop
588#endif
589
590 private:
591 friend class VRTProcessedRasterBand;
592
594 struct Step
595 {
597 std::string osAlgorithm{};
598
600 CPLStringList aosArguments{};
601
604
606 GDALDataType eOutDT = GDT_Unknown;
607
609 int nInBands = 0;
610
612 int nOutBands = 0;
613
615 std::vector<double> adfInNoData{};
616
618 std::vector<double> adfOutNoData{};
619
621 VRTPDWorkingDataPtr pWorkingData = nullptr;
622
623 // NOTE: if adding a new member, edit the move constructor and
624 // assignment operators!
625
626 Step() = default;
627 ~Step();
628 Step(Step &&);
629 Step &operator=(Step &&);
630
631 private:
632 Step(const Step &) = delete;
633 Step &operator=(const Step &) = delete;
634 void deinit();
635 };
636
638 std::string m_osVRTPath{};
639
641 std::unique_ptr<GDALDataset> m_poSrcDS{};
642
644 std::vector<Step> m_aoSteps{};
645
647 CPLXMLTreeCloser m_oXMLTree{nullptr};
648
650 std::vector<std::unique_ptr<GDALDataset>> m_apoOverviewDatasets{};
651
653 std::vector<NoInitByte> m_abyInput{};
654
656 std::vector<NoInitByte> m_abyOutput{};
657
658 CPLErr Init(const CPLXMLNode *, const char *,
659 const VRTProcessedDataset *poParentDS,
660 GDALDataset *poParentSrcDS, int iOvrLevel);
661
662 bool ParseStep(const CPLXMLNode *psStep, bool bIsFinalStep,
663 GDALDataType &eCurrentDT, int &nCurrentBandCount,
664 std::vector<double> &adfInNoData,
665 std::vector<double> &adfOutNoData);
666 bool ProcessRegion(int nXOff, int nYOff, int nBufXSize, int nBufYSize);
667};
668
669/************************************************************************/
670/* VRTRasterBand */
671/* */
672/* Provides support for all the various kinds of metadata but */
673/* no raster access. That is handled by derived classes. */
674/************************************************************************/
675
676constexpr double VRT_DEFAULT_NODATA_VALUE = -10000.0;
677
678class CPL_DLL VRTRasterBand CPL_NON_FINAL : public GDALRasterBand
679{
680 private:
681 void ResetNoDataValues();
682
683 protected:
684 friend class VRTDataset;
685
686 int m_bIsMaskBand = FALSE;
687
688 int m_bNoDataValueSet = FALSE;
689 // If set to true, will not report the existence of nodata.
690 int m_bHideNoDataValue = FALSE;
691 double m_dfNoDataValue = VRT_DEFAULT_NODATA_VALUE;
692
693 bool m_bNoDataSetAsInt64 = false;
694 int64_t m_nNoDataValueInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_INT64;
695
696 bool m_bNoDataSetAsUInt64 = false;
697 uint64_t m_nNoDataValueUInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64;
698
699 std::unique_ptr<GDALColorTable> m_poColorTable{};
700
701 GDALColorInterp m_eColorInterp = GCI_Undefined;
702
703 char *m_pszUnitType = nullptr;
704 CPLStringList m_aosCategoryNames{};
705
706 double m_dfOffset = 0.0;
707 double m_dfScale = 1.0;
708
709 CPLXMLNode *m_psSavedHistograms = nullptr;
710
711 void Initialize(int nXSize, int nYSize);
712
713 std::vector<VRTOverviewInfo> m_aoOverviewInfos{};
714
715 VRTRasterBand *m_poMaskBand = nullptr;
716
717 std::unique_ptr<GDALRasterAttributeTable> m_poRAT{};
718
719 CPL_DISALLOW_COPY_ASSIGN(VRTRasterBand)
720
721 bool IsNoDataValueInDataTypeRange() const;
722
723 public:
724 VRTRasterBand();
725 virtual ~VRTRasterBand();
726
727 virtual CPLErr XMLInit(const CPLXMLNode *, const char *,
728 std::map<CPLString, GDALDataset *> &);
729 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath,
730 bool &bHasWarnedAboutRAMUsage,
731 size_t &nAccRAMUsage);
732
733 CPLErr SetNoDataValue(double) override;
734 CPLErr SetNoDataValueAsInt64(int64_t nNoData) override;
735 CPLErr SetNoDataValueAsUInt64(uint64_t nNoData) override;
736 double GetNoDataValue(int *pbSuccess = nullptr) override;
737 int64_t GetNoDataValueAsInt64(int *pbSuccess = nullptr) override;
738 uint64_t GetNoDataValueAsUInt64(int *pbSuccess = nullptr) override;
739 CPLErr DeleteNoDataValue() override;
740
741 virtual CPLErr SetColorTable(GDALColorTable *) override;
742 virtual GDALColorTable *GetColorTable() override;
743
744 virtual GDALRasterAttributeTable *GetDefaultRAT() override;
745 virtual CPLErr
746 SetDefaultRAT(const GDALRasterAttributeTable *poRAT) override;
747
748 virtual CPLErr SetColorInterpretation(GDALColorInterp) override;
749 virtual GDALColorInterp GetColorInterpretation() override;
750
751 virtual const char *GetUnitType() override;
752 CPLErr SetUnitType(const char *) override;
753
754 virtual char **GetCategoryNames() override;
755 virtual CPLErr SetCategoryNames(char **) override;
756
757 virtual CPLErr SetMetadata(char **papszMD,
758 const char *pszDomain = "") override;
759 virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
760 const char *pszDomain = "") override;
761
762 virtual double GetOffset(int *pbSuccess = nullptr) override;
763 CPLErr SetOffset(double) override;
764 virtual double GetScale(int *pbSuccess = nullptr) override;
765 CPLErr SetScale(double) override;
766
767 virtual int GetOverviewCount() override;
768 virtual GDALRasterBand *GetOverview(int) override;
769
770 virtual CPLErr GetHistogram(double dfMin, double dfMax, int nBuckets,
771 GUIntBig *panHistogram, int bIncludeOutOfRange,
772 int bApproxOK, GDALProgressFunc,
773 void *pProgressData) override;
774
775 virtual CPLErr GetDefaultHistogram(double *pdfMin, double *pdfMax,
776 int *pnBuckets, GUIntBig **ppanHistogram,
777 int bForce, GDALProgressFunc,
778 void *pProgressData) override;
779
780 virtual CPLErr SetDefaultHistogram(double dfMin, double dfMax, int nBuckets,
781 GUIntBig *panHistogram) override;
782
783 CPLErr CopyCommonInfoFrom(GDALRasterBand *);
784
785 virtual void GetFileList(char ***ppapszFileList, int *pnSize,
786 int *pnMaxSize, CPLHashSet *hSetFiles);
787
788 virtual void SetDescription(const char *) override;
789
790 virtual GDALRasterBand *GetMaskBand() override;
791 virtual int GetMaskFlags() override;
792
793 virtual CPLErr CreateMaskBand(int nFlagsIn) override;
794
795 void SetMaskBand(VRTRasterBand *poMaskBand);
796
797 void SetIsMaskBand();
798
799 virtual bool IsMaskBand() const override;
800
801 CPLErr UnsetNoDataValue();
802
803 virtual int CloseDependentDatasets();
804
805 virtual int IsSourcedRasterBand()
806 {
807 return FALSE;
808 }
809
810 virtual int IsPansharpenRasterBand()
811 {
812 return FALSE;
813 }
814};
815
816/************************************************************************/
817/* VRTSourcedRasterBand */
818/************************************************************************/
819
820class VRTSimpleSource;
821
822class CPL_DLL VRTSourcedRasterBand CPL_NON_FINAL : public VRTRasterBand
823{
824 private:
825 CPLString m_osLastLocationInfo{};
826 char **m_papszSourceList = nullptr;
827 int m_nSkipBufferInitialization = -1;
828
829 bool CanUseSourcesMinMaxImplementations();
830
831 bool IsMosaicOfNonOverlappingSimpleSourcesOfFullRasterNoResAndTypeChange(
832 bool bAllowMaxValAdjustment) const;
833
834 CPL_DISALLOW_COPY_ASSIGN(VRTSourcedRasterBand)
835
836 protected:
837 bool SkipBufferInitialization();
838
839 public:
840 int nSources = 0;
841 VRTSource **papoSources = nullptr;
842
843 VRTSourcedRasterBand(GDALDataset *poDS, int nBand);
844 VRTSourcedRasterBand(GDALDataType eType, int nXSize, int nYSize);
845 VRTSourcedRasterBand(GDALDataset *poDS, int nBand, GDALDataType eType,
846 int nXSize, int nYSize);
847 VRTSourcedRasterBand(GDALDataset *poDS, int nBand, GDALDataType eType,
848 int nXSize, int nYSize, int nBlockXSizeIn,
849 int nBlockYSizeIn);
850 virtual ~VRTSourcedRasterBand();
851
852 virtual CPLErr IRasterIO(GDALRWFlag, int, int, int, int, void *, int, int,
853 GDALDataType, GSpacing nPixelSpace,
854 GSpacing nLineSpace,
855 GDALRasterIOExtraArg *psExtraArg) override;
856
857 virtual int IGetDataCoverageStatus(int nXOff, int nYOff, int nXSize,
858 int nYSize, int nMaskFlagStop,
859 double *pdfDataPct) override;
860
861 virtual char **GetMetadataDomainList() override;
862 virtual const char *GetMetadataItem(const char *pszName,
863 const char *pszDomain = "") override;
864 virtual char **GetMetadata(const char *pszDomain = "") override;
865 virtual CPLErr SetMetadata(char **papszMetadata,
866 const char *pszDomain = "") override;
867 virtual CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
868 const char *pszDomain = "") override;
869
870 virtual CPLErr XMLInit(const CPLXMLNode *, const char *,
871 std::map<CPLString, GDALDataset *> &) override;
872 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath,
873 bool &bHasWarnedAboutRAMUsage,
874 size_t &nAccRAMUsage) override;
875
876 virtual double GetMinimum(int *pbSuccess = nullptr) override;
877 virtual double GetMaximum(int *pbSuccess = nullptr) override;
878 virtual CPLErr ComputeRasterMinMax(int bApproxOK,
879 double *adfMinMax) override;
880 virtual CPLErr ComputeStatistics(int bApproxOK, double *pdfMin,
881 double *pdfMax, double *pdfMean,
882 double *pdfStdDev,
883 GDALProgressFunc pfnProgress,
884 void *pProgressData) override;
885 virtual CPLErr GetHistogram(double dfMin, double dfMax, int nBuckets,
886 GUIntBig *panHistogram, int bIncludeOutOfRange,
887 int bApproxOK, GDALProgressFunc pfnProgress,
888 void *pProgressData) override;
889
890 CPLErr AddSource(VRTSource *);
891
892 CPLErr AddSimpleSource(const char *pszFilename, int nBand,
893 double dfSrcXOff = -1, double dfSrcYOff = -1,
894 double dfSrcXSize = -1, double dfSrcYSize = -1,
895 double dfDstXOff = -1, double dfDstYOff = -1,
896 double dfDstXSize = -1, double dfDstYSize = -1,
897 const char *pszResampling = "near",
898 double dfNoDataValue = VRT_NODATA_UNSET);
899
900 CPLErr AddSimpleSource(GDALRasterBand *poSrcBand, double dfSrcXOff = -1,
901 double dfSrcYOff = -1, double dfSrcXSize = -1,
902 double dfSrcYSize = -1, double dfDstXOff = -1,
903 double dfDstYOff = -1, double dfDstXSize = -1,
904 double dfDstYSize = -1,
905 const char *pszResampling = "near",
906 double dfNoDataValue = VRT_NODATA_UNSET);
907
908 CPLErr AddComplexSource(const char *pszFilename, int nBand,
909 double dfSrcXOff = -1, double dfSrcYOff = -1,
910 double dfSrcXSize = -1, double dfSrcYSize = -1,
911 double dfDstXOff = -1, double dfDstYOff = -1,
912 double dfDstXSize = -1, double dfDstYSize = -1,
913 double dfScaleOff = 0.0, double dfScaleRatio = 1.0,
914 double dfNoDataValue = VRT_NODATA_UNSET,
915 int nColorTableComponent = 0);
916
917 CPLErr AddComplexSource(GDALRasterBand *poSrcBand, double dfSrcXOff = -1,
918 double dfSrcYOff = -1, double dfSrcXSize = -1,
919 double dfSrcYSize = -1, double dfDstXOff = -1,
920 double dfDstYOff = -1, double dfDstXSize = -1,
921 double dfDstYSize = -1, double dfScaleOff = 0.0,
922 double dfScaleRatio = 1.0,
923 double dfNoDataValue = VRT_NODATA_UNSET,
924 int nColorTableComponent = 0);
925
926 CPLErr AddMaskBandSource(GDALRasterBand *poSrcBand, double dfSrcXOff = -1,
927 double dfSrcYOff = -1, double dfSrcXSize = -1,
928 double dfSrcYSize = -1, double dfDstXOff = -1,
929 double dfDstYOff = -1, double dfDstXSize = -1,
930 double dfDstYSize = -1);
931
932 CPLErr AddFuncSource(VRTImageReadFunc pfnReadFunc, void *hCBData,
933 double dfNoDataValue = VRT_NODATA_UNSET);
934
935 void ConfigureSource(VRTSimpleSource *poSimpleSource,
936 GDALRasterBand *poSrcBand, int bAddAsMaskBand,
937 double dfSrcXOff, double dfSrcYOff, double dfSrcXSize,
938 double dfSrcYSize, double dfDstXOff, double dfDstYOff,
939 double dfDstXSize, double dfDstYSize);
940
941 void RemoveCoveredSources(CSLConstList papszOptions = nullptr);
942
943 bool CanIRasterIOBeForwardedToEachSource(
944 GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize,
945 int nBufXSize, int nBufYSize, GDALRasterIOExtraArg *psExtraArg) const;
946
947 virtual CPLErr IReadBlock(int, int, void *) override;
948
949 virtual void GetFileList(char ***ppapszFileList, int *pnSize,
950 int *pnMaxSize, CPLHashSet *hSetFiles) override;
951
952 virtual int CloseDependentDatasets() override;
953
954 virtual int IsSourcedRasterBand() override
955 {
956 return TRUE;
957 }
958
959 virtual CPLErr FlushCache(bool bAtClosing) override;
960};
961
962/************************************************************************/
963/* VRTWarpedRasterBand */
964/************************************************************************/
965
966class CPL_DLL VRTWarpedRasterBand final : public VRTRasterBand
967{
968 public:
969 VRTWarpedRasterBand(GDALDataset *poDS, int nBand,
970 GDALDataType eType = GDT_Unknown);
971 virtual ~VRTWarpedRasterBand();
972
973 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath,
974 bool &bHasWarnedAboutRAMUsage,
975 size_t &nAccRAMUsage) override;
976
977 virtual CPLErr IReadBlock(int, int, void *) override;
978 virtual CPLErr IWriteBlock(int, int, void *) override;
979
980 virtual CPLErr IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
981 int nXSize, int nYSize, void *pData, int nBufXSize,
982 int nBufYSize, GDALDataType eBufType,
983 GSpacing nPixelSpace, GSpacing nLineSpace,
984 GDALRasterIOExtraArg *psExtraArg) override;
985
986 virtual int GetOverviewCount() override;
987 virtual GDALRasterBand *GetOverview(int) override;
988
989 private:
990 int m_nIRasterIOCounter =
991 0;
992};
993
994/************************************************************************/
995/* VRTPansharpenedRasterBand */
996/************************************************************************/
997
998class VRTPansharpenedRasterBand final : public VRTRasterBand
999{
1000 int m_nIndexAsPansharpenedBand;
1001
1002 public:
1003 VRTPansharpenedRasterBand(GDALDataset *poDS, int nBand,
1004 GDALDataType eDataType = GDT_Unknown);
1005 virtual ~VRTPansharpenedRasterBand();
1006
1007 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath,
1008 bool &bHasWarnedAboutRAMUsage,
1009 size_t &nAccRAMUsage) override;
1010
1011 virtual CPLErr IReadBlock(int, int, void *) override;
1012
1013 virtual CPLErr IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff,
1014 int nXSize, int nYSize, void *pData, int nBufXSize,
1015 int nBufYSize, GDALDataType eBufType,
1016 GSpacing nPixelSpace, GSpacing nLineSpace,
1017 GDALRasterIOExtraArg *psExtraArg) override;
1018
1019 virtual int GetOverviewCount() override;
1020 virtual GDALRasterBand *GetOverview(int) override;
1021
1022 virtual int IsPansharpenRasterBand() override
1023 {
1024 return TRUE;
1025 }
1026
1027 void SetIndexAsPansharpenedBand(int nIdx)
1028 {
1029 m_nIndexAsPansharpenedBand = nIdx;
1030 }
1031
1032 int GetIndexAsPansharpenedBand() const
1033 {
1034 return m_nIndexAsPansharpenedBand;
1035 }
1036};
1037
1038/************************************************************************/
1039/* VRTProcessedRasterBand */
1040/************************************************************************/
1041
1042class VRTProcessedRasterBand final : public VRTRasterBand
1043{
1044 public:
1045 VRTProcessedRasterBand(VRTProcessedDataset *poDS, int nBand,
1046 GDALDataType eDataType = GDT_Unknown);
1047
1048 virtual CPLErr IReadBlock(int, int, void *) override;
1049
1050 virtual int GetOverviewCount() override;
1051 virtual GDALRasterBand *GetOverview(int) override;
1052
1053 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath,
1054 bool &bHasWarnedAboutRAMUsage,
1055 size_t &nAccRAMUsage) override;
1056};
1057
1058/************************************************************************/
1059/* VRTDerivedRasterBand */
1060/************************************************************************/
1061
1062class VRTDerivedRasterBandPrivateData;
1063
1064class CPL_DLL VRTDerivedRasterBand CPL_NON_FINAL : public VRTSourcedRasterBand
1065{
1066 VRTDerivedRasterBandPrivateData *m_poPrivate;
1067 bool InitializePython();
1068 CPLErr
1069 GetPixelFunctionArguments(const CPLString &,
1070 std::vector<std::pair<CPLString, CPLString>> &);
1071
1072 CPL_DISALLOW_COPY_ASSIGN(VRTDerivedRasterBand)
1073
1074 public:
1075 char *pszFuncName;
1076 GDALDataType eSourceTransferType;
1077
1078 using PixelFunc =
1079 std::function<CPLErr(void **, int, void *, int, int, GDALDataType,
1080 GDALDataType, int, int, CSLConstList)>;
1081
1082 VRTDerivedRasterBand(GDALDataset *poDS, int nBand);
1083 VRTDerivedRasterBand(GDALDataset *poDS, int nBand, GDALDataType eType,
1084 int nXSize, int nYSize);
1085 virtual ~VRTDerivedRasterBand();
1086
1087 virtual CPLErr IRasterIO(GDALRWFlag, int, int, int, int, void *, int, int,
1088 GDALDataType, GSpacing nPixelSpace,
1089 GSpacing nLineSpace,
1090 GDALRasterIOExtraArg *psExtraArg) override;
1091
1092 virtual int IGetDataCoverageStatus(int nXOff, int nYOff, int nXSize,
1093 int nYSize, int nMaskFlagStop,
1094 double *pdfDataPct) override;
1095
1096 static CPLErr AddPixelFunction(const char *pszFuncNameIn,
1097 GDALDerivedPixelFunc pfnPixelFunc);
1098 static CPLErr AddPixelFunction(const char *pszFuncNameIn,
1099 GDALDerivedPixelFuncWithArgs pfnPixelFunc,
1100 const char *pszMetadata);
1101
1102 static const std::pair<PixelFunc, std::string> *
1103 GetPixelFunction(const char *pszFuncNameIn);
1104
1105 void SetPixelFunctionName(const char *pszFuncNameIn);
1106 void SetSourceTransferType(GDALDataType eDataType);
1107 void SetPixelFunctionLanguage(const char *pszLanguage);
1108
1109 virtual CPLErr XMLInit(const CPLXMLNode *, const char *,
1110 std::map<CPLString, GDALDataset *> &) override;
1111 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath,
1112 bool &bHasWarnedAboutRAMUsage,
1113 size_t &nAccRAMUsage) override;
1114
1115 virtual double GetMinimum(int *pbSuccess = nullptr) override;
1116 virtual double GetMaximum(int *pbSuccess = nullptr) override;
1117 virtual CPLErr ComputeRasterMinMax(int bApproxOK,
1118 double *adfMinMax) override;
1119 virtual CPLErr ComputeStatistics(int bApproxOK, double *pdfMin,
1120 double *pdfMax, double *pdfMean,
1121 double *pdfStdDev,
1122 GDALProgressFunc pfnProgress,
1123 void *pProgressData) override;
1124 virtual CPLErr GetHistogram(double dfMin, double dfMax, int nBuckets,
1125 GUIntBig *panHistogram, int bIncludeOutOfRange,
1126 int bApproxOK, GDALProgressFunc pfnProgress,
1127 void *pProgressData) override;
1128
1129 static void Cleanup();
1130};
1131
1132/************************************************************************/
1133/* VRTRawRasterBand */
1134/************************************************************************/
1135
1136class RawRasterBand;
1137
1138class CPL_DLL VRTRawRasterBand CPL_NON_FINAL : public VRTRasterBand
1139{
1140 RawRasterBand *m_poRawRaster;
1141
1142 char *m_pszSourceFilename;
1143 int m_bRelativeToVRT;
1144
1145 CPL_DISALLOW_COPY_ASSIGN(VRTRawRasterBand)
1146
1147 public:
1148 VRTRawRasterBand(GDALDataset *poDS, int nBand,
1149 GDALDataType eType = GDT_Unknown);
1150 virtual ~VRTRawRasterBand();
1151
1152 virtual CPLErr XMLInit(const CPLXMLNode *, const char *,
1153 std::map<CPLString, GDALDataset *> &) override;
1154 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath,
1155 bool &bHasWarnedAboutRAMUsage,
1156 size_t &nAccRAMUsage) override;
1157
1158 virtual CPLErr IRasterIO(GDALRWFlag, int, int, int, int, void *, int, int,
1159 GDALDataType, GSpacing nPixelSpace,
1160 GSpacing nLineSpace,
1161 GDALRasterIOExtraArg *psExtraArg) override;
1162
1163 virtual CPLErr IReadBlock(int, int, void *) override;
1164 virtual CPLErr IWriteBlock(int, int, void *) override;
1165
1166 CPLErr SetRawLink(const char *pszFilename, const char *pszVRTPath,
1167 int bRelativeToVRT, vsi_l_offset nImageOffset,
1168 int nPixelOffset, int nLineOffset,
1169 const char *pszByteOrder);
1170
1171 void ClearRawLink();
1172
1173 CPLVirtualMem *GetVirtualMemAuto(GDALRWFlag eRWFlag, int *pnPixelSpace,
1174 GIntBig *pnLineSpace,
1175 char **papszOptions) override;
1176
1177 virtual void GetFileList(char ***ppapszFileList, int *pnSize,
1178 int *pnMaxSize, CPLHashSet *hSetFiles) override;
1179};
1180
1181/************************************************************************/
1182/* VRTDriver */
1183/************************************************************************/
1184
1185class VRTDriver final : public GDALDriver
1186{
1187 CPL_DISALLOW_COPY_ASSIGN(VRTDriver)
1188
1189 std::map<std::string, VRTSourceParser> m_oMapSourceParser{};
1190
1191 public:
1192 VRTDriver();
1193 virtual ~VRTDriver();
1194
1195 char **papszSourceParsers;
1196
1197 virtual char **GetMetadataDomainList() override;
1198 virtual char **GetMetadata(const char *pszDomain = "") override;
1199 virtual CPLErr SetMetadata(char **papszMetadata,
1200 const char *pszDomain = "") override;
1201
1202 VRTSource *
1203 ParseSource(const CPLXMLNode *psSrc, const char *pszVRTPath,
1204 std::map<CPLString, GDALDataset *> &oMapSharedSources);
1205 void AddSourceParser(const char *pszElementName, VRTSourceParser pfnParser);
1206};
1207
1208/************************************************************************/
1209/* VRTSimpleSource */
1210/************************************************************************/
1211
1212class CPL_DLL VRTSimpleSource CPL_NON_FINAL : public VRTSource
1213{
1214 CPL_DISALLOW_COPY_ASSIGN(VRTSimpleSource)
1215
1216 private:
1217 // Owned by the VRTDataset
1218 std::map<CPLString, GDALDataset *> *m_poMapSharedSources = nullptr;
1219
1220 mutable GDALRasterBand *m_poRasterBand = nullptr;
1221
1222 // When poRasterBand is a mask band, poMaskBandMainBand is the band
1223 // from which the mask band is taken.
1224 mutable GDALRasterBand *m_poMaskBandMainBand = nullptr;
1225
1226 CPLStringList m_aosOpenOptions{};
1227
1228 void OpenSource() const;
1229
1230 protected:
1231 friend class VRTSourcedRasterBand;
1232 friend class VRTDataset;
1233 friend class GDALTileIndexDataset;
1234 friend class GDALTileIndexBand;
1235
1236 int m_nBand = 0;
1237 bool m_bGetMaskBand = false;
1238
1239 /* Value for uninitialized source or destination window. It is chosen such
1240 * that SrcToDst() and DstToSrc() are no-ops if both source and destination
1241 * windows are unset.
1242 */
1243 static constexpr double UNINIT_WINDOW = -1.0;
1244
1245 double m_dfSrcXOff = UNINIT_WINDOW;
1246 double m_dfSrcYOff = UNINIT_WINDOW;
1247 double m_dfSrcXSize = UNINIT_WINDOW;
1248 double m_dfSrcYSize = UNINIT_WINDOW;
1249
1250 double m_dfDstXOff = UNINIT_WINDOW;
1251 double m_dfDstYOff = UNINIT_WINDOW;
1252 double m_dfDstXSize = UNINIT_WINDOW;
1253 double m_dfDstYSize = UNINIT_WINDOW;
1254
1255 CPLString m_osResampling{};
1256
1257 int m_nMaxValue = 0;
1258
1259 int m_bRelativeToVRTOri = -1;
1260 CPLString m_osSourceFileNameOri{};
1261 int m_nExplicitSharedStatus = -1; // -1 unknown, 0 = unshared, 1 = shared
1262 CPLString m_osSrcDSName{};
1263
1264 bool m_bDropRefOnSrcBand = true;
1265
1266 int NeedMaxValAdjustment() const;
1267
1268 GDALRasterBand *GetRasterBandNoOpen() const
1269 {
1270 return m_poRasterBand;
1271 }
1272
1273 void SetRasterBand(GDALRasterBand *poBand, bool bDropRef)
1274 {
1275 m_poRasterBand = poBand;
1276 m_bDropRefOnSrcBand = bDropRef;
1277 }
1278
1279 virtual bool ValidateOpenedBand(GDALRasterBand * /*poBand*/) const
1280 {
1281 return true;
1282 }
1283
1285 bool IsSrcWinSet() const
1286 {
1287 return m_dfSrcXOff != UNINIT_WINDOW || m_dfSrcYOff != UNINIT_WINDOW ||
1288 m_dfSrcXSize != UNINIT_WINDOW || m_dfSrcYSize != UNINIT_WINDOW;
1289 }
1290
1292 bool IsDstWinSet() const
1293 {
1294 return m_dfDstXOff != UNINIT_WINDOW || m_dfDstYOff != UNINIT_WINDOW ||
1295 m_dfDstXSize != UNINIT_WINDOW || m_dfDstYSize != UNINIT_WINDOW;
1296 }
1297
1298 public:
1299 VRTSimpleSource();
1300 VRTSimpleSource(const VRTSimpleSource *poSrcSource, double dfXDstRatio,
1301 double dfYDstRatio);
1302 virtual ~VRTSimpleSource();
1303
1304 virtual CPLErr XMLInit(const CPLXMLNode *psTree, const char *,
1305 std::map<CPLString, GDALDataset *> &) override;
1306 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath) override;
1307
1308 CPLErr ParseSrcRectAndDstRect(const CPLXMLNode *psSrc);
1309
1310 void SetSrcBand(const char *pszFilename, int nBand);
1311 void SetSrcBand(GDALRasterBand *);
1312 void SetSrcMaskBand(GDALRasterBand *);
1313 void SetSrcWindow(double, double, double, double);
1314 void SetDstWindow(double, double, double, double);
1315 void GetDstWindow(double &, double &, double &, double &);
1316
1317 const std::string &GetSourceDatasetName() const
1318 {
1319 return m_osSrcDSName;
1320 }
1321
1322 const CPLString &GetResampling() const
1323 {
1324 return m_osResampling;
1325 }
1326
1327 void SetResampling(const char *pszResampling);
1328
1329 int GetSrcDstWindow(double, double, double, double, int, int,
1330 double *pdfReqXOff, double *pdfReqYOff,
1331 double *pdfReqXSize, double *pdfReqYSize, int *, int *,
1332 int *, int *, int *, int *, int *, int *,
1333 bool &bErrorOut);
1334
1335 virtual CPLErr RasterIO(GDALDataType eVRTBandDataType, int nXOff, int nYOff,
1336 int nXSize, int nYSize, void *pData, int nBufXSize,
1337 int nBufYSize, GDALDataType eBufType,
1338 GSpacing nPixelSpace, GSpacing nLineSpace,
1339 GDALRasterIOExtraArg *psExtraArgIn,
1340 WorkingState &oWorkingState) 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 void DstToSrc(double dfX, double dfY, double &dfXOut, double &dfYOut) const;
1351 void SrcToDst(double dfX, double dfY, double &dfXOut, double &dfYOut) const;
1352
1353 virtual void GetFileList(char ***ppapszFileList, int *pnSize,
1354 int *pnMaxSize, CPLHashSet *hSetFiles) override;
1355
1356 virtual int IsSimpleSource() override
1357 {
1358 return TRUE;
1359 }
1360
1361 virtual const char *GetType()
1362 {
1363 return "SimpleSource";
1364 }
1365
1366 virtual CPLErr FlushCache(bool bAtClosing) override;
1367
1368 GDALRasterBand *GetRasterBand() const;
1369 GDALRasterBand *GetMaskBandMainBand();
1370 int IsSameExceptBandNumber(VRTSimpleSource *poOtherSource);
1371 CPLErr DatasetRasterIO(GDALDataType eVRTBandDataType, int nXOff, int nYOff,
1372 int nXSize, int nYSize, void *pData, int nBufXSize,
1373 int nBufYSize, GDALDataType eBufType, int nBandCount,
1374 int *panBandMap, GSpacing nPixelSpace,
1375 GSpacing nLineSpace, GSpacing nBandSpace,
1376 GDALRasterIOExtraArg *psExtraArg);
1377
1378 void UnsetPreservedRelativeFilenames();
1379
1380 void SetMaxValue(int nVal)
1381 {
1382 m_nMaxValue = nVal;
1383 }
1384};
1385
1386/************************************************************************/
1387/* VRTAveragedSource */
1388/************************************************************************/
1389
1390class VRTAveragedSource final : public VRTSimpleSource
1391{
1392 CPL_DISALLOW_COPY_ASSIGN(VRTAveragedSource)
1393
1394 int m_bNoDataSet = false;
1395 double m_dfNoDataValue = VRT_NODATA_UNSET;
1396
1397 public:
1398 VRTAveragedSource();
1399 virtual CPLErr RasterIO(GDALDataType eVRTBandDataType, int nXOff, int nYOff,
1400 int nXSize, int nYSize, void *pData, int nBufXSize,
1401 int nBufYSize, GDALDataType eBufType,
1402 GSpacing nPixelSpace, GSpacing nLineSpace,
1403 GDALRasterIOExtraArg *psExtraArgIn,
1404 WorkingState &oWorkingState) override;
1405
1406 virtual double GetMinimum(int nXSize, int nYSize, int *pbSuccess) override;
1407 virtual double GetMaximum(int nXSize, int nYSize, int *pbSuccess) override;
1408 virtual CPLErr GetHistogram(int nXSize, int nYSize, double dfMin,
1409 double dfMax, int nBuckets,
1410 GUIntBig *panHistogram, int bIncludeOutOfRange,
1411 int bApproxOK, GDALProgressFunc pfnProgress,
1412 void *pProgressData) override;
1413
1414 void SetNoDataValue(double dfNoDataValue);
1415
1416 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath) override;
1417
1418 virtual const char *GetType() override
1419 {
1420 return "AveragedSource";
1421 }
1422};
1423
1424/************************************************************************/
1425/* VRTNoDataFromMaskSource */
1426/************************************************************************/
1427
1428class VRTNoDataFromMaskSource final : public VRTSimpleSource
1429{
1430 CPL_DISALLOW_COPY_ASSIGN(VRTNoDataFromMaskSource)
1431
1432 bool m_bNoDataSet = false;
1433 double m_dfNoDataValue = 0;
1434 double m_dfMaskValueThreshold = 0;
1435 bool m_bHasRemappedValue = false;
1436 double m_dfRemappedValue = 0;
1437
1438 public:
1439 VRTNoDataFromMaskSource();
1440 virtual CPLErr RasterIO(GDALDataType eVRTBandDataType, int nXOff, int nYOff,
1441 int nXSize, int nYSize, void *pData, int nBufXSize,
1442 int nBufYSize, GDALDataType eBufType,
1443 GSpacing nPixelSpace, GSpacing nLineSpace,
1444 GDALRasterIOExtraArg *psExtraArgIn,
1445 WorkingState &oWorkingState) override;
1446
1447 virtual double GetMinimum(int nXSize, int nYSize, int *pbSuccess) override;
1448 virtual double GetMaximum(int nXSize, int nYSize, int *pbSuccess) override;
1449 virtual CPLErr GetHistogram(int nXSize, int nYSize, double dfMin,
1450 double dfMax, int nBuckets,
1451 GUIntBig *panHistogram, int bIncludeOutOfRange,
1452 int bApproxOK, GDALProgressFunc pfnProgress,
1453 void *pProgressData) override;
1454
1455 void SetParameters(double dfNoDataValue, double dfMaskValueThreshold);
1456 void SetParameters(double dfNoDataValue, double dfMaskValueThreshold,
1457 double dfRemappedValue);
1458
1459 virtual CPLErr XMLInit(const CPLXMLNode *psTree, const char *,
1460 std::map<CPLString, GDALDataset *> &) override;
1461 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath) override;
1462
1463 virtual const char *GetType() override
1464 {
1465 return "VRTNoDataFromMaskSource";
1466 }
1467};
1468
1469/************************************************************************/
1470/* VRTComplexSource */
1471/************************************************************************/
1472
1473class CPL_DLL VRTComplexSource CPL_NON_FINAL : public VRTSimpleSource
1474{
1475 CPL_DISALLOW_COPY_ASSIGN(VRTComplexSource)
1476
1477 protected:
1478 static constexpr int PROCESSING_FLAG_NODATA = 1 << 0;
1479 static constexpr int PROCESSING_FLAG_USE_MASK_BAND =
1480 1 << 1; // Mutually exclusive with NODATA
1481 static constexpr int PROCESSING_FLAG_SCALING_LINEAR = 1 << 2;
1482 static constexpr int PROCESSING_FLAG_SCALING_EXPONENTIAL =
1483 1 << 3; // Mutually exclusive with SCALING_LINEAR
1484 static constexpr int PROCESSING_FLAG_COLOR_TABLE_EXPANSION = 1 << 4;
1485 static constexpr int PROCESSING_FLAG_LUT = 1 << 5;
1486
1487 int m_nProcessingFlags = 0;
1488
1489 // adjusted value should be read with GetAdjustedNoDataValue()
1490 double m_dfNoDataValue = VRT_NODATA_UNSET;
1491 std::string
1492 m_osNoDataValueOri{}; // string value read in XML deserialization
1493
1494 double m_dfScaleOff = 0; // For linear scaling.
1495 double m_dfScaleRatio = 1; // For linear scaling.
1496
1497 // For non-linear scaling with a power function.
1498 bool m_bSrcMinMaxDefined = false;
1499 double m_dfSrcMin = 0;
1500 double m_dfSrcMax = 0;
1501 double m_dfDstMin = 0;
1502 double m_dfDstMax = 0;
1503 double m_dfExponent = 1;
1504
1505 int m_nColorTableComponent = 0;
1506
1507 std::vector<double> m_adfLUTInputs{};
1508 std::vector<double> m_adfLUTOutputs{};
1509
1510 double GetAdjustedNoDataValue() const;
1511
1512 template <class WorkingDT>
1513 CPLErr
1514 RasterIOInternal(GDALRasterBand *poSourceBand,
1515 GDALDataType eVRTBandDataType, int nReqXOff, int nReqYOff,
1516 int nReqXSize, int nReqYSize, void *pData, int nOutXSize,
1517 int nOutYSize, GDALDataType eBufType, GSpacing nPixelSpace,
1518 GSpacing nLineSpace, GDALRasterIOExtraArg *psExtraArg,
1519 GDALDataType eWrkDataType, WorkingState &oWorkingState);
1520
1521 template <class SourceDT, GDALDataType eSourceType>
1522 CPLErr RasterIOProcessNoData(GDALRasterBand *poSourceBand,
1523 GDALDataType eVRTBandDataType, int nReqXOff,
1524 int nReqYOff, int nReqXSize, int nReqYSize,
1525 void *pData, int nOutXSize, int nOutYSize,
1526 GDALDataType eBufType, GSpacing nPixelSpace,
1527 GSpacing nLineSpace,
1528 GDALRasterIOExtraArg *psExtraArg,
1529 WorkingState &oWorkingState);
1530
1531 public:
1532 VRTComplexSource() = default;
1533 VRTComplexSource(const VRTComplexSource *poSrcSource, double dfXDstRatio,
1534 double dfYDstRatio);
1535
1536 virtual CPLErr RasterIO(GDALDataType eVRTBandDataType, int nXOff, int nYOff,
1537 int nXSize, int nYSize, void *pData, int nBufXSize,
1538 int nBufYSize, GDALDataType eBufType,
1539 GSpacing nPixelSpace, GSpacing nLineSpace,
1540 GDALRasterIOExtraArg *psExtraArgIn,
1541 WorkingState &oWorkingState) override;
1542
1543 virtual double GetMinimum(int nXSize, int nYSize, int *pbSuccess) override;
1544 virtual double GetMaximum(int nXSize, int nYSize, int *pbSuccess) override;
1545 virtual CPLErr GetHistogram(int nXSize, int nYSize, double dfMin,
1546 double dfMax, int nBuckets,
1547 GUIntBig *panHistogram, int bIncludeOutOfRange,
1548 int bApproxOK, GDALProgressFunc pfnProgress,
1549 void *pProgressData) override;
1550
1551 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath) override;
1552 virtual CPLErr XMLInit(const CPLXMLNode *, const char *,
1553 std::map<CPLString, GDALDataset *> &) override;
1554
1555 virtual const char *GetType() override
1556 {
1557 return "ComplexSource";
1558 }
1559
1560 bool AreValuesUnchanged() const;
1561
1562 double LookupValue(double dfInput);
1563
1564 void SetNoDataValue(double dfNoDataValue);
1565
1566 void SetUseMaskBand(bool bUseMaskBand)
1567 {
1568 if (bUseMaskBand)
1569 m_nProcessingFlags |= PROCESSING_FLAG_USE_MASK_BAND;
1570 else
1571 m_nProcessingFlags &= ~PROCESSING_FLAG_USE_MASK_BAND;
1572 }
1573
1574 void SetLinearScaling(double dfOffset, double dfScale);
1575 void SetPowerScaling(double dfExponent, double dfSrcMin, double dfSrcMax,
1576 double dfDstMin, double dfDstMax);
1577 void SetColorTableComponent(int nComponent);
1578};
1579
1580/************************************************************************/
1581/* VRTFilteredSource */
1582/************************************************************************/
1583
1584class VRTFilteredSource CPL_NON_FINAL : public VRTComplexSource
1585{
1586 private:
1587 int IsTypeSupported(GDALDataType eTestType) const;
1588
1589 CPL_DISALLOW_COPY_ASSIGN(VRTFilteredSource)
1590
1591 protected:
1592 int m_nSupportedTypesCount;
1593 GDALDataType m_aeSupportedTypes[20];
1594
1595 int m_nExtraEdgePixels;
1596
1597 public:
1598 VRTFilteredSource();
1599 virtual ~VRTFilteredSource();
1600
1601 void SetExtraEdgePixels(int);
1602 void SetFilteringDataTypesSupported(int, GDALDataType *);
1603
1604 virtual CPLErr FilterData(int nXSize, int nYSize, GDALDataType eType,
1605 GByte *pabySrcData, GByte *pabyDstData) = 0;
1606
1607 virtual CPLErr RasterIO(GDALDataType eVRTBandDataType, int nXOff, int nYOff,
1608 int nXSize, int nYSize, void *pData, int nBufXSize,
1609 int nBufYSize, GDALDataType eBufType,
1610 GSpacing nPixelSpace, GSpacing nLineSpace,
1611 GDALRasterIOExtraArg *psExtraArg,
1612 WorkingState &oWorkingState) override;
1613};
1614
1615/************************************************************************/
1616/* VRTKernelFilteredSource */
1617/************************************************************************/
1618
1619class VRTKernelFilteredSource CPL_NON_FINAL : public VRTFilteredSource
1620{
1621 CPL_DISALLOW_COPY_ASSIGN(VRTKernelFilteredSource)
1622
1623 protected:
1624 int m_nKernelSize;
1625
1626 bool m_bSeparable;
1627
1628 double *m_padfKernelCoefs;
1629
1630 int m_bNormalized;
1631
1632 public:
1633 VRTKernelFilteredSource();
1634 virtual ~VRTKernelFilteredSource();
1635
1636 virtual CPLErr XMLInit(const CPLXMLNode *psTree, const char *,
1637 std::map<CPLString, GDALDataset *> &) override;
1638 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath) override;
1639
1640 virtual CPLErr FilterData(int nXSize, int nYSize, GDALDataType eType,
1641 GByte *pabySrcData, GByte *pabyDstData) override;
1642
1643 CPLErr SetKernel(int nKernelSize, bool bSeparable, double *padfCoefs);
1644 void SetNormalized(int);
1645};
1646
1647/************************************************************************/
1648/* VRTAverageFilteredSource */
1649/************************************************************************/
1650
1651class VRTAverageFilteredSource final : public VRTKernelFilteredSource
1652{
1653 CPL_DISALLOW_COPY_ASSIGN(VRTAverageFilteredSource)
1654
1655 public:
1656 explicit VRTAverageFilteredSource(int nKernelSize);
1657 virtual ~VRTAverageFilteredSource();
1658
1659 virtual CPLErr XMLInit(const CPLXMLNode *psTree, const char *,
1660 std::map<CPLString, GDALDataset *> &) override;
1661 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath) override;
1662};
1663
1664/************************************************************************/
1665/* VRTFuncSource */
1666/************************************************************************/
1667class VRTFuncSource final : public VRTSource
1668{
1669 CPL_DISALLOW_COPY_ASSIGN(VRTFuncSource)
1670
1671 public:
1672 VRTFuncSource();
1673 virtual ~VRTFuncSource();
1674
1675 virtual CPLErr XMLInit(const CPLXMLNode *, const char *,
1676 std::map<CPLString, GDALDataset *> &) override
1677 {
1678 return CE_Failure;
1679 }
1680
1681 virtual CPLXMLNode *SerializeToXML(const char *pszVRTPath) override;
1682
1683 virtual CPLErr RasterIO(GDALDataType eVRTBandDataType, int nXOff, int nYOff,
1684 int nXSize, int nYSize, void *pData, int nBufXSize,
1685 int nBufYSize, GDALDataType eBufType,
1686 GSpacing nPixelSpace, GSpacing nLineSpace,
1687 GDALRasterIOExtraArg *psExtraArg,
1688 WorkingState &oWorkingState) override;
1689
1690 virtual double GetMinimum(int nXSize, int nYSize, int *pbSuccess) override;
1691 virtual double GetMaximum(int nXSize, int nYSize, int *pbSuccess) override;
1692 virtual CPLErr GetHistogram(int nXSize, int nYSize, double dfMin,
1693 double dfMax, int nBuckets,
1694 GUIntBig *panHistogram, int bIncludeOutOfRange,
1695 int bApproxOK, GDALProgressFunc pfnProgress,
1696 void *pProgressData) override;
1697
1698 VRTImageReadFunc pfnReadFunc;
1699 void *pCBData;
1700 GDALDataType eType;
1701
1702 float fNoDataValue;
1703};
1704
1705/************************************************************************/
1706/* VRTGroup */
1707/************************************************************************/
1708
1709#ifdef TMPEXPORT
1710#define TMP_CPL_DLL CPL_DLL
1711#else
1712#define TMP_CPL_DLL
1713#endif
1714
1715class VRTMDArray;
1716class VRTAttribute;
1717class VRTDimension;
1718
1719class VRTGroup final : public GDALGroup
1720{
1721 public:
1722 struct Ref
1723 {
1724 VRTGroup *m_ptr;
1725
1726 explicit Ref(VRTGroup *ptr) : m_ptr(ptr)
1727 {
1728 }
1729
1730 Ref(const Ref &) = delete;
1731 Ref &operator=(const Ref &) = delete;
1732 };
1733
1734 private:
1735 std::shared_ptr<Ref> m_poSharedRefRootGroup{};
1736 std::weak_ptr<Ref> m_poWeakRefRootGroup{};
1737 std::shared_ptr<Ref> m_poRefSelf{};
1738
1739 std::string m_osFilename{};
1740 mutable bool m_bDirty = false;
1741 std::string m_osVRTPath{};
1742 std::map<std::string, std::shared_ptr<VRTGroup>> m_oMapGroups{};
1743 std::map<std::string, std::shared_ptr<VRTMDArray>> m_oMapMDArrays{};
1744 std::map<std::string, std::shared_ptr<VRTAttribute>> m_oMapAttributes{};
1745 std::map<std::string, std::shared_ptr<VRTDimension>> m_oMapDimensions{};
1746
1747 std::shared_ptr<VRTGroup>
1748 OpenGroupInternal(const std::string &osName) const;
1749 void SetRootGroupRef(const std::weak_ptr<Ref> &rgRef);
1750 std::weak_ptr<Ref> GetRootGroupRef() const;
1751
1752 protected:
1753 friend class VRTMDArray;
1754 friend std::shared_ptr<GDALMDArray>
1755 VRTDerivedArrayCreate(const char *pszVRTPath, const CPLXMLNode *psTree);
1756
1757 explicit VRTGroup(const char *pszVRTPath);
1758 VRTGroup(const std::string &osParentName, const std::string &osName);
1759
1760 public:
1761 static std::shared_ptr<VRTGroup> Create(const std::string &osParentName,
1762 const std::string &osName)
1763 {
1764 auto poGroup =
1765 std::shared_ptr<VRTGroup>(new VRTGroup(osParentName, osName));
1766 poGroup->SetSelf(poGroup);
1767 return poGroup;
1768 }
1769
1770 ~VRTGroup();
1771
1772 bool XMLInit(const std::shared_ptr<VRTGroup> &poRoot,
1773 const std::shared_ptr<VRTGroup> &poThisGroup,
1774 const CPLXMLNode *psNode, const char *pszVRTPath);
1775
1776 std::vector<std::string>
1777 GetMDArrayNames(CSLConstList papszOptions) const override;
1778 std::shared_ptr<GDALMDArray>
1779 OpenMDArray(const std::string &osName,
1780 CSLConstList papszOptions = nullptr) const override;
1781
1782 std::vector<std::string>
1783 GetGroupNames(CSLConstList papszOptions) const override;
1784
1785 std::shared_ptr<GDALGroup> OpenGroup(const std::string &osName,
1786 CSLConstList) const override
1787 {
1788 return OpenGroupInternal(osName);
1789 }
1790
1791 std::vector<std::shared_ptr<GDALDimension>>
1792 GetDimensions(CSLConstList) const override;
1793
1794 std::vector<std::shared_ptr<GDALAttribute>>
1795 GetAttributes(CSLConstList) const override;
1796
1797 std::shared_ptr<VRTDimension> GetDimension(const std::string &name) const
1798 {
1799 auto oIter = m_oMapDimensions.find(name);
1800 return oIter == m_oMapDimensions.end() ? nullptr : oIter->second;
1801 }
1802
1803 std::shared_ptr<VRTDimension>
1804 GetDimensionFromFullName(const std::string &name, bool bEmitError) const;
1805
1806 std::shared_ptr<GDALGroup>
1807 CreateGroup(const std::string &osName,
1808 CSLConstList papszOptions = nullptr) override;
1809
1810 std::shared_ptr<GDALDimension>
1811 CreateDimension(const std::string &osName, const std::string &osType,
1812 const std::string &osDirection, GUInt64 nSize,
1813 CSLConstList papszOptions = nullptr) override;
1814
1815 std::shared_ptr<GDALAttribute>
1816 CreateAttribute(const std::string &osName,
1817 const std::vector<GUInt64> &anDimensions,
1818 const GDALExtendedDataType &oDataType,
1819 CSLConstList papszOptions = nullptr) override;
1820
1821 std::shared_ptr<GDALMDArray> CreateMDArray(
1822 const std::string &osName,
1823 const std::vector<std::shared_ptr<GDALDimension>> &aoDimensions,
1824 const GDALExtendedDataType &oDataType,
1825 CSLConstList papszOptions) override;
1826
1827 void SetIsRootGroup();
1828
1829 const std::shared_ptr<Ref> &GetRef() const
1830 {
1831 return m_poRefSelf;
1832 }
1833
1834 VRTGroup *GetRootGroup() const;
1835 std::shared_ptr<GDALGroup> GetRootGroupSharedPtr() const;
1836
1837 const std::string &GetVRTPath() const
1838 {
1839 return m_osVRTPath;
1840 }
1841
1842 void SetDirty();
1843
1844 void SetFilename(const std::string &osFilename)
1845 {
1846 m_osFilename = osFilename;
1847 }
1848
1849 const std::string &GetFilename() const
1850 {
1851 return m_osFilename;
1852 }
1853
1854 bool Serialize() const;
1855 CPLXMLNode *SerializeToXML(const char *pszVRTPathIn) const;
1856 void Serialize(CPLXMLNode *psParent, const char *pszVRTPathIn) const;
1857};
1858
1859/************************************************************************/
1860/* VRTDimension */
1861/************************************************************************/
1862
1863class VRTDimension final : public GDALDimension
1864{
1865 std::weak_ptr<VRTGroup::Ref> m_poGroupRef;
1866 std::string m_osIndexingVariableName;
1867
1868 public:
1869 VRTDimension(const std::shared_ptr<VRTGroup::Ref> &poGroupRef,
1870 const std::string &osParentName, const std::string &osName,
1871 const std::string &osType, const std::string &osDirection,
1872 GUInt64 nSize, const std::string &osIndexingVariableName)
1873 : GDALDimension(osParentName, osName, osType, osDirection, nSize),
1874 m_poGroupRef(poGroupRef),
1875 m_osIndexingVariableName(osIndexingVariableName)
1876 {
1877 }
1878
1879 VRTGroup *GetGroup() const;
1880
1881 static std::shared_ptr<VRTDimension>
1882 Create(const std::shared_ptr<VRTGroup> &poThisGroup,
1883 const std::string &osParentName, const CPLXMLNode *psNode);
1884
1885 std::shared_ptr<GDALMDArray> GetIndexingVariable() const override;
1886
1888 std::shared_ptr<GDALMDArray> poIndexingVariable) override;
1889
1890 void Serialize(CPLXMLNode *psParent) const;
1891};
1892
1893/************************************************************************/
1894/* VRTAttribute */
1895/************************************************************************/
1896
1897class VRTAttribute final : public GDALAttribute
1898{
1900 std::vector<std::string> m_aosList{};
1901 std::vector<std::shared_ptr<GDALDimension>> m_dims{};
1902
1903 protected:
1904 bool IRead(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 bool IWrite(const GUInt64 *arrayStartIdx, const size_t *count,
1910 const GInt64 *arrayStep, const GPtrDiff_t *bufferStride,
1911 const GDALExtendedDataType &bufferDataType,
1912 const void *pSrcBuffer) override;
1913
1914 public:
1915 VRTAttribute(const std::string &osParentName, const std::string &osName,
1916 const GDALExtendedDataType &dt,
1917 std::vector<std::string> &&aosList)
1918 : GDALAbstractMDArray(osParentName, osName),
1919 GDALAttribute(osParentName, osName), m_dt(dt),
1920 m_aosList(std::move(aosList))
1921 {
1922 if (m_aosList.size() > 1)
1923 {
1924 m_dims.emplace_back(std::make_shared<GDALDimension>(
1925 std::string(), "dim", std::string(), std::string(),
1926 m_aosList.size()));
1927 }
1928 }
1929
1930 VRTAttribute(const std::string &osParentName, const std::string &osName,
1931 GUInt64 nDim, const GDALExtendedDataType &dt)
1932 : GDALAbstractMDArray(osParentName, osName),
1933 GDALAttribute(osParentName, osName), m_dt(dt)
1934 {
1935 if (nDim != 0)
1936 {
1937 m_dims.emplace_back(std::make_shared<GDALDimension>(
1938 std::string(), "dim", std::string(), std::string(), nDim));
1939 }
1940 }
1941
1942 static bool CreationCommonChecks(
1943 const std::string &osName, const std::vector<GUInt64> &anDimensions,
1944 const std::map<std::string, std::shared_ptr<VRTAttribute>>
1945 &oMapAttributes);
1946
1947 static std::shared_ptr<VRTAttribute> Create(const std::string &osParentName,
1948 const CPLXMLNode *psNode);
1949
1950 const std::vector<std::shared_ptr<GDALDimension>> &
1951 GetDimensions() const override
1952 {
1953 return m_dims;
1954 }
1955
1956 const GDALExtendedDataType &GetDataType() const override
1957 {
1958 return m_dt;
1959 }
1960
1961 void Serialize(CPLXMLNode *psParent) const;
1962};
1963
1964/************************************************************************/
1965/* VRTMDArraySource */
1966/************************************************************************/
1967
1968class VRTMDArraySource
1969{
1970 public:
1971 virtual ~VRTMDArraySource() = default;
1972
1973 virtual bool Read(const GUInt64 *arrayStartIdx, const size_t *count,
1974 const GInt64 *arrayStep, const GPtrDiff_t *bufferStride,
1975 const GDALExtendedDataType &bufferDataType,
1976 void *pDstBuffer) const = 0;
1977
1978 virtual void Serialize(CPLXMLNode *psParent,
1979 const char *pszVRTPath) const = 0;
1980};
1981
1982/************************************************************************/
1983/* VRTMDArray */
1984/************************************************************************/
1985
1986class VRTMDArray final : public GDALMDArray
1987{
1988 protected:
1989 friend class VRTGroup; // for access to SetSelf()
1990
1991 std::weak_ptr<VRTGroup::Ref> m_poGroupRef;
1992 std::string m_osVRTPath{};
1993 std::shared_ptr<VRTGroup> m_poDummyOwningGroup{};
1994
1996 std::vector<std::shared_ptr<GDALDimension>> m_dims;
1997 std::map<std::string, std::shared_ptr<VRTAttribute>> m_oMapAttributes{};
1998 std::vector<std::unique_ptr<VRTMDArraySource>> m_sources{};
1999 std::shared_ptr<OGRSpatialReference> m_poSRS{};
2000 std::vector<GByte> m_abyNoData{};
2001 std::string m_osUnit{};
2002 double m_dfScale = 1.0;
2003 double m_dfOffset = 0.0;
2004 bool m_bHasScale = false;
2005 bool m_bHasOffset = false;
2006 std::string m_osFilename{};
2007
2008 bool IRead(const GUInt64 *arrayStartIdx, const size_t *count,
2009 const GInt64 *arrayStep, const GPtrDiff_t *bufferStride,
2010 const GDALExtendedDataType &bufferDataType,
2011 void *pDstBuffer) const override;
2012
2013 void SetDirty();
2014
2015 public:
2016 VRTMDArray(
2017 const std::shared_ptr<VRTGroup::Ref> &poGroupRef,
2018 const std::string &osParentName, const std::string &osName,
2019 const GDALExtendedDataType &dt,
2020 std::vector<std::shared_ptr<GDALDimension>> &&dims,
2021 std::map<std::string, std::shared_ptr<VRTAttribute>> &&oMapAttributes)
2022 : GDALAbstractMDArray(osParentName, osName),
2023 GDALMDArray(osParentName, osName), m_poGroupRef(poGroupRef),
2024 m_osVRTPath(poGroupRef->m_ptr->GetVRTPath()), m_dt(dt),
2025 m_dims(std::move(dims)), m_oMapAttributes(std::move(oMapAttributes)),
2026 m_osFilename(poGroupRef->m_ptr->GetFilename())
2027 {
2028 }
2029
2030 VRTMDArray(const std::shared_ptr<VRTGroup::Ref> &poGroupRef,
2031 const std::string &osParentName, const std::string &osName,
2032 const std::vector<std::shared_ptr<GDALDimension>> &dims,
2033 const GDALExtendedDataType &dt)
2034 : GDALAbstractMDArray(osParentName, osName),
2035 GDALMDArray(osParentName, osName), m_poGroupRef(poGroupRef),
2036 m_osVRTPath(poGroupRef->m_ptr->GetVRTPath()), m_dt(dt), m_dims(dims),
2037 m_osFilename(poGroupRef->m_ptr->GetFilename())
2038 {
2039 }
2040
2041 bool IsWritable() const override
2042 {
2043 return false;
2044 }
2045
2046 const std::string &GetFilename() const override
2047 {
2048 return m_osFilename;
2049 }
2050
2051 static std::shared_ptr<VRTMDArray> Create(const char *pszVRTPath,
2052 const CPLXMLNode *psNode);
2053
2054 static std::shared_ptr<VRTMDArray>
2055 Create(const std::shared_ptr<VRTGroup> &poThisGroup,
2056 const std::string &osParentName, const CPLXMLNode *psNode);
2057
2058 const std::vector<std::shared_ptr<GDALDimension>> &
2059 GetDimensions() const override
2060 {
2061 return m_dims;
2062 }
2063
2064 std::vector<std::shared_ptr<GDALAttribute>>
2065 GetAttributes(CSLConstList) const override;
2066
2067 const GDALExtendedDataType &GetDataType() const override
2068 {
2069 return m_dt;
2070 }
2071
2072 bool SetSpatialRef(const OGRSpatialReference *poSRS) override;
2073
2074 std::shared_ptr<OGRSpatialReference> GetSpatialRef() const override
2075 {
2076 return m_poSRS;
2077 }
2078
2079 const void *GetRawNoDataValue() const override;
2080
2081 bool SetRawNoDataValue(const void *pRawNoData) override;
2082
2083 const std::string &GetUnit() const override
2084 {
2085 return m_osUnit;
2086 }
2087
2088 bool SetUnit(const std::string &osUnit) override
2089 {
2090 m_osUnit = osUnit;
2091 return true;
2092 }
2093
2094 double GetOffset(bool *pbHasOffset,
2095 GDALDataType *peStorageType) const override
2096 {
2097 if (pbHasOffset)
2098 *pbHasOffset = m_bHasOffset;
2099 if (peStorageType)
2100 *peStorageType = GDT_Unknown;
2101 return m_dfOffset;
2102 }
2103
2104 double GetScale(bool *pbHasScale,
2105 GDALDataType *peStorageType) const override
2106 {
2107 if (pbHasScale)
2108 *pbHasScale = m_bHasScale;
2109 if (peStorageType)
2110 *peStorageType = GDT_Unknown;
2111 return m_dfScale;
2112 }
2113
2114 bool SetOffset(double dfOffset,
2115 GDALDataType /* eStorageType */ = GDT_Unknown) override
2116 {
2117 SetDirty();
2118 m_bHasOffset = true;
2119 m_dfOffset = dfOffset;
2120 return true;
2121 }
2122
2123 bool SetScale(double dfScale,
2124 GDALDataType /* eStorageType */ = GDT_Unknown) override
2125 {
2126 SetDirty();
2127 m_bHasScale = true;
2128 m_dfScale = dfScale;
2129 return true;
2130 }
2131
2132 void AddSource(std::unique_ptr<VRTMDArraySource> &&poSource);
2133
2134 std::shared_ptr<GDALAttribute>
2135 CreateAttribute(const std::string &osName,
2136 const std::vector<GUInt64> &anDimensions,
2137 const GDALExtendedDataType &oDataType,
2138 CSLConstList papszOptions = nullptr) override;
2139
2140 bool CopyFrom(GDALDataset *poSrcDS, const GDALMDArray *poSrcArray,
2141 bool bStrict, GUInt64 &nCurCost, const GUInt64 nTotalCost,
2142 GDALProgressFunc pfnProgress, void *pProgressData) override;
2143
2144 void Serialize(CPLXMLNode *psParent, const char *pszVRTPathIn) const;
2145
2146 VRTGroup *GetGroup() const;
2147
2148 const std::string &GetVRTPath() const
2149 {
2150 return m_osVRTPath;
2151 }
2152
2153 std::shared_ptr<GDALGroup> GetRootGroup() const override
2154 {
2155 auto poGroup = m_poGroupRef.lock();
2156 if (poGroup)
2157 return poGroup->m_ptr->GetRootGroupSharedPtr();
2158 return nullptr;
2159 }
2160};
2161
2162/************************************************************************/
2163/* VRTMDArraySourceInlinedValues */
2164/************************************************************************/
2165
2166class VRTMDArraySourceInlinedValues final : public VRTMDArraySource
2167{
2168 const VRTMDArray *m_poDstArray = nullptr;
2169 bool m_bIsConstantValue;
2170 std::vector<GUInt64> m_anOffset{};
2171 std::vector<size_t> m_anCount{};
2172 std::vector<GByte> m_abyValues{};
2173 std::vector<size_t> m_anInlinedArrayStrideInBytes{};
2175
2176 VRTMDArraySourceInlinedValues(const VRTMDArraySourceInlinedValues &) =
2177 delete;
2178 VRTMDArraySourceInlinedValues &
2179 operator=(const VRTMDArraySourceInlinedValues &) = delete;
2180
2181 public:
2182 VRTMDArraySourceInlinedValues(const VRTMDArray *poDstArray,
2183 bool bIsConstantValue,
2184 std::vector<GUInt64> &&anOffset,
2185 std::vector<size_t> &&anCount,
2186 std::vector<GByte> &&abyValues)
2187 : m_poDstArray(poDstArray), m_bIsConstantValue(bIsConstantValue),
2188 m_anOffset(std::move(anOffset)), m_anCount(std::move(anCount)),
2189 m_abyValues(std::move(abyValues)), m_dt(poDstArray->GetDataType())
2190 {
2191 const auto nDims(poDstArray->GetDimensionCount());
2192 m_anInlinedArrayStrideInBytes.resize(nDims);
2193 if (!bIsConstantValue && nDims > 0)
2194 {
2195 m_anInlinedArrayStrideInBytes.back() =
2196 poDstArray->GetDataType().GetSize();
2197 for (size_t i = nDims - 1; i > 0;)
2198 {
2199 --i;
2200 m_anInlinedArrayStrideInBytes[i] =
2201 m_anInlinedArrayStrideInBytes[i + 1] * m_anCount[i + 1];
2202 }
2203 }
2204 }
2205
2206 ~VRTMDArraySourceInlinedValues();
2207
2208 static std::unique_ptr<VRTMDArraySourceInlinedValues>
2209 Create(const VRTMDArray *poDstArray, const CPLXMLNode *psNode);
2210
2211 bool Read(const GUInt64 *arrayStartIdx, const size_t *count,
2212 const GInt64 *arrayStep, const GPtrDiff_t *bufferStride,
2213 const GDALExtendedDataType &bufferDataType,
2214 void *pDstBuffer) const override;
2215
2216 void Serialize(CPLXMLNode *psParent, const char *pszVRTPath) const override;
2217};
2218
2219/************************************************************************/
2220/* VRTMDArraySourceRegularlySpaced */
2221/************************************************************************/
2222
2223class VRTMDArraySourceRegularlySpaced final : public VRTMDArraySource
2224{
2225 double m_dfStart;
2226 double m_dfIncrement;
2227
2228 public:
2229 VRTMDArraySourceRegularlySpaced(double dfStart, double dfIncrement)
2230 : m_dfStart(dfStart), m_dfIncrement(dfIncrement)
2231 {
2232 }
2233
2234 bool Read(const GUInt64 *arrayStartIdx, const size_t *count,
2235 const GInt64 *arrayStep, const GPtrDiff_t *bufferStride,
2236 const GDALExtendedDataType &bufferDataType,
2237 void *pDstBuffer) const override;
2238
2239 void Serialize(CPLXMLNode *psParent, const char *pszVRTPath) const override;
2240};
2241
2242/************************************************************************/
2243/* VRTMDArraySourceFromArray */
2244/************************************************************************/
2245
2246class VRTMDArraySourceFromArray final : public VRTMDArraySource
2247{
2248 const VRTMDArray *m_poDstArray = nullptr;
2249 bool m_bRelativeToVRTSet = false;
2250 bool m_bRelativeToVRT = false;
2251 std::string m_osFilename{};
2252 std::string m_osArray{};
2253 std::string m_osBand{};
2254 std::vector<int> m_anTransposedAxis{};
2255 std::string m_osViewExpr{};
2256 std::vector<GUInt64> m_anSrcOffset{};
2257 mutable std::vector<GUInt64> m_anCount{};
2258 std::vector<GUInt64> m_anStep{};
2259 std::vector<GUInt64> m_anDstOffset{};
2260
2261 VRTMDArraySourceFromArray(const VRTMDArraySourceFromArray &) = delete;
2262 VRTMDArraySourceFromArray &
2263 operator=(const VRTMDArraySourceFromArray &) = delete;
2264
2265 public:
2266 VRTMDArraySourceFromArray(
2267 const VRTMDArray *poDstArray, bool bRelativeToVRTSet,
2268 bool bRelativeToVRT, const std::string &osFilename,
2269 const std::string &osArray, const std::string &osBand,
2270 std::vector<int> &&anTransposedAxis, const std::string &osViewExpr,
2271 std::vector<GUInt64> &&anSrcOffset, std::vector<GUInt64> &&anCount,
2272 std::vector<GUInt64> &&anStep, std::vector<GUInt64> &&anDstOffset)
2273 : m_poDstArray(poDstArray), m_bRelativeToVRTSet(bRelativeToVRTSet),
2274 m_bRelativeToVRT(bRelativeToVRT), m_osFilename(osFilename),
2275 m_osArray(osArray), m_osBand(osBand),
2276 m_anTransposedAxis(std::move(anTransposedAxis)),
2277 m_osViewExpr(osViewExpr), m_anSrcOffset(std::move(anSrcOffset)),
2278 m_anCount(std::move(anCount)), m_anStep(std::move(anStep)),
2279 m_anDstOffset(std::move(anDstOffset))
2280 {
2281 }
2282
2283 ~VRTMDArraySourceFromArray() override;
2284
2285 static std::unique_ptr<VRTMDArraySourceFromArray>
2286 Create(const VRTMDArray *poDstArray, const CPLXMLNode *psNode);
2287
2288 bool Read(const GUInt64 *arrayStartIdx, const size_t *count,
2289 const GInt64 *arrayStep, const GPtrDiff_t *bufferStride,
2290 const GDALExtendedDataType &bufferDataType,
2291 void *pDstBuffer) const override;
2292
2293 void Serialize(CPLXMLNode *psParent, const char *pszVRTPath) const override;
2294};
2295
2296#endif /* #ifndef DOXYGEN_SKIP */
2297
2298#endif /* ndef VIRTUALDATASET_H_INCLUDED */
String list class designed around our use of C "char**" string lists.
Definition cpl_string.h:449
Convenient string class based on std::string.
Definition cpl_string.h:320
Manage a tree of XML nodes so that all nodes are freed when the instance goes out of scope.
Definition cpl_minixml.h:210
Abstract class, implemented by GDALAttribute and GDALMDArray.
Definition gdal_priv.h:2939
virtual const std::vector< std::shared_ptr< GDALDimension > > & GetDimensions() const =0
Return the dimensions of an attribute/array.
virtual const GDALExtendedDataType & GetDataType() const =0
Return the data type of an attribute/array.
Class modeling an attribute that has a name, a value and a type, and is typically used to describe a ...
Definition gdal_priv.h:3170
A color table / palette.
Definition gdal_priv.h:1312
A set of associated raster bands, usually from one file.
Definition gdal_priv.h:490
int Dereference()
Subtract one from dataset reference count.
Definition gdaldataset.cpp:1588
virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList, const OGRSpatialReference *poGCP_SRS)
Assign GCPs.
Definition gdaldataset.cpp:2019
int GetShared() const
Returns shared flag.
Definition gdaldataset.cpp:1662
Class modeling a a dimension / axis used to index multidimensional arrays.
Definition gdal_priv.h:3654
virtual std::shared_ptr< GDALMDArray > GetIndexingVariable() const
Return the variable that is used to index the dimension (if there is one).
Definition gdalmultidim.cpp:10214
virtual bool SetIndexingVariable(std::shared_ptr< GDALMDArray > poIndexingVariable)
Set the variable that is used to index the dimension.
Definition gdalmultidim.cpp:10235
Format specific driver.
Definition gdal_priv.h:1949
Class used to represent potentially complex data types.
Definition gdal_priv.h:2541
Class modeling a named container of GDALAttribute, GDALMDArray, OGRLayer or other GDALGroup.
Definition gdal_priv.h:2770
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:301
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:270
Class modeling a multi-dimensional array.
Definition gdal_priv.h:3284
virtual bool SetUnit(const std::string &osUnit)
Set the variable unit.
Definition gdalmultidim.cpp:2539
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:3791
virtual bool IsWritable() const =0
Return whether an array is writable.
virtual bool SetScale(double dfScale, GDALDataType eStorageType=GDT_Unknown)
Set the scale value to apply to raw values.
Definition gdalmultidim.cpp:2872
virtual bool SetRawNoDataValue(const void *pRawNoData)
Set the nodata value as a "raw" value.
Definition gdalmultidim.cpp:2731
virtual double GetOffset(bool *pbHasOffset=nullptr, GDALDataType *peStorageType=nullptr) const
Get the offset value to apply to raw values.
Definition gdalmultidim.cpp:2959
virtual const void * GetRawNoDataValue() const
Return the nodata value as a "raw" value.
Definition gdalmultidim.cpp:2615
virtual double GetScale(bool *pbHasScale=nullptr, GDALDataType *peStorageType=nullptr) const
Get the scale value to apply to raw values.
Definition gdalmultidim.cpp:2929
virtual std::shared_ptr< OGRSpatialReference > GetSpatialRef() const
Return the spatial reference system object associated with the array.
Definition gdalmultidim.cpp:2589
virtual const std::string & GetFilename() const =0
Return the filename that contains that array.
virtual bool SetSpatialRef(const OGRSpatialReference *poSRS)
Assign a spatial reference system object to the array.
Definition gdalmultidim.cpp:2575
virtual std::shared_ptr< GDALGroup > GetRootGroup() const
Return the root group to which this arrays belongs too.
Definition gdalmultidim.cpp:4373
virtual bool SetOffset(double dfOffset, GDALDataType eStorageType=GDT_Unknown)
Set the offset value to apply to raw values.
Definition gdalmultidim.cpp:2900
virtual const std::string & GetUnit() const
Return the array unit.
Definition gdalmultidim.cpp:2561
virtual CPLErr SetMetadata(char **papszMetadata, const char *pszDomain="")
Set metadata.
Definition gdalmajorobject.cpp:290
virtual char ** GetMetadataDomainList()
Fetch list of metadata domains.
Definition gdalmajorobject.cpp:160
virtual char ** GetMetadata(const char *pszDomain="")
Fetch metadata.
Definition gdalmajorobject.cpp:247
Class for dataset open functions.
Definition gdal_priv.h:301
Pansharpening operation class.
Definition gdalpansharpen.h:190
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition gdal_rat.h:48
A single raster band (or channel).
Definition gdal_priv.h:1468
GDALDataset * GetDataset()
Fetch the owning dataset handle.
Definition gdalrasterband.cpp:3336
High level image warping class.
Definition gdalwarper.h:502
This class represents an OpenGIS Spatial Reference System, and contains methods for converting betwee...
Definition ogr_spatialref.h:169
CPLErr
Error category.
Definition cpl_error.h:53
Hash set implementation.
struct _CPLHashSet CPLHashSet
Opaque type for a hash set.
Definition cpl_hash_set.h:52
Definitions for CPL mini XML Parser/Serializer.
int GPtrDiff_t
Integer type large enough to hold the difference between 2 addresses.
Definition cpl_port.h:256
#define CPL_NON_FINAL
Mark that a class is explicitly recognized as non-final.
Definition cpl_port.h:1035
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition cpl_port.h:218
GIntBig GInt64
Signed 64 bit integer type.
Definition cpl_port.h:236
#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
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1183
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition cpl_port.h:238
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:185
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:215
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition cpl_virtualmem.h:62
GUIntBig vsi_l_offset
Type for a file offset.
Definition cpl_vsi.h:146
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition gdal.h:315
GDALAccess
Definition gdal.h:125
@ GA_ReadOnly
Definition gdal.h:126
void * VRTPDWorkingDataPtr
Generic pointer for the working structure of VRTProcessedDataset function.
Definition gdal.h:1645
GDALDataType
Definition gdal.h:64
@ GDT_Unknown
Definition gdal.h:65
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:1479
CPLErr GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition gdaldataset.cpp:4127
GDALColorInterp
Definition gdal.h:227
@ GCI_Undefined
Definition gdal.h:228
GDALRWFlag
Definition gdal.h:132
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:1471
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition gdal.h:294
C++ GDAL entry points.
Public (C callable) entry points for virtual GDAL dataset objects.
#define VRT_NODATA_UNSET
Special value to indicate that nodata is not set.
Definition gdal_vrt.h:45
void * VRTDatasetH
Opaque type for a VRT dataset.
Definition gdal_vrt.h:74
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
VRTDatasetH VRTCreate(int, int)
Definition vrtdataset.cpp:82
Document node structure.
Definition cpl_minixml.h:71
Structure to pass extra arguments to RasterIO() method, must be initialized with INIT_RASTERIO_EXTRA_...
Definition gdal.h:176
Ground Control Point.
Definition gdal.h:1077