30 #ifndef VIRTUALDATASET_H_INCLUDED
31 #define VIRTUALDATASET_H_INCLUDED
33 #include "gdal_priv.h"
36 #include "cpl_hash_set.h"
38 int VRTApplyMetadata( CPLXMLNode *, GDALMajorObject * );
39 CPLXMLNode *VRTSerializeMetadata( GDALMajorObject * );
41 int VRTWarpedOverviewTransform(
void *pTransformArg,
int bDstToSrc,
43 double *padfX,
double *padfY,
double *padfZ,
45 void* VRTDeserializeWarpedOverviewTransformer( CPLXMLNode *psTree );
55 GDALRasterBand *poBand;
62 else if( poBand->GetDataset()->GetShared() )
63 GDALClose( (GDALDatasetH) poBand->GetDataset() );
65 poBand->GetDataset()->Dereference();
79 virtual CPLErr RasterIO(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
80 void *pData,
int nBufXSize,
int nBufYSize,
81 GDALDataType eBufType,
82 int nPixelSpace,
int nLineSpace ) = 0;
84 virtual double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess ) = 0;
85 virtual double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess ) = 0;
87 virtual CPLErr XMLInit( CPLXMLNode *psTree,
const char * ) = 0;
88 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath ) = 0;
90 virtual void GetFileList(
char*** ppapszFileList,
int *pnSize,
91 int *pnMaxSize, CPLHashSet* hSetFiles);
93 virtual int IsSimpleSource() {
return FALSE; }
96 typedef VRTSource *(*VRTSourceParser)(CPLXMLNode *,
const char *);
98 VRTSource *VRTParseCoreSources( CPLXMLNode *psTree,
const char * );
99 VRTSource *VRTParseFilterSources( CPLXMLNode *psTree,
const char * );
113 int bGeoTransformSet;
114 double adfGeoTransform[6];
117 GDAL_GCP *pasGCPList;
118 char *pszGCPProjection;
127 int bCompatibleForDatasetIO;
128 int CheckCompatibleForDatasetIO();
131 virtual int CloseDependentDatasets();
137 void SetNeedsFlush() { bNeedsFlush = TRUE; }
138 virtual void FlushCache();
140 void SetWritable(
int bWritable) { this->bWritable = bWritable; }
142 virtual CPLErr CreateMaskBand(
int nFlags );
145 virtual const char *GetProjectionRef(
void);
146 virtual CPLErr SetProjection(
const char * );
147 virtual CPLErr GetGeoTransform(
double * );
148 virtual CPLErr SetGeoTransform(
double * );
150 virtual CPLErr SetMetadata(
char **papszMD,
const char *pszDomain =
"" );
151 virtual CPLErr SetMetadataItem(
const char *pszName,
const char *pszValue,
152 const char *pszDomain =
"" );
154 virtual int GetGCPCount();
155 virtual const char *GetGCPProjection();
156 virtual const GDAL_GCP *GetGCPs();
157 virtual CPLErr SetGCPs(
int nGCPCount,
const GDAL_GCP *pasGCPList,
158 const char *pszGCPProjection );
160 virtual CPLErr AddBand( GDALDataType eType,
161 char **papszOptions=NULL );
163 virtual char **GetFileList();
165 virtual CPLErr IRasterIO( GDALRWFlag eRWFlag,
166 int nXOff,
int nYOff,
int nXSize,
int nYSize,
167 void * pData,
int nBufXSize,
int nBufYSize,
168 GDALDataType eBufType,
169 int nBandCount,
int *panBandMap,
170 int nPixelSpace,
int nLineSpace,
int nBandSpace);
172 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath);
173 virtual CPLErr XMLInit( CPLXMLNode *,
const char * );
175 static int Identify( GDALOpenInfo * );
176 static GDALDataset *Open( GDALOpenInfo * );
177 static GDALDataset *OpenXML(
const char *,
const char * = NULL, GDALAccess eAccess = GA_ReadOnly );
178 static GDALDataset *Create(
const char * pszName,
179 int nXSize,
int nYSize,
int nBands,
180 GDALDataType eType,
char ** papszOptions );
181 static CPLErr Delete(
const char * pszFilename );
188 class GDALWarpOperation;
195 GDALWarpOperation *poWarper;
200 virtual int CloseDependentDatasets();
210 CPLErr Initialize(
void * );
212 virtual CPLErr IBuildOverviews(
const char *,
int,
int *,
213 int,
int *, GDALProgressFunc,
void * );
215 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath );
216 virtual CPLErr XMLInit( CPLXMLNode *,
const char * );
218 virtual CPLErr AddBand( GDALDataType eType,
219 char **papszOptions=NULL );
221 virtual char **GetFileList();
223 CPLErr ProcessBlock(
int iBlockX,
int iBlockY );
225 void GetBlockSize(
int *,
int * );
241 int bHideNoDataValue;
242 double dfNoDataValue;
244 GDALColorTable *poColorTable;
246 GDALColorInterp eColorInterp;
249 char **papszCategoryNames;
254 CPLXMLNode *psSavedHistograms;
256 void Initialize(
int nXSize,
int nYSize );
258 std::vector<VRTOverviewInfo> apoOverviews;
267 virtual CPLErr XMLInit( CPLXMLNode *,
const char * );
268 virtual CPLXMLNode * SerializeToXML(
const char *pszVRTPath );
270 virtual CPLErr SetNoDataValue(
double );
271 virtual double GetNoDataValue(
int *pbSuccess = NULL );
273 virtual CPLErr SetColorTable( GDALColorTable * );
274 virtual GDALColorTable *GetColorTable();
276 virtual CPLErr SetColorInterpretation( GDALColorInterp );
277 virtual GDALColorInterp GetColorInterpretation();
279 virtual const char *GetUnitType();
280 CPLErr SetUnitType(
const char * );
282 virtual char **GetCategoryNames();
283 virtual CPLErr SetCategoryNames(
char ** );
285 virtual CPLErr SetMetadata(
char **papszMD,
const char *pszDomain =
"" );
286 virtual CPLErr SetMetadataItem(
const char *pszName,
const char *pszValue,
287 const char *pszDomain =
"" );
289 virtual double GetOffset(
int *pbSuccess = NULL );
290 CPLErr SetOffset(
double );
291 virtual double GetScale(
int *pbSuccess = NULL );
292 CPLErr SetScale(
double );
294 virtual int GetOverviewCount();
295 virtual GDALRasterBand *GetOverview(
int);
297 virtual CPLErr GetHistogram(
double dfMin,
double dfMax,
298 int nBuckets,
int * panHistogram,
299 int bIncludeOutOfRange,
int bApproxOK,
300 GDALProgressFunc,
void *pProgressData );
302 virtual CPLErr GetDefaultHistogram(
double *pdfMin,
double *pdfMax,
303 int *pnBuckets,
int ** ppanHistogram,
305 GDALProgressFunc,
void *pProgressData);
307 virtual CPLErr SetDefaultHistogram(
double dfMin,
double dfMax,
308 int nBuckets,
int *panHistogram );
310 CPLErr CopyCommonInfoFrom( GDALRasterBand * );
312 virtual void GetFileList(
char*** ppapszFileList,
int *pnSize,
313 int *pnMaxSize, CPLHashSet* hSetFiles);
315 virtual void SetDescription(
const char * );
317 virtual GDALRasterBand *GetMaskBand();
318 virtual int GetMaskFlags();
320 virtual CPLErr CreateMaskBand(
int nFlags );
324 void SetIsMaskBand();
326 CPLErr UnsetNoDataValue();
328 virtual int CloseDependentDatasets();
330 virtual int IsSourcedRasterBand() {
return FALSE; }
340 int bAntiRecursionFlag;
341 CPLString osLastLocationInfo;
343 void Initialize(
int nXSize,
int nYSize );
352 int nXSize,
int nYSize );
355 int nXSize,
int nYSize );
358 virtual CPLErr IRasterIO( GDALRWFlag,
int,
int,
int,
int,
359 void *,
int,
int, GDALDataType,
362 virtual const char *GetMetadataItem(
const char * pszName,
363 const char * pszDomain =
"" );
364 virtual char **GetMetadata(
const char * pszDomain =
"" );
365 virtual CPLErr SetMetadata(
char ** papszMetadata,
366 const char * pszDomain =
"" );
367 virtual CPLErr SetMetadataItem(
const char * pszName,
368 const char * pszValue,
369 const char * pszDomain =
"" );
371 virtual CPLErr XMLInit( CPLXMLNode *,
const char * );
372 virtual CPLXMLNode * SerializeToXML(
const char *pszVRTPath );
374 virtual double GetMinimum(
int *pbSuccess = NULL );
375 virtual double GetMaximum(
int *pbSuccess = NULL );
378 CPLErr AddSimpleSource( GDALRasterBand *poSrcBand,
379 int nSrcXOff=-1,
int nSrcYOff=-1,
380 int nSrcXSize=-1,
int nSrcYSize=-1,
381 int nDstXOff=-1,
int nDstYOff=-1,
382 int nDstXSize=-1,
int nDstYSize=-1,
383 const char *pszResampling =
"near",
384 double dfNoDataValue = VRT_NODATA_UNSET);
385 CPLErr AddComplexSource( GDALRasterBand *poSrcBand,
386 int nSrcXOff=-1,
int nSrcYOff=-1,
387 int nSrcXSize=-1,
int nSrcYSize=-1,
388 int nDstXOff=-1,
int nDstYOff=-1,
389 int nDstXSize=-1,
int nDstYSize=-1,
390 double dfScaleOff=0.0,
391 double dfScaleRatio=1.0,
392 double dfNoDataValue = VRT_NODATA_UNSET,
393 int nColorTableComponent = 0);
395 CPLErr AddMaskBandSource( GDALRasterBand *poSrcBand,
396 int nSrcXOff=-1,
int nSrcYOff=-1,
397 int nSrcXSize=-1,
int nSrcYSize=-1,
398 int nDstXOff=-1,
int nDstYOff=-1,
399 int nDstXSize=-1,
int nDstYSize=-1 );
401 CPLErr AddFuncSource( VRTImageReadFunc pfnReadFunc,
void *hCBData,
402 double dfNoDataValue = VRT_NODATA_UNSET );
405 virtual CPLErr IReadBlock(
int,
int,
void * );
407 virtual void GetFileList(
char*** ppapszFileList,
int *pnSize,
408 int *pnMaxSize, CPLHashSet* hSetFiles);
410 virtual int CloseDependentDatasets();
412 virtual int IsSourcedRasterBand() {
return TRUE; }
423 GDALDataType eType = GDT_Unknown );
426 virtual CPLErr XMLInit( CPLXMLNode *,
const char * );
427 virtual CPLXMLNode * SerializeToXML(
const char *pszVRTPath );
429 virtual CPLErr IReadBlock(
int,
int,
void * );
430 virtual CPLErr IWriteBlock(
int,
int,
void * );
432 virtual int GetOverviewCount();
433 virtual GDALRasterBand *GetOverview(
int);
445 GDALDataType eSourceTransferType;
449 GDALDataType eType,
int nXSize,
int nYSize);
452 virtual CPLErr IRasterIO( GDALRWFlag,
int,
int,
int,
int,
453 void *,
int,
int, GDALDataType,
456 static CPLErr AddPixelFunction
457 (
const char *pszFuncName, GDALDerivedPixelFunc pfnPixelFunc);
458 static GDALDerivedPixelFunc GetPixelFunction(
const char *pszFuncName);
460 void SetPixelFunctionName(
const char *pszFuncName);
461 void SetSourceTransferType(GDALDataType eDataType);
463 virtual CPLErr XMLInit( CPLXMLNode *,
const char * );
464 virtual CPLXMLNode * SerializeToXML(
const char *pszVRTPath );
476 RawRasterBand *poRawRaster;
478 char *pszSourceFilename;
483 GDALDataType eType = GDT_Unknown );
486 virtual CPLErr XMLInit( CPLXMLNode *,
const char * );
487 virtual CPLXMLNode * SerializeToXML(
const char *pszVRTPath );
489 virtual CPLErr IRasterIO( GDALRWFlag,
int,
int,
int,
int,
490 void *,
int,
int, GDALDataType,
493 virtual CPLErr IReadBlock(
int,
int,
void * );
494 virtual CPLErr IWriteBlock(
int,
int,
void * );
496 CPLErr SetRawLink(
const char *pszFilename,
497 const char *pszVRTPath,
499 vsi_l_offset nImageOffset,
500 int nPixelOffset,
int nLineOffset,
501 const char *pszByteOrder );
505 virtual void GetFileList(
char*** ppapszFileList,
int *pnSize,
506 int *pnMaxSize, CPLHashSet* hSetFiles);
515 void *pDeserializerData;
521 char **papszSourceParsers;
523 virtual char **GetMetadata(
const char * pszDomain =
"" );
524 virtual CPLErr SetMetadata(
char ** papszMetadata,
525 const char * pszDomain =
"" );
527 VRTSource *ParseSource( CPLXMLNode *psSrc,
const char *pszVRTPath );
528 void AddSourceParser(
const char *pszElementName,
529 VRTSourceParser pfnParser );
539 GDALRasterBand *poRasterBand;
543 GDALRasterBand *poMaskBandMainBand;
556 double dfNoDataValue;
562 virtual CPLErr XMLInit( CPLXMLNode *psTree,
const char * );
563 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath );
565 void SetSrcBand( GDALRasterBand * );
566 void SetSrcMaskBand( GDALRasterBand * );
567 void SetSrcWindow(
int,
int,
int,
int );
568 void SetDstWindow(
int,
int,
int,
int );
569 void SetNoDataValue(
double dfNoDataValue );
571 int GetSrcDstWindow(
int,
int,
int,
int,
int,
int,
572 int *,
int *,
int *,
int *,
573 int *,
int *,
int *,
int * );
575 virtual CPLErr RasterIO(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
576 void *pData,
int nBufXSize,
int nBufYSize,
577 GDALDataType eBufType,
578 int nPixelSpace,
int nLineSpace );
580 virtual double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess );
581 virtual double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess );
583 void DstToSrc(
double dfX,
double dfY,
584 double &dfXOut,
double &dfYOut );
585 void SrcToDst(
double dfX,
double dfY,
586 double &dfXOut,
double &dfYOut );
588 virtual void GetFileList(
char*** ppapszFileList,
int *pnSize,
589 int *pnMaxSize, CPLHashSet* hSetFiles);
591 virtual int IsSimpleSource() {
return TRUE; }
592 virtual const char* GetType() {
return "SimpleSource"; }
594 GDALRasterBand* GetBand();
596 CPLErr DatasetRasterIO(
597 int nXOff,
int nYOff,
int nXSize,
int nYSize,
598 void * pData,
int nBufXSize,
int nBufYSize,
599 GDALDataType eBufType,
600 int nBandCount,
int *panBandMap,
601 int nPixelSpace,
int nLineSpace,
int nBandSpace);
612 virtual CPLErr RasterIO(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
613 void *pData,
int nBufXSize,
int nBufYSize,
614 GDALDataType eBufType,
615 int nPixelSpace,
int nLineSpace );
617 virtual double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess );
618 virtual double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess );
620 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath );
621 virtual const char* GetType() {
return "AveragedSource"; }
634 virtual CPLErr RasterIO(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
635 void *pData,
int nBufXSize,
int nBufYSize,
636 GDALDataType eBufType,
637 int nPixelSpace,
int nLineSpace );
639 virtual double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess );
640 virtual double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess );
642 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath );
643 virtual CPLErr XMLInit( CPLXMLNode *,
const char * );
644 virtual const char* GetType() {
return "ComplexSource"; }
646 double LookupValue(
double dfInput );
651 double *padfLUTInputs;
652 double *padfLUTOutputs;
654 int nColorTableComponent;
664 int IsTypeSupported( GDALDataType eType );
667 int nSupportedTypesCount;
668 GDALDataType aeSupportedTypes[20];
670 int nExtraEdgePixels;
676 void SetExtraEdgePixels(
int );
677 void SetFilteringDataTypesSupported(
int, GDALDataType * );
679 virtual CPLErr FilterData(
int nXSize,
int nYSize, GDALDataType eType,
680 GByte *pabySrcData, GByte *pabyDstData ) = 0;
682 virtual CPLErr RasterIO(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
683 void *pData,
int nBufXSize,
int nBufYSize,
684 GDALDataType eBufType,
685 int nPixelSpace,
int nLineSpace );
697 double *padfKernelCoefs;
705 virtual CPLErr XMLInit( CPLXMLNode *psTree,
const char * );
706 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath );
708 virtual CPLErr FilterData(
int nXSize,
int nYSize, GDALDataType eType,
709 GByte *pabySrcData, GByte *pabyDstData );
711 CPLErr SetKernel(
int nKernelSize,
double *padfCoefs );
712 void SetNormalized(
int );
725 virtual CPLErr XMLInit( CPLXMLNode *psTree,
const char * );
726 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath );
738 virtual CPLErr XMLInit( CPLXMLNode *,
const char *) {
return CE_Failure; }
739 virtual CPLXMLNode *SerializeToXML(
const char *pszVRTPath );
741 virtual CPLErr RasterIO(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
742 void *pData,
int nBufXSize,
int nBufYSize,
743 GDALDataType eBufType,
744 int nPixelSpace,
int nLineSpace );
746 virtual double GetMinimum(
int nXSize,
int nYSize,
int *pbSuccess );
747 virtual double GetMaximum(
int nXSize,
int nYSize,
int *pbSuccess );
749 VRTImageReadFunc pfnReadFunc;