14#ifndef VIRTUALDATASET_H_INCLUDED
15#define VIRTUALDATASET_H_INCLUDED
21#include "gdal_driver.h"
22#include "gdal_multidim.h"
35CPLErr GDALRegisterDefaultPixelFunc();
36void GDALVRTRegisterDefaultProcessedDatasetFuncs();
41int VRTWarpedOverviewTransform(
void *pTransformArg,
int bDstToSrc,
43 double *padfX,
double *padfY,
double *padfZ,
45void* VRTDeserializeWarpedOverviewTransformer(
CPLXMLNode *psTree );
56 CPLString osFilename{};
58 GDALRasterBand *poBand =
nullptr;
59 int bTriedToOpen = FALSE;
61 VRTOverviewInfo() =
default;
63 VRTOverviewInfo(VRTOverviewInfo &&oOther) noexcept
64 : osFilename(std::move(oOther.osFilename)), nBand(oOther.nBand),
65 poBand(oOther.poBand), bTriedToOpen(oOther.bTriedToOpen)
67 oOther.poBand =
nullptr;
77 if (poBand ==
nullptr)
97class CPL_DLL VRTMapSharedResources
100 VRTMapSharedResources() =
default;
103 GDALDataset *Get(
const std::string &osKey)
const;
108 void Insert(
const std::string &osKey, GDALDataset *poDS);
116 mutable std::mutex m_oMutex{};
117 bool m_bUseMutex =
false;
118 std::map<std::string, GDALDataset *> m_oMap{};
120 std::unique_ptr<std::lock_guard<std::mutex>> LockGuard()
const;
129class CPL_DLL VRTSource
132 struct CPL_DLL WorkingState
136#pragma GCC diagnostic push
137#pragma GCC diagnostic ignored "-Weffc++"
153 inline operator GByte()
const
159#pragma GCC diagnostic pop
162 std::vector<NoInitByte> m_abyWrkBuffer{};
163 std::vector<NoInitByte> m_abyWrkBufferMask{};
166 virtual ~VRTSource();
169 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
172 GDALRasterIOExtraArg *psExtraArg,
173 WorkingState &oWorkingState) = 0;
175 virtual double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess) = 0;
176 virtual double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess) = 0;
177 virtual CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
178 double dfMax,
int nBuckets,
179 GUIntBig *panHistogram,
int bIncludeOutOfRange,
180 int bApproxOK, GDALProgressFunc pfnProgress,
181 void *pProgressData) = 0;
183 virtual CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *,
184 VRTMapSharedResources &) = 0;
185 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath) = 0;
187 virtual void GetFileList(
char ***ppapszFileList,
int *pnSize,
193 virtual bool IsSimpleSource()
const
198 const std::string &GetName()
const
203 void SetName(
const std::string &s)
211 virtual const char *GetType()
const = 0;
213 virtual CPLErr FlushCache(
bool )
219 std::string m_osName{};
222typedef VRTSource *(*VRTSourceParser)(
const CPLXMLNode *,
const char *,
223 VRTMapSharedResources &oMapSharedSources);
225VRTSource *VRTParseCoreSources(
const CPLXMLNode *psTree,
const char *,
226 VRTMapSharedResources &oMapSharedSources);
227VRTSource *VRTParseFilterSources(
const CPLXMLNode *psTree,
const char *,
228 VRTMapSharedResources &oMapSharedSources);
229VRTSource *VRTParseArraySource(
const CPLXMLNode *psTree,
const char *,
230 VRTMapSharedResources &oMapSharedSources);
238template <
class T>
struct VRTFlushCacheStruct
240 static CPLErr FlushCache(T &obj,
bool bAtClosing);
243class VRTWarpedDataset;
244class VRTPansharpenedDataset;
245class VRTProcessedDataset;
247class VRTSimpleSource;
251 friend class VRTRasterBand;
252 friend struct VRTFlushCacheStruct<VRTDataset>;
253 friend struct VRTFlushCacheStruct<VRTWarpedDataset>;
254 friend struct VRTFlushCacheStruct<VRTPansharpenedDataset>;
255 friend struct VRTFlushCacheStruct<VRTProcessedDataset>;
256 friend class VRTSourcedRasterBand;
257 friend class VRTDerivedRasterBand;
258 friend class VRTSimpleSource;
259 friend struct VRTSourcedRasterBandRasterIOJob;
262 std::vector<gdal::GCP> m_asGCPs{};
263 std::unique_ptr<OGRSpatialReference, OGRSpatialReferenceReleaser>
266 bool m_bNeedsFlush =
false;
267 bool m_bWritable =
true;
268 bool m_bCanTakeRef =
true;
270 char *m_pszVRTPath =
nullptr;
272 std::unique_ptr<VRTRasterBand> m_poMaskBand{};
274 mutable int m_nCompatibleForDatasetIO = -1;
275 bool CheckCompatibleForDatasetIO()
const;
279 std::vector<GDALDataset *> m_apoOverviews{};
280 std::vector<GDALDataset *> m_apoOverviewsBak{};
281 CPLStringList m_aosOverviewList{};
282 CPLString m_osOverviewResampling{};
283 std::vector<int> m_anOverviewFactors{};
285 char **m_papszXMLVRTMetadata =
nullptr;
287 VRTMapSharedResources m_oMapSharedSources{};
288 std::shared_ptr<VRTGroup> m_poRootGroup{};
291 VRTSource::WorkingState m_oWorkingState{};
294 struct QueueWorkingStates
297 std::vector<std::unique_ptr<VRTSource::WorkingState>> oStates{};
300 QueueWorkingStates m_oQueueWorkingStates{};
302 bool m_bMultiThreadedRasterIOLastUsed =
false;
304 std::unique_ptr<VRTRasterBand> InitBand(
const char *pszSubclass,
int nBand,
305 bool bAllowPansharpenedOrProcessed);
306 static GDALDataset *OpenVRTProtocol(
const char *pszSpec);
307 bool AddVirtualOverview(
int nOvFactor,
const char *pszResampling);
309 bool GetShiftedDataset(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
310 GDALDataset *&poSrcDataset,
int &nSrcXOff,
313 static bool IsDefaultBlockSize(
int nBlockSize,
int nDimension);
318 bool m_bBlockSizeSpecified =
false;
319 int m_nBlockXSize = 0;
320 int m_nBlockYSize = 0;
322 std::unique_ptr<OGRSpatialReference, OGRSpatialReferenceReleaser> m_poSRS{};
324 int m_bGeoTransformSet =
false;
325 GDALGeoTransform m_gt{};
327 int CloseDependentDatasets()
override;
330 VRTDataset(
int nXSize,
int nYSize,
int nBlockXSize = 0,
331 int nBlockYSize = 0);
332 ~VRTDataset()
override;
336 m_bNeedsFlush =
true;
339 CPLErr FlushCache(
bool bAtClosing)
override;
341 void SetWritable(
int bWritableIn)
343 m_bWritable = CPL_TO_BOOL(bWritableIn);
346 CPLErr CreateMaskBand(
int nFlags)
override;
347 void SetMaskBand(std::unique_ptr<VRTRasterBand> poMaskBand);
349 const OGRSpatialReference *GetSpatialRef()
const override
351 return m_poSRS.get();
354 CPLErr SetSpatialRef(
const OGRSpatialReference *poSRS)
override;
356 CPLErr GetGeoTransform(GDALGeoTransform &)
const override;
357 CPLErr SetGeoTransform(
const GDALGeoTransform &)
override;
359 CPLErr SetMetadata(
char **papszMetadata,
360 const char *pszDomain =
"")
override;
361 CPLErr SetMetadataItem(
const char *pszName,
const char *pszValue,
362 const char *pszDomain =
"")
override;
364 char **GetMetadata(
const char *pszDomain =
"")
override;
365 virtual const char *GetMetadataItem(
const char *pszName,
366 const char *pszDomain =
"")
override;
368 int GetGCPCount()
override;
370 const OGRSpatialReference *GetGCPSpatialRef()
const override
372 return m_poGCP_SRS.get();
375 const GDAL_GCP *GetGCPs()
override;
377 CPLErr SetGCPs(
int nGCPCount,
const GDAL_GCP *pasGCPList,
378 const OGRSpatialReference *poSRS)
override;
381 char **papszOptions =
nullptr)
override;
383 char **GetFileList()
override;
386 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
388 BANDMAP_TYPE panBandMap,
GSpacing nPixelSpace,
390 GDALRasterIOExtraArg *psExtraArg)
override;
392 virtual CPLStringList
393 GetCompressionFormats(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
394 int nBandCount,
const int *panBandList)
override;
395 virtual CPLErr ReadCompressedData(
const char *pszFormat,
int nXOff,
396 int nYOff,
int nXSize,
int nYSize,
397 int nBandCount,
const int *panBandList,
398 void **ppBuffer,
size_t *pnBufferSize,
399 char **ppszDetailedFormat)
override;
401 CPLErr AdviseRead(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
403 int nBandCount,
int *panBandList,
404 char **papszOptions)
override;
406 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath);
407 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *);
409 CPLErr IBuildOverviews(
const char *,
int,
const int *,
int,
const int *,
410 GDALProgressFunc,
void *,
413 std::shared_ptr<GDALGroup> GetRootGroup()
const override;
415 std::shared_ptr<VRTGroup> GetRootVRTGroup()
const
417 return m_poRootGroup;
420 void ClearStatistics()
override;
425 m_nCompatibleForDatasetIO = -1;
429 GDALDataset *GetSingleSimpleSource();
430 void BuildVirtualOverviews();
432 void UnsetPreservedRelativeFilenames();
434 bool IsBlockSizeSpecified()
const
436 return m_bBlockSizeSpecified;
439 int GetBlockXSize()
const
441 return m_nBlockXSize;
444 int GetBlockYSize()
const
446 return m_nBlockYSize;
449 static int Identify(GDALOpenInfo *);
450 static GDALDataset *Open(GDALOpenInfo *);
451 static std::unique_ptr<VRTDataset>
452 OpenXML(
const char *,
const char * =
nullptr,
454 static GDALDataset *Create(
const char *pszName,
int nXSize,
int nYSize,
456 char **papszOptions);
457 static std::unique_ptr<VRTDataset>
458 CreateVRTDataset(
const char *pszName,
int nXSize,
int nYSize,
int nBands,
461 CreateMultiDimensional(
const char *pszFilename,
464 static std::unique_ptr<VRTDataset>
465 CreateVRTMultiDimensional(
const char *pszFilename,
468 static CPLErr Delete(
const char *pszFilename);
470 static int GetNumThreads(GDALDataset *poDS);
472 static bool IsRawRasterBandEnabled();
480class VRTWarpedRasterBand;
482class CPL_DLL VRTWarpedDataset final :
public VRTDataset
484 GDALWarpOperation *m_poWarper;
486 bool m_bIsOverview =
false;
487 std::vector<VRTWarpedDataset *> m_apoOverviews{};
490 bool GetOverviewSize(GDALDataset *poSrcDS,
int iOvr,
int iSrcOvr,
491 int &nOvrXSize,
int &nOvrYSize,
double &dfSrcRatioX,
492 double &dfSrcRatioY)
const;
493 int GetOverviewCount()
const;
494 int GetSrcOverviewLevel(
int iOvr,
bool &bThisLevelOnlyOut)
const;
495 VRTWarpedDataset *CreateImplicitOverview(
int iOvr)
const;
496 void CreateImplicitOverviews();
498 friend class VRTWarpedRasterBand;
503 int CloseDependentDatasets()
override;
506 VRTWarpedDataset(
int nXSize,
int nYSize,
int nBlockXSize = 0,
507 int nBlockYSize = 0);
508 ~VRTWarpedDataset()
override;
510 CPLErr FlushCache(
bool bAtClosing)
override;
512 CPLErr Initialize(
void *);
514 CPLErr IBuildOverviews(
const char *,
int,
const int *,
int,
const int *,
515 GDALProgressFunc,
void *,
518 CPLErr SetMetadataItem(
const char *pszName,
const char *pszValue,
519 const char *pszDomain =
"")
override;
521 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
522 CPLErr XMLInit(
const CPLXMLNode *,
const char *)
override;
525 char **papszOptions =
nullptr)
override;
527 char **GetFileList()
override;
530 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
532 BANDMAP_TYPE panBandMap,
GSpacing nPixelSpace,
534 GDALRasterIOExtraArg *psExtraArg)
override;
536 CPLErr ProcessBlock(
int iBlockX,
int iBlockY);
538 void GetBlockSize(
int *,
int *)
const;
550 GTAdjust_Intersection,
552 GTAdjust_NoneWithoutWarning
555class VRTPansharpenedDataset final :
public VRTDataset
557 friend class VRTPansharpenedRasterBand;
559 std::unique_ptr<GDALPansharpenOperation> m_poPansharpener{};
560 VRTPansharpenedDataset *m_poMainDataset;
561 std::vector<std::unique_ptr<VRTPansharpenedDataset>>
562 m_apoOverviewDatasets{};
564 std::map<CPLString, CPLString> m_oMapToRelativeFilenames{};
566 int m_bLoadingOtherBands;
568 GByte *m_pabyLastBufferBandRasterIO;
569 int m_nLastBandRasterIOXOff;
570 int m_nLastBandRasterIOYOff;
571 int m_nLastBandRasterIOXSize;
572 int m_nLastBandRasterIOYSize;
575 GTAdjustment m_eGTAdjustment;
576 int m_bNoDataDisabled;
578 std::vector<std::unique_ptr<GDALDataset, GDALDatasetUniquePtrReleaser>>
579 m_apoDatasetsToReleaseRef{};
584 int CloseDependentDatasets()
override;
587 VRTPansharpenedDataset(
int nXSize,
int nYSize,
int nBlockXSize = 0,
588 int nBlockYSize = 0);
589 ~VRTPansharpenedDataset()
override;
591 CPLErr FlushCache(
bool bAtClosing)
override;
593 CPLErr XMLInit(
const CPLXMLNode *,
const char *)
override;
594 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
596 CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *pszVRTPath,
601 char **papszOptions =
nullptr)
override;
603 char **GetFileList()
override;
606 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
608 BANDMAP_TYPE panBandMap,
GSpacing nPixelSpace,
610 GDALRasterIOExtraArg *psExtraArg)
override;
612 void GetBlockSize(
int *,
int *)
const;
614 GDALPansharpenOperation *GetPansharpener()
616 return m_poPansharpener.get();
629class VRTProcessedDataset final :
public VRTDataset
632 VRTProcessedDataset(
int nXSize,
int nYSize);
633 ~VRTProcessedDataset()
override;
635 CPLErr FlushCache(
bool bAtClosing)
override;
637 CPLErr XMLInit(
const CPLXMLNode *,
const char *)
override;
638 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
640 void GetBlockSize(
int *,
int *)
const;
644#pragma GCC diagnostic push
645#pragma GCC diagnostic ignored "-Weffc++"
661 inline operator GByte()
const
667#pragma GCC diagnostic pop
672 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
674 BANDMAP_TYPE panBandMap,
GSpacing nPixelSpace,
676 GDALRasterIOExtraArg *psExtraArg)
override;
679 friend class VRTProcessedRasterBand;
685 std::string osAlgorithm{};
688 CPLStringList aosArguments{};
703 std::vector<double> adfInNoData{};
706 std::vector<double> adfOutNoData{};
717 Step &operator=(Step &&);
720 Step(
const Step &) =
delete;
721 Step &operator=(
const Step &) =
delete;
726 std::string m_osVRTPath{};
729 std::unique_ptr<GDALDataset> m_poVRTSrcDS{};
732 std::unique_ptr<GDALDataset> m_poSrcDS{};
735 std::vector<Step> m_aoSteps{};
738 CPLXMLTreeCloser m_oXMLTree{
nullptr};
741 std::vector<std::unique_ptr<GDALDataset>> m_apoOverviewDatasets{};
744 std::vector<NoInitByte> m_abyInput{};
747 std::vector<NoInitByte> m_abyOutput{};
750 enum class ValueProvenance
759 ValueProvenance m_outputBandCountProvenance = ValueProvenance::FROM_SOURCE;
762 int m_outputBandCountValue = 0;
765 ValueProvenance m_outputBandDataTypeProvenance =
766 ValueProvenance::FROM_SOURCE;
772 int m_nWorkingBytesPerPixel = 1;
775 GIntBig m_nAllowedRAMUsage = 0;
777 CPLErr Init(
const CPLXMLNode *,
const char *,
778 const VRTProcessedDataset *poParentDS,
779 GDALDataset *poParentSrcDS,
int iOvrLevel);
781 bool ParseStep(
const CPLXMLNode *psStep,
bool bIsFinalStep,
783 std::vector<double> &adfInNoData,
784 std::vector<double> &adfOutNoData);
785 bool ProcessRegion(
int nXOff,
int nYOff,
int nBufXSize,
int nBufYSize,
786 GDALProgressFunc pfnProgress,
void *pProgressData);
796constexpr double VRT_DEFAULT_NODATA_VALUE = -10000.0;
801 void ResetNoDataValues();
804 friend class VRTDataset;
806 bool m_bIsMaskBand =
false;
808 bool m_bNoDataValueSet =
false;
810 int m_bHideNoDataValue =
false;
811 double m_dfNoDataValue = VRT_DEFAULT_NODATA_VALUE;
813 bool m_bNoDataSetAsInt64 =
false;
814 int64_t m_nNoDataValueInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_INT64;
816 bool m_bNoDataSetAsUInt64 =
false;
817 uint64_t m_nNoDataValueUInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64;
819 std::unique_ptr<GDALColorTable> m_poColorTable{};
823 std::string m_osUnitType{};
824 CPLStringList m_aosCategoryNames{};
826 double m_dfOffset = 0.0;
827 double m_dfScale = 1.0;
829 CPLXMLTreeCloser m_psSavedHistograms{
nullptr};
831 void Initialize(
int nXSize,
int nYSize);
833 std::vector<VRTOverviewInfo> m_aoOverviewInfos{};
835 std::unique_ptr<VRTRasterBand> m_poMaskBand{};
837 std::unique_ptr<GDALRasterAttributeTable> m_poRAT{};
841 bool IsNoDataValueInDataTypeRange()
const;
845 ~VRTRasterBand()
override;
847 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
848 VRTMapSharedResources &);
849 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
850 bool &bHasWarnedAboutRAMUsage,
851 size_t &nAccRAMUsage);
853 CPLErr SetNoDataValue(
double)
override;
854 CPLErr SetNoDataValueAsInt64(int64_t nNoData)
override;
855 CPLErr SetNoDataValueAsUInt64(uint64_t nNoData)
override;
856 double GetNoDataValue(
int *pbSuccess =
nullptr)
override;
857 int64_t GetNoDataValueAsInt64(
int *pbSuccess =
nullptr)
override;
858 uint64_t GetNoDataValueAsUInt64(
int *pbSuccess =
nullptr)
override;
859 CPLErr DeleteNoDataValue()
override;
861 CPLErr SetColorTable(GDALColorTable *)
override;
862 GDALColorTable *GetColorTable()
override;
864 GDALRasterAttributeTable *GetDefaultRAT()
override;
866 SetDefaultRAT(
const GDALRasterAttributeTable *poRAT)
override;
871 const char *GetUnitType()
override;
872 CPLErr SetUnitType(
const char *)
override;
874 char **GetCategoryNames()
override;
875 CPLErr SetCategoryNames(
char **)
override;
877 CPLErr SetMetadata(
char **papszMD,
const char *pszDomain =
"")
override;
878 CPLErr SetMetadataItem(
const char *pszName,
const char *pszValue,
879 const char *pszDomain =
"")
override;
881 double GetOffset(
int *pbSuccess =
nullptr)
override;
882 CPLErr SetOffset(
double)
override;
883 double GetScale(
int *pbSuccess =
nullptr)
override;
884 CPLErr SetScale(
double)
override;
886 int GetOverviewCount()
override;
887 GDALRasterBand *GetOverview(
int)
override;
889 CPLErr GetHistogram(
double dfMin,
double dfMax,
int nBuckets,
890 GUIntBig *panHistogram,
int bIncludeOutOfRange,
891 int bApproxOK, GDALProgressFunc,
892 void *pProgressData)
override;
894 CPLErr GetDefaultHistogram(
double *pdfMin,
double *pdfMax,
int *pnBuckets,
895 GUIntBig **ppanHistogram,
int bForce,
896 GDALProgressFunc,
void *pProgressData)
override;
898 virtual CPLErr SetDefaultHistogram(
double dfMin,
double dfMax,
int nBuckets,
901 CPLErr CopyCommonInfoFrom(GDALRasterBand *);
903 virtual void GetFileList(
char ***ppapszFileList,
int *pnSize,
906 void SetDescription(
const char *)
override;
908 GDALRasterBand *GetMaskBand()
override;
909 int GetMaskFlags()
override;
911 CPLErr CreateMaskBand(
int nFlagsIn)
override;
913 void SetMaskBand(std::unique_ptr<VRTRasterBand> poMaskBand);
915 void SetIsMaskBand();
917 bool IsMaskBand()
const override;
919 CPLErr UnsetNoDataValue();
921 virtual int CloseDependentDatasets();
923 virtual bool IsSourcedRasterBand()
928 virtual bool IsPansharpenRasterBand()
938class VRTSimpleSource;
940class CPL_DLL VRTSourcedRasterBand
CPL_NON_FINAL :
public VRTRasterBand
943 CPLString m_osLastLocationInfo{};
944 CPLStringList m_aosSourceList{};
945 int m_nSkipBufferInitialization = -1;
947 bool CanUseSourcesMinMaxImplementations();
949 bool IsMosaicOfNonOverlappingSimpleSourcesOfFullRasterNoResAndTypeChange(
950 bool bAllowMaxValAdjustment)
const;
955 bool SkipBufferInitialization();
958 std::vector<std::unique_ptr<VRTSource>> m_papoSources{};
960 VRTSourcedRasterBand(GDALDataset *poDS,
int nBand);
961 VRTSourcedRasterBand(
GDALDataType eType,
int nXSize,
int nYSize);
962 VRTSourcedRasterBand(GDALDataset *poDS,
int nBand,
GDALDataType eType,
963 int nXSize,
int nYSize);
964 VRTSourcedRasterBand(GDALDataset *poDS,
int nBand,
GDALDataType eType,
965 int nXSize,
int nYSize,
int nBlockXSizeIn,
967 ~VRTSourcedRasterBand()
override;
971 GDALRasterIOExtraArg *psExtraArg)
override;
973 virtual int IGetDataCoverageStatus(
int nXOff,
int nYOff,
int nXSize,
974 int nYSize,
int nMaskFlagStop,
975 double *pdfDataPct)
override;
977 char **GetMetadataDomainList()
override;
978 virtual const char *GetMetadataItem(
const char *pszName,
979 const char *pszDomain =
"")
override;
980 char **GetMetadata(
const char *pszDomain =
"")
override;
981 CPLErr SetMetadata(
char **papszMetadata,
982 const char *pszDomain =
"")
override;
983 CPLErr SetMetadataItem(
const char *pszName,
const char *pszValue,
984 const char *pszDomain =
"")
override;
986 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
987 VRTMapSharedResources &)
override;
988 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
989 bool &bHasWarnedAboutRAMUsage,
990 size_t &nAccRAMUsage)
override;
992 double GetMinimum(
int *pbSuccess =
nullptr)
override;
993 double GetMaximum(
int *pbSuccess =
nullptr)
override;
994 virtual CPLErr ComputeRasterMinMax(
int bApproxOK,
995 double *adfMinMax)
override;
996 virtual CPLErr ComputeStatistics(
int bApproxOK,
double *pdfMin,
997 double *pdfMax,
double *pdfMean,
999 GDALProgressFunc pfnProgress,
1000 void *pProgressData)
override;
1001 CPLErr GetHistogram(
double dfMin,
double dfMax,
int nBuckets,
1002 GUIntBig *panHistogram,
int bIncludeOutOfRange,
1003 int bApproxOK, GDALProgressFunc pfnProgress,
1004 void *pProgressData)
override;
1006 CPLErr AddSource(std::unique_ptr<VRTSource>);
1008 CPLErr AddSource(VRTSource *);
1010 CPLErr AddSimpleSource(
const char *pszFilename,
int nBand,
1011 double dfSrcXOff = -1,
double dfSrcYOff = -1,
1012 double dfSrcXSize = -1,
double dfSrcYSize = -1,
1013 double dfDstXOff = -1,
double dfDstYOff = -1,
1014 double dfDstXSize = -1,
double dfDstYSize = -1,
1015 const char *pszResampling =
"near",
1018 CPLErr AddSimpleSource(GDALRasterBand *poSrcBand,
double dfSrcXOff = -1,
1019 double dfSrcYOff = -1,
double dfSrcXSize = -1,
1020 double dfSrcYSize = -1,
double dfDstXOff = -1,
1021 double dfDstYOff = -1,
double dfDstXSize = -1,
1022 double dfDstYSize = -1,
1023 const char *pszResampling =
"near",
1026 CPLErr AddComplexSource(
const char *pszFilename,
int nBand,
1027 double dfSrcXOff = -1,
double dfSrcYOff = -1,
1028 double dfSrcXSize = -1,
double dfSrcYSize = -1,
1029 double dfDstXOff = -1,
double dfDstYOff = -1,
1030 double dfDstXSize = -1,
double dfDstYSize = -1,
1031 double dfScaleOff = 0.0,
double dfScaleRatio = 1.0,
1033 int nColorTableComponent = 0);
1035 CPLErr AddComplexSource(GDALRasterBand *poSrcBand,
double dfSrcXOff = -1,
1036 double dfSrcYOff = -1,
double dfSrcXSize = -1,
1037 double dfSrcYSize = -1,
double dfDstXOff = -1,
1038 double dfDstYOff = -1,
double dfDstXSize = -1,
1039 double dfDstYSize = -1,
double dfScaleOff = 0.0,
1040 double dfScaleRatio = 1.0,
1042 int nColorTableComponent = 0);
1044 CPLErr AddMaskBandSource(GDALRasterBand *poSrcBand,
double dfSrcXOff = -1,
1045 double dfSrcYOff = -1,
double dfSrcXSize = -1,
1046 double dfSrcYSize = -1,
double dfDstXOff = -1,
1047 double dfDstYOff = -1,
double dfDstXSize = -1,
1048 double dfDstYSize = -1);
1053 void ConfigureSource(VRTSimpleSource *poSimpleSource,
1054 GDALRasterBand *poSrcBand,
int bAddAsMaskBand,
1055 double dfSrcXOff,
double dfSrcYOff,
double dfSrcXSize,
1056 double dfSrcYSize,
double dfDstXOff,
double dfDstYOff,
1057 double dfDstXSize,
double dfDstYSize);
1059 void RemoveCoveredSources(
CSLConstList papszOptions =
nullptr);
1061 bool CanIRasterIOBeForwardedToEachSource(
1062 GDALRWFlag eRWFlag,
int nXOff,
int nYOff,
int nXSize,
int nYSize,
1063 int nBufXSize,
int nBufYSize, GDALRasterIOExtraArg *psExtraArg)
const;
1065 bool CanMultiThreadRasterIO(
double dfXOff,
double dfYOff,
double dfXSize,
1067 int &nContributingSources)
const;
1069 CPLErr IReadBlock(
int,
int,
void *)
override;
1071 virtual void GetFileList(
char ***ppapszFileList,
int *pnSize,
1072 int *pnMaxSize,
CPLHashSet *hSetFiles)
override;
1074 int CloseDependentDatasets()
override;
1076 bool IsSourcedRasterBand()
override
1081 CPLErr FlushCache(
bool bAtClosing)
override;
1088class CPL_DLL VRTWarpedRasterBand final :
public VRTRasterBand
1091 VRTWarpedRasterBand(GDALDataset *poDS,
int nBand,
1093 ~VRTWarpedRasterBand()
override;
1095 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1096 bool &bHasWarnedAboutRAMUsage,
1097 size_t &nAccRAMUsage)
override;
1099 CPLErr IReadBlock(
int,
int,
void *)
override;
1100 CPLErr IWriteBlock(
int,
int,
void *)
override;
1103 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
1106 GDALRasterIOExtraArg *psExtraArg)
override;
1108 int GetOverviewCount()
override;
1109 GDALRasterBand *GetOverview(
int)
override;
1112 EmitErrorMessageIfWriteNotSupported(
const char *pszCaller)
const override;
1115 int m_nIRasterIOCounter =
1118 int GetBestOverviewLevel(
int &nXOff,
int &nYOff,
int &nXSize,
int &nYSize,
1119 int nBufXSize,
int nBufYSize,
1120 GDALRasterIOExtraArg *psExtraArg)
const;
1127class VRTPansharpenedRasterBand final :
public VRTRasterBand
1129 int m_nIndexAsPansharpenedBand;
1132 VRTPansharpenedRasterBand(GDALDataset *poDS,
int nBand,
1134 ~VRTPansharpenedRasterBand()
override;
1136 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1137 bool &bHasWarnedAboutRAMUsage,
1138 size_t &nAccRAMUsage)
override;
1140 CPLErr IReadBlock(
int,
int,
void *)
override;
1143 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
1146 GDALRasterIOExtraArg *psExtraArg)
override;
1148 int GetOverviewCount()
override;
1149 GDALRasterBand *GetOverview(
int)
override;
1151 bool IsPansharpenRasterBand()
override
1156 void SetIndexAsPansharpenedBand(
int nIdx)
1158 m_nIndexAsPansharpenedBand = nIdx;
1161 int GetIndexAsPansharpenedBand()
const
1163 return m_nIndexAsPansharpenedBand;
1171class VRTProcessedRasterBand final :
public VRTRasterBand
1174 VRTProcessedRasterBand(VRTProcessedDataset *poDS,
int nBand,
1177 CPLErr IReadBlock(
int,
int,
void *)
override;
1179 int GetOverviewCount()
override;
1180 GDALRasterBand *GetOverview(
int)
override;
1182 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1183 bool &bHasWarnedAboutRAMUsage,
1184 size_t &nAccRAMUsage)
override;
1191class VRTDerivedRasterBandPrivateData;
1193class CPL_DLL VRTDerivedRasterBand
CPL_NON_FINAL :
public VRTSourcedRasterBand
1195 VRTDerivedRasterBandPrivateData *m_poPrivate;
1196 bool InitializePython();
1197 CPLErr GetPixelFunctionArguments(
1198 const CPLString &,
const std::vector<int> &anMapBufferIdxToSourceIdx,
1199 int nXOff,
int nYOff, std::vector<std::pair<CPLString, CPLString>> &);
1204 CPLString osFuncName{};
1211 VRTDerivedRasterBand(GDALDataset *poDS,
int nBand);
1212 VRTDerivedRasterBand(GDALDataset *poDS,
int nBand,
GDALDataType eType,
1213 int nXSize,
int nYSize,
int nBlockXSizeIn = 0,
1214 int nBlockYSizeIn = 0);
1215 ~VRTDerivedRasterBand()
override;
1219 GDALRasterIOExtraArg *psExtraArg)
override;
1221 virtual int IGetDataCoverageStatus(
int nXOff,
int nYOff,
int nXSize,
1222 int nYSize,
int nMaskFlagStop,
1223 double *pdfDataPct)
override;
1225 static CPLErr AddPixelFunction(
const char *pszFuncNameIn,
1227 static CPLErr AddPixelFunction(
const char *pszFuncNameIn,
1229 const char *pszMetadata);
1231 static const std::pair<PixelFunc, std::string> *
1232 GetPixelFunction(
const char *pszFuncNameIn);
1234 static std::vector<std::string> GetPixelFunctionNames();
1236 void SetPixelFunctionName(
const char *pszFuncNameIn);
1237 void AddPixelFunctionArgument(
const char *pszArg,
const char *pszValue);
1238 void SetSkipNonContributingSources(
bool bSkip);
1240 void SetPixelFunctionLanguage(
const char *pszLanguage);
1242 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
1243 VRTMapSharedResources &)
override;
1244 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1245 bool &bHasWarnedAboutRAMUsage,
1246 size_t &nAccRAMUsage)
override;
1248 double GetMinimum(
int *pbSuccess =
nullptr)
override;
1249 double GetMaximum(
int *pbSuccess =
nullptr)
override;
1250 virtual CPLErr ComputeRasterMinMax(
int bApproxOK,
1251 double *adfMinMax)
override;
1252 virtual CPLErr ComputeStatistics(
int bApproxOK,
double *pdfMin,
1253 double *pdfMax,
double *pdfMean,
1255 GDALProgressFunc pfnProgress,
1256 void *pProgressData)
override;
1257 CPLErr GetHistogram(
double dfMin,
double dfMax,
int nBuckets,
1258 GUIntBig *panHistogram,
int bIncludeOutOfRange,
1259 int bApproxOK, GDALProgressFunc pfnProgress,
1260 void *pProgressData)
override;
1262 static void Cleanup();
1265#ifndef GDAL_VRT_DISABLE_RAWRASTERBAND
1272class CPL_DLL VRTRawRasterBand
CPL_NON_FINAL :
public VRTRasterBand
1274 RawRasterBand *m_poRawRaster;
1276 char *m_pszSourceFilename;
1277 int m_bRelativeToVRT;
1282 VRTRawRasterBand(GDALDataset *poDS,
int nBand,
1284 ~VRTRawRasterBand()
override;
1286 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
1287 VRTMapSharedResources &)
override;
1288 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1289 bool &bHasWarnedAboutRAMUsage,
1290 size_t &nAccRAMUsage)
override;
1294 GDALRasterIOExtraArg *psExtraArg)
override;
1296 CPLErr IReadBlock(
int,
int,
void *)
override;
1297 CPLErr IWriteBlock(
int,
int,
void *)
override;
1299 CPLErr SetRawLink(
const char *pszFilename,
const char *pszVRTPath,
1301 int nPixelOffset,
int nLineOffset,
1302 const char *pszByteOrder);
1304 void ClearRawLink();
1308 char **papszOptions)
override;
1310 virtual void GetFileList(
char ***ppapszFileList,
int *pnSize,
1311 int *pnMaxSize,
CPLHashSet *hSetFiles)
override;
1323 std::mutex m_oMutex{};
1324 std::map<std::string, VRTSourceParser> m_oMapSourceParser{};
1328 ~VRTDriver()
override;
1330 char **papszSourceParsers;
1333 char **
GetMetadata(
const char *pszDomain =
"")
override;
1335 const char *pszDomain =
"")
override;
1337 VRTSource *ParseSource(
const CPLXMLNode *psSrc,
const char *pszVRTPath,
1338 VRTMapSharedResources &oMapSharedSources);
1339 void AddSourceParser(
const char *pszElementName, VRTSourceParser pfnParser);
1346class CPL_DLL VRTSimpleSource
CPL_NON_FINAL :
public VRTSource
1352 VRTMapSharedResources *m_poMapSharedSources =
nullptr;
1354 mutable GDALRasterBand *m_poRasterBand =
nullptr;
1358 mutable GDALRasterBand *m_poMaskBandMainBand =
nullptr;
1360 CPLStringList m_aosOpenOptionsOri{};
1363 bool m_bSrcDSNameFromVRT =
1366 void OpenSource()
const;
1368 GDALDataset *GetSourceDataset()
const;
1371 friend class VRTSourcedRasterBand;
1372 friend class VRTDerivedRasterBand;
1373 friend class VRTDataset;
1374 friend class GDALTileIndexDataset;
1375 friend class GDALTileIndexBand;
1378 bool m_bGetMaskBand =
false;
1384 static constexpr double UNINIT_WINDOW = -1.0;
1386 double m_dfSrcXOff = UNINIT_WINDOW;
1387 double m_dfSrcYOff = UNINIT_WINDOW;
1388 double m_dfSrcXSize = UNINIT_WINDOW;
1389 double m_dfSrcYSize = UNINIT_WINDOW;
1391 double m_dfDstXOff = UNINIT_WINDOW;
1392 double m_dfDstYOff = UNINIT_WINDOW;
1393 double m_dfDstXSize = UNINIT_WINDOW;
1394 double m_dfDstYSize = UNINIT_WINDOW;
1396 CPLString m_osResampling{};
1398 int m_nMaxValue = 0;
1400 int m_bRelativeToVRTOri = -1;
1401 CPLString m_osSourceFileNameOri{};
1402 int m_nExplicitSharedStatus = -1;
1403 CPLString m_osSrcDSName{};
1405 bool m_bDropRefOnSrcBand =
true;
1407 int NeedMaxValAdjustment()
const;
1409 GDALRasterBand *GetRasterBandNoOpen()
const
1411 return m_poRasterBand;
1414 void SetRasterBand(GDALRasterBand *poBand,
bool bDropRef)
1416 m_poRasterBand = poBand;
1417 m_bDropRefOnSrcBand = bDropRef;
1420 virtual bool ValidateOpenedBand(GDALRasterBand * )
const
1426 bool IsSrcWinSet()
const
1428 return m_dfSrcXOff != UNINIT_WINDOW || m_dfSrcYOff != UNINIT_WINDOW ||
1429 m_dfSrcXSize != UNINIT_WINDOW || m_dfSrcYSize != UNINIT_WINDOW;
1433 bool IsDstWinSet()
const
1435 return m_dfDstXOff != UNINIT_WINDOW || m_dfDstYOff != UNINIT_WINDOW ||
1436 m_dfDstXSize != UNINIT_WINDOW || m_dfDstYSize != UNINIT_WINDOW;
1439 void AddSourceFilenameNode(
const char *pszVRTPath, CPLXMLNode *psSrc);
1443 VRTSimpleSource(
const VRTSimpleSource *poSrcSource,
double dfXDstRatio,
1444 double dfYDstRatio);
1445 ~VRTSimpleSource()
override;
1447 virtual CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *,
1448 VRTMapSharedResources &)
override;
1449 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1451 CPLErr ParseSrcRectAndDstRect(
const CPLXMLNode *psSrc);
1453 void SetSrcBand(
const char *pszFilename,
int nBand);
1454 void SetSrcBand(GDALRasterBand *);
1455 void SetSrcMaskBand(GDALRasterBand *);
1456 void SetSrcWindow(
double,
double,
double,
double);
1457 void SetDstWindow(
double,
double,
double,
double);
1458 void GetDstWindow(
double &,
double &,
double &,
double &)
const;
1459 bool DstWindowIntersects(
double dfXOff,
double dfYOff,
double dfXSize,
1460 double dfYSize)
const;
1462 const std::string &GetSourceDatasetName()
const
1464 return m_osSrcDSName;
1468 void SetSourceDatasetName(
const char *pszFilename,
bool bRelativeToVRT);
1470 const CPLString &GetResampling()
const
1472 return m_osResampling;
1475 void SetResampling(
const char *pszResampling);
1477 int GetSrcDstWindow(
double,
double,
double,
double,
int,
int,
1478 double *pdfReqXOff,
double *pdfReqYOff,
1479 double *pdfReqXSize,
double *pdfReqYSize,
int *,
int *,
1480 int *,
int *,
int *,
int *,
int *,
int *,
1483 int GetSrcDstWindow(
double,
double,
double,
double,
int,
int,
1485 double *pdfReqYOff,
double *pdfReqXSize,
1486 double *pdfReqYSize,
int *,
int *,
int *,
int *,
int *,
1487 int *,
int *,
int *,
bool &bErrorOut);
1490 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1493 GDALRasterIOExtraArg *psExtraArgIn,
1494 WorkingState &oWorkingState)
override;
1496 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1497 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1498 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1499 int nBuckets,
GUIntBig *panHistogram,
1500 int bIncludeOutOfRange,
int bApproxOK,
1501 GDALProgressFunc pfnProgress,
1502 void *pProgressData)
override;
1504 void DstToSrc(
double dfX,
double dfY,
double &dfXOut,
double &dfYOut)
const;
1505 void SrcToDst(
double dfX,
double dfY,
double &dfXOut,
double &dfYOut)
const;
1507 virtual void GetFileList(
char ***ppapszFileList,
int *pnSize,
1508 int *pnMaxSize,
CPLHashSet *hSetFiles)
override;
1510 bool IsSimpleSource()
const override
1518 static const char *GetTypeStatic();
1520 const char *GetType()
const override;
1522 CPLErr FlushCache(
bool bAtClosing)
override;
1524 GDALRasterBand *GetRasterBand()
const;
1525 GDALRasterBand *GetMaskBandMainBand();
1526 bool IsSameExceptBandNumber(
const VRTSimpleSource *poOtherSource)
const;
1528 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1530 const int *panBandMap,
GSpacing nPixelSpace,
1532 GDALRasterIOExtraArg *psExtraArg);
1534 void UnsetPreservedRelativeFilenames();
1536 void SetMaxValue(
int nVal)
1546class VRTAveragedSource final :
public VRTSimpleSource
1550 int m_bNoDataSet =
false;
1554 VRTAveragedSource();
1556 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1559 GDALRasterIOExtraArg *psExtraArgIn,
1560 WorkingState &oWorkingState)
override;
1562 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1563 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1564 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1565 int nBuckets,
GUIntBig *panHistogram,
1566 int bIncludeOutOfRange,
int bApproxOK,
1567 GDALProgressFunc pfnProgress,
1568 void *pProgressData)
override;
1570 void SetNoDataValue(
double dfNoDataValue);
1572 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1577 static const char *GetTypeStatic();
1579 const char *GetType()
const override;
1586class VRTNoDataFromMaskSource final :
public VRTSimpleSource
1590 bool m_bNoDataSet =
false;
1591 double m_dfNoDataValue = 0;
1592 double m_dfMaskValueThreshold = 0;
1593 bool m_bHasRemappedValue =
false;
1594 double m_dfRemappedValue = 0;
1597 VRTNoDataFromMaskSource();
1599 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1602 GDALRasterIOExtraArg *psExtraArgIn,
1603 WorkingState &oWorkingState)
override;
1605 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1606 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1607 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1608 int nBuckets,
GUIntBig *panHistogram,
1609 int bIncludeOutOfRange,
int bApproxOK,
1610 GDALProgressFunc pfnProgress,
1611 void *pProgressData)
override;
1613 void SetParameters(
double dfNoDataValue,
double dfMaskValueThreshold);
1614 void SetParameters(
double dfNoDataValue,
double dfMaskValueThreshold,
1615 double dfRemappedValue);
1617 virtual CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *,
1618 VRTMapSharedResources &)
override;
1619 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1624 static const char *GetTypeStatic();
1626 const char *GetType()
const override;
1633class CPL_DLL VRTComplexSource
CPL_NON_FINAL :
public VRTSimpleSource
1638 static constexpr int PROCESSING_FLAG_NODATA = 1 << 0;
1639 static constexpr int PROCESSING_FLAG_USE_MASK_BAND =
1641 static constexpr int PROCESSING_FLAG_SCALING_LINEAR = 1 << 2;
1642 static constexpr int PROCESSING_FLAG_SCALING_EXPONENTIAL =
1644 static constexpr int PROCESSING_FLAG_COLOR_TABLE_EXPANSION = 1 << 4;
1645 static constexpr int PROCESSING_FLAG_LUT = 1 << 5;
1647 int m_nProcessingFlags = 0;
1652 m_osNoDataValueOri{};
1654 double m_dfScaleOff = 0;
1655 double m_dfScaleRatio = 1;
1658 bool m_bSrcMinMaxDefined =
false;
1659 double m_dfSrcMin = 0;
1660 double m_dfSrcMax = 0;
1661 double m_dfDstMin = 0;
1662 double m_dfDstMax = 0;
1663 double m_dfExponent = 1;
1664 bool m_bClip =
true;
1666 int m_nColorTableComponent = 0;
1668 std::vector<double> m_adfLUTInputs{};
1669 std::vector<double> m_adfLUTOutputs{};
1671 double GetAdjustedNoDataValue()
const;
1673 template <
class WorkingDT>
1675 RasterIOInternal(GDALRasterBand *poSourceBand,
1676 GDALDataType eVRTBandDataType,
int nReqXOff,
int nReqYOff,
1677 int nReqXSize,
int nReqYSize,
void *pData,
int nOutXSize,
1679 GSpacing nLineSpace, GDALRasterIOExtraArg *psExtraArg,
1680 GDALDataType eWrkDataType, WorkingState &oWorkingState);
1682 template <
class SourceDT, GDALDataType eSourceType>
1683 CPLErr RasterIOProcessNoData(GDALRasterBand *poSourceBand,
1685 int nReqYOff,
int nReqXSize,
int nReqYSize,
1686 void *pData,
int nOutXSize,
int nOutYSize,
1689 GDALRasterIOExtraArg *psExtraArg,
1690 WorkingState &oWorkingState);
1693 VRTComplexSource() =
default;
1694 VRTComplexSource(
const VRTComplexSource *poSrcSource,
double dfXDstRatio,
1695 double dfYDstRatio);
1698 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1701 GDALRasterIOExtraArg *psExtraArgIn,
1702 WorkingState &oWorkingState)
override;
1704 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1705 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1706 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1707 int nBuckets,
GUIntBig *panHistogram,
1708 int bIncludeOutOfRange,
int bApproxOK,
1709 GDALProgressFunc pfnProgress,
1710 void *pProgressData)
override;
1712 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1713 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
1714 VRTMapSharedResources &)
override;
1719 static const char *GetTypeStatic();
1721 const char *GetType()
const override;
1723 bool AreValuesUnchanged()
const;
1725 double LookupValue(
double dfInput);
1727 void SetNoDataValue(
double dfNoDataValue);
1729 void SetUseMaskBand(
bool bUseMaskBand)
1732 m_nProcessingFlags |= PROCESSING_FLAG_USE_MASK_BAND;
1734 m_nProcessingFlags &= ~PROCESSING_FLAG_USE_MASK_BAND;
1737 void SetLinearScaling(
double dfOffset,
double dfScale);
1738 void SetPowerScaling(
double dfExponent,
double dfSrcMin,
double dfSrcMax,
1739 double dfDstMin,
double dfDstMax,
bool bClip =
true);
1740 void SetColorTableComponent(
int nComponent);
1742 void SetLUT(
const std::vector<double> &adfLUTInputs,
1743 const std::vector<double> &adfLUTOutputs);
1750class VRTFilteredSource
CPL_NON_FINAL :
public VRTComplexSource
1758 int m_nSupportedTypesCount;
1761 int m_nExtraEdgePixels;
1764 VRTFilteredSource();
1765 ~VRTFilteredSource()
override;
1767 const char *GetType()
const override = 0;
1769 void SetExtraEdgePixels(
int);
1770 void SetFilteringDataTypesSupported(
int,
GDALDataType *);
1776 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1779 GDALRasterIOExtraArg *psExtraArg,
1780 WorkingState &oWorkingState)
override;
1787class VRTKernelFilteredSource
CPL_NON_FINAL :
public VRTFilteredSource
1792 int m_nKernelSize = 0;
1793 bool m_bSeparable =
false;
1795 std::vector<double> m_adfKernelCoefs{};
1796 bool m_bNormalized =
false;
1797 std::string m_function{};
1800 VRTKernelFilteredSource();
1802 const char *GetType()
const override;
1804 virtual CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *,
1805 VRTMapSharedResources &)
override;
1806 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1809 GByte *pabySrcData,
GByte *pabyDstData)
override;
1811 CPLErr SetKernel(
int nKernelSize,
bool bSeparable,
1812 const std::vector<double> &adfNewCoefs);
1813 void SetNormalized(
bool);
1815 void SetFunction(
const std::string &s)
1825class VRTAverageFilteredSource final :
public VRTKernelFilteredSource
1830 explicit VRTAverageFilteredSource(
int nKernelSize);
1831 ~VRTAverageFilteredSource()
override;
1833 const char *GetType()
const override;
1835 virtual CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *,
1836 VRTMapSharedResources &)
override;
1837 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1843class VRTFuncSource final :
public VRTSource
1849 ~VRTFuncSource()
override;
1851 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
1852 VRTMapSharedResources &)
override
1857 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1860 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1863 GDALRasterIOExtraArg *psExtraArg,
1864 WorkingState &oWorkingState)
override;
1866 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1867 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1868 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1869 int nBuckets,
GUIntBig *panHistogram,
1870 int bIncludeOutOfRange,
int bApproxOK,
1871 GDALProgressFunc pfnProgress,
1872 void *pProgressData)
override;
1874 const char *GetType()
const override;
1888#define TMP_CPL_DLL CPL_DLL
1904 explicit Ref(VRTGroup *ptr) : m_ptr(ptr)
1908 Ref(
const Ref &) =
delete;
1909 Ref &operator=(
const Ref &) =
delete;
1913 std::shared_ptr<Ref> m_poSharedRefRootGroup{};
1914 std::weak_ptr<Ref> m_poWeakRefRootGroup{};
1915 std::shared_ptr<Ref> m_poRefSelf{};
1917 std::string m_osFilename{};
1918 mutable bool m_bDirty =
false;
1919 std::string m_osVRTPath{};
1920 std::vector<std::string> m_aosGroupNames{};
1921 std::map<std::string, std::shared_ptr<VRTGroup>> m_oMapGroups{};
1922 std::vector<std::string> m_aosMDArrayNames{};
1923 std::map<std::string, std::shared_ptr<VRTMDArray>> m_oMapMDArrays{};
1924 std::map<std::string, std::shared_ptr<VRTAttribute>> m_oMapAttributes{};
1925 std::map<std::string, std::shared_ptr<VRTDimension>> m_oMapDimensions{};
1927 std::shared_ptr<VRTGroup>
1928 OpenGroupInternal(
const std::string &osName)
const;
1929 void SetRootGroupRef(
const std::weak_ptr<Ref> &rgRef);
1930 std::weak_ptr<Ref> GetRootGroupRef()
const;
1933 friend class VRTMDArray;
1934 friend std::shared_ptr<GDALMDArray>
1935 VRTDerivedArrayCreate(
const char *pszVRTPath,
const CPLXMLNode *psTree);
1937 explicit VRTGroup(
const char *pszVRTPath);
1938 VRTGroup(
const std::string &osParentName,
const std::string &osName);
1941 static std::shared_ptr<VRTGroup> Create(
const std::string &osParentName,
1942 const std::string &osName)
1945 std::shared_ptr<VRTGroup>(
new VRTGroup(osParentName, osName));
1946 poGroup->SetSelf(poGroup);
1950 ~VRTGroup()
override;
1952 bool XMLInit(
const std::shared_ptr<VRTGroup> &poRoot,
1953 const std::shared_ptr<VRTGroup> &poThisGroup,
1954 const CPLXMLNode *psNode,
const char *pszVRTPath);
1956 std::vector<std::string>
1957 GetMDArrayNames(
CSLConstList papszOptions)
const override;
1958 std::shared_ptr<GDALMDArray>
1959 OpenMDArray(
const std::string &osName,
1962 std::vector<std::string>
1963 GetGroupNames(
CSLConstList papszOptions)
const override;
1965 std::shared_ptr<GDALGroup> OpenGroup(
const std::string &osName,
1968 return OpenGroupInternal(osName);
1971 std::vector<std::shared_ptr<GDALDimension>>
1974 std::vector<std::shared_ptr<GDALAttribute>>
1977 std::shared_ptr<VRTDimension> GetDimension(
const std::string &name)
const
1979 auto oIter = m_oMapDimensions.find(name);
1980 return oIter == m_oMapDimensions.end() ? nullptr : oIter->second;
1983 std::shared_ptr<VRTDimension>
1984 GetDimensionFromFullName(
const std::string &name,
bool bEmitError)
const;
1986 std::shared_ptr<GDALGroup>
1987 CreateGroup(
const std::string &osName,
1990 std::shared_ptr<VRTGroup>
1991 CreateVRTGroup(
const std::string &osName,
1994 std::shared_ptr<GDALDimension>
1995 CreateDimension(
const std::string &osName,
const std::string &osType,
1996 const std::string &osDirection,
GUInt64 nSize,
1999 std::shared_ptr<GDALAttribute>
2000 CreateAttribute(
const std::string &osName,
2001 const std::vector<GUInt64> &anDimensions,
2002 const GDALExtendedDataType &oDataType,
2005 std::shared_ptr<GDALMDArray> CreateMDArray(
2006 const std::string &osName,
2007 const std::vector<std::shared_ptr<GDALDimension>> &aoDimensions,
2008 const GDALExtendedDataType &oDataType,
2011 std::shared_ptr<VRTMDArray> CreateVRTMDArray(
2012 const std::string &osName,
2013 const std::vector<std::shared_ptr<GDALDimension>> &aoDimensions,
2014 const GDALExtendedDataType &oDataType,
2017 void SetIsRootGroup();
2019 const std::shared_ptr<Ref> &GetRef()
const
2024 VRTGroup *GetRootGroup()
const;
2025 std::shared_ptr<VRTGroup> GetRootGroupSharedPtr()
const;
2027 const std::string &GetVRTPath()
const
2032 void SetVRTPath(
const std::string &osVRTPath)
2034 m_osVRTPath = osVRTPath;
2039 void SetFilename(
const std::string &osFilename)
2041 m_osFilename = osFilename;
2044 const std::string &GetFilename()
const
2046 return m_osFilename;
2049 bool Serialize()
const;
2050 CPLXMLNode *SerializeToXML(
const char *pszVRTPathIn)
const;
2051 void Serialize(CPLXMLNode *psParent,
const char *pszVRTPathIn)
const;
2060 std::weak_ptr<VRTGroup::Ref> m_poGroupRef;
2061 std::string m_osIndexingVariableName;
2064 VRTDimension(
const std::shared_ptr<VRTGroup::Ref> &poGroupRef,
2065 const std::string &osParentName,
const std::string &osName,
2066 const std::string &osType,
const std::string &osDirection,
2067 GUInt64 nSize,
const std::string &osIndexingVariableName)
2068 : GDALDimension(osParentName, osName, osType, osDirection, nSize),
2069 m_poGroupRef(poGroupRef),
2070 m_osIndexingVariableName(osIndexingVariableName)
2074 VRTGroup *GetGroup()
const;
2076 static std::shared_ptr<VRTDimension>
2077 Create(
const std::shared_ptr<VRTGroup> &poThisGroup,
2078 const std::string &osParentName,
const CPLXMLNode *psNode);
2083 std::shared_ptr<GDALMDArray> poIndexingVariable)
override;
2085 void Serialize(CPLXMLNode *psParent)
const;
2094 GDALExtendedDataType m_dt;
2095 std::vector<std::string> m_aosList{};
2096 std::vector<std::shared_ptr<GDALDimension>> m_dims{};
2099 bool IRead(
const GUInt64 *arrayStartIdx,
const size_t *count,
2101 const GDALExtendedDataType &bufferDataType,
2102 void *pDstBuffer)
const override;
2104 bool IWrite(
const GUInt64 *arrayStartIdx,
const size_t *count,
2106 const GDALExtendedDataType &bufferDataType,
2107 const void *pSrcBuffer)
override;
2110 VRTAttribute(
const std::string &osParentName,
const std::string &osName,
2111 const GDALExtendedDataType &dt,
2112 std::vector<std::string> &&aosList)
2113 : GDALAbstractMDArray(osParentName, osName),
2114 GDALAttribute(osParentName, osName), m_dt(dt),
2115 m_aosList(std::move(aosList))
2117 if (m_aosList.size() > 1)
2119 m_dims.emplace_back(std::make_shared<GDALDimension>(
2120 std::string(),
"dim", std::string(), std::string(),
2125 VRTAttribute(
const std::string &osParentName,
const std::string &osName,
2126 GUInt64 nDim,
const GDALExtendedDataType &dt)
2127 : GDALAbstractMDArray(osParentName, osName),
2128 GDALAttribute(osParentName, osName), m_dt(dt)
2132 m_dims.emplace_back(std::make_shared<GDALDimension>(
2133 std::string(),
"dim", std::string(), std::string(), nDim));
2137 static bool CreationCommonChecks(
2138 const std::string &osName,
const std::vector<GUInt64> &anDimensions,
2139 const std::map<std::string, std::shared_ptr<VRTAttribute>>
2142 static std::shared_ptr<VRTAttribute> Create(
const std::string &osParentName,
2143 const CPLXMLNode *psNode);
2145 const std::vector<std::shared_ptr<GDALDimension>> &
2151 const GDALExtendedDataType &
GetDataType()
const override
2156 void Serialize(CPLXMLNode *psParent)
const;
2163class VRTMDArraySource
2166 virtual ~VRTMDArraySource();
2168 enum class RelationShip
2171 PARTIAL_INTERSECTION,
2175 virtual RelationShip GetRelationship(
const uint64_t *arrayStartIdx,
2176 const size_t *count)
const = 0;
2178 virtual bool GetRawBlockInfo(
const uint64_t *arrayStartIdx,
2179 const size_t *count,
2180 GDALMDArrayRawBlockInfo &info)
const = 0;
2182 virtual bool Read(
const GUInt64 *arrayStartIdx,
const size_t *count,
2184 const GDALExtendedDataType &bufferDataType,
2185 void *pDstBuffer)
const = 0;
2187 virtual void Serialize(CPLXMLNode *psParent,
2188 const char *pszVRTPath)
const = 0;
2198 friend class VRTGroup;
2200 std::weak_ptr<VRTGroup::Ref> m_poGroupRef;
2201 std::string m_osVRTPath{};
2202 std::shared_ptr<VRTGroup> m_poDummyOwningGroup{};
2204 GDALExtendedDataType m_dt;
2205 std::vector<std::shared_ptr<GDALDimension>> m_dims;
2206 std::map<std::string, std::shared_ptr<VRTAttribute>> m_oMapAttributes{};
2207 std::vector<std::unique_ptr<VRTMDArraySource>> m_sources{};
2208 std::shared_ptr<OGRSpatialReference> m_poSRS{};
2209 std::vector<GByte> m_abyNoData{};
2210 std::string m_osUnit{};
2211 double m_dfScale = 1.0;
2212 double m_dfOffset = 0.0;
2213 bool m_bHasScale =
false;
2214 bool m_bHasOffset =
false;
2215 std::string m_osFilename{};
2216 std::vector<GUInt64> m_anBlockSize{};
2218 bool IRead(
const GUInt64 *arrayStartIdx,
const size_t *count,
2220 const GDALExtendedDataType &bufferDataType,
2221 void *pDstBuffer)
const override;
2227 const std::shared_ptr<VRTGroup::Ref> &poGroupRef,
2228 const std::string &osParentName,
const std::string &osName,
2229 const GDALExtendedDataType &dt,
2230 std::vector<std::shared_ptr<GDALDimension>> &&dims,
2231 std::map<std::string, std::shared_ptr<VRTAttribute>> &&oMapAttributes,
2232 std::vector<GUInt64> &&anBlockSize)
2233 : GDALAbstractMDArray(osParentName, osName),
2234 GDALMDArray(osParentName, osName), m_poGroupRef(poGroupRef),
2235 m_osVRTPath(poGroupRef->m_ptr->GetVRTPath()), m_dt(dt),
2236 m_dims(std::move(dims)), m_oMapAttributes(std::move(oMapAttributes)),
2237 m_osFilename(poGroupRef->m_ptr->GetFilename()),
2238 m_anBlockSize(std::move(anBlockSize))
2242 VRTMDArray(
const std::shared_ptr<VRTGroup::Ref> &poGroupRef,
2243 const std::string &osParentName,
const std::string &osName,
2244 const std::vector<std::shared_ptr<GDALDimension>> &dims,
2245 const GDALExtendedDataType &dt,
2246 const std::vector<GUInt64> &anBlockSize)
2247 : GDALAbstractMDArray(osParentName, osName),
2248 GDALMDArray(osParentName, osName), m_poGroupRef(poGroupRef),
2249 m_osVRTPath(poGroupRef->m_ptr->GetVRTPath()), m_dt(dt), m_dims(dims),
2250 m_osFilename(poGroupRef->m_ptr->GetFilename()),
2251 m_anBlockSize(anBlockSize)
2262 return m_osFilename;
2265 static std::shared_ptr<VRTMDArray> Create(
const char *pszVRTPath,
2266 const CPLXMLNode *psNode);
2268 static std::shared_ptr<VRTMDArray>
2269 Create(
const std::shared_ptr<VRTGroup> &poThisGroup,
2270 const std::string &osParentName,
const CPLXMLNode *psNode);
2272 const std::vector<std::shared_ptr<GDALDimension>> &
2278 std::vector<std::shared_ptr<GDALAttribute>>
2281 const GDALExtendedDataType &
GetDataType()
const override
2286 bool SetSpatialRef(
const OGRSpatialReference *poSRS)
override;
2288 std::shared_ptr<OGRSpatialReference>
GetSpatialRef()
const override
2297 const std::string &
GetUnit()
const override
2302 bool SetUnit(
const std::string &osUnit)
override
2312 *pbHasOffset = m_bHasOffset;
2322 *pbHasScale = m_bHasScale;
2332 m_bHasOffset =
true;
2333 m_dfOffset = dfOffset;
2342 m_dfScale = dfScale;
2346 void AddSource(std::unique_ptr<VRTMDArraySource> &&poSource);
2348 std::shared_ptr<GDALAttribute>
2350 const std::vector<GUInt64> &anDimensions,
2351 const GDALExtendedDataType &oDataType,
2354 bool CopyFrom(GDALDataset *poSrcDS,
const GDALMDArray *poSrcArray,
2356 GDALProgressFunc pfnProgress,
void *pProgressData)
override;
2358 void Serialize(CPLXMLNode *psParent,
const char *pszVRTPathIn)
const;
2360 VRTGroup *GetGroup()
const;
2362 const std::string &GetVRTPath()
const
2367 std::shared_ptr<VRTGroup> GetRootVRTGroup()
const
2369 auto poGroup = m_poGroupRef.lock();
2371 return poGroup->m_ptr->GetRootGroupSharedPtr();
2375 std::shared_ptr<GDALGroup>
GetRootGroup()
const override
2377 return GetRootVRTGroup();
2382 return m_anBlockSize;
2386 GDALMDArrayRawBlockInfo &info)
const override;
2393class VRTMDArraySourceInlinedValues final :
public VRTMDArraySource
2395 const VRTMDArray *m_poDstArray =
nullptr;
2396 bool m_bIsConstantValue;
2397 std::vector<GUInt64> m_anOffset{};
2398 std::vector<size_t> m_anCount{};
2399 std::vector<GByte> m_abyValues{};
2400 std::vector<size_t> m_anInlinedArrayStrideInBytes{};
2401 GDALExtendedDataType m_dt;
2403 VRTMDArraySourceInlinedValues(
const VRTMDArraySourceInlinedValues &) =
2405 VRTMDArraySourceInlinedValues &
2406 operator=(
const VRTMDArraySourceInlinedValues &) =
delete;
2409 VRTMDArraySourceInlinedValues(
const VRTMDArray *poDstArray,
2410 bool bIsConstantValue,
2411 std::vector<GUInt64> &&anOffset,
2412 std::vector<size_t> &&anCount,
2413 std::vector<GByte> &&abyValues)
2414 : m_poDstArray(poDstArray), m_bIsConstantValue(bIsConstantValue),
2415 m_anOffset(std::move(anOffset)), m_anCount(std::move(anCount)),
2416 m_abyValues(std::move(abyValues)), m_dt(poDstArray->GetDataType())
2418 const auto nDims(poDstArray->GetDimensionCount());
2419 m_anInlinedArrayStrideInBytes.resize(nDims);
2420 if (!bIsConstantValue && nDims > 0)
2422 m_anInlinedArrayStrideInBytes.back() =
2423 poDstArray->GetDataType().GetSize();
2424 for (
size_t i = nDims - 1; i > 0;)
2427 m_anInlinedArrayStrideInBytes[i] =
2428 m_anInlinedArrayStrideInBytes[i + 1] * m_anCount[i + 1];
2433 ~VRTMDArraySourceInlinedValues()
override;
2435 static std::unique_ptr<VRTMDArraySourceInlinedValues>
2436 Create(
const VRTMDArray *poDstArray,
const CPLXMLNode *psNode);
2438 RelationShip GetRelationship(
const uint64_t * ,
2439 const size_t * )
const override
2441 return RelationShip::PARTIAL_INTERSECTION;
2444 bool GetRawBlockInfo(
const uint64_t * ,
2446 GDALMDArrayRawBlockInfo & )
const override
2451 bool Read(
const GUInt64 *arrayStartIdx,
const size_t *count,
2453 const GDALExtendedDataType &bufferDataType,
2454 void *pDstBuffer)
const override;
2456 void Serialize(CPLXMLNode *psParent,
const char *pszVRTPath)
const override;
2463class VRTMDArraySourceRegularlySpaced final :
public VRTMDArraySource
2466 double m_dfIncrement;
2469 VRTMDArraySourceRegularlySpaced(
double dfStart,
double dfIncrement)
2470 : m_dfStart(dfStart), m_dfIncrement(dfIncrement)
2474 RelationShip GetRelationship(
const uint64_t * ,
2475 const size_t * )
const override
2477 return RelationShip::PARTIAL_INTERSECTION;
2480 bool GetRawBlockInfo(
const uint64_t * ,
2482 GDALMDArrayRawBlockInfo & )
const override
2487 bool Read(
const GUInt64 *arrayStartIdx,
const size_t *count,
2489 const GDALExtendedDataType &bufferDataType,
2490 void *pDstBuffer)
const override;
2492 void Serialize(CPLXMLNode *psParent,
const char *pszVRTPath)
const override;
2499struct VRTArrayDatasetWrapper;
2501class VRTMDArraySourceFromArray final :
public VRTMDArraySource
2503 const VRTMDArray *m_poDstArray =
nullptr;
2504 bool m_bRelativeToVRTSet =
false;
2505 bool m_bRelativeToVRT =
false;
2506 std::string m_osFilename{};
2507 std::string m_osArray{};
2508 std::string m_osBand{};
2509 std::vector<int> m_anTransposedAxis{};
2510 std::string m_osViewExpr{};
2511 std::vector<GUInt64> m_anSrcOffset{};
2512 mutable std::vector<GUInt64> m_anCount{};
2513 std::vector<GUInt64> m_anStep{};
2514 std::vector<GUInt64> m_anDstOffset{};
2516 std::pair<std::shared_ptr<VRTArrayDatasetWrapper>,
2517 std::shared_ptr<GDALMDArray>>
2518 GetSourceArray()
const;
2520 VRTMDArraySourceFromArray(
const VRTMDArraySourceFromArray &) =
delete;
2521 VRTMDArraySourceFromArray &
2522 operator=(
const VRTMDArraySourceFromArray &) =
delete;
2525 VRTMDArraySourceFromArray(
2526 const VRTMDArray *poDstArray,
bool bRelativeToVRTSet,
2527 bool bRelativeToVRT,
const std::string &osFilename,
2528 const std::string &osArray,
const std::string &osBand,
2529 std::vector<int> &&anTransposedAxis,
const std::string &osViewExpr,
2530 std::vector<GUInt64> &&anSrcOffset, std::vector<GUInt64> &&anCount,
2531 std::vector<GUInt64> &&anStep, std::vector<GUInt64> &&anDstOffset)
2532 : m_poDstArray(poDstArray), m_bRelativeToVRTSet(bRelativeToVRTSet),
2533 m_bRelativeToVRT(bRelativeToVRT), m_osFilename(osFilename),
2534 m_osArray(osArray), m_osBand(osBand),
2535 m_anTransposedAxis(std::move(anTransposedAxis)),
2536 m_osViewExpr(osViewExpr), m_anSrcOffset(std::move(anSrcOffset)),
2537 m_anCount(std::move(anCount)), m_anStep(std::move(anStep)),
2538 m_anDstOffset(std::move(anDstOffset))
2542 ~VRTMDArraySourceFromArray()
override;
2544 static std::unique_ptr<VRTMDArraySourceFromArray>
2545 Create(
const VRTMDArray *poDstArray,
const CPLXMLNode *psNode);
2547 RelationShip GetRelationship(
const uint64_t *arrayStartIdx,
2548 const size_t *count)
const override;
2550 bool GetRawBlockInfo(
const uint64_t *arrayStartIdx,
const size_t *count,
2551 GDALMDArrayRawBlockInfo &info)
const override;
2553 bool Read(
const GUInt64 *arrayStartIdx,
const size_t *count,
2555 const GDALExtendedDataType &bufferDataType,
2556 void *pDstBuffer)
const override;
2558 void Serialize(CPLXMLNode *psParent,
const char *pszVRTPath)
const override;
Convenient string class based on std::string.
Definition cpl_string.h:320
virtual const std::vector< std::shared_ptr< GDALDimension > > & GetDimensions() const =0
Return the dimensions of an attribute/array.
virtual std::vector< GUInt64 > GetBlockSize() const
Return the "natural" block size of the array along all dimensions.
Definition gdalmultidim.cpp:2431
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_multidim.h:729
A set of associated raster bands, usually from one file.
Definition gdal_dataset.h:76
int Dereference()
Subtract one from dataset reference count.
Definition gdaldataset.cpp:1782
virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList, const OGRSpatialReference *poGCP_SRS)
Assign GCPs.
Definition gdaldataset.cpp:2237
int GetShared() const
Returns shared flag.
Definition gdaldataset.cpp:1854
Class modeling a a dimension / axis used to index multidimensional arrays.
Definition gdal_multidim.h:1232
virtual std::shared_ptr< GDALMDArray > GetIndexingVariable() const
Return the variable that is used to index the dimension (if there is one).
Definition gdalmultidim.cpp:11020
virtual bool SetIndexingVariable(std::shared_ptr< GDALMDArray > poIndexingVariable)
Set the variable that is used to index the dimension.
Definition gdalmultidim.cpp:11041
Format specific driver.
Definition gdal_driver.h:63
Class modeling a named container of GDALAttribute, GDALMDArray, OGRLayer or other GDALGroup.
Definition gdal_multidim.h:305
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:289
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:258
Class modeling a multi-dimensional array.
Definition gdal_multidim.h:852
virtual bool SetUnit(const std::string &osUnit)
Set the variable unit.
Definition gdalmultidim.cpp:2638
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:4041
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:2971
virtual bool SetRawNoDataValue(const void *pRawNoData)
Set the nodata value as a "raw" value.
Definition gdalmultidim.cpp:2830
virtual double GetOffset(bool *pbHasOffset=nullptr, GDALDataType *peStorageType=nullptr) const
Get the offset value to apply to raw values.
Definition gdalmultidim.cpp:3058
virtual const void * GetRawNoDataValue() const
Return the nodata value as a "raw" value.
Definition gdalmultidim.cpp:2714
virtual double GetScale(bool *pbHasScale=nullptr, GDALDataType *peStorageType=nullptr) const
Get the scale value to apply to raw values.
Definition gdalmultidim.cpp:3028
virtual std::shared_ptr< OGRSpatialReference > GetSpatialRef() const
Return the spatial reference system object associated with the array.
Definition gdalmultidim.cpp:2688
virtual const std::string & GetFilename() const =0
Return the filename that contains that array.
virtual bool GetRawBlockInfo(const uint64_t *panBlockCoordinates, GDALMDArrayRawBlockInfo &info) const
Return information on a raw block.
Definition gdalmultidim.cpp:15282
virtual bool SetSpatialRef(const OGRSpatialReference *poSRS)
Assign a spatial reference system object to the array.
Definition gdalmultidim.cpp:2674
virtual std::shared_ptr< GDALGroup > GetRootGroup() const
Return the root group to which this arrays belongs too.
Definition gdalmultidim.cpp:4623
virtual bool SetOffset(double dfOffset, GDALDataType eStorageType=GDT_Unknown)
Set the offset value to apply to raw values.
Definition gdalmultidim.cpp:2999
virtual const std::string & GetUnit() const
Return the array unit.
Definition gdalmultidim.cpp:2660
virtual CPLErr SetMetadata(char **papszMetadata, const char *pszDomain="")
Set metadata.
Definition gdalmajorobject.cpp:271
virtual char ** GetMetadataDomainList()
Fetch list of metadata domains.
Definition gdalmajorobject.cpp:143
virtual char ** GetMetadata(const char *pszDomain="")
Fetch metadata.
Definition gdalmajorobject.cpp:228
Pansharpening operation class.
Definition gdalpansharpen.h:176
A single raster band (or channel).
Definition gdal_rasterband.h:105
GDALDataset * GetDataset() const
Fetch the owning dataset handle.
Definition gdalrasterband.cpp:3983
High level image warping class.
Definition gdalwarper.h:504
CPLErr
Error category.
Definition cpl_error.h:37
struct _CPLHashSet CPLHashSet
Opaque type for a hash set.
Definition cpl_hash_set.h:35
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:246
#define CPL_NON_FINAL
Mark that a class is explicitly recognized as non-final.
Definition cpl_port.h:929
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition cpl_port.h:208
GIntBig GInt64
Signed 64 bit integer type.
Definition cpl_port.h:226
#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:936
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition cpl_port.h:228
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:175
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:205
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition cpl_virtualmem.h:45
GUIntBig vsi_l_offset
Type for a file offset.
Definition cpl_vsi.h:136
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition gdal.h:386
GDALAccess
Definition gdal.h:118
@ GA_ReadOnly
Definition gdal.h:119
void * VRTPDWorkingDataPtr
Generic pointer for the working structure of VRTProcessedDataset function.
Definition gdal.h:1789
GDALDataType
Definition gdal.h:48
@ GDT_Unknown
Definition gdal.h:49
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:1607
GDALRIOResampleAlg
RasterIO() resampling method.
Definition gdal.h:135
CPLErr GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition gdaldataset.cpp:4478
GDALColorInterp
Types of color interpretation for raster bands.
Definition gdal.h:270
@ GCI_Undefined
Definition gdal.h:271
GDALRWFlag
Definition gdal.h:125
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:1599
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition gdal_fwd.h:45
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:28
void * VRTDatasetH
Opaque type for a VRT dataset.
Definition gdal_vrt.h:57
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:33
VRTDatasetH VRTCreate(int, int)
Definition vrtdataset.cpp:77
Document node structure.
Definition cpl_minixml.h:54