31 #ifndef VIRTUALDATASET_H_INCLUDED
32 #define VIRTUALDATASET_H_INCLUDED
48 CPLErr GDALRegisterDefaultPixelFunc();
51 int VRTWarpedOverviewTransform(
void *pTransformArg,
int bDstToSrc,
53 double *padfX,
double *padfY,
double *padfZ,
55 void* VRTDeserializeWarpedOverviewTransformer(
CPLXMLNode *psTree );
69 int bTriedToOpen = FALSE;
71 VRTOverviewInfo() =
default;
72 VRTOverviewInfo(VRTOverviewInfo&& oOther) noexcept:
73 osFilename(std::move(oOther.osFilename)),
75 poBand(oOther.poBand),
76 bTriedToOpen(oOther.bTriedToOpen)
78 oOther.poBand =
nullptr;
82 if( poBand ==
nullptr )
95 class CPL_DLL VRTSource
101 int nXOff,
int nYOff,
int nXSize,
int nYSize,
102 void *pData,
int nBufXSize,
int nBufYSize,
107 virtual double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess ) = 0;
108 virtual double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess ) = 0;
109 virtual CPLErr ComputeRasterMinMax(
int nXSize,
int nYSize,
int bApproxOK,
110 double* adfMinMax ) = 0;
111 virtual CPLErr ComputeStatistics(
int nXSize,
int nYSize,
113 double *pdfMin,
double *pdfMax,
114 double *pdfMean,
double *pdfStdDev,
115 GDALProgressFunc pfnProgress,
116 void *pProgressData ) = 0;
117 virtual CPLErr GetHistogram(
int nXSize,
int nYSize,
118 double dfMin,
double dfMax,
119 int nBuckets,
GUIntBig * panHistogram,
120 int bIncludeOutOfRange,
int bApproxOK,
121 GDALProgressFunc pfnProgress,
122 void *pProgressData ) = 0;
125 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath ) = 0;
127 virtual void GetFileList(
char*** ppapszFileList,
int *pnSize,
130 virtual int IsSimpleSource() {
return FALSE; }
131 virtual CPLErr FlushCache() {
return CE_None; }
134 typedef VRTSource *(*VRTSourceParser)(
CPLXMLNode *,
const char *,
void* pUniqueHandle);
136 VRTSource *VRTParseCoreSources( CPLXMLNode *psTree,
const char *,
void* pUniqueHandle );
137 VRTSource *VRTParseFilterSources( CPLXMLNode *psTree,
const char *,
void* pUniqueHandle );
145 template<
class T>
struct VRTFlushCacheStruct
147 static void FlushCache(T& obj);
150 class VRTWarpedDataset;
151 class VRTPansharpenedDataset;
155 friend class VRTRasterBand;
156 friend struct VRTFlushCacheStruct<VRTDataset>;
157 friend struct VRTFlushCacheStruct<VRTWarpedDataset>;
158 friend struct VRTFlushCacheStruct<VRTPansharpenedDataset>;
160 char *m_pszProjection;
162 int m_bGeoTransformSet;
163 double m_adfGeoTransform[6];
167 char *m_pszGCPProjection;
174 VRTRasterBand *m_poMaskBand;
176 int m_bCompatibleForDatasetIO;
177 int CheckCompatibleForDatasetIO();
178 std::vector<GDALDataset*> m_apoOverviews;
179 std::vector<GDALDataset*> m_apoOverviewsBak;
180 char **m_papszXMLVRTMetadata;
182 VRTRasterBand* InitBand(
const char* pszSubclass,
int nBand,
183 bool bAllowPansharpened);
188 virtual
int CloseDependentDatasets() override;
191 VRTDataset(
int nXSize,
int nYSize);
192 virtual ~VRTDataset();
194 void SetNeedsFlush() { m_bNeedsFlush = TRUE; }
197 void SetWritable(
int bWritableIn) { m_bWritable = bWritableIn; }
200 void SetMaskBand(VRTRasterBand* poMaskBand);
208 const char *pszDomain =
"" )
override;
210 const char *pszDomain =
"" )
override;
212 virtual char**
GetMetadata(
const char *pszDomain =
"" )
override;
218 const char *pszGCPProjection )
override;
221 char **papszOptions=
nullptr )
override;
226 int nXOff,
int nYOff,
int nXSize,
int nYSize,
227 void * pData,
int nBufXSize,
int nBufYSize,
229 int nBandCount,
int *panBandMap,
235 int nBufXSize,
int nBufYSize,
237 int nBandCount,
int *panBandList,
238 char **papszOptions )
override;
240 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath);
241 virtual CPLErr XMLInit( CPLXMLNode *,
const char * );
243 virtual CPLErr IBuildOverviews(
const char *,
int,
int *,
244 int,
int *, GDALProgressFunc,
void * )
override;
248 void BuildVirtualOverviews();
250 void UnsetPreservedRelativeFilenames();
254 static GDALDataset *OpenXML(
const char *,
const char * =
nullptr,
257 int nXSize,
int nYSize,
int nBands,
259 static CPLErr Delete(
const char * pszFilename );
267 class VRTWarpedRasterBand;
269 class CPL_DLL VRTWarpedDataset :
public VRTDataset
275 int m_nOverviewCount;
276 VRTWarpedDataset **m_papoOverviews;
279 void CreateImplicitOverviews();
281 struct VerticalShiftGrid
286 double dfToMeterDest;
289 std::vector<VerticalShiftGrid> m_aoVerticalShiftGrids;
291 friend class VRTWarpedRasterBand;
296 virtual
int CloseDependentDatasets() override;
299 VRTWarpedDataset(
int nXSize,
int nYSize );
300 virtual ~VRTWarpedDataset();
302 virtual
void FlushCache() override;
304 CPLErr Initialize(
void * );
306 virtual
CPLErr IBuildOverviews( const
char *,
int,
int *,
307 int,
int *, GDALProgressFunc,
void * ) override;
309 virtual
CPLErr SetMetadataItem( const
char *pszName, const
char *pszValue,
310 const
char *pszDomain = "" ) override;
312 virtual CPLXMLNode *SerializeToXML( const
char *pszVRTPath ) override;
313 virtual
CPLErr XMLInit( CPLXMLNode *, const
char * ) override;
316 char **papszOptions=
nullptr ) override;
318 virtual
char **GetFileList() override;
320 CPLErr ProcessBlock(
int iBlockX,
int iBlockY );
322 void GetBlockSize(
int *,
int * ) const;
324 void SetApplyVerticalShiftGrid(const
char* pszVGrids,
327 double dfToMeterDest,
328 char** papszOptions );
340 GTAdjust_Intersection,
342 GTAdjust_NoneWithoutWarning
345 class VRTPansharpenedDataset :
public VRTDataset
347 friend class VRTPansharpenedRasterBand;
352 VRTPansharpenedDataset* m_poMainDataset;
353 std::vector<VRTPansharpenedDataset*> m_apoOverviewDatasets;
355 std::map<CPLString,CPLString> m_oMapToRelativeFilenames;
357 int m_bLoadingOtherBands;
359 GByte *m_pabyLastBufferBandRasterIO;
360 int m_nLastBandRasterIOXOff;
361 int m_nLastBandRasterIOYOff;
362 int m_nLastBandRasterIOXSize;
363 int m_nLastBandRasterIOYSize;
366 GTAdjustment m_eGTAdjustment;
367 int m_bNoDataDisabled;
369 std::vector<GDALDataset*> m_apoDatasetsToClose;
374 virtual
int CloseDependentDatasets() override;
377 VRTPansharpenedDataset(
int nXSize,
int nYSize );
378 virtual ~VRTPansharpenedDataset();
380 virtual
void FlushCache() override;
382 virtual
CPLErr XMLInit( CPLXMLNode *, const
char * ) override;
383 virtual CPLXMLNode * SerializeToXML( const
char *pszVRTPath ) override;
385 CPLErr XMLInit( CPLXMLNode *psTree, const
char *pszVRTPath,
387 int nInputSpectralBandsIn,
391 char **papszOptions=
nullptr ) override;
393 virtual
char **GetFileList() override;
396 int nXOff,
int nYOff,
int nXSize,
int nYSize,
397 void * pData,
int nBufXSize,
int nBufYSize,
399 int nBandCount,
int *panBandMap,
404 void GetBlockSize(
int *,
int * ) const;
421 int m_bNoDataValueSet;
423 int m_bHideNoDataValue;
424 double m_dfNoDataValue;
426 std::unique_ptr<GDALColorTable> m_poColorTable;
431 char **m_papszCategoryNames;
436 CPLXMLNode *m_psSavedHistograms;
438 void Initialize(
int nXSize,
int nYSize );
440 std::vector<VRTOverviewInfo> m_apoOverviews;
442 VRTRasterBand *m_poMaskBand;
444 std::unique_ptr<GDALRasterAttributeTable> m_poRAT;
451 virtual ~VRTRasterBand();
453 virtual
CPLErr XMLInit( CPLXMLNode *, const
char *,
void* );
454 virtual CPLXMLNode * SerializeToXML( const
char *pszVRTPath );
456 virtual
CPLErr SetNoDataValue(
double ) override;
457 virtual
double GetNoDataValue(
int *pbSuccess =
nullptr ) override;
458 virtual
CPLErr DeleteNoDataValue() override;
469 virtual const
char *GetUnitType() override;
470 CPLErr SetUnitType( const
char * ) override;
472 virtual
char **GetCategoryNames() override;
473 virtual
CPLErr SetCategoryNames(
char ** ) override;
475 virtual
CPLErr SetMetadata(
char **papszMD, const
char *pszDomain = "" ) override;
476 virtual
CPLErr SetMetadataItem( const
char *pszName, const
char *pszValue,
477 const
char *pszDomain = "" ) override;
479 virtual
double GetOffset(
int *pbSuccess =
nullptr ) override;
480 CPLErr SetOffset(
double ) override;
481 virtual
double GetScale(
int *pbSuccess =
nullptr ) override;
482 CPLErr SetScale(
double ) override;
484 virtual
int GetOverviewCount() override;
487 virtual
CPLErr GetHistogram(
double dfMin,
double dfMax,
488 int nBuckets,
GUIntBig * panHistogram,
489 int bIncludeOutOfRange,
int bApproxOK,
490 GDALProgressFunc,
void *pProgressData ) override;
492 virtual
CPLErr GetDefaultHistogram(
double *pdfMin,
double *pdfMax,
493 int *pnBuckets,
GUIntBig ** ppanHistogram,
495 GDALProgressFunc,
void *pProgressData) override;
497 virtual
CPLErr SetDefaultHistogram(
double dfMin,
double dfMax,
498 int nBuckets,
GUIntBig *panHistogram ) override;
502 virtual
void GetFileList(
char*** ppapszFileList,
int *pnSize,
505 virtual
void SetDescription( const
char * ) override;
507 virtual GDALRasterBand *GetMaskBand() override;
508 virtual
int GetMaskFlags() override;
510 virtual
CPLErr CreateMaskBand(
int nFlagsIn ) override;
512 void SetMaskBand(VRTRasterBand* poMaskBand);
514 void SetIsMaskBand();
516 CPLErr UnsetNoDataValue();
518 virtual
int CloseDependentDatasets();
520 virtual
int IsSourcedRasterBand() {
return FALSE; }
521 virtual int IsPansharpenRasterBand() {
return FALSE; }
528 class VRTSimpleSource;
530 class CPL_DLL VRTSourcedRasterBand :
public VRTRasterBand
533 int m_nRecursionCounter;
535 char **m_papszSourceList;
537 bool CanUseSourcesMinMaxImplementations();
538 void CheckSource( VRTSimpleSource *poSS );
544 VRTSource **papoSources;
545 int bSkipBufferInitialization;
547 VRTSourcedRasterBand(
GDALDataset *poDS,
int nBand );
549 int nXSize,
int nYSize );
550 VRTSourcedRasterBand(
GDALDataset *poDS,
int nBand,
552 int nXSize,
int nYSize );
553 virtual ~VRTSourcedRasterBand();
560 virtual
int IGetDataCoverageStatus(
int nXOff,
int nYOff,
561 int nXSize,
int nYSize,
563 double* pdfDataPct) override;
565 virtual
char **GetMetadataDomainList() override;
566 virtual const
char *GetMetadataItem( const
char * pszName,
567 const
char * pszDomain = "" ) override;
568 virtual
char **GetMetadata( const
char * pszDomain = "" ) override;
569 virtual
CPLErr SetMetadata(
char ** papszMetadata,
570 const
char * pszDomain = "" ) override;
571 virtual
CPLErr SetMetadataItem( const
char * pszName,
572 const
char * pszValue,
573 const
char * pszDomain = "" ) override;
575 virtual
CPLErr XMLInit( CPLXMLNode *, const
char *,
void* ) override;
576 virtual CPLXMLNode * SerializeToXML( const
char *pszVRTPath ) override;
578 virtual
double GetMinimum(
int *pbSuccess =
nullptr ) override;
579 virtual
double GetMaximum(
int *pbSuccess =
nullptr ) override;
580 virtual
CPLErr ComputeRasterMinMax(
int bApproxOK,
double* adfMinMax ) override;
581 virtual
CPLErr ComputeStatistics(
int bApproxOK,
582 double *pdfMin,
double *pdfMax,
583 double *pdfMean,
double *pdfStdDev,
584 GDALProgressFunc pfnProgress,
585 void *pProgressData ) override;
586 virtual
CPLErr GetHistogram(
double dfMin,
double dfMax,
587 int nBuckets,
GUIntBig * panHistogram,
588 int bIncludeOutOfRange,
int bApproxOK,
589 GDALProgressFunc pfnProgress,
590 void *pProgressData ) override;
592 CPLErr AddSource( VRTSource * );
594 double dfSrcXOff=-1,
double dfSrcYOff=-1,
595 double dfSrcXSize=-1,
double dfSrcYSize=-1,
596 double dfDstXOff=-1,
double dfDstYOff=-1,
597 double dfDstXSize=-1,
double dfDstYSize=-1,
598 const
char *pszResampling = "near",
601 double dfSrcXOff=-1,
double dfSrcYOff=-1,
602 double dfSrcXSize=-1,
double dfSrcYSize=-1,
603 double dfDstXOff=-1,
double dfDstYOff=-1,
604 double dfDstXSize=-1,
double dfDstYSize=-1,
605 double dfScaleOff=0.0,
606 double dfScaleRatio=1.0,
607 double dfNoDataValue = VRT_NODATA_UNSET,
608 int nColorTableComponent = 0);
611 double dfSrcXOff=-1,
double dfSrcYOff=-1,
612 double dfSrcXSize=-1,
613 double dfSrcYSize=-1,
614 double dfDstXOff=-1,
double dfDstYOff=-1,
615 double dfDstXSize=-1,
616 double dfDstYSize=-1 );
619 double dfNoDataValue = VRT_NODATA_UNSET );
621 void ConfigureSource(VRTSimpleSource *poSimpleSource,
624 double dfSrcXOff,
double dfSrcYOff,
625 double dfSrcXSize,
double dfSrcYSize,
626 double dfDstXOff,
double dfDstYOff,
627 double dfDstXSize,
double dfDstYSize );
629 virtual
CPLErr IReadBlock(
int,
int,
void * ) override;
631 virtual
void GetFileList(
char*** ppapszFileList,
int *pnSize,
632 int *pnMaxSize,
CPLHashSet* hSetFiles) override;
634 virtual
int CloseDependentDatasets() override;
636 virtual
int IsSourcedRasterBand()
override {
return TRUE; }
638 virtual CPLErr FlushCache()
override;
645 class CPL_DLL VRTWarpedRasterBand :
public VRTRasterBand
650 virtual ~VRTWarpedRasterBand();
652 virtual CPLXMLNode * SerializeToXML(
const char *pszVRTPath )
override;
654 virtual CPLErr IReadBlock(
int,
int,
void * )
override;
655 virtual CPLErr IWriteBlock(
int,
int,
void * )
override;
657 virtual int GetOverviewCount()
override;
664 class VRTPansharpenedRasterBand :
public VRTRasterBand
666 int m_nIndexAsPansharpenedBand;
669 VRTPansharpenedRasterBand(
672 virtual ~VRTPansharpenedRasterBand();
674 virtual CPLXMLNode * SerializeToXML(
const char *pszVRTPath )
override;
676 virtual CPLErr IReadBlock(
int,
int,
void * )
override;
679 int nXOff,
int nYOff,
int nXSize,
int nYSize,
680 void * pData,
int nBufXSize,
int nBufYSize,
685 virtual int GetOverviewCount()
override;
688 virtual int IsPansharpenRasterBand()
override {
return TRUE; }
690 void SetIndexAsPansharpenedBand(
int nIdx )
691 { m_nIndexAsPansharpenedBand = nIdx; }
692 int GetIndexAsPansharpenedBand()
const
693 {
return m_nIndexAsPansharpenedBand; }
700 class VRTDerivedRasterBandPrivateData;
702 class CPL_DLL VRTDerivedRasterBand :
public VRTSourcedRasterBand
704 VRTDerivedRasterBandPrivateData* m_poPrivate;
705 bool InitializePython();
713 VRTDerivedRasterBand(
GDALDataset *poDS,
int nBand );
714 VRTDerivedRasterBand(
GDALDataset *poDS,
int nBand,
716 virtual ~VRTDerivedRasterBand();
723 virtual
int IGetDataCoverageStatus(
int nXOff,
int nYOff,
724 int nXSize,
int nYSize,
726 double* pdfDataPct) override;
728 static
CPLErr AddPixelFunction( const
char *pszFuncName,
732 void SetPixelFunctionName( const
char *pszFuncName );
733 void SetSourceTransferType( GDALDataType eDataType );
734 void SetPixelFunctionLanguage( const
char* pszLanguage );
736 virtual
CPLErr XMLInit( CPLXMLNode *, const
char *,
void* ) override;
737 virtual CPLXMLNode * SerializeToXML( const
char *pszVRTPath ) override;
739 virtual
double GetMinimum(
int *pbSuccess =
nullptr ) override;
740 virtual
double GetMaximum(
int *pbSuccess =
nullptr ) override;
741 virtual
CPLErr ComputeRasterMinMax(
int bApproxOK,
double* adfMinMax ) override;
742 virtual
CPLErr ComputeStatistics(
int bApproxOK,
743 double *pdfMin,
double *pdfMax,
744 double *pdfMean,
double *pdfStdDev,
745 GDALProgressFunc pfnProgress,
746 void *pProgressData ) override;
747 virtual
CPLErr GetHistogram(
double dfMin,
double dfMax,
748 int nBuckets,
GUIntBig * panHistogram,
749 int bIncludeOutOfRange,
int bApproxOK,
750 GDALProgressFunc pfnProgress,
751 void *pProgressData ) override;
753 static
void Cleanup();
762 class CPL_DLL VRTRawRasterBand : public VRTRasterBand
764 RawRasterBand *m_poRawRaster;
766 char *m_pszSourceFilename;
767 int m_bRelativeToVRT;
774 virtual ~VRTRawRasterBand();
776 virtual
CPLErr XMLInit( CPLXMLNode *, const
char *,
void* ) override;
777 virtual CPLXMLNode * SerializeToXML( const
char *pszVRTPath ) override;
779 virtual
CPLErr IRasterIO( GDALRWFlag,
int,
int,
int,
int,
780 void *,
int,
int, GDALDataType,
784 virtual
CPLErr IReadBlock(
int,
int,
void * ) override;
785 virtual
CPLErr IWriteBlock(
int,
int,
void * ) override;
787 CPLErr SetRawLink( const
char *pszFilename,
788 const
char *pszVRTPath,
791 int nPixelOffset,
int nLineOffset,
792 const
char *pszByteOrder );
796 virtual
void GetFileList(
char*** ppapszFileList,
int *pnSize,
797 int *pnMaxSize,
CPLHashSet* hSetFiles ) override;
810 virtual ~VRTDriver();
812 char **papszSourceParsers;
814 virtual
char **GetMetadataDomainList() override;
815 virtual
char **GetMetadata( const
char * pszDomain = "" ) override;
816 virtual
CPLErr SetMetadata(
char ** papszMetadata,
817 const
char * pszDomain = "" ) override;
819 VRTSource *ParseSource( CPLXMLNode *psSrc, const
char *pszVRTPath,
820 void* pUniqueHandle );
821 void AddSourceParser( const
char *pszElementName,
822 VRTSourceParser pfnParser );
829 class CPL_DLL VRTSimpleSource : public VRTSource
834 friend class VRTSourcedRasterBand;
853 double m_dfNoDataValue;
858 int m_bRelativeToVRTOri;
860 int m_nExplicitSharedStatus;
862 int NeedMaxValAdjustment() const;
866 VRTSimpleSource( const VRTSimpleSource* poSrcSource,
867 double dfXDstRatio,
double dfYDstRatio );
868 virtual ~VRTSimpleSource();
870 virtual
CPLErr XMLInit( CPLXMLNode *psTree, const
char *,
void* ) override;
871 virtual CPLXMLNode *SerializeToXML( const
char *pszVRTPath ) override;
874 void SetSrcMaskBand( GDALRasterBand * );
875 void SetSrcWindow(
double,
double,
double,
double );
876 void SetDstWindow(
double,
double,
double,
double );
877 void SetNoDataValue(
double dfNoDataValue );
878 const
CPLString& GetResampling()
const {
return m_osResampling; }
879 void SetResampling(
const char* pszResampling );
881 int GetSrcDstWindow(
int,
int,
int,
int,
int,
int,
882 double *pdfReqXOff,
double *pdfReqYOff,
883 double *pdfReqXSize,
double *pdfReqYSize,
884 int *,
int *,
int *,
int *,
885 int *,
int *,
int *,
int * );
887 virtual CPLErr RasterIO( GDALDataType eBandDataType,
888 int nXOff,
int nYOff,
int nXSize,
int nYSize,
889 void *pData,
int nBufXSize,
int nBufYSize,
890 GDALDataType eBufType,
894 virtual double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess )
override;
895 virtual double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess )
override;
896 virtual CPLErr ComputeRasterMinMax(
int nXSize,
int nYSize,
int bApproxOK,
897 double* adfMinMax )
override;
898 virtual CPLErr ComputeStatistics(
int nXSize,
int nYSize,
900 double *pdfMin,
double *pdfMax,
901 double *pdfMean,
double *pdfStdDev,
902 GDALProgressFunc pfnProgress,
903 void *pProgressData )
override;
904 virtual CPLErr GetHistogram(
int nXSize,
int nYSize,
905 double dfMin,
double dfMax,
906 int nBuckets,
GUIntBig * panHistogram,
907 int bIncludeOutOfRange,
int bApproxOK,
908 GDALProgressFunc pfnProgress,
909 void *pProgressData )
override;
911 void DstToSrc(
double dfX,
double dfY,
912 double &dfXOut,
double &dfYOut )
const;
913 void SrcToDst(
double dfX,
double dfY,
914 double &dfXOut,
double &dfYOut )
const;
916 virtual void GetFileList(
char*** ppapszFileList,
int *pnSize,
917 int *pnMaxSize,
CPLHashSet* hSetFiles )
override;
919 virtual int IsSimpleSource()
override {
return TRUE; }
920 virtual const char* GetType() {
return "SimpleSource"; }
921 virtual CPLErr FlushCache()
override;
924 int IsSameExceptBandNumber( VRTSimpleSource* poOtherSource );
926 GDALDataType eBandDataType,
927 int nXOff,
int nYOff,
int nXSize,
int nYSize,
928 void * pData,
int nBufXSize,
int nBufYSize,
929 GDALDataType eBufType,
930 int nBandCount,
int *panBandMap,
935 void UnsetPreservedRelativeFilenames();
937 void SetMaxValue(
int nVal ) { m_nMaxValue = nVal; }
944 class VRTAveragedSource :
public VRTSimpleSource
950 virtual
CPLErr RasterIO( GDALDataType eBandDataType,
951 int nXOff,
int nYOff,
int nXSize,
int nYSize,
952 void *pData,
int nBufXSize,
int nBufYSize,
953 GDALDataType eBufType,
957 virtual
double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess ) override;
958 virtual
double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess ) override;
959 virtual
CPLErr ComputeRasterMinMax(
int nXSize,
int nYSize,
int bApproxOK,
960 double* adfMinMax ) override;
961 virtual
CPLErr ComputeStatistics(
int nXSize,
int nYSize,
963 double *pdfMin,
double *pdfMax,
964 double *pdfMean,
double *pdfStdDev,
965 GDALProgressFunc pfnProgress,
966 void *pProgressData ) override;
967 virtual
CPLErr GetHistogram(
int nXSize,
int nYSize,
968 double dfMin,
double dfMax,
969 int nBuckets,
GUIntBig * panHistogram,
970 int bIncludeOutOfRange,
int bApproxOK,
971 GDALProgressFunc pfnProgress,
972 void *pProgressData ) override;
974 virtual CPLXMLNode *SerializeToXML( const
char *pszVRTPath ) override;
975 virtual const
char* GetType()
override {
return "AveragedSource"; }
986 VRT_SCALING_EXPONENTIAL,
987 } VRTComplexSourceScaling;
989 class CPL_DLL VRTComplexSource :
public VRTSimpleSource
994 VRTComplexSourceScaling m_eScalingType;
996 double m_dfScaleRatio;
999 int m_bSrcMinMaxDefined;
1004 double m_dfExponent;
1006 int m_nColorTableComponent;
1008 template <class WorkingDT>
1009 CPLErr RasterIOInternal(
int nReqXOff,
int nReqYOff,
1010 int nReqXSize,
int nReqYSize,
1011 void *pData,
int nOutXSize,
int nOutYSize,
1012 GDALDataType eBufType,
1015 GDALDataType eWrkDataType );
1019 VRTComplexSource(const VRTComplexSource* poSrcSource,
1020 double dfXDstRatio,
double dfYDstRatio);
1021 virtual ~VRTComplexSource();
1023 virtual
CPLErr RasterIO( GDALDataType eBandDataType,
1024 int nXOff,
int nYOff,
int nXSize,
int nYSize,
1025 void *pData,
int nBufXSize,
int nBufYSize,
1026 GDALDataType eBufType,
1030 virtual
double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess ) override;
1031 virtual
double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess ) override;
1032 virtual
CPLErr ComputeRasterMinMax(
int nXSize,
int nYSize,
int bApproxOK,
1033 double* adfMinMax ) override;
1034 virtual
CPLErr ComputeStatistics(
int nXSize,
int nYSize,
1036 double *pdfMin,
double *pdfMax,
1037 double *pdfMean,
double *pdfStdDev,
1038 GDALProgressFunc pfnProgress,
1039 void *pProgressData ) override;
1040 virtual
CPLErr GetHistogram(
int nXSize,
int nYSize,
1041 double dfMin,
double dfMax,
1042 int nBuckets,
GUIntBig * panHistogram,
1043 int bIncludeOutOfRange,
int bApproxOK,
1044 GDALProgressFunc pfnProgress,
1045 void *pProgressData ) override;
1047 virtual CPLXMLNode *SerializeToXML( const
char *pszVRTPath ) override;
1048 virtual
CPLErr XMLInit( CPLXMLNode *, const
char *,
void* ) override;
1049 virtual const
char* GetType()
override {
return "ComplexSource"; }
1051 double LookupValue(
double dfInput );
1053 void SetLinearScaling(
double dfOffset,
double dfScale );
1054 void SetPowerScaling(
double dfExponent,
1059 void SetColorTableComponent(
int nComponent );
1061 double *m_padfLUTInputs;
1062 double *m_padfLUTOutputs;
1063 int m_nLUTItemCount;
1070 class VRTFilteredSource :
public VRTComplexSource
1073 int IsTypeSupported( GDALDataType eTestType )
const;
1078 int m_nSupportedTypesCount;
1079 GDALDataType m_aeSupportedTypes[20];
1081 int m_nExtraEdgePixels;
1084 VRTFilteredSource();
1085 virtual ~VRTFilteredSource();
1087 void SetExtraEdgePixels(
int );
1088 void SetFilteringDataTypesSupported(
int, GDALDataType * );
1090 virtual
CPLErr FilterData(
int nXSize,
int nYSize, GDALDataType eType,
1091 GByte *pabySrcData,
GByte *pabyDstData ) = 0;
1093 virtual
CPLErr RasterIO( GDALDataType eBandDataType,
1094 int nXOff,
int nYOff,
int nXSize,
int nYSize,
1095 void *pData,
int nBufXSize,
int nBufYSize,
1096 GDALDataType eBufType,
1105 class VRTKernelFilteredSource : public VRTFilteredSource
1114 double *m_padfKernelCoefs;
1119 VRTKernelFilteredSource();
1120 virtual ~VRTKernelFilteredSource();
1122 virtual
CPLErr XMLInit( CPLXMLNode *psTree, const
char *,
void* ) override;
1123 virtual CPLXMLNode *SerializeToXML( const
char *pszVRTPath ) override;
1125 virtual
CPLErr FilterData(
int nXSize,
int nYSize, GDALDataType eType,
1126 GByte *pabySrcData,
GByte *pabyDstData ) override;
1128 CPLErr SetKernel(
int nKernelSize,
bool bSeparable,
double *padfCoefs );
1129 void SetNormalized(
int );
1136 class VRTAverageFilteredSource : public VRTKernelFilteredSource
1141 explicit VRTAverageFilteredSource(
int nKernelSize );
1142 virtual ~VRTAverageFilteredSource();
1144 virtual
CPLErr XMLInit( CPLXMLNode *psTree, const
char *,
void* ) override;
1145 virtual CPLXMLNode *SerializeToXML( const
char *pszVRTPath ) override;
1151 class VRTFuncSource : public VRTSource
1157 virtual ~VRTFuncSource();
1159 virtual
CPLErr XMLInit( CPLXMLNode *, const
char *,
void* )
override {
return CE_Failure; }
1160 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath )
override;
1162 virtual CPLErr RasterIO( GDALDataType eBandDataType,
1163 int nXOff,
int nYOff,
int nXSize,
int nYSize,
1164 void *pData,
int nBufXSize,
int nBufYSize,
1165 GDALDataType eBufType,
1169 virtual double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess )
override;
1170 virtual double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess )
override;
1171 virtual CPLErr ComputeRasterMinMax(
int nXSize,
int nYSize,
int bApproxOK,
1172 double* adfMinMax )
override;
1173 virtual CPLErr ComputeStatistics(
int nXSize,
int nYSize,
1175 double *pdfMin,
double *pdfMax,
1176 double *pdfMean,
double *pdfStdDev,
1177 GDALProgressFunc pfnProgress,
1178 void *pProgressData )
override;
1179 virtual CPLErr GetHistogram(
int nXSize,
int nYSize,
1180 double dfMin,
double dfMax,
1181 int nBuckets,
GUIntBig * panHistogram,
1182 int bIncludeOutOfRange,
int bApproxOK,
1183 GDALProgressFunc pfnProgress,
1184 void *pProgressData )
override;
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:51
The GDALRasterAttributeTable (or RAT) class is used to encapsulate a table used to provide attribute ...
Definition: gdal_rat.h:47
virtual CPLErr GetGeoTransform(double *padfTransform)
Fetch the affine transformation coefficients.
Definition: gdaldataset.cpp:922
GDALDataType
Definition: gdal.h:60
Document node structure.
Definition: cpl_minixml.h:66
virtual CPLErr AddBand(GDALDataType eType, char **papszOptions=nullptr)
Add a band to a dataset.
Definition: gdaldataset.cpp:548
virtual void FlushCache(void)
Flush all write cached data to disk.
Definition: gdaldataset.cpp:396
virtual CPLErr AdviseRead(int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, GDALDataType eDT, int nBandCount, int *panBandList, char **papszOptions)
Advise driver of upcoming read requests.
Definition: gdaldataset.cpp:2263
virtual const char * GetProjectionRef(void)
Fetch the projection definition string for this dataset.
Definition: gdaldataset.cpp:824
GDALRWFlag
Definition: gdal.h:119
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:766
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:215
void * GDALRasterBandH
Opaque type used for the C bindings of the C++ GDALRasterBand class.
Definition: gdal.h:258
Pansharpening operation class.
Definition: gdalpansharpen.h:188
Convenient string class based on std::string.
Definition: cpl_string.h:327
virtual CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList, const char *pszGCPProjection)
Assign GCPs.
Definition: gdaldataset.cpp:1382
void char ** GetMetadata(const char *pszDomain="") override
Fetch metadata.
Definition: gdaldataset.cpp:3469
#define VRT_NODATA_UNSET
Special value to indicate that nodata is not set.
Definition: gdal_vrt.h:45
GIntBig GSpacing
Type to express pixel, line or band spacing.
Definition: gdal.h:273
int Dereference()
Subtract one from dataset reference count.
Definition: gdaldataset.cpp:1130
virtual const GDAL_GCP * GetGCPs()
Fetch GCPs.
Definition: gdaldataset.cpp:1332
static GDALDataset * Open(const char *pszFilename, unsigned int nOpenFlags=0, const char *const *papszAllowedDrivers=nullptr, const char *const *papszOpenOptions=nullptr, const char *const *papszSiblingFiles=nullptr)
Definition: gdal_priv.h:602
virtual CPLErr SetGeoTransform(double *padfTransform)
Set the affine transformation coefficients.
Definition: gdaldataset.cpp:977
virtual int GetGCPCount()
Get number of GCPs.
Definition: gdaldataset.cpp:1264
Class for dataset open functions.
Definition: gdal_priv.h:265
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:435
High level image warping class.
Definition: gdalwarper.h:440
virtual CPLErr CreateMaskBand(int nFlagsIn)
Adds a mask band to the dataset.
Definition: gdaldataset.cpp:2445
unsigned long long GUIntBig
Large unsigned integer type (generally 64-bit unsigned integer type).
Definition: cpl_port.h:251
virtual char ** GetFileList(void)
Fetch files forming dataset.
Definition: gdaldataset.cpp:2345
virtual CPLErr SetProjection(const char *pszProjection)
Set the projection reference string for this dataset.
Definition: gdaldataset.cpp:864
virtual const char * GetGCPProjection()
Get output projection for GCPs.
Definition: gdaldataset.cpp:1299
void GDALClose(GDALDatasetH)
Close GDAL dataset.
Definition: gdaldataset.cpp:3046
Object with metadata.
Definition: gdal_priv.h:132
GDALDataset * GetDataset()
Fetch the owning dataset handle.
Definition: gdalrasterband.cpp:2826
CPLErr SetMetadataItem(const char *pszName, const char *pszValue, const char *pszDomain) override
Set single metadata item.
GUIntBig vsi_l_offset
Type for a file offset.
Definition: cpl_vsi.h:139
A single raster band (or channel).
Definition: gdal_priv.h:1032
GDALAccess
Definition: gdal.h:113
A set of associated raster bands, usually from one file.
Definition: gdal_priv.h:335
CPLErr SetMetadata(char **papszMetadata, const char *pszDomain) override
Set metadata.
GDALColorInterp
Definition: gdal.h:190
Public (C callable) entry points for virtual GDAL dataset objects.
struct _CPLHashSet CPLHashSet
Opaque type for a hash set.
Definition: cpl_hash_set.h:52
int GetShared() const
Returns shared flag.
Definition: gdaldataset.cpp:1202
Format specific driver.
Definition: gdal_priv.h:1386
A color table / palette.
Definition: gdal_priv.h:937
Ground Control Point.
Definition: gdal.h:560
CPLErr
Error category.
Definition: cpl_error.h:52
#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:989