- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

# vrtdataset.h

    00001 /******************************************************************************
    00002  * $Id: vrtdataset.h 27044 2014-03-16 23:41:27Z rouault $
    00003  *
    00004  * Project:  Virtual GDAL Datasets
    00005  * Purpose:  Declaration of virtual gdal dataset classes.
    00006  * Author:   Frank Warmerdam, warmerdam@pobox.com
    00007  *
    00008  ******************************************************************************
    00009  * Copyright (c) 2001, Frank Warmerdam <warmerdam@pobox.com>
    00010  * Copyright (c) 2007-2013, Even Rouault <even dot rouault at mines-paris dot org>
    00011  *
    00012  * Permission is hereby granted, free of charge, to any person obtaining a
    00013  * copy of this software and associated documentation files (the "Software"),
    00014  * to deal in the Software without restriction, including without limitation
    00015  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
    00016  * and/or sell copies of the Software, and to permit persons to whom the
    00017  * Software is furnished to do so, subject to the following conditions:
    00018  *
    00019  * The above copyright notice and this permission notice shall be included
    00020  * in all copies or substantial portions of the Software.
    00021  *
    00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    00023  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00024  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    00025  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00026  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    00027  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    00028  * DEALINGS IN THE SOFTWARE.
    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 /*                          VRTOverviewInfo()                           */
    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             /* do nothing */;
    00063         else if( poBand->GetDataset()->GetShared() )
    00064             GDALClose( (GDALDatasetH) poBand->GetDataset() );
    00065         else
    00066             poBand->GetDataset()->Dereference();
    00067     }
    00068 };
    00069
    00070
    00071 /************************************************************************/
    00072 /*                              VRTSource                               */
    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 /*                              VRTDataset                              */
    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     /* Used by PDF driver for example */
    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 /*                           VRTWarpedDataset                           */
    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( /* GDALWarpOptions */ 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 /*                            VRTRasterBand                             */
    00245 /*                                                                      */
    00246 /*      Provides support for all the various kinds of metadata but      */
    00247 /*      no raster access.  That is handled by derived classes.          */
    00248 /************************************************************************/
    00249
    00250 class CPL_DLL VRTRasterBand : public GDALRasterBand
    00251 {
    00252   protected:
    00253     int            bIsMaskBand;
    00254
    00255     int            bNoDataValueSet;
    00256     int            bHideNoDataValue; // If set to true, will not report the existance of nodata
    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 /*                         VRTSourcedRasterBand                         */
    00350 /************************************************************************/
    00351
    00352 class VRTSimpleSource;
    00353
    00354 class CPL_DLL VRTSourcedRasterBand : public VRTRasterBand
    00355 {
    00356   private:
    00357     int            bAntiRecursionFlag;
    00358     CPLString      osLastLocationInfo;
    00359     char         **papszSourceList;
    00360
    00361     void           Initialize( int nXSize, int nYSize );
    00362
    00363   public:
    00364     int            nSources;
    00365     VRTSource    **papoSources;
    00366     int            bEqualAreas;
    00367
    00368                    VRTSourcedRasterBand( GDALDataset *poDS, int nBand );
    00369                    VRTSourcedRasterBand( GDALDataType eType,
    00370                                          int nXSize, int nYSize );
    00371                    VRTSourcedRasterBand( GDALDataset *poDS, int nBand,
    00372                                          GDALDataType eType,
    00373                                          int nXSize, int nYSize );
    00374     virtual        ~VRTSourcedRasterBand();
    00375
    00376     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
    00377                               void *, int, int, GDALDataType,
    00378                               int, int );
    00379
    00380     virtual char      **GetMetadataDomainList();
    00381     virtual const char *GetMetadataItem( const char * pszName,
    00382                                          const char * pszDomain = "" );
    00383     virtual char      **GetMetadata( const char * pszDomain = "" );
    00384     virtual CPLErr      SetMetadata( char ** papszMetadata,
    00385                                      const char * pszDomain = "" );
    00386     virtual CPLErr      SetMetadataItem( const char * pszName,
    00387                                          const char * pszValue,
    00388                                          const char * pszDomain = "" );
    00389
    00390     virtual CPLErr         XMLInit( CPLXMLNode *, const char * );
    00391     virtual CPLXMLNode *   SerializeToXML( const char *pszVRTPath );
    00392
    00393     virtual double GetMinimum( int *pbSuccess = NULL );
    00394     virtual double GetMaximum(int *pbSuccess = NULL );
    00395     virtual CPLErr ComputeRasterMinMax( int bApproxOK, double* adfMinMax );
    00396     virtual CPLErr ComputeStatistics( int bApproxOK,
    00397                                       double *pdfMin, double *pdfMax,
    00398                                       double *pdfMean, double *pdfStdDev,
    00399                                       GDALProgressFunc pfnProgress, void *pProgressData );
    00400     virtual CPLErr  GetHistogram( double dfMin, double dfMax,
    00401                                   int nBuckets, int * panHistogram,
    00402                                   int bIncludeOutOfRange, int bApproxOK,
    00403                                   GDALProgressFunc pfnProgress, void *pProgressData );
    00404
    00405     CPLErr         AddSource( VRTSource * );
    00406     CPLErr         AddSimpleSource( GDALRasterBand *poSrcBand,
    00407                                     int nSrcXOff=-1, int nSrcYOff=-1,
    00408                                     int nSrcXSize=-1, int nSrcYSize=-1,
    00409                                     int nDstXOff=-1, int nDstYOff=-1,
    00410                                     int nDstXSize=-1, int nDstYSize=-1,
    00411                                     const char *pszResampling = "near",
    00412                                     double dfNoDataValue = VRT_NODATA_UNSET);
    00413     CPLErr         AddComplexSource( GDALRasterBand *poSrcBand,
    00414                                      int nSrcXOff=-1, int nSrcYOff=-1,
    00415                                      int nSrcXSize=-1, int nSrcYSize=-1,
    00416                                      int nDstXOff=-1, int nDstYOff=-1,
    00417                                      int nDstXSize=-1, int nDstYSize=-1,
    00418                                      double dfScaleOff=0.0,
    00419                                      double dfScaleRatio=1.0,
    00420                                      double dfNoDataValue = VRT_NODATA_UNSET,
    00421                                      int nColorTableComponent = 0);
    00422
    00423     CPLErr         AddMaskBandSource( GDALRasterBand *poSrcBand,
    00424                                       int nSrcXOff=-1, int nSrcYOff=-1,
    00425                                       int nSrcXSize=-1, int nSrcYSize=-1,
    00426                                       int nDstXOff=-1, int nDstYOff=-1,
    00427                                       int nDstXSize=-1, int nDstYSize=-1 );
    00428
    00429     CPLErr         AddFuncSource( VRTImageReadFunc pfnReadFunc, void *hCBData,
    00430                                   double dfNoDataValue = VRT_NODATA_UNSET );
    00431
    00432     void           ConfigureSource(VRTSimpleSource *poSimpleSource,
    00433                                            GDALRasterBand *poSrcBand,
    00434                                            int bAddAsMaskBand,
    00435                                            int nSrcXOff, int nSrcYOff,
    00436                                            int nSrcXSize, int nSrcYSize,
    00437                                            int nDstXOff, int nDstYOff,
    00438                                            int nDstXSize, int nDstYSize);
    00439
    00440     virtual CPLErr IReadBlock( int, int, void * );
    00441
    00442     virtual void   GetFileList(char*** ppapszFileList, int *pnSize,
    00443                                int *pnMaxSize, CPLHashSet* hSetFiles);
    00444
    00445     virtual int         CloseDependentDatasets();
    00446
    00447     virtual int         IsSourcedRasterBand() { return TRUE; }
    00448 };
    00449
    00450 /************************************************************************/
    00451 /*                         VRTWarpedRasterBand                          */
    00452 /************************************************************************/
    00453
    00454 class CPL_DLL VRTWarpedRasterBand : public VRTRasterBand
    00455 {
    00456   public:
    00457                    VRTWarpedRasterBand( GDALDataset *poDS, int nBand,
    00458                                      GDALDataType eType = GDT_Unknown );
    00459     virtual        ~VRTWarpedRasterBand();
    00460
    00461     virtual CPLErr         XMLInit( CPLXMLNode *, const char * );
    00462     virtual CPLXMLNode *   SerializeToXML( const char *pszVRTPath );
    00463
    00464     virtual CPLErr IReadBlock( int, int, void * );
    00465     virtual CPLErr IWriteBlock( int, int, void * );
    00466
    00467     virtual int GetOverviewCount();
    00468     virtual GDALRasterBand *GetOverview(int);
    00469 };
    00470
    00471 /************************************************************************/
    00472 /*                         VRTDerivedRasterBand                         */
    00473 /************************************************************************/
    00474
    00475 class CPL_DLL VRTDerivedRasterBand : public VRTSourcedRasterBand
    00476 {
    00477
    00478  public:
    00479     char *pszFuncName;
    00480     GDALDataType eSourceTransferType;
    00481
    00482     VRTDerivedRasterBand(GDALDataset *poDS, int nBand);
    00483     VRTDerivedRasterBand(GDALDataset *poDS, int nBand,
    00484                          GDALDataType eType, int nXSize, int nYSize);
    00485     virtual        ~VRTDerivedRasterBand();
    00486
    00487     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
    00488                               void *, int, int, GDALDataType,
    00489                               int, int );
    00490
    00491     static CPLErr AddPixelFunction
    00492         (const char *pszFuncName, GDALDerivedPixelFunc pfnPixelFunc);
    00493     static GDALDerivedPixelFunc GetPixelFunction(const char *pszFuncName);
    00494
    00495     void SetPixelFunctionName(const char *pszFuncName);
    00496     void SetSourceTransferType(GDALDataType eDataType);
    00497
    00498     virtual CPLErr         XMLInit( CPLXMLNode *, const char * );
    00499     virtual CPLXMLNode *   SerializeToXML( const char *pszVRTPath );
    00500
    00501 };
    00502
    00503 /************************************************************************/
    00504 /*                           VRTRawRasterBand                           */
    00505 /************************************************************************/
    00506
    00507 class RawRasterBand;
    00508
    00509 class CPL_DLL VRTRawRasterBand : public VRTRasterBand
    00510 {
    00511     RawRasterBand  *poRawRaster;
    00512
    00513     char           *pszSourceFilename;
    00514     int            bRelativeToVRT;
    00515
    00516   public:
    00517                    VRTRawRasterBand( GDALDataset *poDS, int nBand,
    00518                                      GDALDataType eType = GDT_Unknown );
    00519     virtual        ~VRTRawRasterBand();
    00520
    00521     virtual CPLErr         XMLInit( CPLXMLNode *, const char * );
    00522     virtual CPLXMLNode *   SerializeToXML( const char *pszVRTPath );
    00523
    00524     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
    00525                               void *, int, int, GDALDataType,
    00526                               int, int );
    00527
    00528     virtual CPLErr IReadBlock( int, int, void * );
    00529     virtual CPLErr IWriteBlock( int, int, void * );
    00530
    00531     CPLErr         SetRawLink( const char *pszFilename,
    00532                                const char *pszVRTPath,
    00533                                int bRelativeToVRT,
    00534                                vsi_l_offset nImageOffset,
    00535                                int nPixelOffset, int nLineOffset,
    00536                                const char *pszByteOrder );
    00537
    00538     void           ClearRawLink();
    00539
    00540     virtual void   GetFileList(char*** ppapszFileList, int *pnSize,
    00541                                int *pnMaxSize, CPLHashSet* hSetFiles);
    00542 };
    00543
    00544 /************************************************************************/
    00545 /*                              VRTDriver                               */
    00546 /************************************************************************/
    00547
    00548 class VRTDriver : public GDALDriver
    00549 {
    00550     void        *pDeserializerData;
    00551
    00552   public:
    00553                  VRTDriver();
    00554                  ~VRTDriver();
    00555
    00556     char         **papszSourceParsers;
    00557
    00558     virtual char      **GetMetadataDomainList();
    00559     virtual char      **GetMetadata( const char * pszDomain = "" );
    00560     virtual CPLErr      SetMetadata( char ** papszMetadata,
    00561                                      const char * pszDomain = "" );
    00562
    00563     VRTSource   *ParseSource( CPLXMLNode *psSrc, const char *pszVRTPath );
    00564     void         AddSourceParser( const char *pszElementName,
    00565                                   VRTSourceParser pfnParser );
    00566 };
    00567
    00568 /************************************************************************/
    00569 /*                           VRTSimpleSource                            */
    00570 /************************************************************************/
    00571
    00572 class CPL_DLL VRTSimpleSource : public VRTSource
    00573 {
    00574 protected:
    00575     GDALRasterBand      *poRasterBand;
    00576
    00577     /* when poRasterBand is a mask band, poMaskBandMainBand is the band */
    00578     /* from which the mask band is taken */
    00579     GDALRasterBand      *poMaskBandMainBand;
    00580
    00581     int                 nSrcXOff;
    00582     int                 nSrcYOff;
    00583     int                 nSrcXSize;
    00584     int                 nSrcYSize;
    00585
    00586     int                 nDstXOff;
    00587     int                 nDstYOff;
    00588     int                 nDstXSize;
    00589     int                 nDstYSize;
    00590
    00591     int                 bNoDataSet;
    00592     double              dfNoDataValue;
    00593
    00594 public:
    00595             VRTSimpleSource();
    00596     virtual ~VRTSimpleSource();
    00597
    00598     virtual CPLErr  XMLInit( CPLXMLNode *psTree, const char * );
    00599     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
    00600
    00601     void           SetSrcBand( GDALRasterBand * );
    00602     void           SetSrcMaskBand( GDALRasterBand * );
    00603     void           SetSrcWindow( int, int, int, int );
    00604     void           SetDstWindow( int, int, int, int );
    00605     void           SetNoDataValue( double dfNoDataValue );
    00606
    00607     int            GetSrcDstWindow( int, int, int, int, int, int,
    00608                                     int *, int *, int *, int *,
    00609                                     int *, int *, int *, int * );
    00610
    00611     virtual CPLErr  RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
    00612                               void *pData, int nBufXSize, int nBufYSize,
    00613                               GDALDataType eBufType,
    00614                               int nPixelSpace, int nLineSpace );
    00615
    00616     virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
    00617     virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
    00618     virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
    00619     virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
    00620                                       int bApproxOK,
    00621                                       double *pdfMin, double *pdfMax,
    00622                                       double *pdfMean, double *pdfStdDev,
    00623                                       GDALProgressFunc pfnProgress, void *pProgressData );
    00624     virtual CPLErr  GetHistogram( int nXSize, int nYSize,
    00625                                   double dfMin, double dfMax,
    00626                                   int nBuckets, int * panHistogram,
    00627                                   int bIncludeOutOfRange, int bApproxOK,
    00628                                   GDALProgressFunc pfnProgress, void *pProgressData );
    00629
    00630     void            DstToSrc( double dfX, double dfY,
    00631                               double &dfXOut, double &dfYOut );
    00632     void            SrcToDst( double dfX, double dfY,
    00633                               double &dfXOut, double &dfYOut );
    00634
    00635     virtual void   GetFileList(char*** ppapszFileList, int *pnSize,
    00636                                int *pnMaxSize, CPLHashSet* hSetFiles);
    00637
    00638     virtual int    IsSimpleSource() { return TRUE; }
    00639     virtual const char* GetType() { return "SimpleSource"; }
    00640
    00641     GDALRasterBand* GetBand();
    00642     int             IsSameExceptBandNumber(VRTSimpleSource* poOtherSource);
    00643     CPLErr          DatasetRasterIO(
    00644                                int nXOff, int nYOff, int nXSize, int nYSize,
    00645                                void * pData, int nBufXSize, int nBufYSize,
    00646                                GDALDataType eBufType,
    00647                                int nBandCount, int *panBandMap,
    00648                                int nPixelSpace, int nLineSpace, int nBandSpace);
    00649 };
    00650
    00651 /************************************************************************/
    00652 /*                          VRTAveragedSource                           */
    00653 /************************************************************************/
    00654
    00655 class VRTAveragedSource : public VRTSimpleSource
    00656 {
    00657 public:
    00658                     VRTAveragedSource();
    00659     virtual CPLErr  RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
    00660                               void *pData, int nBufXSize, int nBufYSize,
    00661                               GDALDataType eBufType,
    00662                               int nPixelSpace, int nLineSpace );
    00663
    00664     virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
    00665     virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
    00666     virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
    00667     virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
    00668                                       int bApproxOK,
    00669                                       double *pdfMin, double *pdfMax,
    00670                                       double *pdfMean, double *pdfStdDev,
    00671                                       GDALProgressFunc pfnProgress, void *pProgressData );
    00672     virtual CPLErr  GetHistogram( int nXSize, int nYSize,
    00673                                   double dfMin, double dfMax,
    00674                                   int nBuckets, int * panHistogram,
    00675                                   int bIncludeOutOfRange, int bApproxOK,
    00676                                   GDALProgressFunc pfnProgress, void *pProgressData );
    00677
    00678     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
    00679     virtual const char* GetType() { return "AveragedSource"; }
    00680 };
    00681
    00682 /************************************************************************/
    00683 /*                           VRTComplexSource                           */
    00684 /************************************************************************/
    00685
    00686 typedef enum
    00687 {
    00688     VRT_SCALING_NONE,
    00689     VRT_SCALING_LINEAR,
    00690     VRT_SCALING_EXPONENTIAL,
    00691 } VRTComplexSourceScaling;
    00692
    00693 class CPL_DLL VRTComplexSource : public VRTSimpleSource
    00694 {
    00695 protected:
    00696     VRTComplexSourceScaling eScalingType;
    00697     double         dfScaleOff; /* for linear scaling */
    00698     double         dfScaleRatio; /* for linear scaling */
    00699
    00700     /* For non-linear scaling with a power function. */
    00701     int            bSrcMinMaxDefined;
    00702     double         dfSrcMin;
    00703     double         dfSrcMax;
    00704     double         dfDstMin;
    00705     double         dfDstMax;
    00706     double         dfExponent;
    00707
    00708     int            nColorTableComponent;
    00709
    00710     CPLErr          RasterIOInternal( int nReqXOff, int nReqYOff,
    00711                                       int nReqXSize, int nReqYSize,
    00712                                       void *pData, int nOutXSize, int nOutYSize,
    00713                                       GDALDataType eBufType,
    00714                                       int nPixelSpace, int nLineSpace );
    00715
    00716 public:
    00717                    VRTComplexSource();
    00718     virtual        ~VRTComplexSource();
    00719
    00720     virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
    00721                              void *pData, int nBufXSize, int nBufYSize,
    00722                              GDALDataType eBufType,
    00723                              int nPixelSpace, int nLineSpace );
    00724
    00725     virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
    00726     virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
    00727     virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
    00728     virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
    00729                                       int bApproxOK,
    00730                                       double *pdfMin, double *pdfMax,
    00731                                       double *pdfMean, double *pdfStdDev,
    00732                                       GDALProgressFunc pfnProgress, void *pProgressData );
    00733     virtual CPLErr  GetHistogram( int nXSize, int nYSize,
    00734                                   double dfMin, double dfMax,
    00735                                   int nBuckets, int * panHistogram,
    00736                                   int bIncludeOutOfRange, int bApproxOK,
    00737                                   GDALProgressFunc pfnProgress, void *pProgressData );
    00738
    00739     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
    00740     virtual CPLErr XMLInit( CPLXMLNode *, const char * );
    00741     virtual const char* GetType() { return "ComplexSource"; }
    00742
    00743     double  LookupValue( double dfInput );
    00744
    00745     void    SetLinearScaling(double dfOffset, double dfScale);
    00746     void    SetPowerScaling(double dfExponent,
    00747                             double dfSrcMin,
    00748                             double dfSrcMax,
    00749                             double dfDstMin,
    00750                             double dfDstMax);
    00751     void    SetColorTableComponent(int nComponent);
    00752
    00753     double         *padfLUTInputs;
    00754     double         *padfLUTOutputs;
    00755     int            nLUTItemCount;
    00756
    00757 };
    00758
    00759 /************************************************************************/
    00760 /*                           VRTFilteredSource                          */
    00761 /************************************************************************/
    00762
    00763 class VRTFilteredSource : public VRTComplexSource
    00764 {
    00765 private:
    00766     int          IsTypeSupported( GDALDataType eType );
    00767
    00768 protected:
    00769     int          nSupportedTypesCount;
    00770     GDALDataType aeSupportedTypes[20];
    00771
    00772     int          nExtraEdgePixels;
    00773
    00774 public:
    00775             VRTFilteredSource();
    00776     virtual ~VRTFilteredSource();
    00777
    00778     void    SetExtraEdgePixels( int );
    00779     void    SetFilteringDataTypesSupported( int, GDALDataType * );
    00780
    00781     virtual CPLErr  FilterData( int nXSize, int nYSize, GDALDataType eType,
    00782                                 GByte *pabySrcData, GByte *pabyDstData ) = 0;
    00783
    00784     virtual CPLErr  RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
    00785                               void *pData, int nBufXSize, int nBufYSize,
    00786                               GDALDataType eBufType,
    00787                               int nPixelSpace, int nLineSpace );
    00788 };
    00789
    00790 /************************************************************************/
    00791 /*                       VRTKernelFilteredSource                        */
    00792 /************************************************************************/
    00793
    00794 class VRTKernelFilteredSource : public VRTFilteredSource
    00795 {
    00796 protected:
    00797     int     nKernelSize;
    00798
    00799     double  *padfKernelCoefs;
    00800
    00801     int     bNormalized;
    00802
    00803 public:
    00804             VRTKernelFilteredSource();
    00805     virtual ~VRTKernelFilteredSource();
    00806
    00807     virtual CPLErr  XMLInit( CPLXMLNode *psTree, const char * );
    00808     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
    00809
    00810     virtual CPLErr  FilterData( int nXSize, int nYSize, GDALDataType eType,
    00811                                 GByte *pabySrcData, GByte *pabyDstData );
    00812
    00813     CPLErr          SetKernel( int nKernelSize, double *padfCoefs );
    00814     void            SetNormalized( int );
    00815 };
    00816
    00817 /************************************************************************/
    00818 /*                       VRTAverageFilteredSource                       */
    00819 /************************************************************************/
    00820
    00821 class VRTAverageFilteredSource : public VRTKernelFilteredSource
    00822 {
    00823 public:
    00824             VRTAverageFilteredSource( int nKernelSize );
    00825     virtual ~VRTAverageFilteredSource();
    00826
    00827     virtual CPLErr  XMLInit( CPLXMLNode *psTree, const char * );
    00828     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
    00829 };
    00830
    00831 /************************************************************************/
    00832 /*                            VRTFuncSource                             */
    00833 /************************************************************************/
    00834 class VRTFuncSource : public VRTSource
    00835 {
    00836 public:
    00837             VRTFuncSource();
    00838     virtual ~VRTFuncSource();
    00839
    00840     virtual CPLErr  XMLInit( CPLXMLNode *, const char *) { return CE_Failure; }
    00841     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
    00842
    00843     virtual CPLErr  RasterIO( int nXOff, int nYOff, int nXSize, int nYSize,
    00844                               void *pData, int nBufXSize, int nBufYSize,
    00845                               GDALDataType eBufType,
    00846                               int nPixelSpace, int nLineSpace );
    00847
    00848     virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
    00849     virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
    00850     virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
    00851     virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
    00852                                       int bApproxOK,
    00853                                       double *pdfMin, double *pdfMax,
    00854                                       double *pdfMean, double *pdfStdDev,
    00855                                       GDALProgressFunc pfnProgress, void *pProgressData );
    00856     virtual CPLErr  GetHistogram( int nXSize, int nYSize,
    00857                                   double dfMin, double dfMax,
    00858                                   int nBuckets, int * panHistogram,
    00859                                   int bIncludeOutOfRange, int bApproxOK,
    00860                                   GDALProgressFunc pfnProgress, void *pProgressData );
    00861
    00862     VRTImageReadFunc    pfnReadFunc;
    00863     void               *pCBData;
    00864     GDALDataType        eType;
    00865
    00866     float               fNoDataValue;
    00867 };
    00868
    00869 #endif /* ndef VIRTUALDATASET_H_INCLUDED */

Generated for GDAL by 1.7.1.