00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef VIRTUALDATASET_H_INCLUDED
00031 #define VIRTUALDATASET_H_INCLUDED
00032
00033 #include "gdal_priv.h"
00034 #include "gdal_pam.h"
00035 #include "gdal_vrt.h"
00036 #include "cpl_hash_set.h"
00037
00038 int VRTApplyMetadata( CPLXMLNode *, GDALMajorObject * );
00039 CPLXMLNode *VRTSerializeMetadata( GDALMajorObject * );
00040
00041 int VRTWarpedOverviewTransform( void *pTransformArg, int bDstToSrc,
00042 int nPointCount,
00043 double *padfX, double *padfY, double *padfZ,
00044 int *panSuccess );
00045 void* VRTDeserializeWarpedOverviewTransformer( CPLXMLNode *psTree );
00046
00047
00048
00049
00050 class VRTOverviewInfo
00051 {
00052 public:
00053 CPLString osFilename;
00054 int nBand;
00055 GDALRasterBand *poBand;
00056 int bTriedToOpen;
00057
00058 VRTOverviewInfo() : poBand(NULL), bTriedToOpen(FALSE) {}
00059 ~VRTOverviewInfo() {
00060 if( poBand == NULL )
00061 ;
00062 else if( poBand->GetDataset()->GetShared() )
00063 GDALClose( (GDALDatasetH) poBand->GetDataset() );
00064 else
00065 poBand->GetDataset()->Dereference();
00066 }
00067 };
00068
00069
00070
00071
00072
00073
00074 class CPL_DLL VRTSource
00075 {
00076 public:
00077 virtual ~VRTSource();
00078
00079 virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
00080 void *pData, int nBufXSize, int nBufYSize,
00081 GDALDataType eBufType,
00082 int nPixelSpace, int nLineSpace ) = 0;
00083
00084 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) = 0;
00085 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) = 0;
00086 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax ) = 0;
00087 virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
00088 int bApproxOK,
00089 double *pdfMin, double *pdfMax,
00090 double *pdfMean, double *pdfStdDev,
00091 GDALProgressFunc pfnProgress, void *pProgressData ) = 0;
00092 virtual CPLErr GetHistogram( int nXSize, int nYSize,
00093 double dfMin, double dfMax,
00094 int nBuckets, int * panHistogram,
00095 int bIncludeOutOfRange, int bApproxOK,
00096 GDALProgressFunc pfnProgress, void *pProgressData ) = 0;
00097
00098 virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * ) = 0;
00099 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) = 0;
00100
00101 virtual void GetFileList(char*** ppapszFileList, int *pnSize,
00102 int *pnMaxSize, CPLHashSet* hSetFiles);
00103
00104 virtual int IsSimpleSource() { return FALSE; }
00105 };
00106
00107 typedef VRTSource *(*VRTSourceParser)(CPLXMLNode *, const char *);
00108
00109 VRTSource *VRTParseCoreSources( CPLXMLNode *psTree, const char * );
00110 VRTSource *VRTParseFilterSources( CPLXMLNode *psTree, const char * );
00111
00112
00113
00114
00115
00116 class VRTRasterBand;
00117
00118 class CPL_DLL VRTDataset : public GDALDataset
00119 {
00120 friend class VRTRasterBand;
00121
00122 char *pszProjection;
00123
00124 int bGeoTransformSet;
00125 double adfGeoTransform[6];
00126
00127 int nGCPCount;
00128 GDAL_GCP *pasGCPList;
00129 char *pszGCPProjection;
00130
00131 int bNeedsFlush;
00132 int bWritable;
00133
00134 char *pszVRTPath;
00135
00136 VRTRasterBand *poMaskBand;
00137
00138 int bCompatibleForDatasetIO;
00139 int CheckCompatibleForDatasetIO();
00140
00141 protected:
00142 virtual int CloseDependentDatasets();
00143
00144 public:
00145 VRTDataset(int nXSize, int nYSize);
00146 ~VRTDataset();
00147
00148 void SetNeedsFlush() { bNeedsFlush = TRUE; }
00149 virtual void FlushCache();
00150
00151 void SetWritable(int bWritable) { this->bWritable = bWritable; }
00152
00153 virtual CPLErr CreateMaskBand( int nFlags );
00154 void SetMaskBand(VRTRasterBand* poMaskBand);
00155
00156 virtual const char *GetProjectionRef(void);
00157 virtual CPLErr SetProjection( const char * );
00158 virtual CPLErr GetGeoTransform( double * );
00159 virtual CPLErr SetGeoTransform( double * );
00160
00161 virtual CPLErr SetMetadata( char **papszMD, const char *pszDomain = "" );
00162 virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue,
00163 const char *pszDomain = "" );
00164
00165 virtual int GetGCPCount();
00166 virtual const char *GetGCPProjection();
00167 virtual const GDAL_GCP *GetGCPs();
00168 virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
00169 const char *pszGCPProjection );
00170
00171 virtual CPLErr AddBand( GDALDataType eType,
00172 char **papszOptions=NULL );
00173
00174 virtual char **GetFileList();
00175
00176 virtual CPLErr IRasterIO( GDALRWFlag eRWFlag,
00177 int nXOff, int nYOff, int nXSize, int nYSize,
00178 void * pData, int nBufXSize, int nBufYSize,
00179 GDALDataType eBufType,
00180 int nBandCount, int *panBandMap,
00181 int nPixelSpace, int nLineSpace, int nBandSpace);
00182
00183 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath);
00184 virtual CPLErr XMLInit( CPLXMLNode *, const char * );
00185
00186
00187 GDALDataset* GetSingleSimpleSource();
00188
00189 static int Identify( GDALOpenInfo * );
00190 static GDALDataset *Open( GDALOpenInfo * );
00191 static GDALDataset *OpenXML( const char *, const char * = NULL, GDALAccess eAccess = GA_ReadOnly );
00192 static GDALDataset *Create( const char * pszName,
00193 int nXSize, int nYSize, int nBands,
00194 GDALDataType eType, char ** papszOptions );
00195 static CPLErr Delete( const char * pszFilename );
00196 };
00197
00198
00199
00200
00201
00202 class GDALWarpOperation;
00203 class VRTWarpedRasterBand;
00204
00205 class CPL_DLL VRTWarpedDataset : public VRTDataset
00206 {
00207 int nBlockXSize;
00208 int nBlockYSize;
00209 GDALWarpOperation *poWarper;
00210
00211 friend class VRTWarpedRasterBand;
00212
00213 protected:
00214 virtual int CloseDependentDatasets();
00215
00216 public:
00217 int nOverviewCount;
00218 VRTWarpedDataset **papoOverviews;
00219
00220 public:
00221 VRTWarpedDataset( int nXSize, int nYSize );
00222 ~VRTWarpedDataset();
00223
00224 CPLErr Initialize( void * );
00225
00226 virtual CPLErr IBuildOverviews( const char *, int, int *,
00227 int, int *, GDALProgressFunc, void * );
00228
00229 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
00230 virtual CPLErr XMLInit( CPLXMLNode *, const char * );
00231
00232 virtual CPLErr AddBand( GDALDataType eType,
00233 char **papszOptions=NULL );
00234
00235 virtual char **GetFileList();
00236
00237 CPLErr ProcessBlock( int iBlockX, int iBlockY );
00238
00239 void GetBlockSize( int *, int * );
00240 };
00241
00242
00243
00244
00245
00246
00247
00248
00249 class CPL_DLL VRTRasterBand : public GDALRasterBand
00250 {
00251 protected:
00252 int bIsMaskBand;
00253
00254 int bNoDataValueSet;
00255 int bHideNoDataValue;
00256 double dfNoDataValue;
00257
00258 GDALColorTable *poColorTable;
00259
00260 GDALColorInterp eColorInterp;
00261
00262 char *pszUnitType;
00263 char **papszCategoryNames;
00264
00265 double dfOffset;
00266 double dfScale;
00267
00268 CPLXMLNode *psSavedHistograms;
00269
00270 void Initialize( int nXSize, int nYSize );
00271
00272 std::vector<VRTOverviewInfo> apoOverviews;
00273
00274 VRTRasterBand *poMaskBand;
00275
00276 public:
00277
00278 VRTRasterBand();
00279 virtual ~VRTRasterBand();
00280
00281 virtual CPLErr XMLInit( CPLXMLNode *, const char * );
00282 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath );
00283
00284 virtual CPLErr SetNoDataValue( double );
00285 virtual double GetNoDataValue( int *pbSuccess = NULL );
00286
00287 virtual CPLErr SetColorTable( GDALColorTable * );
00288 virtual GDALColorTable *GetColorTable();
00289
00290 virtual CPLErr SetColorInterpretation( GDALColorInterp );
00291 virtual GDALColorInterp GetColorInterpretation();
00292
00293 virtual const char *GetUnitType();
00294 CPLErr SetUnitType( const char * );
00295
00296 virtual char **GetCategoryNames();
00297 virtual CPLErr SetCategoryNames( char ** );
00298
00299 virtual CPLErr SetMetadata( char **papszMD, const char *pszDomain = "" );
00300 virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue,
00301 const char *pszDomain = "" );
00302
00303 virtual double GetOffset( int *pbSuccess = NULL );
00304 CPLErr SetOffset( double );
00305 virtual double GetScale( int *pbSuccess = NULL );
00306 CPLErr SetScale( double );
00307
00308 virtual int GetOverviewCount();
00309 virtual GDALRasterBand *GetOverview(int);
00310
00311 virtual CPLErr GetHistogram( double dfMin, double dfMax,
00312 int nBuckets, int * panHistogram,
00313 int bIncludeOutOfRange, int bApproxOK,
00314 GDALProgressFunc, void *pProgressData );
00315
00316 virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
00317 int *pnBuckets, int ** ppanHistogram,
00318 int bForce,
00319 GDALProgressFunc, void *pProgressData);
00320
00321 virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
00322 int nBuckets, int *panHistogram );
00323
00324 CPLErr CopyCommonInfoFrom( GDALRasterBand * );
00325
00326 virtual void GetFileList(char*** ppapszFileList, int *pnSize,
00327 int *pnMaxSize, CPLHashSet* hSetFiles);
00328
00329 virtual void SetDescription( const char * );
00330
00331 virtual GDALRasterBand *GetMaskBand();
00332 virtual int GetMaskFlags();
00333
00334 virtual CPLErr CreateMaskBand( int nFlags );
00335
00336 void SetMaskBand(VRTRasterBand* poMaskBand);
00337
00338 void SetIsMaskBand();
00339
00340 CPLErr UnsetNoDataValue();
00341
00342 virtual int CloseDependentDatasets();
00343
00344 virtual int IsSourcedRasterBand() { return FALSE; }
00345 };
00346
00347
00348
00349
00350
00351 class VRTSimpleSource;
00352
00353 class CPL_DLL VRTSourcedRasterBand : public VRTRasterBand
00354 {
00355 private:
00356 int bAntiRecursionFlag;
00357 CPLString osLastLocationInfo;
00358 char **papszSourceList;
00359
00360 void Initialize( int nXSize, int nYSize );
00361
00362 public:
00363 int nSources;
00364 VRTSource **papoSources;
00365 int bEqualAreas;
00366
00367 VRTSourcedRasterBand( GDALDataset *poDS, int nBand );
00368 VRTSourcedRasterBand( GDALDataType eType,
00369 int nXSize, int nYSize );
00370 VRTSourcedRasterBand( GDALDataset *poDS, int nBand,
00371 GDALDataType eType,
00372 int nXSize, int nYSize );
00373 virtual ~VRTSourcedRasterBand();
00374
00375 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00376 void *, int, int, GDALDataType,
00377 int, int );
00378
00379 virtual const char *GetMetadataItem( const char * pszName,
00380 const char * pszDomain = "" );
00381 virtual char **GetMetadata( const char * pszDomain = "" );
00382 virtual CPLErr SetMetadata( char ** papszMetadata,
00383 const char * pszDomain = "" );
00384 virtual CPLErr SetMetadataItem( const char * pszName,
00385 const char * pszValue,
00386 const char * pszDomain = "" );
00387
00388 virtual CPLErr XMLInit( CPLXMLNode *, const char * );
00389 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath );
00390
00391 virtual double GetMinimum( int *pbSuccess = NULL );
00392 virtual double GetMaximum(int *pbSuccess = NULL );
00393 virtual CPLErr ComputeRasterMinMax( int bApproxOK, double* adfMinMax );
00394 virtual CPLErr ComputeStatistics( int bApproxOK,
00395 double *pdfMin, double *pdfMax,
00396 double *pdfMean, double *pdfStdDev,
00397 GDALProgressFunc pfnProgress, void *pProgressData );
00398 virtual CPLErr GetHistogram( double dfMin, double dfMax,
00399 int nBuckets, int * panHistogram,
00400 int bIncludeOutOfRange, int bApproxOK,
00401 GDALProgressFunc pfnProgress, void *pProgressData );
00402
00403 CPLErr AddSource( VRTSource * );
00404 CPLErr AddSimpleSource( GDALRasterBand *poSrcBand,
00405 int nSrcXOff=-1, int nSrcYOff=-1,
00406 int nSrcXSize=-1, int nSrcYSize=-1,
00407 int nDstXOff=-1, int nDstYOff=-1,
00408 int nDstXSize=-1, int nDstYSize=-1,
00409 const char *pszResampling = "near",
00410 double dfNoDataValue = VRT_NODATA_UNSET);
00411 CPLErr AddComplexSource( GDALRasterBand *poSrcBand,
00412 int nSrcXOff=-1, int nSrcYOff=-1,
00413 int nSrcXSize=-1, int nSrcYSize=-1,
00414 int nDstXOff=-1, int nDstYOff=-1,
00415 int nDstXSize=-1, int nDstYSize=-1,
00416 double dfScaleOff=0.0,
00417 double dfScaleRatio=1.0,
00418 double dfNoDataValue = VRT_NODATA_UNSET,
00419 int nColorTableComponent = 0);
00420
00421 CPLErr AddMaskBandSource( GDALRasterBand *poSrcBand,
00422 int nSrcXOff=-1, int nSrcYOff=-1,
00423 int nSrcXSize=-1, int nSrcYSize=-1,
00424 int nDstXOff=-1, int nDstYOff=-1,
00425 int nDstXSize=-1, int nDstYSize=-1 );
00426
00427 CPLErr AddFuncSource( VRTImageReadFunc pfnReadFunc, void *hCBData,
00428 double dfNoDataValue = VRT_NODATA_UNSET );
00429
00430 void ConfigureSource(VRTSimpleSource *poSimpleSource,
00431 GDALRasterBand *poSrcBand,
00432 int bAddAsMaskBand,
00433 int nSrcXOff, int nSrcYOff,
00434 int nSrcXSize, int nSrcYSize,
00435 int nDstXOff, int nDstYOff,
00436 int nDstXSize, int nDstYSize);
00437
00438 virtual CPLErr IReadBlock( int, int, void * );
00439
00440 virtual void GetFileList(char*** ppapszFileList, int *pnSize,
00441 int *pnMaxSize, CPLHashSet* hSetFiles);
00442
00443 virtual int CloseDependentDatasets();
00444
00445 virtual int IsSourcedRasterBand() { return TRUE; }
00446 };
00447
00448
00449
00450
00451
00452 class CPL_DLL VRTWarpedRasterBand : public VRTRasterBand
00453 {
00454 public:
00455 VRTWarpedRasterBand( GDALDataset *poDS, int nBand,
00456 GDALDataType eType = GDT_Unknown );
00457 virtual ~VRTWarpedRasterBand();
00458
00459 virtual CPLErr XMLInit( CPLXMLNode *, const char * );
00460 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath );
00461
00462 virtual CPLErr IReadBlock( int, int, void * );
00463 virtual CPLErr IWriteBlock( int, int, void * );
00464
00465 virtual int GetOverviewCount();
00466 virtual GDALRasterBand *GetOverview(int);
00467 };
00468
00469
00470
00471
00472
00473 class CPL_DLL VRTDerivedRasterBand : public VRTSourcedRasterBand
00474 {
00475
00476 public:
00477 char *pszFuncName;
00478 GDALDataType eSourceTransferType;
00479
00480 VRTDerivedRasterBand(GDALDataset *poDS, int nBand);
00481 VRTDerivedRasterBand(GDALDataset *poDS, int nBand,
00482 GDALDataType eType, int nXSize, int nYSize);
00483 virtual ~VRTDerivedRasterBand();
00484
00485 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00486 void *, int, int, GDALDataType,
00487 int, int );
00488
00489 static CPLErr AddPixelFunction
00490 (const char *pszFuncName, GDALDerivedPixelFunc pfnPixelFunc);
00491 static GDALDerivedPixelFunc GetPixelFunction(const char *pszFuncName);
00492
00493 void SetPixelFunctionName(const char *pszFuncName);
00494 void SetSourceTransferType(GDALDataType eDataType);
00495
00496 virtual CPLErr XMLInit( CPLXMLNode *, const char * );
00497 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath );
00498
00499 };
00500
00501
00502
00503
00504
00505 class RawRasterBand;
00506
00507 class CPL_DLL VRTRawRasterBand : public VRTRasterBand
00508 {
00509 RawRasterBand *poRawRaster;
00510
00511 char *pszSourceFilename;
00512 int bRelativeToVRT;
00513
00514 public:
00515 VRTRawRasterBand( GDALDataset *poDS, int nBand,
00516 GDALDataType eType = GDT_Unknown );
00517 virtual ~VRTRawRasterBand();
00518
00519 virtual CPLErr XMLInit( CPLXMLNode *, const char * );
00520 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath );
00521
00522 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
00523 void *, int, int, GDALDataType,
00524 int, int );
00525
00526 virtual CPLErr IReadBlock( int, int, void * );
00527 virtual CPLErr IWriteBlock( int, int, void * );
00528
00529 CPLErr SetRawLink( const char *pszFilename,
00530 const char *pszVRTPath,
00531 int bRelativeToVRT,
00532 vsi_l_offset nImageOffset,
00533 int nPixelOffset, int nLineOffset,
00534 const char *pszByteOrder );
00535
00536 void ClearRawLink();
00537
00538 virtual void GetFileList(char*** ppapszFileList, int *pnSize,
00539 int *pnMaxSize, CPLHashSet* hSetFiles);
00540 };
00541
00542
00543
00544
00545
00546 class VRTDriver : public GDALDriver
00547 {
00548 void *pDeserializerData;
00549
00550 public:
00551 VRTDriver();
00552 ~VRTDriver();
00553
00554 char **papszSourceParsers;
00555
00556 virtual char **GetMetadata( const char * pszDomain = "" );
00557 virtual CPLErr SetMetadata( char ** papszMetadata,
00558 const char * pszDomain = "" );
00559
00560 VRTSource *ParseSource( CPLXMLNode *psSrc, const char *pszVRTPath );
00561 void AddSourceParser( const char *pszElementName,
00562 VRTSourceParser pfnParser );
00563 };
00564
00565
00566
00567
00568
00569 class CPL_DLL VRTSimpleSource : public VRTSource
00570 {
00571 protected:
00572 GDALRasterBand *poRasterBand;
00573
00574
00575
00576 GDALRasterBand *poMaskBandMainBand;
00577
00578 int nSrcXOff;
00579 int nSrcYOff;
00580 int nSrcXSize;
00581 int nSrcYSize;
00582
00583 int nDstXOff;
00584 int nDstYOff;
00585 int nDstXSize;
00586 int nDstYSize;
00587
00588 int bNoDataSet;
00589 double dfNoDataValue;
00590
00591 public:
00592 VRTSimpleSource();
00593 virtual ~VRTSimpleSource();
00594
00595 virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * );
00596 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
00597
00598 void SetSrcBand( GDALRasterBand * );
00599 void SetSrcMaskBand( GDALRasterBand * );
00600 void SetSrcWindow( int, int, int, int );
00601 void SetDstWindow( int, int, int, int );
00602 void SetNoDataValue( double dfNoDataValue );
00603
00604 int GetSrcDstWindow( int, int, int, int, int, int,
00605 int *, int *, int *, int *,
00606 int *, int *, int *, int * );
00607
00608 virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
00609 void *pData, int nBufXSize, int nBufYSize,
00610 GDALDataType eBufType,
00611 int nPixelSpace, int nLineSpace );
00612
00613 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
00614 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
00615 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
00616 virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
00617 int bApproxOK,
00618 double *pdfMin, double *pdfMax,
00619 double *pdfMean, double *pdfStdDev,
00620 GDALProgressFunc pfnProgress, void *pProgressData );
00621 virtual CPLErr GetHistogram( int nXSize, int nYSize,
00622 double dfMin, double dfMax,
00623 int nBuckets, int * panHistogram,
00624 int bIncludeOutOfRange, int bApproxOK,
00625 GDALProgressFunc pfnProgress, void *pProgressData );
00626
00627 void DstToSrc( double dfX, double dfY,
00628 double &dfXOut, double &dfYOut );
00629 void SrcToDst( double dfX, double dfY,
00630 double &dfXOut, double &dfYOut );
00631
00632 virtual void GetFileList(char*** ppapszFileList, int *pnSize,
00633 int *pnMaxSize, CPLHashSet* hSetFiles);
00634
00635 virtual int IsSimpleSource() { return TRUE; }
00636 virtual const char* GetType() { return "SimpleSource"; }
00637
00638 GDALRasterBand* GetBand();
00639 int IsSameExceptBandNumber(VRTSimpleSource* poOtherSource);
00640 CPLErr DatasetRasterIO(
00641 int nXOff, int nYOff, int nXSize, int nYSize,
00642 void * pData, int nBufXSize, int nBufYSize,
00643 GDALDataType eBufType,
00644 int nBandCount, int *panBandMap,
00645 int nPixelSpace, int nLineSpace, int nBandSpace);
00646 };
00647
00648
00649
00650
00651
00652 class VRTAveragedSource : public VRTSimpleSource
00653 {
00654 public:
00655 VRTAveragedSource();
00656 virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
00657 void *pData, int nBufXSize, int nBufYSize,
00658 GDALDataType eBufType,
00659 int nPixelSpace, int nLineSpace );
00660
00661 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
00662 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
00663 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
00664 virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
00665 int bApproxOK,
00666 double *pdfMin, double *pdfMax,
00667 double *pdfMean, double *pdfStdDev,
00668 GDALProgressFunc pfnProgress, void *pProgressData );
00669 virtual CPLErr GetHistogram( int nXSize, int nYSize,
00670 double dfMin, double dfMax,
00671 int nBuckets, int * panHistogram,
00672 int bIncludeOutOfRange, int bApproxOK,
00673 GDALProgressFunc pfnProgress, void *pProgressData );
00674
00675 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
00676 virtual const char* GetType() { return "AveragedSource"; }
00677 };
00678
00679
00680
00681
00682
00683 typedef enum
00684 {
00685 VRT_SCALING_NONE,
00686 VRT_SCALING_LINEAR,
00687 VRT_SCALING_EXPONENTIAL,
00688 } VRTComplexSourceScaling;
00689
00690 class CPL_DLL VRTComplexSource : public VRTSimpleSource
00691 {
00692 protected:
00693 VRTComplexSourceScaling eScalingType;
00694 double dfScaleOff;
00695 double dfScaleRatio;
00696
00697
00698 int bSrcMinMaxDefined;
00699 double dfSrcMin;
00700 double dfSrcMax;
00701 double dfDstMin;
00702 double dfDstMax;
00703 double dfExponent;
00704
00705 int nColorTableComponent;
00706
00707 CPLErr RasterIOInternal( int nReqXOff, int nReqYOff,
00708 int nReqXSize, int nReqYSize,
00709 void *pData, int nOutXSize, int nOutYSize,
00710 GDALDataType eBufType,
00711 int nPixelSpace, int nLineSpace );
00712
00713 public:
00714 VRTComplexSource();
00715 virtual ~VRTComplexSource();
00716
00717 virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
00718 void *pData, int nBufXSize, int nBufYSize,
00719 GDALDataType eBufType,
00720 int nPixelSpace, int nLineSpace );
00721
00722 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
00723 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
00724 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
00725 virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
00726 int bApproxOK,
00727 double *pdfMin, double *pdfMax,
00728 double *pdfMean, double *pdfStdDev,
00729 GDALProgressFunc pfnProgress, void *pProgressData );
00730 virtual CPLErr GetHistogram( int nXSize, int nYSize,
00731 double dfMin, double dfMax,
00732 int nBuckets, int * panHistogram,
00733 int bIncludeOutOfRange, int bApproxOK,
00734 GDALProgressFunc pfnProgress, void *pProgressData );
00735
00736 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
00737 virtual CPLErr XMLInit( CPLXMLNode *, const char * );
00738 virtual const char* GetType() { return "ComplexSource"; }
00739
00740 double LookupValue( double dfInput );
00741
00742 void SetLinearScaling(double dfOffset, double dfScale);
00743 void SetPowerScaling(double dfExponent,
00744 double dfSrcMin,
00745 double dfSrcMax,
00746 double dfDstMin,
00747 double dfDstMax);
00748 void SetColorTableComponent(int nComponent);
00749
00750 double *padfLUTInputs;
00751 double *padfLUTOutputs;
00752 int nLUTItemCount;
00753
00754 };
00755
00756
00757
00758
00759
00760 class VRTFilteredSource : public VRTComplexSource
00761 {
00762 private:
00763 int IsTypeSupported( GDALDataType eType );
00764
00765 protected:
00766 int nSupportedTypesCount;
00767 GDALDataType aeSupportedTypes[20];
00768
00769 int nExtraEdgePixels;
00770
00771 public:
00772 VRTFilteredSource();
00773 virtual ~VRTFilteredSource();
00774
00775 void SetExtraEdgePixels( int );
00776 void SetFilteringDataTypesSupported( int, GDALDataType * );
00777
00778 virtual CPLErr FilterData( int nXSize, int nYSize, GDALDataType eType,
00779 GByte *pabySrcData, GByte *pabyDstData ) = 0;
00780
00781 virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
00782 void *pData, int nBufXSize, int nBufYSize,
00783 GDALDataType eBufType,
00784 int nPixelSpace, int nLineSpace );
00785 };
00786
00787
00788
00789
00790
00791 class VRTKernelFilteredSource : public VRTFilteredSource
00792 {
00793 protected:
00794 int nKernelSize;
00795
00796 double *padfKernelCoefs;
00797
00798 int bNormalized;
00799
00800 public:
00801 VRTKernelFilteredSource();
00802 virtual ~VRTKernelFilteredSource();
00803
00804 virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * );
00805 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
00806
00807 virtual CPLErr FilterData( int nXSize, int nYSize, GDALDataType eType,
00808 GByte *pabySrcData, GByte *pabyDstData );
00809
00810 CPLErr SetKernel( int nKernelSize, double *padfCoefs );
00811 void SetNormalized( int );
00812 };
00813
00814
00815
00816
00817
00818 class VRTAverageFilteredSource : public VRTKernelFilteredSource
00819 {
00820 public:
00821 VRTAverageFilteredSource( int nKernelSize );
00822 virtual ~VRTAverageFilteredSource();
00823
00824 virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * );
00825 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
00826 };
00827
00828
00829
00830
00831 class VRTFuncSource : public VRTSource
00832 {
00833 public:
00834 VRTFuncSource();
00835 virtual ~VRTFuncSource();
00836
00837 virtual CPLErr XMLInit( CPLXMLNode *, const char *) { return CE_Failure; }
00838 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
00839
00840 virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
00841 void *pData, int nBufXSize, int nBufYSize,
00842 GDALDataType eBufType,
00843 int nPixelSpace, int nLineSpace );
00844
00845 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
00846 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
00847 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
00848 virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
00849 int bApproxOK,
00850 double *pdfMin, double *pdfMax,
00851 double *pdfMean, double *pdfStdDev,
00852 GDALProgressFunc pfnProgress, void *pProgressData );
00853 virtual CPLErr GetHistogram( int nXSize, int nYSize,
00854 double dfMin, double dfMax,
00855 int nBuckets, int * panHistogram,
00856 int bIncludeOutOfRange, int bApproxOK,
00857 GDALProgressFunc pfnProgress, void *pProgressData );
00858
00859 VRTImageReadFunc pfnReadFunc;
00860 void *pCBData;
00861 GDALDataType eType;
00862
00863 float fNoDataValue;
00864 };
00865
00866 #endif