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 VRTSource() =
default;
220 VRTSource(
const VRTSource &) =
default;
222 std::string m_osName{};
225typedef VRTSource *(*VRTSourceParser)(
const CPLXMLNode *,
const char *,
226 VRTMapSharedResources &oMapSharedSources);
228VRTSource *VRTParseCoreSources(
const CPLXMLNode *psTree,
const char *,
229 VRTMapSharedResources &oMapSharedSources);
230VRTSource *VRTParseFilterSources(
const CPLXMLNode *psTree,
const char *,
231 VRTMapSharedResources &oMapSharedSources);
232VRTSource *VRTParseArraySource(
const CPLXMLNode *psTree,
const char *,
233 VRTMapSharedResources &oMapSharedSources);
241template <
class T>
struct VRTFlushCacheStruct
243 static CPLErr FlushCache(T &obj,
bool bAtClosing);
246class VRTWarpedDataset;
247class VRTPansharpenedDataset;
248class VRTProcessedDataset;
250class VRTSimpleSource;
254 friend class VRTRasterBand;
255 friend struct VRTFlushCacheStruct<VRTDataset>;
256 friend struct VRTFlushCacheStruct<VRTWarpedDataset>;
257 friend struct VRTFlushCacheStruct<VRTPansharpenedDataset>;
258 friend struct VRTFlushCacheStruct<VRTProcessedDataset>;
259 friend class VRTSourcedRasterBand;
260 friend class VRTDerivedRasterBand;
261 friend class VRTSimpleSource;
262 friend struct VRTSourcedRasterBandRasterIOJob;
265 std::vector<gdal::GCP> m_asGCPs{};
266 OGRSpatialReferenceRefCountedPtr m_poGCP_SRS{};
268 bool m_bNeedsFlush =
false;
269 bool m_bWritable =
true;
270 bool m_bCanTakeRef =
true;
272 char *m_pszVRTPath =
nullptr;
274 std::unique_ptr<VRTRasterBand> m_poMaskBand{};
276 mutable int m_nCompatibleForDatasetIO = -1;
277 bool CheckCompatibleForDatasetIO()
const;
281 std::vector<GDALDataset *> m_apoOverviews{};
282 std::vector<GDALDataset *> m_apoOverviewsBak{};
283 CPLStringList m_aosOverviewList{};
284 CPLString m_osOverviewResampling{};
285 std::vector<int> m_anOverviewFactors{};
287 char **m_papszXMLVRTMetadata =
nullptr;
289 VRTMapSharedResources m_oMapSharedSources{};
290 std::shared_ptr<VRTGroup> m_poRootGroup{};
293 VRTSource::WorkingState m_oWorkingState{};
296 struct QueueWorkingStates
299 std::vector<std::unique_ptr<VRTSource::WorkingState>> oStates{};
302 QueueWorkingStates m_oQueueWorkingStates{};
304 bool m_bMultiThreadedRasterIOLastUsed =
false;
306 std::unique_ptr<VRTRasterBand> InitBand(
const char *pszSubclass,
int nBand,
307 bool bAllowPansharpenedOrProcessed);
308 static GDALDataset *OpenVRTProtocol(
const char *pszSpec);
309 bool AddVirtualOverview(
int nOvFactor,
const char *pszResampling);
311 bool GetShiftedDataset(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
312 GDALDataset *&poSrcDataset,
int &nSrcXOff,
315 static bool IsDefaultBlockSize(
int nBlockSize,
int nDimension);
320 bool m_bBlockSizeSpecified =
false;
321 int m_nBlockXSize = 0;
322 int m_nBlockYSize = 0;
324 OGRSpatialReferenceRefCountedPtr m_poSRS{};
326 int m_bGeoTransformSet =
false;
327 GDALGeoTransform m_gt{};
329 int CloseDependentDatasets()
override;
332 VRTDataset(
int nXSize,
int nYSize,
int nBlockXSize = 0,
333 int nBlockYSize = 0);
334 ~VRTDataset()
override;
338 m_bNeedsFlush =
true;
341 CPLErr FlushCache(
bool bAtClosing)
override;
343 void SetWritable(
int bWritableIn)
345 m_bWritable = CPL_TO_BOOL(bWritableIn);
348 CPLErr CreateMaskBand(
int nFlags)
override;
349 void SetMaskBand(std::unique_ptr<VRTRasterBand> poMaskBand);
351 const OGRSpatialReference *GetSpatialRef()
const override
353 return m_poSRS.get();
356 CPLErr SetSpatialRef(
const OGRSpatialReference *poSRS)
override;
358 CPLErr GetGeoTransform(GDALGeoTransform &)
const override;
359 CPLErr SetGeoTransform(
const GDALGeoTransform &)
override;
362 const char *pszDomain =
"")
override;
363 CPLErr SetMetadataItem(
const char *pszName,
const char *pszValue,
364 const char *pszDomain =
"")
override;
366 CSLConstList GetMetadata(
const char *pszDomain =
"")
override;
367 virtual const char *GetMetadataItem(
const char *pszName,
368 const char *pszDomain =
"")
override;
370 int GetGCPCount()
override;
372 const OGRSpatialReference *GetGCPSpatialRef()
const override
374 return m_poGCP_SRS.get();
377 const GDAL_GCP *GetGCPs()
override;
379 CPLErr SetGCPs(
int nGCPCount,
const GDAL_GCP *pasGCPList,
380 const OGRSpatialReference *poSRS)
override;
385 char **GetFileList()
override;
388 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
390 BANDMAP_TYPE panBandMap,
GSpacing nPixelSpace,
392 GDALRasterIOExtraArg *psExtraArg)
override;
394 virtual CPLStringList
395 GetCompressionFormats(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
396 int nBandCount,
const int *panBandList)
override;
397 virtual CPLErr ReadCompressedData(
const char *pszFormat,
int nXOff,
398 int nYOff,
int nXSize,
int nYSize,
399 int nBandCount,
const int *panBandList,
400 void **ppBuffer,
size_t *pnBufferSize,
401 char **ppszDetailedFormat)
override;
403 CPLErr AdviseRead(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
405 int nBandCount,
int *panBandList,
408 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath);
409 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *);
411 CPLErr IBuildOverviews(
const char *,
int,
const int *,
int,
const int *,
412 GDALProgressFunc,
void *,
415 std::shared_ptr<GDALGroup> GetRootGroup()
const override;
417 std::shared_ptr<VRTGroup> GetRootVRTGroup()
const
419 return m_poRootGroup;
422 void ClearStatistics()
override;
427 m_nCompatibleForDatasetIO = -1;
431 GDALDataset *GetSingleSimpleSource();
432 void BuildVirtualOverviews();
434 void UnsetPreservedRelativeFilenames();
436 bool IsBlockSizeSpecified()
const
438 return m_bBlockSizeSpecified;
441 int GetBlockXSize()
const
443 return m_nBlockXSize;
446 int GetBlockYSize()
const
448 return m_nBlockYSize;
451 static int Identify(GDALOpenInfo *);
452 static GDALDataset *Open(GDALOpenInfo *);
453 static std::unique_ptr<VRTDataset>
454 OpenXML(
const char *,
const char * =
nullptr,
456 static GDALDataset *Create(
const char *pszName,
int nXSize,
int nYSize,
459 static std::unique_ptr<VRTDataset>
460 CreateVRTDataset(
const char *pszName,
int nXSize,
int nYSize,
int nBands,
463 CreateMultiDimensional(
const char *pszFilename,
466 static std::unique_ptr<VRTDataset>
467 CreateVRTMultiDimensional(
const char *pszFilename,
470 static CPLErr Delete(
const char *pszFilename);
472 static int GetNumThreads(GDALDataset *poDS);
474 static bool IsRawRasterBandEnabled();
482class VRTWarpedRasterBand;
484class CPL_DLL VRTWarpedDataset final :
public VRTDataset
486 GDALWarpOperation *m_poWarper;
488 bool m_bIsOverview =
false;
489 std::vector<VRTWarpedDataset *> m_apoOverviews{};
492 bool GetOverviewSize(GDALDataset *poSrcDS,
int iOvr,
int iSrcOvr,
493 int &nOvrXSize,
int &nOvrYSize,
double &dfSrcRatioX,
494 double &dfSrcRatioY)
const;
495 int GetOverviewCount()
const;
496 int GetSrcOverviewLevel(
int iOvr,
bool &bThisLevelOnlyOut)
const;
497 VRTWarpedDataset *CreateImplicitOverview(
int iOvr)
const;
498 void CreateImplicitOverviews();
500 friend class VRTWarpedRasterBand;
505 int CloseDependentDatasets()
override;
508 VRTWarpedDataset(
int nXSize,
int nYSize,
int nBlockXSize = 0,
509 int nBlockYSize = 0);
510 ~VRTWarpedDataset()
override;
512 CPLErr FlushCache(
bool bAtClosing)
override;
514 CPLErr Initialize(
void *);
516 CPLErr IBuildOverviews(
const char *,
int,
const int *,
int,
const int *,
517 GDALProgressFunc,
void *,
520 CPLErr SetMetadataItem(
const char *pszName,
const char *pszValue,
521 const char *pszDomain =
"")
override;
523 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
524 CPLErr XMLInit(
const CPLXMLNode *,
const char *)
override;
529 char **GetFileList()
override;
532 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
534 BANDMAP_TYPE panBandMap,
GSpacing nPixelSpace,
536 GDALRasterIOExtraArg *psExtraArg)
override;
538 CPLErr ProcessBlock(
int iBlockX,
int iBlockY);
540 void GetBlockSize(
int *,
int *)
const;
552 GTAdjust_Intersection,
554 GTAdjust_NoneWithoutWarning
557class VRTPansharpenedDataset final :
public VRTDataset
559 friend class VRTPansharpenedRasterBand;
561 std::unique_ptr<GDALPansharpenOperation> m_poPansharpener{};
562 VRTPansharpenedDataset *m_poMainDataset;
563 std::vector<std::unique_ptr<VRTPansharpenedDataset>>
564 m_apoOverviewDatasets{};
566 std::map<CPLString, CPLString> m_oMapToRelativeFilenames{};
568 int m_bLoadingOtherBands;
570 GByte *m_pabyLastBufferBandRasterIO;
571 int m_nLastBandRasterIOXOff;
572 int m_nLastBandRasterIOYOff;
573 int m_nLastBandRasterIOXSize;
574 int m_nLastBandRasterIOYSize;
577 GTAdjustment m_eGTAdjustment;
578 int m_bNoDataDisabled;
580 std::vector<std::unique_ptr<GDALDataset, GDALDatasetUniquePtrReleaser>>
581 m_apoDatasetsToReleaseRef{};
586 int CloseDependentDatasets()
override;
589 VRTPansharpenedDataset(
int nXSize,
int nYSize,
int nBlockXSize = 0,
590 int nBlockYSize = 0);
591 ~VRTPansharpenedDataset()
override;
593 CPLErr FlushCache(
bool bAtClosing)
override;
595 CPLErr XMLInit(
const CPLXMLNode *,
const char *)
override;
596 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
598 CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *pszVRTPath,
605 char **GetFileList()
override;
608 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
610 BANDMAP_TYPE panBandMap,
GSpacing nPixelSpace,
612 GDALRasterIOExtraArg *psExtraArg)
override;
614 void GetBlockSize(
int *,
int *)
const;
616 GDALPansharpenOperation *GetPansharpener()
618 return m_poPansharpener.get();
631class VRTProcessedDataset final :
public VRTDataset
634 VRTProcessedDataset(
int nXSize,
int nYSize);
635 ~VRTProcessedDataset()
override;
637 CPLErr FlushCache(
bool bAtClosing)
override;
639 CPLErr XMLInit(
const CPLXMLNode *,
const char *)
override;
640 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
642 void GetBlockSize(
int *,
int *)
const;
646#pragma GCC diagnostic push
647#pragma GCC diagnostic ignored "-Weffc++"
663 inline operator GByte()
const
669#pragma GCC diagnostic pop
674 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
676 BANDMAP_TYPE panBandMap,
GSpacing nPixelSpace,
678 GDALRasterIOExtraArg *psExtraArg)
override;
681 friend class VRTProcessedRasterBand;
687 std::string osAlgorithm{};
690 CPLStringList aosArguments{};
705 std::vector<double> adfInNoData{};
708 std::vector<double> adfOutNoData{};
719 Step &operator=(Step &&);
722 Step(
const Step &) =
delete;
723 Step &operator=(
const Step &) =
delete;
728 std::string m_osVRTPath{};
731 std::unique_ptr<GDALDataset> m_poVRTSrcDS{};
734 std::unique_ptr<GDALDataset> m_poSrcDS{};
737 std::vector<Step> m_aoSteps{};
740 CPLXMLTreeCloser m_oXMLTree{
nullptr};
743 std::vector<std::unique_ptr<GDALDataset>> m_apoOverviewDatasets{};
746 std::vector<NoInitByte> m_abyInput{};
749 std::vector<NoInitByte> m_abyOutput{};
752 enum class ValueProvenance
761 ValueProvenance m_outputBandCountProvenance = ValueProvenance::FROM_SOURCE;
764 int m_outputBandCountValue = 0;
767 ValueProvenance m_outputBandDataTypeProvenance =
768 ValueProvenance::FROM_SOURCE;
774 int m_nWorkingBytesPerPixel = 1;
777 GIntBig m_nAllowedRAMUsage = 0;
779 CPLErr Init(
const CPLXMLNode *,
const char *,
780 const VRTProcessedDataset *poParentDS,
781 GDALDataset *poParentSrcDS,
int iOvrLevel);
783 bool ParseStep(
const CPLXMLNode *psStep,
bool bIsFinalStep,
785 std::vector<double> &adfInNoData,
786 std::vector<double> &adfOutNoData);
787 bool ProcessRegion(
int nXOff,
int nYOff,
int nBufXSize,
int nBufYSize,
788 GDALProgressFunc pfnProgress,
void *pProgressData);
798constexpr double VRT_DEFAULT_NODATA_VALUE = -10000.0;
803 void ResetNoDataValues();
806 friend class VRTDataset;
808 bool m_bIsMaskBand =
false;
810 bool m_bNoDataValueSet =
false;
812 int m_bHideNoDataValue =
false;
813 double m_dfNoDataValue = VRT_DEFAULT_NODATA_VALUE;
815 bool m_bNoDataSetAsInt64 =
false;
816 int64_t m_nNoDataValueInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_INT64;
818 bool m_bNoDataSetAsUInt64 =
false;
819 uint64_t m_nNoDataValueUInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64;
821 std::unique_ptr<GDALColorTable> m_poColorTable{};
825 std::string m_osUnitType{};
826 CPLStringList m_aosCategoryNames{};
828 double m_dfOffset = 0.0;
829 double m_dfScale = 1.0;
831 CPLXMLTreeCloser m_psSavedHistograms{
nullptr};
833 void Initialize(
int nXSize,
int nYSize);
835 std::vector<VRTOverviewInfo> m_aoOverviewInfos{};
837 std::unique_ptr<VRTRasterBand> m_poMaskBand{};
839 std::unique_ptr<GDALRasterAttributeTable> m_poRAT{};
843 bool IsNoDataValueInDataTypeRange()
const;
847 ~VRTRasterBand()
override;
849 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
850 VRTMapSharedResources &);
851 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
852 bool &bHasWarnedAboutRAMUsage,
853 size_t &nAccRAMUsage);
855 CPLErr SetNoDataValue(
double)
override;
856 CPLErr SetNoDataValueAsInt64(int64_t nNoData)
override;
857 CPLErr SetNoDataValueAsUInt64(uint64_t nNoData)
override;
858 double GetNoDataValue(
int *pbSuccess =
nullptr)
override;
859 int64_t GetNoDataValueAsInt64(
int *pbSuccess =
nullptr)
override;
860 uint64_t GetNoDataValueAsUInt64(
int *pbSuccess =
nullptr)
override;
861 CPLErr DeleteNoDataValue()
override;
863 CPLErr SetColorTable(GDALColorTable *)
override;
864 GDALColorTable *GetColorTable()
override;
866 GDALRasterAttributeTable *GetDefaultRAT()
override;
868 SetDefaultRAT(
const GDALRasterAttributeTable *poRAT)
override;
873 const char *GetUnitType()
override;
874 CPLErr SetUnitType(
const char *)
override;
876 char **GetCategoryNames()
override;
877 CPLErr SetCategoryNames(
char **)
override;
880 const char *pszDomain =
"")
override;
881 CPLErr SetMetadataItem(
const char *pszName,
const char *pszValue,
882 const char *pszDomain =
"")
override;
884 double GetOffset(
int *pbSuccess =
nullptr)
override;
885 CPLErr SetOffset(
double)
override;
886 double GetScale(
int *pbSuccess =
nullptr)
override;
887 CPLErr SetScale(
double)
override;
889 int GetOverviewCount()
override;
890 GDALRasterBand *GetOverview(
int)
override;
892 CPLErr GetHistogram(
double dfMin,
double dfMax,
int nBuckets,
893 GUIntBig *panHistogram,
int bIncludeOutOfRange,
894 int bApproxOK, GDALProgressFunc,
895 void *pProgressData)
override;
897 CPLErr GetDefaultHistogram(
double *pdfMin,
double *pdfMax,
int *pnBuckets,
898 GUIntBig **ppanHistogram,
int bForce,
899 GDALProgressFunc,
void *pProgressData)
override;
901 virtual CPLErr SetDefaultHistogram(
double dfMin,
double dfMax,
int nBuckets,
904 CPLErr CopyCommonInfoFrom(
const GDALRasterBand *);
906 virtual void GetFileList(
char ***ppapszFileList,
int *pnSize,
909 void SetDescription(
const char *)
override;
911 GDALRasterBand *GetMaskBand()
override;
912 int GetMaskFlags()
override;
914 CPLErr CreateMaskBand(
int nFlagsIn)
override;
916 void SetMaskBand(std::unique_ptr<VRTRasterBand> poMaskBand);
918 void SetIsMaskBand();
920 bool IsMaskBand()
const override;
922 CPLErr UnsetNoDataValue();
924 virtual int CloseDependentDatasets();
926 virtual bool IsSourcedRasterBand()
931 virtual bool IsPansharpenRasterBand()
941class VRTSimpleSource;
943class CPL_DLL VRTSourcedRasterBand
CPL_NON_FINAL :
public VRTRasterBand
946 CPLString m_osLastLocationInfo{};
947 CPLStringList m_aosSourceList{};
948 int m_nSkipBufferInitialization = -1;
950 bool CanUseSourcesMinMaxImplementations();
952 bool IsMosaicOfNonOverlappingSimpleSourcesOfFullRasterNoResAndTypeChange(
953 bool bAllowMaxValAdjustment)
const;
958 bool SkipBufferInitialization();
960 void InitializeOutputBuffer(
void *pData,
int nBufXSize,
int nBufYSize,
965 std::vector<std::unique_ptr<VRTSource>> m_papoSources{};
967 VRTSourcedRasterBand(GDALDataset *poDS,
int nBand);
968 VRTSourcedRasterBand(
GDALDataType eType,
int nXSize,
int nYSize);
969 VRTSourcedRasterBand(GDALDataset *poDS,
int nBand,
GDALDataType eType,
970 int nXSize,
int nYSize);
971 VRTSourcedRasterBand(GDALDataset *poDS,
int nBand,
GDALDataType eType,
972 int nXSize,
int nYSize,
int nBlockXSizeIn,
974 ~VRTSourcedRasterBand()
override;
976 void CopyForCloneWithoutSources(
const VRTSourcedRasterBand *poSrcBand);
978 virtual std::unique_ptr<VRTSourcedRasterBand>
979 CloneWithoutSources(GDALDataset *poNewDS,
int nNewXSize,
980 int nNewYSize)
const;
984 GDALRasterIOExtraArg *psExtraArg)
override;
986 bool MayMultiBlockReadingBeMultiThreaded()
const override;
988 virtual int IGetDataCoverageStatus(
int nXOff,
int nYOff,
int nXSize,
989 int nYSize,
int nMaskFlagStop,
990 double *pdfDataPct)
override;
992 char **GetMetadataDomainList()
override;
993 virtual const char *GetMetadataItem(
const char *pszName,
994 const char *pszDomain =
"")
override;
995 CSLConstList GetMetadata(
const char *pszDomain =
"")
override;
997 const char *pszDomain =
"")
override;
998 CPLErr SetMetadataItem(
const char *pszName,
const char *pszValue,
999 const char *pszDomain =
"")
override;
1001 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
1002 VRTMapSharedResources &)
override;
1003 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1004 bool &bHasWarnedAboutRAMUsage,
1005 size_t &nAccRAMUsage)
override;
1007 double GetMinimum(
int *pbSuccess =
nullptr)
override;
1008 double GetMaximum(
int *pbSuccess =
nullptr)
override;
1009 virtual CPLErr ComputeRasterMinMax(
int bApproxOK,
1010 double *adfMinMax)
override;
1011 virtual CPLErr ComputeStatistics(
int bApproxOK,
double *pdfMin,
1012 double *pdfMax,
double *pdfMean,
1014 GDALProgressFunc pfnProgress,
1015 void *pProgressData)
override;
1016 CPLErr GetHistogram(
double dfMin,
double dfMax,
int nBuckets,
1017 GUIntBig *panHistogram,
int bIncludeOutOfRange,
1018 int bApproxOK, GDALProgressFunc pfnProgress,
1019 void *pProgressData)
override;
1021 CPLErr AddSource(std::unique_ptr<VRTSource>);
1023 CPLErr AddSource(VRTSource *);
1025 CPLErr AddSimpleSource(
const char *pszFilename,
int nBand,
1026 double dfSrcXOff = -1,
double dfSrcYOff = -1,
1027 double dfSrcXSize = -1,
double dfSrcYSize = -1,
1028 double dfDstXOff = -1,
double dfDstYOff = -1,
1029 double dfDstXSize = -1,
double dfDstYSize = -1,
1030 const char *pszResampling =
"near",
1033 CPLErr AddSimpleSource(GDALRasterBand *poSrcBand,
double dfSrcXOff = -1,
1034 double dfSrcYOff = -1,
double dfSrcXSize = -1,
1035 double dfSrcYSize = -1,
double dfDstXOff = -1,
1036 double dfDstYOff = -1,
double dfDstXSize = -1,
1037 double dfDstYSize = -1,
1038 const char *pszResampling =
"near",
1041 CPLErr AddComplexSource(
const char *pszFilename,
int nBand,
1042 double dfSrcXOff = -1,
double dfSrcYOff = -1,
1043 double dfSrcXSize = -1,
double dfSrcYSize = -1,
1044 double dfDstXOff = -1,
double dfDstYOff = -1,
1045 double dfDstXSize = -1,
double dfDstYSize = -1,
1046 double dfScaleOff = 0.0,
double dfScaleRatio = 1.0,
1048 int nColorTableComponent = 0);
1050 CPLErr AddComplexSource(GDALRasterBand *poSrcBand,
double dfSrcXOff = -1,
1051 double dfSrcYOff = -1,
double dfSrcXSize = -1,
1052 double dfSrcYSize = -1,
double dfDstXOff = -1,
1053 double dfDstYOff = -1,
double dfDstXSize = -1,
1054 double dfDstYSize = -1,
double dfScaleOff = 0.0,
1055 double dfScaleRatio = 1.0,
1057 int nColorTableComponent = 0);
1059 CPLErr AddMaskBandSource(GDALRasterBand *poSrcBand,
double dfSrcXOff = -1,
1060 double dfSrcYOff = -1,
double dfSrcXSize = -1,
1061 double dfSrcYSize = -1,
double dfDstXOff = -1,
1062 double dfDstYOff = -1,
double dfDstXSize = -1,
1063 double dfDstYSize = -1);
1068 void ConfigureSource(VRTSimpleSource *poSimpleSource,
1069 GDALRasterBand *poSrcBand,
int bAddAsMaskBand,
1070 double dfSrcXOff,
double dfSrcYOff,
double dfSrcXSize,
1071 double dfSrcYSize,
double dfDstXOff,
double dfDstYOff,
1072 double dfDstXSize,
double dfDstYSize);
1074 void RemoveCoveredSources(
CSLConstList papszOptions =
nullptr);
1076 bool CanIRasterIOBeForwardedToEachSource(
1077 GDALRWFlag eRWFlag,
int nXOff,
int nYOff,
int nXSize,
int nYSize,
1078 int nBufXSize,
int nBufYSize,
1079 const GDALRasterIOExtraArg *psExtraArg)
const;
1081 bool CanMultiThreadRasterIO(
double dfXOff,
double dfYOff,
double dfXSize,
1083 int &nContributingSources)
const;
1085 CPLErr IReadBlock(
int,
int,
void *)
override;
1087 virtual void GetFileList(
char ***ppapszFileList,
int *pnSize,
1088 int *pnMaxSize,
CPLHashSet *hSetFiles)
override;
1090 int CloseDependentDatasets()
override;
1092 bool IsSourcedRasterBand()
override
1097 CPLErr FlushCache(
bool bAtClosing)
override;
1104class CPL_DLL VRTWarpedRasterBand final :
public VRTRasterBand
1107 VRTWarpedRasterBand(GDALDataset *poDS,
int nBand,
1109 ~VRTWarpedRasterBand()
override;
1111 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1112 bool &bHasWarnedAboutRAMUsage,
1113 size_t &nAccRAMUsage)
override;
1115 CPLErr IReadBlock(
int,
int,
void *)
override;
1116 CPLErr IWriteBlock(
int,
int,
void *)
override;
1119 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
1122 GDALRasterIOExtraArg *psExtraArg)
override;
1124 int GetOverviewCount()
override;
1125 GDALRasterBand *GetOverview(
int)
override;
1128 EmitErrorMessageIfWriteNotSupported(
const char *pszCaller)
const override;
1131 int m_nIRasterIOCounter =
1134 int GetBestOverviewLevel(
int &nXOff,
int &nYOff,
int &nXSize,
int &nYSize,
1135 int nBufXSize,
int nBufYSize,
1136 GDALRasterIOExtraArg *psExtraArg)
const;
1143class VRTPansharpenedRasterBand final :
public VRTRasterBand
1145 int m_nIndexAsPansharpenedBand;
1148 VRTPansharpenedRasterBand(GDALDataset *poDS,
int nBand,
1150 ~VRTPansharpenedRasterBand()
override;
1152 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1153 bool &bHasWarnedAboutRAMUsage,
1154 size_t &nAccRAMUsage)
override;
1156 CPLErr IReadBlock(
int,
int,
void *)
override;
1159 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
1162 GDALRasterIOExtraArg *psExtraArg)
override;
1164 int GetOverviewCount()
override;
1165 GDALRasterBand *GetOverview(
int)
override;
1167 bool IsPansharpenRasterBand()
override
1172 void SetIndexAsPansharpenedBand(
int nIdx)
1174 m_nIndexAsPansharpenedBand = nIdx;
1177 int GetIndexAsPansharpenedBand()
const
1179 return m_nIndexAsPansharpenedBand;
1187class VRTProcessedRasterBand final :
public VRTRasterBand
1190 VRTProcessedRasterBand(VRTProcessedDataset *poDS,
int nBand,
1193 CPLErr IReadBlock(
int,
int,
void *)
override;
1195 int GetOverviewCount()
override;
1196 GDALRasterBand *GetOverview(
int)
override;
1198 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1199 bool &bHasWarnedAboutRAMUsage,
1200 size_t &nAccRAMUsage)
override;
1207class VRTDerivedRasterBandPrivateData;
1209class CPL_DLL VRTDerivedRasterBand
CPL_NON_FINAL :
public VRTSourcedRasterBand
1211 VRTDerivedRasterBandPrivateData *m_poPrivate;
1212 bool InitializePython();
1213 CPLErr GetPixelFunctionArguments(
1214 const CPLString &,
const std::vector<int> &anMapBufferIdxToSourceIdx,
1215 int nXOff,
int nYOff, std::vector<std::pair<CPLString, CPLString>> &);
1220 CPLString osFuncName{};
1227 VRTDerivedRasterBand(GDALDataset *poDS,
int nBand);
1228 VRTDerivedRasterBand(GDALDataset *poDS,
int nBand,
GDALDataType eType,
1229 int nXSize,
int nYSize,
int nBlockXSizeIn = 0,
1230 int nBlockYSizeIn = 0);
1231 ~VRTDerivedRasterBand()
override;
1233 void CopyForCloneWithoutSources(
const VRTDerivedRasterBand *poSrcBand);
1235 std::unique_ptr<VRTSourcedRasterBand>
1236 CloneWithoutSources(GDALDataset *poNewDS,
int nNewXSize,
1237 int nNewYSize)
const override;
1241 GDALRasterIOExtraArg *psExtraArg)
override;
1243 virtual int IGetDataCoverageStatus(
int nXOff,
int nYOff,
int nXSize,
1244 int nYSize,
int nMaskFlagStop,
1245 double *pdfDataPct)
override;
1247 static CPLErr AddPixelFunction(
const char *pszFuncNameIn,
1249 static CPLErr AddPixelFunction(
const char *pszFuncNameIn,
1251 const char *pszMetadata);
1253 static const std::pair<PixelFunc, std::string> *
1254 GetPixelFunction(
const char *pszFuncNameIn);
1256 static std::vector<std::string> GetPixelFunctionNames();
1258 void SetPixelFunctionName(
const char *pszFuncNameIn);
1259 void AddPixelFunctionArgument(
const char *pszArg,
const char *pszValue);
1260 void SetSkipNonContributingSources(
bool bSkip);
1262 void SetPixelFunctionLanguage(
const char *pszLanguage);
1264 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
1265 VRTMapSharedResources &)
override;
1266 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1267 bool &bHasWarnedAboutRAMUsage,
1268 size_t &nAccRAMUsage)
override;
1270 double GetMinimum(
int *pbSuccess =
nullptr)
override;
1271 double GetMaximum(
int *pbSuccess =
nullptr)
override;
1272 virtual CPLErr ComputeRasterMinMax(
int bApproxOK,
1273 double *adfMinMax)
override;
1274 virtual CPLErr ComputeStatistics(
int bApproxOK,
double *pdfMin,
1275 double *pdfMax,
double *pdfMean,
1277 GDALProgressFunc pfnProgress,
1278 void *pProgressData)
override;
1279 CPLErr GetHistogram(
double dfMin,
double dfMax,
int nBuckets,
1280 GUIntBig *panHistogram,
int bIncludeOutOfRange,
1281 int bApproxOK, GDALProgressFunc pfnProgress,
1282 void *pProgressData)
override;
1284 static void Cleanup();
1287#ifndef GDAL_VRT_DISABLE_RAWRASTERBAND
1294class CPL_DLL VRTRawRasterBand
CPL_NON_FINAL :
public VRTRasterBand
1296 RawRasterBand *m_poRawRaster;
1298 char *m_pszSourceFilename;
1299 int m_bRelativeToVRT;
1304 VRTRawRasterBand(GDALDataset *poDS,
int nBand,
1306 ~VRTRawRasterBand()
override;
1308 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
1309 VRTMapSharedResources &)
override;
1310 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1311 bool &bHasWarnedAboutRAMUsage,
1312 size_t &nAccRAMUsage)
override;
1316 GDALRasterIOExtraArg *psExtraArg)
override;
1318 CPLErr IReadBlock(
int,
int,
void *)
override;
1319 CPLErr IWriteBlock(
int,
int,
void *)
override;
1321 CPLErr SetRawLink(
const char *pszFilename,
const char *pszVRTPath,
1323 int nPixelOffset,
int nLineOffset,
1324 const char *pszByteOrder);
1326 void ClearRawLink();
1332 virtual void GetFileList(
char ***ppapszFileList,
int *pnSize,
1333 int *pnMaxSize,
CPLHashSet *hSetFiles)
override;
1345 std::mutex m_oMutex{};
1346 std::map<std::string, VRTSourceParser> m_oMapSourceParser{};
1350 ~VRTDriver()
override;
1352 char **papszSourceParsers;
1357 const char *pszDomain =
"")
override;
1359 VRTSource *ParseSource(
const CPLXMLNode *psSrc,
const char *pszVRTPath,
1360 VRTMapSharedResources &oMapSharedSources);
1361 void AddSourceParser(
const char *pszElementName, VRTSourceParser pfnParser);
1368class CPL_DLL VRTSimpleSource
CPL_NON_FINAL :
public VRTSource
1374 VRTMapSharedResources *m_poMapSharedSources =
nullptr;
1376 mutable GDALRasterBand *m_poRasterBand =
nullptr;
1380 mutable GDALRasterBand *m_poMaskBandMainBand =
nullptr;
1382 CPLStringList m_aosOpenOptionsOri{};
1385 bool m_bSrcDSNameFromVRT =
1388 void OpenSource()
const;
1390 GDALDataset *GetSourceDataset()
const;
1393 friend class VRTSourcedRasterBand;
1394 friend class VRTDerivedRasterBand;
1395 friend class VRTDataset;
1396 friend class GDALTileIndexDataset;
1397 friend class GDALTileIndexBand;
1400 bool m_bGetMaskBand =
false;
1406 static constexpr double UNINIT_WINDOW = -1.0;
1408 double m_dfSrcXOff = UNINIT_WINDOW;
1409 double m_dfSrcYOff = UNINIT_WINDOW;
1410 double m_dfSrcXSize = UNINIT_WINDOW;
1411 double m_dfSrcYSize = UNINIT_WINDOW;
1413 double m_dfDstXOff = UNINIT_WINDOW;
1414 double m_dfDstYOff = UNINIT_WINDOW;
1415 double m_dfDstXSize = UNINIT_WINDOW;
1416 double m_dfDstYSize = UNINIT_WINDOW;
1418 CPLString m_osResampling{};
1420 int m_nMaxValue = 0;
1422 int m_bRelativeToVRTOri = -1;
1423 CPLString m_osSourceFileNameOri{};
1424 int m_nExplicitSharedStatus = -1;
1425 CPLString m_osSrcDSName{};
1427 bool m_bDropRefOnSrcBand =
true;
1429 int NeedMaxValAdjustment()
const;
1431 GDALRasterBand *GetRasterBandNoOpen()
const
1433 return m_poRasterBand;
1436 void SetRasterBand(GDALRasterBand *poBand,
bool bDropRef)
1438 m_poRasterBand = poBand;
1439 m_bDropRefOnSrcBand = bDropRef;
1442 virtual bool ValidateOpenedBand(GDALRasterBand * )
const
1448 bool IsSrcWinSet()
const
1450 return m_dfSrcXOff != UNINIT_WINDOW || m_dfSrcYOff != UNINIT_WINDOW ||
1451 m_dfSrcXSize != UNINIT_WINDOW || m_dfSrcYSize != UNINIT_WINDOW;
1455 bool IsDstWinSet()
const
1457 return m_dfDstXOff != UNINIT_WINDOW || m_dfDstYOff != UNINIT_WINDOW ||
1458 m_dfDstXSize != UNINIT_WINDOW || m_dfDstYSize != UNINIT_WINDOW;
1461 void AddSourceFilenameNode(
const char *pszVRTPath, CPLXMLNode *psSrc);
1465 VRTSimpleSource(
const VRTSimpleSource *poSrcSource,
double dfXDstRatio,
1466 double dfYDstRatio);
1467 ~VRTSimpleSource()
override;
1469 virtual CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *,
1470 VRTMapSharedResources &)
override;
1471 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1473 CPLErr ParseSrcRectAndDstRect(
const CPLXMLNode *psSrc);
1475 void SetSrcBand(
const char *pszFilename,
int nBand);
1476 void SetSrcBand(GDALRasterBand *);
1477 void SetSrcMaskBand(GDALRasterBand *);
1478 void SetSrcWindow(
double,
double,
double,
double);
1479 void SetDstWindow(
double,
double,
double,
double);
1480 void GetDstWindow(
double &,
double &,
double &,
double &)
const;
1481 bool DstWindowIntersects(
double dfXOff,
double dfYOff,
double dfXSize,
1482 double dfYSize)
const;
1484 const std::string &GetSourceDatasetName()
const
1486 return m_osSrcDSName;
1490 void SetSourceDatasetName(
const char *pszFilename,
bool bRelativeToVRT);
1492 const CPLString &GetResampling()
const
1494 return m_osResampling;
1497 void SetResampling(
const char *pszResampling);
1499 int GetSrcDstWindow(
double,
double,
double,
double,
int,
int,
1500 double *pdfReqXOff,
double *pdfReqYOff,
1501 double *pdfReqXSize,
double *pdfReqYSize,
int *,
int *,
1502 int *,
int *,
int *,
int *,
int *,
int *,
1505 int GetSrcDstWindow(
double,
double,
double,
double,
int,
int,
1507 double *pdfReqYOff,
double *pdfReqXSize,
1508 double *pdfReqYSize,
int *,
int *,
int *,
int *,
int *,
1509 int *,
int *,
int *,
bool &bErrorOut);
1512 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1515 GDALRasterIOExtraArg *psExtraArgIn,
1516 WorkingState &oWorkingState)
override;
1518 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1519 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1520 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1521 int nBuckets,
GUIntBig *panHistogram,
1522 int bIncludeOutOfRange,
int bApproxOK,
1523 GDALProgressFunc pfnProgress,
1524 void *pProgressData)
override;
1526 void DstToSrc(
double dfX,
double dfY,
double &dfXOut,
double &dfYOut)
const;
1527 void SrcToDst(
double dfX,
double dfY,
double &dfXOut,
double &dfYOut)
const;
1529 virtual void GetFileList(
char ***ppapszFileList,
int *pnSize,
1530 int *pnMaxSize,
CPLHashSet *hSetFiles)
override;
1532 bool IsSimpleSource()
const override
1540 static const char *GetTypeStatic();
1542 const char *GetType()
const override;
1544 CPLErr FlushCache(
bool bAtClosing)
override;
1546 GDALRasterBand *GetRasterBand()
const;
1547 GDALRasterBand *GetMaskBandMainBand();
1548 bool IsSameExceptBandNumber(
const VRTSimpleSource *poOtherSource)
const;
1550 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1552 const int *panBandMap,
GSpacing nPixelSpace,
1554 GDALRasterIOExtraArg *psExtraArg);
1556 void UnsetPreservedRelativeFilenames();
1558 void SetMaxValue(
int nVal)
1563 static std::pair<std::string, bool>
1564 ComputeSourceNameAndRelativeFlag(
const char *pszVRTPath,
1565 const std::string &osSourceNameIn);
1572class VRTAveragedSource final :
public VRTSimpleSource
1576 int m_bNoDataSet =
false;
1580 VRTAveragedSource();
1582 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1585 GDALRasterIOExtraArg *psExtraArgIn,
1586 WorkingState &oWorkingState)
override;
1588 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1589 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1590 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1591 int nBuckets,
GUIntBig *panHistogram,
1592 int bIncludeOutOfRange,
int bApproxOK,
1593 GDALProgressFunc pfnProgress,
1594 void *pProgressData)
override;
1596 void SetNoDataValue(
double dfNoDataValue);
1598 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1603 static const char *GetTypeStatic();
1605 const char *GetType()
const override;
1612class VRTNoDataFromMaskSource final :
public VRTSimpleSource
1616 bool m_bNoDataSet =
false;
1617 double m_dfNoDataValue = 0;
1618 double m_dfMaskValueThreshold = 0;
1619 bool m_bHasRemappedValue =
false;
1620 double m_dfRemappedValue = 0;
1623 VRTNoDataFromMaskSource();
1625 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1628 GDALRasterIOExtraArg *psExtraArgIn,
1629 WorkingState &oWorkingState)
override;
1631 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1632 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1633 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1634 int nBuckets,
GUIntBig *panHistogram,
1635 int bIncludeOutOfRange,
int bApproxOK,
1636 GDALProgressFunc pfnProgress,
1637 void *pProgressData)
override;
1639 void SetParameters(
double dfNoDataValue,
double dfMaskValueThreshold);
1640 void SetParameters(
double dfNoDataValue,
double dfMaskValueThreshold,
1641 double dfRemappedValue);
1643 virtual CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *,
1644 VRTMapSharedResources &)
override;
1645 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1650 static const char *GetTypeStatic();
1652 const char *GetType()
const override;
1659class CPL_DLL VRTComplexSource
CPL_NON_FINAL :
public VRTSimpleSource
1664 static constexpr int PROCESSING_FLAG_NODATA = 1 << 0;
1665 static constexpr int PROCESSING_FLAG_USE_MASK_BAND =
1667 static constexpr int PROCESSING_FLAG_SCALING_LINEAR = 1 << 2;
1668 static constexpr int PROCESSING_FLAG_SCALING_EXPONENTIAL =
1670 static constexpr int PROCESSING_FLAG_COLOR_TABLE_EXPANSION = 1 << 4;
1671 static constexpr int PROCESSING_FLAG_LUT = 1 << 5;
1673 int m_nProcessingFlags = 0;
1678 m_osNoDataValueOri{};
1680 double m_dfScaleOff = 0;
1681 double m_dfScaleRatio = 1;
1684 bool m_bSrcMinMaxDefined =
false;
1685 double m_dfSrcMin = 0;
1686 double m_dfSrcMax = 0;
1687 double m_dfDstMin = 0;
1688 double m_dfDstMax = 0;
1689 double m_dfExponent = 1;
1690 bool m_bClip =
true;
1692 int m_nColorTableComponent = 0;
1694 std::vector<double> m_adfLUTInputs{};
1695 std::vector<double> m_adfLUTOutputs{};
1697 double GetAdjustedNoDataValue()
const;
1699 template <
class WorkingDT>
1701 RasterIOInternal(GDALRasterBand *poSourceBand,
1702 GDALDataType eVRTBandDataType,
int nReqXOff,
int nReqYOff,
1703 int nReqXSize,
int nReqYSize,
void *pData,
int nOutXSize,
1705 GSpacing nLineSpace, GDALRasterIOExtraArg *psExtraArg,
1706 GDALDataType eWrkDataType, WorkingState &oWorkingState);
1708 template <
class WorkingDT, GDALDataType eWorkDT>
1709 CPLErr RasterIOProcessNoData(GDALRasterBand *poSourceBand,
1711 int nReqYOff,
int nReqXSize,
int nReqYSize,
1712 void *pData,
int nOutXSize,
int nOutYSize,
1715 GDALRasterIOExtraArg *psExtraArg,
1716 WorkingState &oWorkingState);
1719 VRTComplexSource() =
default;
1720 VRTComplexSource(
const VRTComplexSource *poSrcSource,
double dfXDstRatio,
1721 double dfYDstRatio);
1724 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1727 GDALRasterIOExtraArg *psExtraArgIn,
1728 WorkingState &oWorkingState)
override;
1730 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1731 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1732 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1733 int nBuckets,
GUIntBig *panHistogram,
1734 int bIncludeOutOfRange,
int bApproxOK,
1735 GDALProgressFunc pfnProgress,
1736 void *pProgressData)
override;
1738 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1739 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
1740 VRTMapSharedResources &)
override;
1745 static const char *GetTypeStatic();
1747 const char *GetType()
const override;
1749 bool AreValuesUnchanged()
const;
1751 double LookupValue(
double dfInput);
1753 void SetNoDataValue(
double dfNoDataValue);
1755 void SetUseMaskBand(
bool bUseMaskBand)
1758 m_nProcessingFlags |= PROCESSING_FLAG_USE_MASK_BAND;
1760 m_nProcessingFlags &= ~PROCESSING_FLAG_USE_MASK_BAND;
1763 void SetLinearScaling(
double dfOffset,
double dfScale);
1764 void SetPowerScaling(
double dfExponent,
double dfSrcMin,
double dfSrcMax,
1765 double dfDstMin,
double dfDstMax,
bool bClip =
true);
1766 void SetColorTableComponent(
int nComponent);
1768 void SetLUT(
const std::vector<double> &adfLUTInputs,
1769 const std::vector<double> &adfLUTOutputs);
1776class VRTFilteredSource
CPL_NON_FINAL :
public VRTComplexSource
1784 int m_nSupportedTypesCount;
1787 int m_nExtraEdgePixels;
1790 VRTFilteredSource();
1791 ~VRTFilteredSource()
override;
1793 const char *GetType()
const override = 0;
1795 void SetExtraEdgePixels(
int);
1796 void SetFilteringDataTypesSupported(
int,
GDALDataType *);
1802 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1805 GDALRasterIOExtraArg *psExtraArg,
1806 WorkingState &oWorkingState)
override;
1813class VRTKernelFilteredSource
CPL_NON_FINAL :
public VRTFilteredSource
1818 int m_nKernelSize = 0;
1819 bool m_bSeparable =
false;
1821 std::vector<double> m_adfKernelCoefs{};
1822 bool m_bNormalized =
false;
1823 std::string m_function{};
1826 VRTKernelFilteredSource();
1828 const char *GetType()
const override;
1830 virtual CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *,
1831 VRTMapSharedResources &)
override;
1832 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1835 GByte *pabySrcData,
GByte *pabyDstData)
override;
1837 CPLErr SetKernel(
int nKernelSize,
bool bSeparable,
1838 const std::vector<double> &adfNewCoefs);
1839 void SetNormalized(
bool);
1841 void SetFunction(
const std::string &s)
1851class VRTAverageFilteredSource final :
public VRTKernelFilteredSource
1856 explicit VRTAverageFilteredSource(
int nKernelSize);
1857 ~VRTAverageFilteredSource()
override;
1859 const char *GetType()
const override;
1861 virtual CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *,
1862 VRTMapSharedResources &)
override;
1863 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1869class VRTFuncSource final :
public VRTSource
1875 ~VRTFuncSource()
override;
1877 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
1878 VRTMapSharedResources &)
override
1883 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1886 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1889 GDALRasterIOExtraArg *psExtraArg,
1890 WorkingState &oWorkingState)
override;
1892 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1893 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1894 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1895 int nBuckets,
GUIntBig *panHistogram,
1896 int bIncludeOutOfRange,
int bApproxOK,
1897 GDALProgressFunc pfnProgress,
1898 void *pProgressData)
override;
1900 const char *GetType()
const override;
1914#define TMP_CPL_DLL CPL_DLL
1930 explicit Ref(VRTGroup *ptr) : m_ptr(ptr)
1934 Ref(
const Ref &) =
delete;
1935 Ref &operator=(
const Ref &) =
delete;
1939 std::shared_ptr<Ref> m_poSharedRefRootGroup{};
1940 std::weak_ptr<Ref> m_poWeakRefRootGroup{};
1941 std::shared_ptr<Ref> m_poRefSelf{};
1943 std::string m_osFilename{};
1944 mutable bool m_bDirty =
false;
1945 std::string m_osVRTPath{};
1946 std::vector<std::string> m_aosGroupNames{};
1947 std::map<std::string, std::shared_ptr<VRTGroup>> m_oMapGroups{};
1948 std::vector<std::string> m_aosMDArrayNames{};
1949 std::map<std::string, std::shared_ptr<VRTMDArray>> m_oMapMDArrays{};
1950 std::map<std::string, std::shared_ptr<VRTAttribute>> m_oMapAttributes{};
1951 std::map<std::string, std::shared_ptr<VRTDimension>> m_oMapDimensions{};
1953 std::shared_ptr<VRTGroup>
1954 OpenGroupInternal(
const std::string &osName)
const;
1955 void SetRootGroupRef(
const std::weak_ptr<Ref> &rgRef);
1956 std::weak_ptr<Ref> GetRootGroupRef()
const;
1959 friend class VRTMDArray;
1960 friend std::shared_ptr<GDALMDArray>
1961 VRTDerivedArrayCreate(
const char *pszVRTPath,
const CPLXMLNode *psTree);
1963 explicit VRTGroup(
const char *pszVRTPath);
1964 VRTGroup(
const std::string &osParentName,
const std::string &osName);
1967 static std::shared_ptr<VRTGroup> Create(
const std::string &osParentName,
1968 const std::string &osName)
1971 std::shared_ptr<VRTGroup>(
new VRTGroup(osParentName, osName));
1972 poGroup->SetSelf(poGroup);
1976 ~VRTGroup()
override;
1978 bool XMLInit(
const std::shared_ptr<VRTGroup> &poRoot,
1979 const std::shared_ptr<VRTGroup> &poThisGroup,
1980 const CPLXMLNode *psNode,
const char *pszVRTPath);
1982 std::vector<std::string>
1983 GetMDArrayNames(
CSLConstList papszOptions)
const override;
1984 std::shared_ptr<GDALMDArray>
1985 OpenMDArray(
const std::string &osName,
1988 std::vector<std::string>
1989 GetGroupNames(
CSLConstList papszOptions)
const override;
1991 std::shared_ptr<GDALGroup> OpenGroup(
const std::string &osName,
1994 return OpenGroupInternal(osName);
1997 std::vector<std::shared_ptr<GDALDimension>>
2000 std::vector<std::shared_ptr<GDALAttribute>>
2003 std::shared_ptr<VRTDimension> GetDimension(
const std::string &name)
const
2005 auto oIter = m_oMapDimensions.find(name);
2006 return oIter == m_oMapDimensions.end() ? nullptr : oIter->second;
2009 std::shared_ptr<VRTDimension>
2010 GetDimensionFromFullName(
const std::string &name,
bool bEmitError)
const;
2012 std::shared_ptr<GDALGroup>
2013 CreateGroup(
const std::string &osName,
2016 std::shared_ptr<VRTGroup>
2017 CreateVRTGroup(
const std::string &osName,
2020 std::shared_ptr<GDALDimension>
2021 CreateDimension(
const std::string &osName,
const std::string &osType,
2022 const std::string &osDirection,
GUInt64 nSize,
2025 std::shared_ptr<GDALAttribute>
2026 CreateAttribute(
const std::string &osName,
2027 const std::vector<GUInt64> &anDimensions,
2028 const GDALExtendedDataType &oDataType,
2031 std::shared_ptr<GDALMDArray> CreateMDArray(
2032 const std::string &osName,
2033 const std::vector<std::shared_ptr<GDALDimension>> &aoDimensions,
2034 const GDALExtendedDataType &oDataType,
2037 std::shared_ptr<VRTMDArray> CreateVRTMDArray(
2038 const std::string &osName,
2039 const std::vector<std::shared_ptr<GDALDimension>> &aoDimensions,
2040 const GDALExtendedDataType &oDataType,
2043 void SetIsRootGroup();
2045 const std::shared_ptr<Ref> &GetRef()
const
2050 VRTGroup *GetRootGroup()
const;
2051 std::shared_ptr<VRTGroup> GetRootGroupSharedPtr()
const;
2053 const std::string &GetVRTPath()
const
2058 void SetVRTPath(
const std::string &osVRTPath)
2060 m_osVRTPath = osVRTPath;
2065 void SetFilename(
const std::string &osFilename)
2067 m_osFilename = osFilename;
2070 const std::string &GetFilename()
const
2072 return m_osFilename;
2075 bool Serialize()
const;
2076 CPLXMLNode *SerializeToXML(
const char *pszVRTPathIn)
const;
2077 void Serialize(CPLXMLNode *psParent,
const char *pszVRTPathIn)
const;
2086 std::weak_ptr<VRTGroup::Ref> m_poGroupRef;
2087 std::string m_osIndexingVariableName;
2090 VRTDimension(
const std::shared_ptr<VRTGroup::Ref> &poGroupRef,
2091 const std::string &osParentName,
const std::string &osName,
2092 const std::string &osType,
const std::string &osDirection,
2093 GUInt64 nSize,
const std::string &osIndexingVariableName)
2094 : GDALDimension(osParentName, osName, osType, osDirection, nSize),
2095 m_poGroupRef(poGroupRef),
2096 m_osIndexingVariableName(osIndexingVariableName)
2100 VRTGroup *GetGroup()
const;
2102 static std::shared_ptr<VRTDimension>
2103 Create(
const std::shared_ptr<VRTGroup> &poThisGroup,
2104 const std::string &osParentName,
const CPLXMLNode *psNode);
2109 std::shared_ptr<GDALMDArray> poIndexingVariable)
override;
2111 void Serialize(CPLXMLNode *psParent)
const;
2120 GDALExtendedDataType m_dt;
2121 std::vector<std::string> m_aosList{};
2122 std::vector<std::shared_ptr<GDALDimension>> m_dims{};
2125 bool IRead(
const GUInt64 *arrayStartIdx,
const size_t *count,
2127 const GDALExtendedDataType &bufferDataType,
2128 void *pDstBuffer)
const override;
2130 bool IWrite(
const GUInt64 *arrayStartIdx,
const size_t *count,
2132 const GDALExtendedDataType &bufferDataType,
2133 const void *pSrcBuffer)
override;
2136 VRTAttribute(
const std::string &osParentName,
const std::string &osName,
2137 const GDALExtendedDataType &dt,
2138 std::vector<std::string> &&aosList)
2139 : GDALAbstractMDArray(osParentName, osName),
2140 GDALAttribute(osParentName, osName), m_dt(dt),
2141 m_aosList(std::move(aosList))
2143 if (m_aosList.size() > 1)
2145 m_dims.emplace_back(std::make_shared<GDALDimension>(
2146 std::string(),
"dim", std::string(), std::string(),
2151 VRTAttribute(
const std::string &osParentName,
const std::string &osName,
2152 GUInt64 nDim,
const GDALExtendedDataType &dt)
2153 : GDALAbstractMDArray(osParentName, osName),
2154 GDALAttribute(osParentName, osName), m_dt(dt)
2158 m_dims.emplace_back(std::make_shared<GDALDimension>(
2159 std::string(),
"dim", std::string(), std::string(), nDim));
2163 static bool CreationCommonChecks(
2164 const std::string &osName,
const std::vector<GUInt64> &anDimensions,
2165 const std::map<std::string, std::shared_ptr<VRTAttribute>>
2168 static std::shared_ptr<VRTAttribute> Create(
const std::string &osParentName,
2169 const CPLXMLNode *psNode);
2171 const std::vector<std::shared_ptr<GDALDimension>> &
2177 const GDALExtendedDataType &
GetDataType()
const override
2182 void Serialize(CPLXMLNode *psParent)
const;
2189class VRTMDArraySource
2192 virtual ~VRTMDArraySource();
2194 enum class RelationShip
2197 PARTIAL_INTERSECTION,
2201 virtual RelationShip GetRelationship(
const uint64_t *arrayStartIdx,
2202 const size_t *count)
const = 0;
2204 virtual bool GetRawBlockInfo(
const uint64_t *arrayStartIdx,
2205 const size_t *count,
2206 GDALMDArrayRawBlockInfo &info)
const = 0;
2208 virtual bool Read(
const GUInt64 *arrayStartIdx,
const size_t *count,
2210 const GDALExtendedDataType &bufferDataType,
2211 void *pDstBuffer)
const = 0;
2213 virtual void Serialize(CPLXMLNode *psParent,
2214 const char *pszVRTPath)
const = 0;
2224 friend class VRTGroup;
2226 std::weak_ptr<VRTGroup::Ref> m_poGroupRef;
2227 std::string m_osVRTPath{};
2228 std::shared_ptr<VRTGroup> m_poDummyOwningGroup{};
2230 GDALExtendedDataType m_dt;
2231 std::vector<std::shared_ptr<GDALDimension>> m_dims;
2232 std::map<std::string, std::shared_ptr<VRTAttribute>> m_oMapAttributes{};
2233 std::vector<std::unique_ptr<VRTMDArraySource>> m_sources{};
2234 std::shared_ptr<OGRSpatialReference> m_poSRS{};
2235 std::vector<GByte> m_abyNoData{};
2236 std::string m_osUnit{};
2237 double m_dfScale = 1.0;
2238 double m_dfOffset = 0.0;
2239 bool m_bHasScale =
false;
2240 bool m_bHasOffset =
false;
2241 std::string m_osFilename{};
2242 std::vector<GUInt64> m_anBlockSize{};
2243 std::vector<std::string> m_aosOverviewFullname{};
2244 mutable std::vector<std::shared_ptr<GDALMDArray>> m_apoOverviews{};
2246 bool IRead(
const GUInt64 *arrayStartIdx,
const size_t *count,
2248 const GDALExtendedDataType &bufferDataType,
2249 void *pDstBuffer)
const override;
2255 const std::shared_ptr<VRTGroup::Ref> &poGroupRef,
2256 const std::string &osParentName,
const std::string &osName,
2257 const GDALExtendedDataType &dt,
2258 std::vector<std::shared_ptr<GDALDimension>> &&dims,
2259 std::map<std::string, std::shared_ptr<VRTAttribute>> &&oMapAttributes,
2260 std::vector<GUInt64> &&anBlockSize)
2261 : GDALAbstractMDArray(osParentName, osName),
2262 GDALMDArray(osParentName, osName), m_poGroupRef(poGroupRef),
2263 m_osVRTPath(poGroupRef->m_ptr->GetVRTPath()), m_dt(dt),
2264 m_dims(std::move(dims)), m_oMapAttributes(std::move(oMapAttributes)),
2265 m_osFilename(poGroupRef->m_ptr->GetFilename()),
2266 m_anBlockSize(std::move(anBlockSize))
2270 VRTMDArray(
const std::shared_ptr<VRTGroup::Ref> &poGroupRef,
2271 const std::string &osParentName,
const std::string &osName,
2272 const std::vector<std::shared_ptr<GDALDimension>> &dims,
2273 const GDALExtendedDataType &dt,
2274 const std::vector<GUInt64> &anBlockSize)
2275 : GDALAbstractMDArray(osParentName, osName),
2276 GDALMDArray(osParentName, osName), m_poGroupRef(poGroupRef),
2277 m_osVRTPath(poGroupRef->m_ptr->GetVRTPath()), m_dt(dt), m_dims(dims),
2278 m_osFilename(poGroupRef->m_ptr->GetFilename()),
2279 m_anBlockSize(anBlockSize)
2290 return m_osFilename;
2293 static std::shared_ptr<VRTMDArray> Create(
const char *pszVRTPath,
2294 const CPLXMLNode *psNode);
2296 static std::shared_ptr<VRTMDArray>
2297 Create(
const std::shared_ptr<VRTGroup> &poThisGroup,
2298 const std::string &osParentName,
const CPLXMLNode *psNode);
2300 const std::vector<std::shared_ptr<GDALDimension>> &
2306 std::vector<std::shared_ptr<GDALAttribute>>
2309 const GDALExtendedDataType &
GetDataType()
const override
2314 bool SetSpatialRef(
const OGRSpatialReference *poSRS)
override;
2316 std::shared_ptr<OGRSpatialReference>
GetSpatialRef()
const override
2325 const std::string &
GetUnit()
const override
2330 bool SetUnit(
const std::string &osUnit)
override
2340 *pbHasOffset = m_bHasOffset;
2350 *pbHasScale = m_bHasScale;
2360 m_bHasOffset =
true;
2361 m_dfOffset = dfOffset;
2370 m_dfScale = dfScale;
2374 void AddSource(std::unique_ptr<VRTMDArraySource> &&poSource);
2376 std::shared_ptr<GDALAttribute>
2378 const std::vector<GUInt64> &anDimensions,
2379 const GDALExtendedDataType &oDataType,
2382 bool CopyFrom(GDALDataset *poSrcDS,
const GDALMDArray *poSrcArray,
2384 GDALProgressFunc pfnProgress,
void *pProgressData)
override;
2386 void Serialize(CPLXMLNode *psParent,
const char *pszVRTPathIn)
const;
2388 VRTGroup *GetGroup()
const;
2390 const std::string &GetVRTPath()
const
2395 std::shared_ptr<VRTGroup> GetRootVRTGroup()
const
2397 auto poGroup = m_poGroupRef.lock();
2399 return poGroup->m_ptr->GetRootGroupSharedPtr();
2403 std::shared_ptr<GDALGroup>
GetRootGroup()
const override
2405 return GetRootVRTGroup();
2410 return m_anBlockSize;
2414 GDALMDArrayRawBlockInfo &info)
const override;
2418 std::shared_ptr<GDALMDArray>
GetOverview(
int idx)
const override;
2425class VRTMDArraySourceInlinedValues final :
public VRTMDArraySource
2427 const VRTMDArray *m_poDstArray =
nullptr;
2428 bool m_bIsConstantValue;
2429 std::vector<GUInt64> m_anOffset{};
2430 std::vector<size_t> m_anCount{};
2431 std::vector<GByte> m_abyValues{};
2432 std::vector<size_t> m_anInlinedArrayStrideInBytes{};
2433 GDALExtendedDataType m_dt;
2435 VRTMDArraySourceInlinedValues(
const VRTMDArraySourceInlinedValues &) =
2437 VRTMDArraySourceInlinedValues &
2438 operator=(
const VRTMDArraySourceInlinedValues &) =
delete;
2441 VRTMDArraySourceInlinedValues(
const VRTMDArray *poDstArray,
2442 bool bIsConstantValue,
2443 std::vector<GUInt64> &&anOffset,
2444 std::vector<size_t> &&anCount,
2445 std::vector<GByte> &&abyValues)
2446 : m_poDstArray(poDstArray), m_bIsConstantValue(bIsConstantValue),
2447 m_anOffset(std::move(anOffset)), m_anCount(std::move(anCount)),
2448 m_abyValues(std::move(abyValues)), m_dt(poDstArray->GetDataType())
2450 const auto nDims(poDstArray->GetDimensionCount());
2451 m_anInlinedArrayStrideInBytes.resize(nDims);
2452 if (!bIsConstantValue && nDims > 0)
2454 m_anInlinedArrayStrideInBytes.back() =
2455 poDstArray->GetDataType().GetSize();
2456 for (
size_t i = nDims - 1; i > 0;)
2459 m_anInlinedArrayStrideInBytes[i] =
2460 m_anInlinedArrayStrideInBytes[i + 1] * m_anCount[i + 1];
2465 ~VRTMDArraySourceInlinedValues()
override;
2467 static std::unique_ptr<VRTMDArraySourceInlinedValues>
2468 Create(
const VRTMDArray *poDstArray,
const CPLXMLNode *psNode);
2470 RelationShip GetRelationship(
const uint64_t * ,
2471 const size_t * )
const override
2473 return RelationShip::PARTIAL_INTERSECTION;
2476 bool GetRawBlockInfo(
const uint64_t * ,
2478 GDALMDArrayRawBlockInfo & )
const override
2483 bool Read(
const GUInt64 *arrayStartIdx,
const size_t *count,
2485 const GDALExtendedDataType &bufferDataType,
2486 void *pDstBuffer)
const override;
2488 void Serialize(CPLXMLNode *psParent,
const char *pszVRTPath)
const override;
2495class VRTMDArraySourceRegularlySpaced final :
public VRTMDArraySource
2498 double m_dfIncrement;
2501 VRTMDArraySourceRegularlySpaced(
double dfStart,
double dfIncrement)
2502 : m_dfStart(dfStart), m_dfIncrement(dfIncrement)
2506 RelationShip GetRelationship(
const uint64_t * ,
2507 const size_t * )
const override
2509 return RelationShip::PARTIAL_INTERSECTION;
2512 bool GetRawBlockInfo(
const uint64_t * ,
2514 GDALMDArrayRawBlockInfo & )
const override
2519 bool Read(
const GUInt64 *arrayStartIdx,
const size_t *count,
2521 const GDALExtendedDataType &bufferDataType,
2522 void *pDstBuffer)
const override;
2524 void Serialize(CPLXMLNode *psParent,
const char *pszVRTPath)
const override;
2531struct VRTArrayDatasetWrapper;
2533class VRTMDArraySourceFromArray final :
public VRTMDArraySource
2535 const VRTMDArray *m_poDstArray =
nullptr;
2536 bool m_bRelativeToVRTSet =
false;
2537 bool m_bRelativeToVRT =
false;
2538 std::string m_osFilename{};
2539 std::string m_osArray{};
2540 std::string m_osBand{};
2541 std::vector<int> m_anTransposedAxis{};
2542 std::string m_osViewExpr{};
2543 std::vector<GUInt64> m_anSrcOffset{};
2544 mutable std::vector<GUInt64> m_anCount{};
2545 std::vector<GUInt64> m_anStep{};
2546 std::vector<GUInt64> m_anDstOffset{};
2548 std::pair<std::shared_ptr<VRTArrayDatasetWrapper>,
2549 std::shared_ptr<GDALMDArray>>
2550 GetSourceArray()
const;
2552 VRTMDArraySourceFromArray(
const VRTMDArraySourceFromArray &) =
delete;
2553 VRTMDArraySourceFromArray &
2554 operator=(
const VRTMDArraySourceFromArray &) =
delete;
2557 VRTMDArraySourceFromArray(
2558 const VRTMDArray *poDstArray,
bool bRelativeToVRTSet,
2559 bool bRelativeToVRT,
const std::string &osFilename,
2560 const std::string &osArray,
const std::string &osBand,
2561 std::vector<int> &&anTransposedAxis,
const std::string &osViewExpr,
2562 std::vector<GUInt64> &&anSrcOffset, std::vector<GUInt64> &&anCount,
2563 std::vector<GUInt64> &&anStep, std::vector<GUInt64> &&anDstOffset)
2564 : m_poDstArray(poDstArray), m_bRelativeToVRTSet(bRelativeToVRTSet),
2565 m_bRelativeToVRT(bRelativeToVRT), m_osFilename(osFilename),
2566 m_osArray(osArray), m_osBand(osBand),
2567 m_anTransposedAxis(std::move(anTransposedAxis)),
2568 m_osViewExpr(osViewExpr), m_anSrcOffset(std::move(anSrcOffset)),
2569 m_anCount(std::move(anCount)), m_anStep(std::move(anStep)),
2570 m_anDstOffset(std::move(anDstOffset))
2574 ~VRTMDArraySourceFromArray()
override;
2576 static std::unique_ptr<VRTMDArraySourceFromArray>
2577 Create(
const VRTMDArray *poDstArray,
const CPLXMLNode *psNode);
2579 RelationShip GetRelationship(
const uint64_t *arrayStartIdx,
2580 const size_t *count)
const override;
2582 bool GetRawBlockInfo(
const uint64_t *arrayStartIdx,
const size_t *count,
2583 GDALMDArrayRawBlockInfo &info)
const override;
2585 bool Read(
const GUInt64 *arrayStartIdx,
const size_t *count,
2587 const GDALExtendedDataType &bufferDataType,
2588 void *pDstBuffer)
const override;
2590 void Serialize(CPLXMLNode *psParent,
const char *pszVRTPath)
const override;
Convenient string class based on std::string.
Definition cpl_string.h:338
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_abstract_array.cpp:782
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:77
int Dereference()
Subtract one from dataset reference count.
Definition gdaldataset.cpp:1905
virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList, const OGRSpatialReference *poGCP_SRS)
Assign GCPs.
Definition gdaldataset.cpp:2360
int GetShared() const
Returns shared flag.
Definition gdaldataset.cpp:1977
Class modeling a a dimension / axis used to index multidimensional arrays.
Definition gdal_multidim.h:1242
virtual std::shared_ptr< GDALMDArray > GetIndexingVariable() const
Return the variable that is used to index the dimension (if there is one).
Definition gdalmultidim_dimension.cpp:59
virtual bool SetIndexingVariable(std::shared_ptr< GDALMDArray > poIndexingVariable)
Set the variable that is used to index the dimension.
Definition gdalmultidim_dimension.cpp:80
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_attribute.cpp:124
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_attribute.cpp:93
Class modeling a multi-dimensional array.
Definition gdal_multidim.h:852
virtual bool SetUnit(const std::string &osUnit)
Set the variable unit.
Definition gdalmultidim_array.cpp:50
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_array.cpp:618
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_array.cpp:383
virtual bool SetRawNoDataValue(const void *pRawNoData)
Set the nodata value as a "raw" value.
Definition gdalmultidim_array.cpp:242
virtual double GetOffset(bool *pbHasOffset=nullptr, GDALDataType *peStorageType=nullptr) const
Get the offset value to apply to raw values.
Definition gdalmultidim_array.cpp:470
virtual const void * GetRawNoDataValue() const
Return the nodata value as a "raw" value.
Definition gdalmultidim_array.cpp:126
virtual double GetScale(bool *pbHasScale=nullptr, GDALDataType *peStorageType=nullptr) const
Get the scale value to apply to raw values.
Definition gdalmultidim_array.cpp:440
virtual std::shared_ptr< OGRSpatialReference > GetSpatialRef() const
Return the spatial reference system object associated with the array.
Definition gdalmultidim_array.cpp:100
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_c_api_array.cpp:1422
virtual int GetOverviewCount() const
Return the number of overview arrays available.
Definition gdalmultidim_c_api_array.cpp:1530
virtual bool SetSpatialRef(const OGRSpatialReference *poSRS)
Assign a spatial reference system object to the array.
Definition gdalmultidim_array.cpp:86
virtual std::shared_ptr< GDALMDArray > GetOverview(int idx) const
Get overview array object.
Definition gdalmultidim_c_api_array.cpp:1571
virtual std::shared_ptr< GDALGroup > GetRootGroup() const
Return the root group to which this arrays belongs too.
Definition gdalmultidim_array.cpp:1207
virtual bool SetOffset(double dfOffset, GDALDataType eStorageType=GDT_Unknown)
Set the offset value to apply to raw values.
Definition gdalmultidim_array.cpp:411
virtual const std::string & GetUnit() const
Return the array unit.
Definition gdalmultidim_array.cpp:72
virtual CSLConstList GetMetadata(const char *pszDomain="")
Fetch metadata.
Definition gdalmajorobject.cpp:228
virtual CPLErr SetMetadata(CSLConstList papszMetadata, const char *pszDomain="")
Set metadata.
Definition gdalmajorobject.cpp:271
virtual char ** GetMetadataDomainList()
Fetch list of metadata domains.
Definition gdalmajorobject.cpp:143
Pansharpening operation class.
Definition gdalpansharpen.h:176
A single raster band (or channel).
Definition gdal_rasterband.h:108
GDALDataset * GetDataset() const
Fetch the owning dataset handle.
Definition gdalrasterband.cpp:4000
High level image warping class.
Definition gdalwarper.h:504
CPLErr
Error category / error level.
Definition cpl_error.h:45
@ CE_None
No error.
Definition cpl_error.h:47
@ CE_Failure
Error that prevents the current operation to succeed.
Definition cpl_error.h:60
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:236
#define CPL_NON_FINAL
Mark that a class is explicitly recognized as non-final.
Definition cpl_port.h:1094
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition cpl_port.h:198
GIntBig GInt64
Signed 64 bit integer type.
Definition cpl_port.h:216
#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:1101
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1252
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition cpl_port.h:218
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:165
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:195
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:412
GDALAccess
Definition gdal.h:120
@ GA_ReadOnly
Definition gdal.h:121
void * VRTPDWorkingDataPtr
Generic pointer for the working structure of VRTProcessedDataset function.
Definition gdal.h:1847
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:1665
GDALRIOResampleAlg
RasterIO() resampling method.
Definition gdal.h:137
CPLErr GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition gdaldataset.cpp:4723
GDALColorInterp
Types of color interpretation for raster bands.
Definition gdal.h:294
@ GCI_Undefined
Definition gdal.h:295
GDALRWFlag
Definition gdal.h:127
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:1657
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:78
Document node structure.
Definition cpl_minixml.h:54