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 std::unique_ptr<OGRSpatialReference, OGRSpatialReferenceReleaser>
269 bool m_bNeedsFlush =
false;
270 bool m_bWritable =
true;
271 bool m_bCanTakeRef =
true;
273 char *m_pszVRTPath =
nullptr;
275 std::unique_ptr<VRTRasterBand> m_poMaskBand{};
277 mutable int m_nCompatibleForDatasetIO = -1;
278 bool CheckCompatibleForDatasetIO()
const;
282 std::vector<GDALDataset *> m_apoOverviews{};
283 std::vector<GDALDataset *> m_apoOverviewsBak{};
284 CPLStringList m_aosOverviewList{};
285 CPLString m_osOverviewResampling{};
286 std::vector<int> m_anOverviewFactors{};
288 char **m_papszXMLVRTMetadata =
nullptr;
290 VRTMapSharedResources m_oMapSharedSources{};
291 std::shared_ptr<VRTGroup> m_poRootGroup{};
294 VRTSource::WorkingState m_oWorkingState{};
297 struct QueueWorkingStates
300 std::vector<std::unique_ptr<VRTSource::WorkingState>> oStates{};
303 QueueWorkingStates m_oQueueWorkingStates{};
305 bool m_bMultiThreadedRasterIOLastUsed =
false;
307 std::unique_ptr<VRTRasterBand> InitBand(
const char *pszSubclass,
int nBand,
308 bool bAllowPansharpenedOrProcessed);
309 static GDALDataset *OpenVRTProtocol(
const char *pszSpec);
310 bool AddVirtualOverview(
int nOvFactor,
const char *pszResampling);
312 bool GetShiftedDataset(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
313 GDALDataset *&poSrcDataset,
int &nSrcXOff,
316 static bool IsDefaultBlockSize(
int nBlockSize,
int nDimension);
321 bool m_bBlockSizeSpecified =
false;
322 int m_nBlockXSize = 0;
323 int m_nBlockYSize = 0;
325 std::unique_ptr<OGRSpatialReference, OGRSpatialReferenceReleaser> m_poSRS{};
327 int m_bGeoTransformSet =
false;
328 GDALGeoTransform m_gt{};
330 int CloseDependentDatasets()
override;
333 VRTDataset(
int nXSize,
int nYSize,
int nBlockXSize = 0,
334 int nBlockYSize = 0);
335 ~VRTDataset()
override;
339 m_bNeedsFlush =
true;
342 CPLErr FlushCache(
bool bAtClosing)
override;
344 void SetWritable(
int bWritableIn)
346 m_bWritable = CPL_TO_BOOL(bWritableIn);
349 CPLErr CreateMaskBand(
int nFlags)
override;
350 void SetMaskBand(std::unique_ptr<VRTRasterBand> poMaskBand);
352 const OGRSpatialReference *GetSpatialRef()
const override
354 return m_poSRS.get();
357 CPLErr SetSpatialRef(
const OGRSpatialReference *poSRS)
override;
359 CPLErr GetGeoTransform(GDALGeoTransform &)
const override;
360 CPLErr SetGeoTransform(
const GDALGeoTransform &)
override;
362 CPLErr SetMetadata(
char **papszMetadata,
363 const char *pszDomain =
"")
override;
364 CPLErr SetMetadataItem(
const char *pszName,
const char *pszValue,
365 const char *pszDomain =
"")
override;
367 char **GetMetadata(
const char *pszDomain =
"")
override;
368 virtual const char *GetMetadataItem(
const char *pszName,
369 const char *pszDomain =
"")
override;
371 int GetGCPCount()
override;
373 const OGRSpatialReference *GetGCPSpatialRef()
const override
375 return m_poGCP_SRS.get();
378 const GDAL_GCP *GetGCPs()
override;
380 CPLErr SetGCPs(
int nGCPCount,
const GDAL_GCP *pasGCPList,
381 const OGRSpatialReference *poSRS)
override;
384 char **papszOptions =
nullptr)
override;
386 char **GetFileList()
override;
389 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
391 BANDMAP_TYPE panBandMap,
GSpacing nPixelSpace,
393 GDALRasterIOExtraArg *psExtraArg)
override;
395 virtual CPLStringList
396 GetCompressionFormats(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
397 int nBandCount,
const int *panBandList)
override;
398 virtual CPLErr ReadCompressedData(
const char *pszFormat,
int nXOff,
399 int nYOff,
int nXSize,
int nYSize,
400 int nBandCount,
const int *panBandList,
401 void **ppBuffer,
size_t *pnBufferSize,
402 char **ppszDetailedFormat)
override;
404 CPLErr AdviseRead(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
406 int nBandCount,
int *panBandList,
407 char **papszOptions)
override;
409 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath);
410 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *);
412 CPLErr IBuildOverviews(
const char *,
int,
const int *,
int,
const int *,
413 GDALProgressFunc,
void *,
416 std::shared_ptr<GDALGroup> GetRootGroup()
const override;
418 std::shared_ptr<VRTGroup> GetRootVRTGroup()
const
420 return m_poRootGroup;
423 void ClearStatistics()
override;
428 m_nCompatibleForDatasetIO = -1;
432 GDALDataset *GetSingleSimpleSource();
433 void BuildVirtualOverviews();
435 void UnsetPreservedRelativeFilenames();
437 bool IsBlockSizeSpecified()
const
439 return m_bBlockSizeSpecified;
442 int GetBlockXSize()
const
444 return m_nBlockXSize;
447 int GetBlockYSize()
const
449 return m_nBlockYSize;
452 static int Identify(GDALOpenInfo *);
453 static GDALDataset *Open(GDALOpenInfo *);
454 static std::unique_ptr<VRTDataset>
455 OpenXML(
const char *,
const char * =
nullptr,
457 static GDALDataset *Create(
const char *pszName,
int nXSize,
int nYSize,
459 char **papszOptions);
460 static std::unique_ptr<VRTDataset>
461 CreateVRTDataset(
const char *pszName,
int nXSize,
int nYSize,
int nBands,
464 CreateMultiDimensional(
const char *pszFilename,
467 static std::unique_ptr<VRTDataset>
468 CreateVRTMultiDimensional(
const char *pszFilename,
471 static CPLErr Delete(
const char *pszFilename);
473 static int GetNumThreads(GDALDataset *poDS);
475 static bool IsRawRasterBandEnabled();
483class VRTWarpedRasterBand;
485class CPL_DLL VRTWarpedDataset final :
public VRTDataset
487 GDALWarpOperation *m_poWarper;
489 bool m_bIsOverview =
false;
490 std::vector<VRTWarpedDataset *> m_apoOverviews{};
493 bool GetOverviewSize(GDALDataset *poSrcDS,
int iOvr,
int iSrcOvr,
494 int &nOvrXSize,
int &nOvrYSize,
double &dfSrcRatioX,
495 double &dfSrcRatioY)
const;
496 int GetOverviewCount()
const;
497 int GetSrcOverviewLevel(
int iOvr,
bool &bThisLevelOnlyOut)
const;
498 VRTWarpedDataset *CreateImplicitOverview(
int iOvr)
const;
499 void CreateImplicitOverviews();
501 friend class VRTWarpedRasterBand;
506 int CloseDependentDatasets()
override;
509 VRTWarpedDataset(
int nXSize,
int nYSize,
int nBlockXSize = 0,
510 int nBlockYSize = 0);
511 ~VRTWarpedDataset()
override;
513 CPLErr FlushCache(
bool bAtClosing)
override;
515 CPLErr Initialize(
void *);
517 CPLErr IBuildOverviews(
const char *,
int,
const int *,
int,
const int *,
518 GDALProgressFunc,
void *,
521 CPLErr SetMetadataItem(
const char *pszName,
const char *pszValue,
522 const char *pszDomain =
"")
override;
524 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
525 CPLErr XMLInit(
const CPLXMLNode *,
const char *)
override;
528 char **papszOptions =
nullptr)
override;
530 char **GetFileList()
override;
533 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
535 BANDMAP_TYPE panBandMap,
GSpacing nPixelSpace,
537 GDALRasterIOExtraArg *psExtraArg)
override;
539 CPLErr ProcessBlock(
int iBlockX,
int iBlockY);
541 void GetBlockSize(
int *,
int *)
const;
553 GTAdjust_Intersection,
555 GTAdjust_NoneWithoutWarning
558class VRTPansharpenedDataset final :
public VRTDataset
560 friend class VRTPansharpenedRasterBand;
562 std::unique_ptr<GDALPansharpenOperation> m_poPansharpener{};
563 VRTPansharpenedDataset *m_poMainDataset;
564 std::vector<std::unique_ptr<VRTPansharpenedDataset>>
565 m_apoOverviewDatasets{};
567 std::map<CPLString, CPLString> m_oMapToRelativeFilenames{};
569 int m_bLoadingOtherBands;
571 GByte *m_pabyLastBufferBandRasterIO;
572 int m_nLastBandRasterIOXOff;
573 int m_nLastBandRasterIOYOff;
574 int m_nLastBandRasterIOXSize;
575 int m_nLastBandRasterIOYSize;
578 GTAdjustment m_eGTAdjustment;
579 int m_bNoDataDisabled;
581 std::vector<std::unique_ptr<GDALDataset, GDALDatasetUniquePtrReleaser>>
582 m_apoDatasetsToReleaseRef{};
587 int CloseDependentDatasets()
override;
590 VRTPansharpenedDataset(
int nXSize,
int nYSize,
int nBlockXSize = 0,
591 int nBlockYSize = 0);
592 ~VRTPansharpenedDataset()
override;
594 CPLErr FlushCache(
bool bAtClosing)
override;
596 CPLErr XMLInit(
const CPLXMLNode *,
const char *)
override;
597 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
599 CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *pszVRTPath,
604 char **papszOptions =
nullptr)
override;
606 char **GetFileList()
override;
609 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
611 BANDMAP_TYPE panBandMap,
GSpacing nPixelSpace,
613 GDALRasterIOExtraArg *psExtraArg)
override;
615 void GetBlockSize(
int *,
int *)
const;
617 GDALPansharpenOperation *GetPansharpener()
619 return m_poPansharpener.get();
632class VRTProcessedDataset final :
public VRTDataset
635 VRTProcessedDataset(
int nXSize,
int nYSize);
636 ~VRTProcessedDataset()
override;
638 CPLErr FlushCache(
bool bAtClosing)
override;
640 CPLErr XMLInit(
const CPLXMLNode *,
const char *)
override;
641 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
643 void GetBlockSize(
int *,
int *)
const;
647#pragma GCC diagnostic push
648#pragma GCC diagnostic ignored "-Weffc++"
664 inline operator GByte()
const
670#pragma GCC diagnostic pop
675 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
677 BANDMAP_TYPE panBandMap,
GSpacing nPixelSpace,
679 GDALRasterIOExtraArg *psExtraArg)
override;
682 friend class VRTProcessedRasterBand;
688 std::string osAlgorithm{};
691 CPLStringList aosArguments{};
706 std::vector<double> adfInNoData{};
709 std::vector<double> adfOutNoData{};
720 Step &operator=(Step &&);
723 Step(
const Step &) =
delete;
724 Step &operator=(
const Step &) =
delete;
729 std::string m_osVRTPath{};
732 std::unique_ptr<GDALDataset> m_poVRTSrcDS{};
735 std::unique_ptr<GDALDataset> m_poSrcDS{};
738 std::vector<Step> m_aoSteps{};
741 CPLXMLTreeCloser m_oXMLTree{
nullptr};
744 std::vector<std::unique_ptr<GDALDataset>> m_apoOverviewDatasets{};
747 std::vector<NoInitByte> m_abyInput{};
750 std::vector<NoInitByte> m_abyOutput{};
753 enum class ValueProvenance
762 ValueProvenance m_outputBandCountProvenance = ValueProvenance::FROM_SOURCE;
765 int m_outputBandCountValue = 0;
768 ValueProvenance m_outputBandDataTypeProvenance =
769 ValueProvenance::FROM_SOURCE;
775 int m_nWorkingBytesPerPixel = 1;
778 GIntBig m_nAllowedRAMUsage = 0;
780 CPLErr Init(
const CPLXMLNode *,
const char *,
781 const VRTProcessedDataset *poParentDS,
782 GDALDataset *poParentSrcDS,
int iOvrLevel);
784 bool ParseStep(
const CPLXMLNode *psStep,
bool bIsFinalStep,
786 std::vector<double> &adfInNoData,
787 std::vector<double> &adfOutNoData);
788 bool ProcessRegion(
int nXOff,
int nYOff,
int nBufXSize,
int nBufYSize,
789 GDALProgressFunc pfnProgress,
void *pProgressData);
799constexpr double VRT_DEFAULT_NODATA_VALUE = -10000.0;
804 void ResetNoDataValues();
807 friend class VRTDataset;
809 bool m_bIsMaskBand =
false;
811 bool m_bNoDataValueSet =
false;
813 int m_bHideNoDataValue =
false;
814 double m_dfNoDataValue = VRT_DEFAULT_NODATA_VALUE;
816 bool m_bNoDataSetAsInt64 =
false;
817 int64_t m_nNoDataValueInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_INT64;
819 bool m_bNoDataSetAsUInt64 =
false;
820 uint64_t m_nNoDataValueUInt64 = GDAL_PAM_DEFAULT_NODATA_VALUE_UINT64;
822 std::unique_ptr<GDALColorTable> m_poColorTable{};
826 std::string m_osUnitType{};
827 CPLStringList m_aosCategoryNames{};
829 double m_dfOffset = 0.0;
830 double m_dfScale = 1.0;
832 CPLXMLTreeCloser m_psSavedHistograms{
nullptr};
834 void Initialize(
int nXSize,
int nYSize);
836 std::vector<VRTOverviewInfo> m_aoOverviewInfos{};
838 std::unique_ptr<VRTRasterBand> m_poMaskBand{};
840 std::unique_ptr<GDALRasterAttributeTable> m_poRAT{};
844 bool IsNoDataValueInDataTypeRange()
const;
848 ~VRTRasterBand()
override;
850 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
851 VRTMapSharedResources &);
852 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
853 bool &bHasWarnedAboutRAMUsage,
854 size_t &nAccRAMUsage);
856 CPLErr SetNoDataValue(
double)
override;
857 CPLErr SetNoDataValueAsInt64(int64_t nNoData)
override;
858 CPLErr SetNoDataValueAsUInt64(uint64_t nNoData)
override;
859 double GetNoDataValue(
int *pbSuccess =
nullptr)
override;
860 int64_t GetNoDataValueAsInt64(
int *pbSuccess =
nullptr)
override;
861 uint64_t GetNoDataValueAsUInt64(
int *pbSuccess =
nullptr)
override;
862 CPLErr DeleteNoDataValue()
override;
864 CPLErr SetColorTable(GDALColorTable *)
override;
865 GDALColorTable *GetColorTable()
override;
867 GDALRasterAttributeTable *GetDefaultRAT()
override;
869 SetDefaultRAT(
const GDALRasterAttributeTable *poRAT)
override;
874 const char *GetUnitType()
override;
875 CPLErr SetUnitType(
const char *)
override;
877 char **GetCategoryNames()
override;
878 CPLErr SetCategoryNames(
char **)
override;
880 CPLErr SetMetadata(
char **papszMD,
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(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 std::unique_ptr<VRTSourcedRasterBand>
979 CloneWithoutSources(GDALDataset *poNewDS,
int nNewXSize,
980 int nNewYSize)
const;
984 GDALRasterIOExtraArg *psExtraArg)
override;
986 virtual int IGetDataCoverageStatus(
int nXOff,
int nYOff,
int nXSize,
987 int nYSize,
int nMaskFlagStop,
988 double *pdfDataPct)
override;
990 char **GetMetadataDomainList()
override;
991 virtual const char *GetMetadataItem(
const char *pszName,
992 const char *pszDomain =
"")
override;
993 char **GetMetadata(
const char *pszDomain =
"")
override;
994 CPLErr SetMetadata(
char **papszMetadata,
995 const char *pszDomain =
"")
override;
996 CPLErr SetMetadataItem(
const char *pszName,
const char *pszValue,
997 const char *pszDomain =
"")
override;
999 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
1000 VRTMapSharedResources &)
override;
1001 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1002 bool &bHasWarnedAboutRAMUsage,
1003 size_t &nAccRAMUsage)
override;
1005 double GetMinimum(
int *pbSuccess =
nullptr)
override;
1006 double GetMaximum(
int *pbSuccess =
nullptr)
override;
1007 virtual CPLErr ComputeRasterMinMax(
int bApproxOK,
1008 double *adfMinMax)
override;
1009 virtual CPLErr ComputeStatistics(
int bApproxOK,
double *pdfMin,
1010 double *pdfMax,
double *pdfMean,
1012 GDALProgressFunc pfnProgress,
1013 void *pProgressData)
override;
1014 CPLErr GetHistogram(
double dfMin,
double dfMax,
int nBuckets,
1015 GUIntBig *panHistogram,
int bIncludeOutOfRange,
1016 int bApproxOK, GDALProgressFunc pfnProgress,
1017 void *pProgressData)
override;
1019 CPLErr AddSource(std::unique_ptr<VRTSource>);
1021 CPLErr AddSource(VRTSource *);
1023 CPLErr AddSimpleSource(
const char *pszFilename,
int nBand,
1024 double dfSrcXOff = -1,
double dfSrcYOff = -1,
1025 double dfSrcXSize = -1,
double dfSrcYSize = -1,
1026 double dfDstXOff = -1,
double dfDstYOff = -1,
1027 double dfDstXSize = -1,
double dfDstYSize = -1,
1028 const char *pszResampling =
"near",
1031 CPLErr AddSimpleSource(GDALRasterBand *poSrcBand,
double dfSrcXOff = -1,
1032 double dfSrcYOff = -1,
double dfSrcXSize = -1,
1033 double dfSrcYSize = -1,
double dfDstXOff = -1,
1034 double dfDstYOff = -1,
double dfDstXSize = -1,
1035 double dfDstYSize = -1,
1036 const char *pszResampling =
"near",
1039 CPLErr AddComplexSource(
const char *pszFilename,
int nBand,
1040 double dfSrcXOff = -1,
double dfSrcYOff = -1,
1041 double dfSrcXSize = -1,
double dfSrcYSize = -1,
1042 double dfDstXOff = -1,
double dfDstYOff = -1,
1043 double dfDstXSize = -1,
double dfDstYSize = -1,
1044 double dfScaleOff = 0.0,
double dfScaleRatio = 1.0,
1046 int nColorTableComponent = 0);
1048 CPLErr AddComplexSource(GDALRasterBand *poSrcBand,
double dfSrcXOff = -1,
1049 double dfSrcYOff = -1,
double dfSrcXSize = -1,
1050 double dfSrcYSize = -1,
double dfDstXOff = -1,
1051 double dfDstYOff = -1,
double dfDstXSize = -1,
1052 double dfDstYSize = -1,
double dfScaleOff = 0.0,
1053 double dfScaleRatio = 1.0,
1055 int nColorTableComponent = 0);
1057 CPLErr AddMaskBandSource(GDALRasterBand *poSrcBand,
double dfSrcXOff = -1,
1058 double dfSrcYOff = -1,
double dfSrcXSize = -1,
1059 double dfSrcYSize = -1,
double dfDstXOff = -1,
1060 double dfDstYOff = -1,
double dfDstXSize = -1,
1061 double dfDstYSize = -1);
1066 void ConfigureSource(VRTSimpleSource *poSimpleSource,
1067 GDALRasterBand *poSrcBand,
int bAddAsMaskBand,
1068 double dfSrcXOff,
double dfSrcYOff,
double dfSrcXSize,
1069 double dfSrcYSize,
double dfDstXOff,
double dfDstYOff,
1070 double dfDstXSize,
double dfDstYSize);
1072 void RemoveCoveredSources(
CSLConstList papszOptions =
nullptr);
1074 bool CanIRasterIOBeForwardedToEachSource(
1075 GDALRWFlag eRWFlag,
int nXOff,
int nYOff,
int nXSize,
int nYSize,
1076 int nBufXSize,
int nBufYSize, GDALRasterIOExtraArg *psExtraArg)
const;
1078 bool CanMultiThreadRasterIO(
double dfXOff,
double dfYOff,
double dfXSize,
1080 int &nContributingSources)
const;
1082 CPLErr IReadBlock(
int,
int,
void *)
override;
1084 virtual void GetFileList(
char ***ppapszFileList,
int *pnSize,
1085 int *pnMaxSize,
CPLHashSet *hSetFiles)
override;
1087 int CloseDependentDatasets()
override;
1089 bool IsSourcedRasterBand()
override
1094 CPLErr FlushCache(
bool bAtClosing)
override;
1101class CPL_DLL VRTWarpedRasterBand final :
public VRTRasterBand
1104 VRTWarpedRasterBand(GDALDataset *poDS,
int nBand,
1106 ~VRTWarpedRasterBand()
override;
1108 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1109 bool &bHasWarnedAboutRAMUsage,
1110 size_t &nAccRAMUsage)
override;
1112 CPLErr IReadBlock(
int,
int,
void *)
override;
1113 CPLErr IWriteBlock(
int,
int,
void *)
override;
1116 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
1119 GDALRasterIOExtraArg *psExtraArg)
override;
1121 int GetOverviewCount()
override;
1122 GDALRasterBand *GetOverview(
int)
override;
1125 EmitErrorMessageIfWriteNotSupported(
const char *pszCaller)
const override;
1128 int m_nIRasterIOCounter =
1131 int GetBestOverviewLevel(
int &nXOff,
int &nYOff,
int &nXSize,
int &nYSize,
1132 int nBufXSize,
int nBufYSize,
1133 GDALRasterIOExtraArg *psExtraArg)
const;
1140class VRTPansharpenedRasterBand final :
public VRTRasterBand
1142 int m_nIndexAsPansharpenedBand;
1145 VRTPansharpenedRasterBand(GDALDataset *poDS,
int nBand,
1147 ~VRTPansharpenedRasterBand()
override;
1149 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1150 bool &bHasWarnedAboutRAMUsage,
1151 size_t &nAccRAMUsage)
override;
1153 CPLErr IReadBlock(
int,
int,
void *)
override;
1156 int nYSize,
void *pData,
int nBufXSize,
int nBufYSize,
1159 GDALRasterIOExtraArg *psExtraArg)
override;
1161 int GetOverviewCount()
override;
1162 GDALRasterBand *GetOverview(
int)
override;
1164 bool IsPansharpenRasterBand()
override
1169 void SetIndexAsPansharpenedBand(
int nIdx)
1171 m_nIndexAsPansharpenedBand = nIdx;
1174 int GetIndexAsPansharpenedBand()
const
1176 return m_nIndexAsPansharpenedBand;
1184class VRTProcessedRasterBand final :
public VRTRasterBand
1187 VRTProcessedRasterBand(VRTProcessedDataset *poDS,
int nBand,
1190 CPLErr IReadBlock(
int,
int,
void *)
override;
1192 int GetOverviewCount()
override;
1193 GDALRasterBand *GetOverview(
int)
override;
1195 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1196 bool &bHasWarnedAboutRAMUsage,
1197 size_t &nAccRAMUsage)
override;
1204class VRTDerivedRasterBandPrivateData;
1206class CPL_DLL VRTDerivedRasterBand
CPL_NON_FINAL :
public VRTSourcedRasterBand
1208 VRTDerivedRasterBandPrivateData *m_poPrivate;
1209 bool InitializePython();
1210 CPLErr GetPixelFunctionArguments(
1211 const CPLString &,
const std::vector<int> &anMapBufferIdxToSourceIdx,
1212 int nXOff,
int nYOff, std::vector<std::pair<CPLString, CPLString>> &);
1217 CPLString osFuncName{};
1224 VRTDerivedRasterBand(GDALDataset *poDS,
int nBand);
1225 VRTDerivedRasterBand(GDALDataset *poDS,
int nBand,
GDALDataType eType,
1226 int nXSize,
int nYSize,
int nBlockXSizeIn = 0,
1227 int nBlockYSizeIn = 0);
1228 ~VRTDerivedRasterBand()
override;
1230 void CopyForCloneWithoutSources(
const VRTDerivedRasterBand *poSrcBand);
1232 std::unique_ptr<VRTSourcedRasterBand>
1233 CloneWithoutSources(GDALDataset *poNewDS,
int nNewXSize,
1234 int nNewYSize)
const;
1238 GDALRasterIOExtraArg *psExtraArg)
override;
1240 virtual int IGetDataCoverageStatus(
int nXOff,
int nYOff,
int nXSize,
1241 int nYSize,
int nMaskFlagStop,
1242 double *pdfDataPct)
override;
1244 static CPLErr AddPixelFunction(
const char *pszFuncNameIn,
1246 static CPLErr AddPixelFunction(
const char *pszFuncNameIn,
1248 const char *pszMetadata);
1250 static const std::pair<PixelFunc, std::string> *
1251 GetPixelFunction(
const char *pszFuncNameIn);
1253 static std::vector<std::string> GetPixelFunctionNames();
1255 void SetPixelFunctionName(
const char *pszFuncNameIn);
1256 void AddPixelFunctionArgument(
const char *pszArg,
const char *pszValue);
1257 void SetSkipNonContributingSources(
bool bSkip);
1259 void SetPixelFunctionLanguage(
const char *pszLanguage);
1261 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
1262 VRTMapSharedResources &)
override;
1263 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1264 bool &bHasWarnedAboutRAMUsage,
1265 size_t &nAccRAMUsage)
override;
1267 double GetMinimum(
int *pbSuccess =
nullptr)
override;
1268 double GetMaximum(
int *pbSuccess =
nullptr)
override;
1269 virtual CPLErr ComputeRasterMinMax(
int bApproxOK,
1270 double *adfMinMax)
override;
1271 virtual CPLErr ComputeStatistics(
int bApproxOK,
double *pdfMin,
1272 double *pdfMax,
double *pdfMean,
1274 GDALProgressFunc pfnProgress,
1275 void *pProgressData)
override;
1276 CPLErr GetHistogram(
double dfMin,
double dfMax,
int nBuckets,
1277 GUIntBig *panHistogram,
int bIncludeOutOfRange,
1278 int bApproxOK, GDALProgressFunc pfnProgress,
1279 void *pProgressData)
override;
1281 static void Cleanup();
1284#ifndef GDAL_VRT_DISABLE_RAWRASTERBAND
1291class CPL_DLL VRTRawRasterBand
CPL_NON_FINAL :
public VRTRasterBand
1293 RawRasterBand *m_poRawRaster;
1295 char *m_pszSourceFilename;
1296 int m_bRelativeToVRT;
1301 VRTRawRasterBand(GDALDataset *poDS,
int nBand,
1303 ~VRTRawRasterBand()
override;
1305 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
1306 VRTMapSharedResources &)
override;
1307 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath,
1308 bool &bHasWarnedAboutRAMUsage,
1309 size_t &nAccRAMUsage)
override;
1313 GDALRasterIOExtraArg *psExtraArg)
override;
1315 CPLErr IReadBlock(
int,
int,
void *)
override;
1316 CPLErr IWriteBlock(
int,
int,
void *)
override;
1318 CPLErr SetRawLink(
const char *pszFilename,
const char *pszVRTPath,
1320 int nPixelOffset,
int nLineOffset,
1321 const char *pszByteOrder);
1323 void ClearRawLink();
1327 char **papszOptions)
override;
1329 virtual void GetFileList(
char ***ppapszFileList,
int *pnSize,
1330 int *pnMaxSize,
CPLHashSet *hSetFiles)
override;
1342 std::mutex m_oMutex{};
1343 std::map<std::string, VRTSourceParser> m_oMapSourceParser{};
1347 ~VRTDriver()
override;
1349 char **papszSourceParsers;
1352 char **
GetMetadata(
const char *pszDomain =
"")
override;
1354 const char *pszDomain =
"")
override;
1356 VRTSource *ParseSource(
const CPLXMLNode *psSrc,
const char *pszVRTPath,
1357 VRTMapSharedResources &oMapSharedSources);
1358 void AddSourceParser(
const char *pszElementName, VRTSourceParser pfnParser);
1365class CPL_DLL VRTSimpleSource
CPL_NON_FINAL :
public VRTSource
1371 VRTMapSharedResources *m_poMapSharedSources =
nullptr;
1373 mutable GDALRasterBand *m_poRasterBand =
nullptr;
1377 mutable GDALRasterBand *m_poMaskBandMainBand =
nullptr;
1379 CPLStringList m_aosOpenOptionsOri{};
1382 bool m_bSrcDSNameFromVRT =
1385 void OpenSource()
const;
1387 GDALDataset *GetSourceDataset()
const;
1390 friend class VRTSourcedRasterBand;
1391 friend class VRTDerivedRasterBand;
1392 friend class VRTDataset;
1393 friend class GDALTileIndexDataset;
1394 friend class GDALTileIndexBand;
1397 bool m_bGetMaskBand =
false;
1403 static constexpr double UNINIT_WINDOW = -1.0;
1405 double m_dfSrcXOff = UNINIT_WINDOW;
1406 double m_dfSrcYOff = UNINIT_WINDOW;
1407 double m_dfSrcXSize = UNINIT_WINDOW;
1408 double m_dfSrcYSize = UNINIT_WINDOW;
1410 double m_dfDstXOff = UNINIT_WINDOW;
1411 double m_dfDstYOff = UNINIT_WINDOW;
1412 double m_dfDstXSize = UNINIT_WINDOW;
1413 double m_dfDstYSize = UNINIT_WINDOW;
1415 CPLString m_osResampling{};
1417 int m_nMaxValue = 0;
1419 int m_bRelativeToVRTOri = -1;
1420 CPLString m_osSourceFileNameOri{};
1421 int m_nExplicitSharedStatus = -1;
1422 CPLString m_osSrcDSName{};
1424 bool m_bDropRefOnSrcBand =
true;
1426 int NeedMaxValAdjustment()
const;
1428 GDALRasterBand *GetRasterBandNoOpen()
const
1430 return m_poRasterBand;
1433 void SetRasterBand(GDALRasterBand *poBand,
bool bDropRef)
1435 m_poRasterBand = poBand;
1436 m_bDropRefOnSrcBand = bDropRef;
1439 virtual bool ValidateOpenedBand(GDALRasterBand * )
const
1445 bool IsSrcWinSet()
const
1447 return m_dfSrcXOff != UNINIT_WINDOW || m_dfSrcYOff != UNINIT_WINDOW ||
1448 m_dfSrcXSize != UNINIT_WINDOW || m_dfSrcYSize != UNINIT_WINDOW;
1452 bool IsDstWinSet()
const
1454 return m_dfDstXOff != UNINIT_WINDOW || m_dfDstYOff != UNINIT_WINDOW ||
1455 m_dfDstXSize != UNINIT_WINDOW || m_dfDstYSize != UNINIT_WINDOW;
1458 void AddSourceFilenameNode(
const char *pszVRTPath, CPLXMLNode *psSrc);
1462 VRTSimpleSource(
const VRTSimpleSource *poSrcSource,
double dfXDstRatio,
1463 double dfYDstRatio);
1464 ~VRTSimpleSource()
override;
1466 virtual CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *,
1467 VRTMapSharedResources &)
override;
1468 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1470 CPLErr ParseSrcRectAndDstRect(
const CPLXMLNode *psSrc);
1472 void SetSrcBand(
const char *pszFilename,
int nBand);
1473 void SetSrcBand(GDALRasterBand *);
1474 void SetSrcMaskBand(GDALRasterBand *);
1475 void SetSrcWindow(
double,
double,
double,
double);
1476 void SetDstWindow(
double,
double,
double,
double);
1477 void GetDstWindow(
double &,
double &,
double &,
double &)
const;
1478 bool DstWindowIntersects(
double dfXOff,
double dfYOff,
double dfXSize,
1479 double dfYSize)
const;
1481 const std::string &GetSourceDatasetName()
const
1483 return m_osSrcDSName;
1487 void SetSourceDatasetName(
const char *pszFilename,
bool bRelativeToVRT);
1489 const CPLString &GetResampling()
const
1491 return m_osResampling;
1494 void SetResampling(
const char *pszResampling);
1496 int GetSrcDstWindow(
double,
double,
double,
double,
int,
int,
1497 double *pdfReqXOff,
double *pdfReqYOff,
1498 double *pdfReqXSize,
double *pdfReqYSize,
int *,
int *,
1499 int *,
int *,
int *,
int *,
int *,
int *,
1502 int GetSrcDstWindow(
double,
double,
double,
double,
int,
int,
1504 double *pdfReqYOff,
double *pdfReqXSize,
1505 double *pdfReqYSize,
int *,
int *,
int *,
int *,
int *,
1506 int *,
int *,
int *,
bool &bErrorOut);
1509 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1512 GDALRasterIOExtraArg *psExtraArgIn,
1513 WorkingState &oWorkingState)
override;
1515 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1516 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1517 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1518 int nBuckets,
GUIntBig *panHistogram,
1519 int bIncludeOutOfRange,
int bApproxOK,
1520 GDALProgressFunc pfnProgress,
1521 void *pProgressData)
override;
1523 void DstToSrc(
double dfX,
double dfY,
double &dfXOut,
double &dfYOut)
const;
1524 void SrcToDst(
double dfX,
double dfY,
double &dfXOut,
double &dfYOut)
const;
1526 virtual void GetFileList(
char ***ppapszFileList,
int *pnSize,
1527 int *pnMaxSize,
CPLHashSet *hSetFiles)
override;
1529 bool IsSimpleSource()
const override
1537 static const char *GetTypeStatic();
1539 const char *GetType()
const override;
1541 CPLErr FlushCache(
bool bAtClosing)
override;
1543 GDALRasterBand *GetRasterBand()
const;
1544 GDALRasterBand *GetMaskBandMainBand();
1545 bool IsSameExceptBandNumber(
const VRTSimpleSource *poOtherSource)
const;
1547 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1549 const int *panBandMap,
GSpacing nPixelSpace,
1551 GDALRasterIOExtraArg *psExtraArg);
1553 void UnsetPreservedRelativeFilenames();
1555 void SetMaxValue(
int nVal)
1565class VRTAveragedSource final :
public VRTSimpleSource
1569 int m_bNoDataSet =
false;
1573 VRTAveragedSource();
1575 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1578 GDALRasterIOExtraArg *psExtraArgIn,
1579 WorkingState &oWorkingState)
override;
1581 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1582 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1583 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1584 int nBuckets,
GUIntBig *panHistogram,
1585 int bIncludeOutOfRange,
int bApproxOK,
1586 GDALProgressFunc pfnProgress,
1587 void *pProgressData)
override;
1589 void SetNoDataValue(
double dfNoDataValue);
1591 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1596 static const char *GetTypeStatic();
1598 const char *GetType()
const override;
1605class VRTNoDataFromMaskSource final :
public VRTSimpleSource
1609 bool m_bNoDataSet =
false;
1610 double m_dfNoDataValue = 0;
1611 double m_dfMaskValueThreshold = 0;
1612 bool m_bHasRemappedValue =
false;
1613 double m_dfRemappedValue = 0;
1616 VRTNoDataFromMaskSource();
1618 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1621 GDALRasterIOExtraArg *psExtraArgIn,
1622 WorkingState &oWorkingState)
override;
1624 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1625 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1626 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1627 int nBuckets,
GUIntBig *panHistogram,
1628 int bIncludeOutOfRange,
int bApproxOK,
1629 GDALProgressFunc pfnProgress,
1630 void *pProgressData)
override;
1632 void SetParameters(
double dfNoDataValue,
double dfMaskValueThreshold);
1633 void SetParameters(
double dfNoDataValue,
double dfMaskValueThreshold,
1634 double dfRemappedValue);
1636 virtual CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *,
1637 VRTMapSharedResources &)
override;
1638 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1643 static const char *GetTypeStatic();
1645 const char *GetType()
const override;
1652class CPL_DLL VRTComplexSource
CPL_NON_FINAL :
public VRTSimpleSource
1657 static constexpr int PROCESSING_FLAG_NODATA = 1 << 0;
1658 static constexpr int PROCESSING_FLAG_USE_MASK_BAND =
1660 static constexpr int PROCESSING_FLAG_SCALING_LINEAR = 1 << 2;
1661 static constexpr int PROCESSING_FLAG_SCALING_EXPONENTIAL =
1663 static constexpr int PROCESSING_FLAG_COLOR_TABLE_EXPANSION = 1 << 4;
1664 static constexpr int PROCESSING_FLAG_LUT = 1 << 5;
1666 int m_nProcessingFlags = 0;
1671 m_osNoDataValueOri{};
1673 double m_dfScaleOff = 0;
1674 double m_dfScaleRatio = 1;
1677 bool m_bSrcMinMaxDefined =
false;
1678 double m_dfSrcMin = 0;
1679 double m_dfSrcMax = 0;
1680 double m_dfDstMin = 0;
1681 double m_dfDstMax = 0;
1682 double m_dfExponent = 1;
1683 bool m_bClip =
true;
1685 int m_nColorTableComponent = 0;
1687 std::vector<double> m_adfLUTInputs{};
1688 std::vector<double> m_adfLUTOutputs{};
1690 double GetAdjustedNoDataValue()
const;
1692 template <
class WorkingDT>
1694 RasterIOInternal(GDALRasterBand *poSourceBand,
1695 GDALDataType eVRTBandDataType,
int nReqXOff,
int nReqYOff,
1696 int nReqXSize,
int nReqYSize,
void *pData,
int nOutXSize,
1698 GSpacing nLineSpace, GDALRasterIOExtraArg *psExtraArg,
1699 GDALDataType eWrkDataType, WorkingState &oWorkingState);
1701 template <
class SourceDT, GDALDataType eSourceType>
1702 CPLErr RasterIOProcessNoData(GDALRasterBand *poSourceBand,
1704 int nReqYOff,
int nReqXSize,
int nReqYSize,
1705 void *pData,
int nOutXSize,
int nOutYSize,
1708 GDALRasterIOExtraArg *psExtraArg,
1709 WorkingState &oWorkingState);
1712 VRTComplexSource() =
default;
1713 VRTComplexSource(
const VRTComplexSource *poSrcSource,
double dfXDstRatio,
1714 double dfYDstRatio);
1717 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1720 GDALRasterIOExtraArg *psExtraArgIn,
1721 WorkingState &oWorkingState)
override;
1723 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1724 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1725 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1726 int nBuckets,
GUIntBig *panHistogram,
1727 int bIncludeOutOfRange,
int bApproxOK,
1728 GDALProgressFunc pfnProgress,
1729 void *pProgressData)
override;
1731 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1732 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
1733 VRTMapSharedResources &)
override;
1738 static const char *GetTypeStatic();
1740 const char *GetType()
const override;
1742 bool AreValuesUnchanged()
const;
1744 double LookupValue(
double dfInput);
1746 void SetNoDataValue(
double dfNoDataValue);
1748 void SetUseMaskBand(
bool bUseMaskBand)
1751 m_nProcessingFlags |= PROCESSING_FLAG_USE_MASK_BAND;
1753 m_nProcessingFlags &= ~PROCESSING_FLAG_USE_MASK_BAND;
1756 void SetLinearScaling(
double dfOffset,
double dfScale);
1757 void SetPowerScaling(
double dfExponent,
double dfSrcMin,
double dfSrcMax,
1758 double dfDstMin,
double dfDstMax,
bool bClip =
true);
1759 void SetColorTableComponent(
int nComponent);
1761 void SetLUT(
const std::vector<double> &adfLUTInputs,
1762 const std::vector<double> &adfLUTOutputs);
1769class VRTFilteredSource
CPL_NON_FINAL :
public VRTComplexSource
1777 int m_nSupportedTypesCount;
1780 int m_nExtraEdgePixels;
1783 VRTFilteredSource();
1784 ~VRTFilteredSource()
override;
1786 const char *GetType()
const override = 0;
1788 void SetExtraEdgePixels(
int);
1789 void SetFilteringDataTypesSupported(
int,
GDALDataType *);
1795 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1798 GDALRasterIOExtraArg *psExtraArg,
1799 WorkingState &oWorkingState)
override;
1806class VRTKernelFilteredSource
CPL_NON_FINAL :
public VRTFilteredSource
1811 int m_nKernelSize = 0;
1812 bool m_bSeparable =
false;
1814 std::vector<double> m_adfKernelCoefs{};
1815 bool m_bNormalized =
false;
1816 std::string m_function{};
1819 VRTKernelFilteredSource();
1821 const char *GetType()
const override;
1823 virtual CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *,
1824 VRTMapSharedResources &)
override;
1825 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1828 GByte *pabySrcData,
GByte *pabyDstData)
override;
1830 CPLErr SetKernel(
int nKernelSize,
bool bSeparable,
1831 const std::vector<double> &adfNewCoefs);
1832 void SetNormalized(
bool);
1834 void SetFunction(
const std::string &s)
1844class VRTAverageFilteredSource final :
public VRTKernelFilteredSource
1849 explicit VRTAverageFilteredSource(
int nKernelSize);
1850 ~VRTAverageFilteredSource()
override;
1852 const char *GetType()
const override;
1854 virtual CPLErr XMLInit(
const CPLXMLNode *psTree,
const char *,
1855 VRTMapSharedResources &)
override;
1856 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1862class VRTFuncSource final :
public VRTSource
1868 ~VRTFuncSource()
override;
1870 virtual CPLErr XMLInit(
const CPLXMLNode *,
const char *,
1871 VRTMapSharedResources &)
override
1876 CPLXMLNode *SerializeToXML(
const char *pszVRTPath)
override;
1879 int nXSize,
int nYSize,
void *pData,
int nBufXSize,
1882 GDALRasterIOExtraArg *psExtraArg,
1883 WorkingState &oWorkingState)
override;
1885 double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1886 double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess)
override;
1887 CPLErr GetHistogram(
int nXSize,
int nYSize,
double dfMin,
double dfMax,
1888 int nBuckets,
GUIntBig *panHistogram,
1889 int bIncludeOutOfRange,
int bApproxOK,
1890 GDALProgressFunc pfnProgress,
1891 void *pProgressData)
override;
1893 const char *GetType()
const override;
1907#define TMP_CPL_DLL CPL_DLL
1923 explicit Ref(VRTGroup *ptr) : m_ptr(ptr)
1927 Ref(
const Ref &) =
delete;
1928 Ref &operator=(
const Ref &) =
delete;
1932 std::shared_ptr<Ref> m_poSharedRefRootGroup{};
1933 std::weak_ptr<Ref> m_poWeakRefRootGroup{};
1934 std::shared_ptr<Ref> m_poRefSelf{};
1936 std::string m_osFilename{};
1937 mutable bool m_bDirty =
false;
1938 std::string m_osVRTPath{};
1939 std::vector<std::string> m_aosGroupNames{};
1940 std::map<std::string, std::shared_ptr<VRTGroup>> m_oMapGroups{};
1941 std::vector<std::string> m_aosMDArrayNames{};
1942 std::map<std::string, std::shared_ptr<VRTMDArray>> m_oMapMDArrays{};
1943 std::map<std::string, std::shared_ptr<VRTAttribute>> m_oMapAttributes{};
1944 std::map<std::string, std::shared_ptr<VRTDimension>> m_oMapDimensions{};
1946 std::shared_ptr<VRTGroup>
1947 OpenGroupInternal(
const std::string &osName)
const;
1948 void SetRootGroupRef(
const std::weak_ptr<Ref> &rgRef);
1949 std::weak_ptr<Ref> GetRootGroupRef()
const;
1952 friend class VRTMDArray;
1953 friend std::shared_ptr<GDALMDArray>
1954 VRTDerivedArrayCreate(
const char *pszVRTPath,
const CPLXMLNode *psTree);
1956 explicit VRTGroup(
const char *pszVRTPath);
1957 VRTGroup(
const std::string &osParentName,
const std::string &osName);
1960 static std::shared_ptr<VRTGroup> Create(
const std::string &osParentName,
1961 const std::string &osName)
1964 std::shared_ptr<VRTGroup>(
new VRTGroup(osParentName, osName));
1965 poGroup->SetSelf(poGroup);
1969 ~VRTGroup()
override;
1971 bool XMLInit(
const std::shared_ptr<VRTGroup> &poRoot,
1972 const std::shared_ptr<VRTGroup> &poThisGroup,
1973 const CPLXMLNode *psNode,
const char *pszVRTPath);
1975 std::vector<std::string>
1976 GetMDArrayNames(
CSLConstList papszOptions)
const override;
1977 std::shared_ptr<GDALMDArray>
1978 OpenMDArray(
const std::string &osName,
1981 std::vector<std::string>
1982 GetGroupNames(
CSLConstList papszOptions)
const override;
1984 std::shared_ptr<GDALGroup> OpenGroup(
const std::string &osName,
1987 return OpenGroupInternal(osName);
1990 std::vector<std::shared_ptr<GDALDimension>>
1993 std::vector<std::shared_ptr<GDALAttribute>>
1996 std::shared_ptr<VRTDimension> GetDimension(
const std::string &name)
const
1998 auto oIter = m_oMapDimensions.find(name);
1999 return oIter == m_oMapDimensions.end() ? nullptr : oIter->second;
2002 std::shared_ptr<VRTDimension>
2003 GetDimensionFromFullName(
const std::string &name,
bool bEmitError)
const;
2005 std::shared_ptr<GDALGroup>
2006 CreateGroup(
const std::string &osName,
2009 std::shared_ptr<VRTGroup>
2010 CreateVRTGroup(
const std::string &osName,
2013 std::shared_ptr<GDALDimension>
2014 CreateDimension(
const std::string &osName,
const std::string &osType,
2015 const std::string &osDirection,
GUInt64 nSize,
2018 std::shared_ptr<GDALAttribute>
2019 CreateAttribute(
const std::string &osName,
2020 const std::vector<GUInt64> &anDimensions,
2021 const GDALExtendedDataType &oDataType,
2024 std::shared_ptr<GDALMDArray> CreateMDArray(
2025 const std::string &osName,
2026 const std::vector<std::shared_ptr<GDALDimension>> &aoDimensions,
2027 const GDALExtendedDataType &oDataType,
2030 std::shared_ptr<VRTMDArray> CreateVRTMDArray(
2031 const std::string &osName,
2032 const std::vector<std::shared_ptr<GDALDimension>> &aoDimensions,
2033 const GDALExtendedDataType &oDataType,
2036 void SetIsRootGroup();
2038 const std::shared_ptr<Ref> &GetRef()
const
2043 VRTGroup *GetRootGroup()
const;
2044 std::shared_ptr<VRTGroup> GetRootGroupSharedPtr()
const;
2046 const std::string &GetVRTPath()
const
2051 void SetVRTPath(
const std::string &osVRTPath)
2053 m_osVRTPath = osVRTPath;
2058 void SetFilename(
const std::string &osFilename)
2060 m_osFilename = osFilename;
2063 const std::string &GetFilename()
const
2065 return m_osFilename;
2068 bool Serialize()
const;
2069 CPLXMLNode *SerializeToXML(
const char *pszVRTPathIn)
const;
2070 void Serialize(CPLXMLNode *psParent,
const char *pszVRTPathIn)
const;
2079 std::weak_ptr<VRTGroup::Ref> m_poGroupRef;
2080 std::string m_osIndexingVariableName;
2083 VRTDimension(
const std::shared_ptr<VRTGroup::Ref> &poGroupRef,
2084 const std::string &osParentName,
const std::string &osName,
2085 const std::string &osType,
const std::string &osDirection,
2086 GUInt64 nSize,
const std::string &osIndexingVariableName)
2087 : GDALDimension(osParentName, osName, osType, osDirection, nSize),
2088 m_poGroupRef(poGroupRef),
2089 m_osIndexingVariableName(osIndexingVariableName)
2093 VRTGroup *GetGroup()
const;
2095 static std::shared_ptr<VRTDimension>
2096 Create(
const std::shared_ptr<VRTGroup> &poThisGroup,
2097 const std::string &osParentName,
const CPLXMLNode *psNode);
2102 std::shared_ptr<GDALMDArray> poIndexingVariable)
override;
2104 void Serialize(CPLXMLNode *psParent)
const;
2113 GDALExtendedDataType m_dt;
2114 std::vector<std::string> m_aosList{};
2115 std::vector<std::shared_ptr<GDALDimension>> m_dims{};
2118 bool IRead(
const GUInt64 *arrayStartIdx,
const size_t *count,
2120 const GDALExtendedDataType &bufferDataType,
2121 void *pDstBuffer)
const override;
2123 bool IWrite(
const GUInt64 *arrayStartIdx,
const size_t *count,
2125 const GDALExtendedDataType &bufferDataType,
2126 const void *pSrcBuffer)
override;
2129 VRTAttribute(
const std::string &osParentName,
const std::string &osName,
2130 const GDALExtendedDataType &dt,
2131 std::vector<std::string> &&aosList)
2132 : GDALAbstractMDArray(osParentName, osName),
2133 GDALAttribute(osParentName, osName), m_dt(dt),
2134 m_aosList(std::move(aosList))
2136 if (m_aosList.size() > 1)
2138 m_dims.emplace_back(std::make_shared<GDALDimension>(
2139 std::string(),
"dim", std::string(), std::string(),
2144 VRTAttribute(
const std::string &osParentName,
const std::string &osName,
2145 GUInt64 nDim,
const GDALExtendedDataType &dt)
2146 : GDALAbstractMDArray(osParentName, osName),
2147 GDALAttribute(osParentName, osName), m_dt(dt)
2151 m_dims.emplace_back(std::make_shared<GDALDimension>(
2152 std::string(),
"dim", std::string(), std::string(), nDim));
2156 static bool CreationCommonChecks(
2157 const std::string &osName,
const std::vector<GUInt64> &anDimensions,
2158 const std::map<std::string, std::shared_ptr<VRTAttribute>>
2161 static std::shared_ptr<VRTAttribute> Create(
const std::string &osParentName,
2162 const CPLXMLNode *psNode);
2164 const std::vector<std::shared_ptr<GDALDimension>> &
2170 const GDALExtendedDataType &
GetDataType()
const override
2175 void Serialize(CPLXMLNode *psParent)
const;
2182class VRTMDArraySource
2185 virtual ~VRTMDArraySource();
2187 enum class RelationShip
2190 PARTIAL_INTERSECTION,
2194 virtual RelationShip GetRelationship(
const uint64_t *arrayStartIdx,
2195 const size_t *count)
const = 0;
2197 virtual bool GetRawBlockInfo(
const uint64_t *arrayStartIdx,
2198 const size_t *count,
2199 GDALMDArrayRawBlockInfo &info)
const = 0;
2201 virtual bool Read(
const GUInt64 *arrayStartIdx,
const size_t *count,
2203 const GDALExtendedDataType &bufferDataType,
2204 void *pDstBuffer)
const = 0;
2206 virtual void Serialize(CPLXMLNode *psParent,
2207 const char *pszVRTPath)
const = 0;
2217 friend class VRTGroup;
2219 std::weak_ptr<VRTGroup::Ref> m_poGroupRef;
2220 std::string m_osVRTPath{};
2221 std::shared_ptr<VRTGroup> m_poDummyOwningGroup{};
2223 GDALExtendedDataType m_dt;
2224 std::vector<std::shared_ptr<GDALDimension>> m_dims;
2225 std::map<std::string, std::shared_ptr<VRTAttribute>> m_oMapAttributes{};
2226 std::vector<std::unique_ptr<VRTMDArraySource>> m_sources{};
2227 std::shared_ptr<OGRSpatialReference> m_poSRS{};
2228 std::vector<GByte> m_abyNoData{};
2229 std::string m_osUnit{};
2230 double m_dfScale = 1.0;
2231 double m_dfOffset = 0.0;
2232 bool m_bHasScale =
false;
2233 bool m_bHasOffset =
false;
2234 std::string m_osFilename{};
2235 std::vector<GUInt64> m_anBlockSize{};
2237 bool IRead(
const GUInt64 *arrayStartIdx,
const size_t *count,
2239 const GDALExtendedDataType &bufferDataType,
2240 void *pDstBuffer)
const override;
2246 const std::shared_ptr<VRTGroup::Ref> &poGroupRef,
2247 const std::string &osParentName,
const std::string &osName,
2248 const GDALExtendedDataType &dt,
2249 std::vector<std::shared_ptr<GDALDimension>> &&dims,
2250 std::map<std::string, std::shared_ptr<VRTAttribute>> &&oMapAttributes,
2251 std::vector<GUInt64> &&anBlockSize)
2252 : GDALAbstractMDArray(osParentName, osName),
2253 GDALMDArray(osParentName, osName), m_poGroupRef(poGroupRef),
2254 m_osVRTPath(poGroupRef->m_ptr->GetVRTPath()), m_dt(dt),
2255 m_dims(std::move(dims)), m_oMapAttributes(std::move(oMapAttributes)),
2256 m_osFilename(poGroupRef->m_ptr->GetFilename()),
2257 m_anBlockSize(std::move(anBlockSize))
2261 VRTMDArray(
const std::shared_ptr<VRTGroup::Ref> &poGroupRef,
2262 const std::string &osParentName,
const std::string &osName,
2263 const std::vector<std::shared_ptr<GDALDimension>> &dims,
2264 const GDALExtendedDataType &dt,
2265 const std::vector<GUInt64> &anBlockSize)
2266 : GDALAbstractMDArray(osParentName, osName),
2267 GDALMDArray(osParentName, osName), m_poGroupRef(poGroupRef),
2268 m_osVRTPath(poGroupRef->m_ptr->GetVRTPath()), m_dt(dt), m_dims(dims),
2269 m_osFilename(poGroupRef->m_ptr->GetFilename()),
2270 m_anBlockSize(anBlockSize)
2281 return m_osFilename;
2284 static std::shared_ptr<VRTMDArray> Create(
const char *pszVRTPath,
2285 const CPLXMLNode *psNode);
2287 static std::shared_ptr<VRTMDArray>
2288 Create(
const std::shared_ptr<VRTGroup> &poThisGroup,
2289 const std::string &osParentName,
const CPLXMLNode *psNode);
2291 const std::vector<std::shared_ptr<GDALDimension>> &
2297 std::vector<std::shared_ptr<GDALAttribute>>
2300 const GDALExtendedDataType &
GetDataType()
const override
2305 bool SetSpatialRef(
const OGRSpatialReference *poSRS)
override;
2307 std::shared_ptr<OGRSpatialReference>
GetSpatialRef()
const override
2316 const std::string &
GetUnit()
const override
2321 bool SetUnit(
const std::string &osUnit)
override
2331 *pbHasOffset = m_bHasOffset;
2341 *pbHasScale = m_bHasScale;
2351 m_bHasOffset =
true;
2352 m_dfOffset = dfOffset;
2361 m_dfScale = dfScale;
2365 void AddSource(std::unique_ptr<VRTMDArraySource> &&poSource);
2367 std::shared_ptr<GDALAttribute>
2369 const std::vector<GUInt64> &anDimensions,
2370 const GDALExtendedDataType &oDataType,
2373 bool CopyFrom(GDALDataset *poSrcDS,
const GDALMDArray *poSrcArray,
2375 GDALProgressFunc pfnProgress,
void *pProgressData)
override;
2377 void Serialize(CPLXMLNode *psParent,
const char *pszVRTPathIn)
const;
2379 VRTGroup *GetGroup()
const;
2381 const std::string &GetVRTPath()
const
2386 std::shared_ptr<VRTGroup> GetRootVRTGroup()
const
2388 auto poGroup = m_poGroupRef.lock();
2390 return poGroup->m_ptr->GetRootGroupSharedPtr();
2394 std::shared_ptr<GDALGroup>
GetRootGroup()
const override
2396 return GetRootVRTGroup();
2401 return m_anBlockSize;
2405 GDALMDArrayRawBlockInfo &info)
const override;
2412class VRTMDArraySourceInlinedValues final :
public VRTMDArraySource
2414 const VRTMDArray *m_poDstArray =
nullptr;
2415 bool m_bIsConstantValue;
2416 std::vector<GUInt64> m_anOffset{};
2417 std::vector<size_t> m_anCount{};
2418 std::vector<GByte> m_abyValues{};
2419 std::vector<size_t> m_anInlinedArrayStrideInBytes{};
2420 GDALExtendedDataType m_dt;
2422 VRTMDArraySourceInlinedValues(
const VRTMDArraySourceInlinedValues &) =
2424 VRTMDArraySourceInlinedValues &
2425 operator=(
const VRTMDArraySourceInlinedValues &) =
delete;
2428 VRTMDArraySourceInlinedValues(
const VRTMDArray *poDstArray,
2429 bool bIsConstantValue,
2430 std::vector<GUInt64> &&anOffset,
2431 std::vector<size_t> &&anCount,
2432 std::vector<GByte> &&abyValues)
2433 : m_poDstArray(poDstArray), m_bIsConstantValue(bIsConstantValue),
2434 m_anOffset(std::move(anOffset)), m_anCount(std::move(anCount)),
2435 m_abyValues(std::move(abyValues)), m_dt(poDstArray->GetDataType())
2437 const auto nDims(poDstArray->GetDimensionCount());
2438 m_anInlinedArrayStrideInBytes.resize(nDims);
2439 if (!bIsConstantValue && nDims > 0)
2441 m_anInlinedArrayStrideInBytes.back() =
2442 poDstArray->GetDataType().GetSize();
2443 for (
size_t i = nDims - 1; i > 0;)
2446 m_anInlinedArrayStrideInBytes[i] =
2447 m_anInlinedArrayStrideInBytes[i + 1] * m_anCount[i + 1];
2452 ~VRTMDArraySourceInlinedValues()
override;
2454 static std::unique_ptr<VRTMDArraySourceInlinedValues>
2455 Create(
const VRTMDArray *poDstArray,
const CPLXMLNode *psNode);
2457 RelationShip GetRelationship(
const uint64_t * ,
2458 const size_t * )
const override
2460 return RelationShip::PARTIAL_INTERSECTION;
2463 bool GetRawBlockInfo(
const uint64_t * ,
2465 GDALMDArrayRawBlockInfo & )
const override
2470 bool Read(
const GUInt64 *arrayStartIdx,
const size_t *count,
2472 const GDALExtendedDataType &bufferDataType,
2473 void *pDstBuffer)
const override;
2475 void Serialize(CPLXMLNode *psParent,
const char *pszVRTPath)
const override;
2482class VRTMDArraySourceRegularlySpaced final :
public VRTMDArraySource
2485 double m_dfIncrement;
2488 VRTMDArraySourceRegularlySpaced(
double dfStart,
double dfIncrement)
2489 : m_dfStart(dfStart), m_dfIncrement(dfIncrement)
2493 RelationShip GetRelationship(
const uint64_t * ,
2494 const size_t * )
const override
2496 return RelationShip::PARTIAL_INTERSECTION;
2499 bool GetRawBlockInfo(
const uint64_t * ,
2501 GDALMDArrayRawBlockInfo & )
const override
2506 bool Read(
const GUInt64 *arrayStartIdx,
const size_t *count,
2508 const GDALExtendedDataType &bufferDataType,
2509 void *pDstBuffer)
const override;
2511 void Serialize(CPLXMLNode *psParent,
const char *pszVRTPath)
const override;
2518struct VRTArrayDatasetWrapper;
2520class VRTMDArraySourceFromArray final :
public VRTMDArraySource
2522 const VRTMDArray *m_poDstArray =
nullptr;
2523 bool m_bRelativeToVRTSet =
false;
2524 bool m_bRelativeToVRT =
false;
2525 std::string m_osFilename{};
2526 std::string m_osArray{};
2527 std::string m_osBand{};
2528 std::vector<int> m_anTransposedAxis{};
2529 std::string m_osViewExpr{};
2530 std::vector<GUInt64> m_anSrcOffset{};
2531 mutable std::vector<GUInt64> m_anCount{};
2532 std::vector<GUInt64> m_anStep{};
2533 std::vector<GUInt64> m_anDstOffset{};
2535 std::pair<std::shared_ptr<VRTArrayDatasetWrapper>,
2536 std::shared_ptr<GDALMDArray>>
2537 GetSourceArray()
const;
2539 VRTMDArraySourceFromArray(
const VRTMDArraySourceFromArray &) =
delete;
2540 VRTMDArraySourceFromArray &
2541 operator=(
const VRTMDArraySourceFromArray &) =
delete;
2544 VRTMDArraySourceFromArray(
2545 const VRTMDArray *poDstArray,
bool bRelativeToVRTSet,
2546 bool bRelativeToVRT,
const std::string &osFilename,
2547 const std::string &osArray,
const std::string &osBand,
2548 std::vector<int> &&anTransposedAxis,
const std::string &osViewExpr,
2549 std::vector<GUInt64> &&anSrcOffset, std::vector<GUInt64> &&anCount,
2550 std::vector<GUInt64> &&anStep, std::vector<GUInt64> &&anDstOffset)
2551 : m_poDstArray(poDstArray), m_bRelativeToVRTSet(bRelativeToVRTSet),
2552 m_bRelativeToVRT(bRelativeToVRT), m_osFilename(osFilename),
2553 m_osArray(osArray), m_osBand(osBand),
2554 m_anTransposedAxis(std::move(anTransposedAxis)),
2555 m_osViewExpr(osViewExpr), m_anSrcOffset(std::move(anSrcOffset)),
2556 m_anCount(std::move(anCount)), m_anStep(std::move(anStep)),
2557 m_anDstOffset(std::move(anDstOffset))
2561 ~VRTMDArraySourceFromArray()
override;
2563 static std::unique_ptr<VRTMDArraySourceFromArray>
2564 Create(
const VRTMDArray *poDstArray,
const CPLXMLNode *psNode);
2566 RelationShip GetRelationship(
const uint64_t *arrayStartIdx,
2567 const size_t *count)
const override;
2569 bool GetRawBlockInfo(
const uint64_t *arrayStartIdx,
const size_t *count,
2570 GDALMDArrayRawBlockInfo &info)
const override;
2572 bool Read(
const GUInt64 *arrayStartIdx,
const size_t *count,
2574 const GDALExtendedDataType &bufferDataType,
2575 void *pDstBuffer)
const override;
2577 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