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