LCOV - code coverage report
Current view: directory - frmts/vrt - vrtdataset.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 19 15 78.9 %
Date: 2013-03-30 Functions: 16 11 68.8 %

       1                 : /******************************************************************************
       2                 :  * $Id: vrtdataset.h 25569 2013-01-26 22:32:26Z rouault $
       3                 :  *
       4                 :  * Project:  Virtual GDAL Datasets
       5                 :  * Purpose:  Declaration of virtual gdal dataset classes.
       6                 :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2001, Frank Warmerdam <warmerdam@pobox.com>
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  *
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  *
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : #ifndef VIRTUALDATASET_H_INCLUDED
      31                 : #define VIRTUALDATASET_H_INCLUDED
      32                 : 
      33                 : #include "gdal_priv.h"
      34                 : #include "gdal_pam.h"
      35                 : #include "gdal_vrt.h"
      36                 : #include "cpl_hash_set.h"
      37                 : 
      38                 : int VRTApplyMetadata( CPLXMLNode *, GDALMajorObject * );
      39                 : CPLXMLNode *VRTSerializeMetadata( GDALMajorObject * );
      40                 : 
      41                 : int VRTWarpedOverviewTransform( void *pTransformArg, int bDstToSrc,
      42                 :                                 int nPointCount,
      43                 :                                 double *padfX, double *padfY, double *padfZ,
      44                 :                                 int *panSuccess );
      45                 : void* VRTDeserializeWarpedOverviewTransformer( CPLXMLNode *psTree );
      46                 : 
      47                 : /************************************************************************/
      48                 : /*                          VRTOverviewInfo()                           */
      49                 : /************************************************************************/
      50                 : class VRTOverviewInfo
      51               9 : {
      52                 : public:
      53                 :     CPLString       osFilename;
      54                 :     int             nBand;
      55                 :     GDALRasterBand *poBand;
      56                 :     int             bTriedToOpen;
      57                 :     
      58               9 :     VRTOverviewInfo() : poBand(NULL), bTriedToOpen(FALSE) {}
      59              18 :     ~VRTOverviewInfo() {
      60              18 :         if( poBand == NULL ) 
      61                 :             /* do nothing */;
      62               5 :         else if( poBand->GetDataset()->GetShared() )
      63               5 :             GDALClose( (GDALDatasetH) poBand->GetDataset() );
      64                 :         else
      65               0 :             poBand->GetDataset()->Dereference();
      66              18 :     }
      67                 : };
      68                 : 
      69                 : 
      70                 : /************************************************************************/
      71                 : /*                              VRTSource                               */
      72                 : /************************************************************************/
      73                 : 
      74                 : class VRTSource 
      75            5564 : {
      76                 : public:
      77                 :     virtual ~VRTSource();
      78                 : 
      79                 :     virtual CPLErr  RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 
      80                 :                               void *pData, int nBufXSize, int nBufYSize, 
      81                 :                               GDALDataType eBufType, 
      82                 :                               int nPixelSpace, int nLineSpace ) = 0;
      83                 : 
      84                 :     virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) = 0;
      85                 :     virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) = 0;
      86                 :     virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax ) = 0;
      87                 :     virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
      88                 :                                       int bApproxOK, 
      89                 :                                       double *pdfMin, double *pdfMax, 
      90                 :                                       double *pdfMean, double *pdfStdDev,
      91                 :                                       GDALProgressFunc pfnProgress, void *pProgressData ) = 0;
      92                 :     virtual CPLErr  GetHistogram( int nXSize, int nYSize,
      93                 :                                   double dfMin, double dfMax,
      94                 :                                   int nBuckets, int * panHistogram,
      95                 :                                   int bIncludeOutOfRange, int bApproxOK,
      96                 :                                   GDALProgressFunc pfnProgress, void *pProgressData ) = 0;
      97                 : 
      98                 :     virtual CPLErr  XMLInit( CPLXMLNode *psTree, const char * ) = 0;
      99                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) = 0;
     100                 :     
     101                 :     virtual void   GetFileList(char*** ppapszFileList, int *pnSize,
     102                 :                                int *pnMaxSize, CPLHashSet* hSetFiles);
     103                 : 
     104               0 :     virtual int    IsSimpleSource() { return FALSE; }
     105                 : };
     106                 : 
     107                 : typedef VRTSource *(*VRTSourceParser)(CPLXMLNode *, const char *);
     108                 : 
     109                 : VRTSource *VRTParseCoreSources( CPLXMLNode *psTree, const char * );
     110                 : VRTSource *VRTParseFilterSources( CPLXMLNode *psTree, const char * );
     111                 : 
     112                 : /************************************************************************/
     113                 : /*                              VRTDataset                              */
     114                 : /************************************************************************/
     115                 : 
     116                 : class VRTRasterBand;
     117                 : 
     118                 : class CPL_DLL VRTDataset : public GDALDataset
     119                 : {
     120                 :     friend class VRTRasterBand;
     121                 : 
     122                 :     char           *pszProjection;
     123                 : 
     124                 :     int            bGeoTransformSet;
     125                 :     double         adfGeoTransform[6];
     126                 : 
     127                 :     int           nGCPCount;
     128                 :     GDAL_GCP      *pasGCPList;
     129                 :     char          *pszGCPProjection;
     130                 : 
     131                 :     int            bNeedsFlush;
     132                 :     int            bWritable;
     133                 :     
     134                 :     char          *pszVRTPath;
     135                 : 
     136                 :     VRTRasterBand *poMaskBand;
     137                 : 
     138                 :     int            bCompatibleForDatasetIO;
     139                 :     int            CheckCompatibleForDatasetIO();
     140                 : 
     141                 :   protected:
     142                 :     virtual int         CloseDependentDatasets();
     143                 : 
     144                 :   public:
     145                 :                  VRTDataset(int nXSize, int nYSize);
     146                 :                 ~VRTDataset();
     147                 : 
     148            9644 :     void          SetNeedsFlush() { bNeedsFlush = TRUE; }
     149                 :     virtual void  FlushCache();
     150                 :     
     151                 :     void SetWritable(int bWritable) { this->bWritable = bWritable; }
     152                 : 
     153                 :     virtual CPLErr          CreateMaskBand( int nFlags );
     154                 :     void SetMaskBand(VRTRasterBand* poMaskBand);
     155                 : 
     156                 :     virtual const char *GetProjectionRef(void);
     157                 :     virtual CPLErr SetProjection( const char * );
     158                 :     virtual CPLErr GetGeoTransform( double * );
     159                 :     virtual CPLErr SetGeoTransform( double * );
     160                 : 
     161                 :     virtual CPLErr SetMetadata( char **papszMD, const char *pszDomain = "" );
     162                 :     virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue,
     163                 :                                     const char *pszDomain = "" );
     164                 : 
     165                 :     virtual int    GetGCPCount();
     166                 :     virtual const char *GetGCPProjection();
     167                 :     virtual const GDAL_GCP *GetGCPs();
     168                 :     virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
     169                 :                             const char *pszGCPProjection );
     170                 : 
     171                 :     virtual CPLErr AddBand( GDALDataType eType, 
     172                 :                             char **papszOptions=NULL );
     173                 :                             
     174                 :     virtual char      **GetFileList();
     175                 : 
     176                 :     virtual CPLErr  IRasterIO( GDALRWFlag eRWFlag,
     177                 :                                int nXOff, int nYOff, int nXSize, int nYSize,
     178                 :                                void * pData, int nBufXSize, int nBufYSize,
     179                 :                                GDALDataType eBufType,
     180                 :                                int nBandCount, int *panBandMap,
     181                 :                                int nPixelSpace, int nLineSpace, int nBandSpace);
     182                 : 
     183                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath);
     184                 :     virtual CPLErr      XMLInit( CPLXMLNode *, const char * );
     185                 : 
     186                 :     /* Used by PDF driver for example */
     187                 :     GDALDataset*        GetSingleSimpleSource();
     188                 :  
     189                 :     static int          Identify( GDALOpenInfo * );
     190                 :     static GDALDataset *Open( GDALOpenInfo * );
     191                 :     static GDALDataset *OpenXML( const char *, const char * = NULL, GDALAccess eAccess = GA_ReadOnly );
     192                 :     static GDALDataset *Create( const char * pszName,
     193                 :                                 int nXSize, int nYSize, int nBands,
     194                 :                                 GDALDataType eType, char ** papszOptions );
     195                 :     static CPLErr       Delete( const char * pszFilename );
     196                 : };
     197                 : 
     198                 : /************************************************************************/
     199                 : /*                           VRTWarpedDataset                           */
     200                 : /************************************************************************/
     201                 : 
     202                 : class GDALWarpOperation;
     203                 : class VRTWarpedRasterBand;
     204                 : 
     205                 : class CPL_DLL VRTWarpedDataset : public VRTDataset
     206                 : {
     207                 :     int               nBlockXSize;
     208                 :     int               nBlockYSize;
     209                 :     GDALWarpOperation *poWarper;
     210                 : 
     211                 :     friend class VRTWarpedRasterBand;
     212                 : 
     213                 :   protected:
     214                 :     virtual int         CloseDependentDatasets();
     215                 : 
     216                 : public:
     217                 :     int               nOverviewCount;
     218                 :     VRTWarpedDataset  **papoOverviews;
     219                 : 
     220                 : public:
     221                 :                       VRTWarpedDataset( int nXSize, int nYSize );
     222                 :                      ~VRTWarpedDataset();
     223                 : 
     224                 :     CPLErr            Initialize( /* GDALWarpOptions */ void * );
     225                 : 
     226                 :     virtual CPLErr IBuildOverviews( const char *, int, int *,
     227                 :                                     int, int *, GDALProgressFunc, void * );
     228                 :     
     229                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     230                 :     virtual CPLErr    XMLInit( CPLXMLNode *, const char * );
     231                 : 
     232                 :     virtual CPLErr AddBand( GDALDataType eType, 
     233                 :                             char **papszOptions=NULL );
     234                 :                             
     235                 :     virtual char      **GetFileList();
     236                 :     
     237                 :     CPLErr            ProcessBlock( int iBlockX, int iBlockY );
     238                 : 
     239                 :     void              GetBlockSize( int *, int * );
     240                 : };
     241                 : 
     242                 : /************************************************************************/
     243                 : /*                            VRTRasterBand                             */
     244                 : /*                                                                      */
     245                 : /*      Provides support for all the various kinds of metadata but      */
     246                 : /*      no raster access.  That is handled by derived classes.          */
     247                 : /************************************************************************/
     248                 : 
     249                 : class CPL_DLL VRTRasterBand : public GDALRasterBand
     250                 : {
     251                 :   protected:
     252                 :     int            bIsMaskBand;
     253                 : 
     254                 :     int            bNoDataValueSet;
     255                 :     int            bHideNoDataValue; // If set to true, will not report the existance of nodata
     256                 :     double         dfNoDataValue;
     257                 : 
     258                 :     GDALColorTable *poColorTable;
     259                 : 
     260                 :     GDALColorInterp eColorInterp;
     261                 : 
     262                 :     char           *pszUnitType;
     263                 :     char           **papszCategoryNames;
     264                 :     
     265                 :     double         dfOffset;
     266                 :     double         dfScale;
     267                 : 
     268                 :     CPLXMLNode    *psSavedHistograms;
     269                 : 
     270                 :     void           Initialize( int nXSize, int nYSize );
     271                 : 
     272                 :     std::vector<VRTOverviewInfo> apoOverviews;
     273                 : 
     274                 :     VRTRasterBand *poMaskBand;
     275                 : 
     276                 :   public:
     277                 : 
     278                 :                     VRTRasterBand();
     279                 :     virtual        ~VRTRasterBand();
     280                 : 
     281                 :     virtual CPLErr         XMLInit( CPLXMLNode *, const char * );
     282                 :     virtual CPLXMLNode *   SerializeToXML( const char *pszVRTPath );
     283                 : 
     284                 :     virtual CPLErr SetNoDataValue( double );
     285                 :     virtual double GetNoDataValue( int *pbSuccess = NULL );
     286                 : 
     287                 :     virtual CPLErr SetColorTable( GDALColorTable * ); 
     288                 :     virtual GDALColorTable *GetColorTable();
     289                 : 
     290                 :     virtual CPLErr SetColorInterpretation( GDALColorInterp );
     291                 :     virtual GDALColorInterp GetColorInterpretation();
     292                 : 
     293                 :     virtual const char *GetUnitType();
     294                 :     CPLErr SetUnitType( const char * ); 
     295                 : 
     296                 :     virtual char **GetCategoryNames();
     297                 :     virtual CPLErr SetCategoryNames( char ** );
     298                 : 
     299                 :     virtual CPLErr SetMetadata( char **papszMD, const char *pszDomain = "" );
     300                 :     virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue,
     301                 :                                     const char *pszDomain = "" );
     302                 : 
     303                 :     virtual double GetOffset( int *pbSuccess = NULL );
     304                 :     CPLErr SetOffset( double );
     305                 :     virtual double GetScale( int *pbSuccess = NULL );
     306                 :     CPLErr SetScale( double );
     307                 : 
     308                 :     virtual int GetOverviewCount();
     309                 :     virtual GDALRasterBand *GetOverview(int);
     310                 :     
     311                 :     virtual CPLErr  GetHistogram( double dfMin, double dfMax,
     312                 :                           int nBuckets, int * panHistogram,
     313                 :                           int bIncludeOutOfRange, int bApproxOK,
     314                 :                           GDALProgressFunc, void *pProgressData );
     315                 : 
     316                 :     virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
     317                 :                                         int *pnBuckets, int ** ppanHistogram,
     318                 :                                         int bForce,
     319                 :                                         GDALProgressFunc, void *pProgressData);
     320                 : 
     321                 :     virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
     322                 :                                         int nBuckets, int *panHistogram );
     323                 : 
     324                 :     CPLErr         CopyCommonInfoFrom( GDALRasterBand * );
     325                 :     
     326                 :     virtual void   GetFileList(char*** ppapszFileList, int *pnSize,
     327                 :                                int *pnMaxSize, CPLHashSet* hSetFiles);
     328                 :     
     329                 :     virtual void   SetDescription( const char * );
     330                 : 
     331                 :     virtual GDALRasterBand *GetMaskBand();
     332                 :     virtual int             GetMaskFlags();
     333                 : 
     334                 :     virtual CPLErr          CreateMaskBand( int nFlags );
     335                 :     
     336                 :     void SetMaskBand(VRTRasterBand* poMaskBand);
     337                 : 
     338                 :     void SetIsMaskBand();
     339                 : 
     340                 :     CPLErr UnsetNoDataValue();
     341                 : 
     342                 :     virtual int         CloseDependentDatasets();
     343                 : 
     344              25 :     virtual int         IsSourcedRasterBand() { return FALSE; }
     345                 : };
     346                 : 
     347                 : /************************************************************************/
     348                 : /*                         VRTSourcedRasterBand                         */
     349                 : /************************************************************************/
     350                 : 
     351                 : class CPL_DLL VRTSourcedRasterBand : public VRTRasterBand
     352                 : {
     353                 :   private:
     354                 :     int            bAntiRecursionFlag;
     355                 :     CPLString      osLastLocationInfo;
     356                 :     char         **papszSourceList;
     357                 : 
     358                 :     void           Initialize( int nXSize, int nYSize );
     359                 : 
     360                 :   public:
     361                 :     int            nSources;
     362                 :     VRTSource    **papoSources;
     363                 :     int            bEqualAreas;
     364                 : 
     365                 :                    VRTSourcedRasterBand( GDALDataset *poDS, int nBand );
     366                 :                    VRTSourcedRasterBand( GDALDataType eType, 
     367                 :                                          int nXSize, int nYSize );
     368                 :                    VRTSourcedRasterBand( GDALDataset *poDS, int nBand, 
     369                 :                                          GDALDataType eType, 
     370                 :                                          int nXSize, int nYSize );
     371                 :     virtual        ~VRTSourcedRasterBand();
     372                 : 
     373                 :     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
     374                 :                               void *, int, int, GDALDataType,
     375                 :                               int, int );
     376                 : 
     377                 :     virtual const char *GetMetadataItem( const char * pszName,
     378                 :                                          const char * pszDomain = "" );
     379                 :     virtual char      **GetMetadata( const char * pszDomain = "" );
     380                 :     virtual CPLErr      SetMetadata( char ** papszMetadata,
     381                 :                                      const char * pszDomain = "" );
     382                 :     virtual CPLErr      SetMetadataItem( const char * pszName,
     383                 :                                          const char * pszValue,
     384                 :                                          const char * pszDomain = "" );
     385                 : 
     386                 :     virtual CPLErr         XMLInit( CPLXMLNode *, const char * );
     387                 :     virtual CPLXMLNode *   SerializeToXML( const char *pszVRTPath );
     388                 : 
     389                 :     virtual double GetMinimum( int *pbSuccess = NULL );
     390                 :     virtual double GetMaximum(int *pbSuccess = NULL );
     391                 :     virtual CPLErr ComputeRasterMinMax( int bApproxOK, double* adfMinMax );
     392                 :     virtual CPLErr ComputeStatistics( int bApproxOK, 
     393                 :                                       double *pdfMin, double *pdfMax, 
     394                 :                                       double *pdfMean, double *pdfStdDev,
     395                 :                                       GDALProgressFunc pfnProgress, void *pProgressData );
     396                 :     virtual CPLErr  GetHistogram( double dfMin, double dfMax,
     397                 :                                   int nBuckets, int * panHistogram,
     398                 :                                   int bIncludeOutOfRange, int bApproxOK,
     399                 :                                   GDALProgressFunc pfnProgress, void *pProgressData );
     400                 : 
     401                 :     CPLErr         AddSource( VRTSource * );
     402                 :     CPLErr         AddSimpleSource( GDALRasterBand *poSrcBand, 
     403                 :                                     int nSrcXOff=-1, int nSrcYOff=-1, 
     404                 :                                     int nSrcXSize=-1, int nSrcYSize=-1, 
     405                 :                                     int nDstXOff=-1, int nDstYOff=-1, 
     406                 :                                     int nDstXSize=-1, int nDstYSize=-1,
     407                 :                                     const char *pszResampling = "near",
     408                 :                                     double dfNoDataValue = VRT_NODATA_UNSET);
     409                 :     CPLErr         AddComplexSource( GDALRasterBand *poSrcBand, 
     410                 :                                      int nSrcXOff=-1, int nSrcYOff=-1, 
     411                 :                                      int nSrcXSize=-1, int nSrcYSize=-1, 
     412                 :                                      int nDstXOff=-1, int nDstYOff=-1, 
     413                 :                                      int nDstXSize=-1, int nDstYSize=-1,
     414                 :                                      double dfScaleOff=0.0, 
     415                 :                                      double dfScaleRatio=1.0,
     416                 :                                      double dfNoDataValue = VRT_NODATA_UNSET,
     417                 :                                      int nColorTableComponent = 0);
     418                 : 
     419                 :     CPLErr         AddMaskBandSource( GDALRasterBand *poSrcBand,
     420                 :                                       int nSrcXOff=-1, int nSrcYOff=-1,
     421                 :                                       int nSrcXSize=-1, int nSrcYSize=-1,
     422                 :                                       int nDstXOff=-1, int nDstYOff=-1,
     423                 :                                       int nDstXSize=-1, int nDstYSize=-1 );
     424                 : 
     425                 :     CPLErr         AddFuncSource( VRTImageReadFunc pfnReadFunc, void *hCBData,
     426                 :                                   double dfNoDataValue = VRT_NODATA_UNSET );
     427                 : 
     428                 : 
     429                 :     virtual CPLErr IReadBlock( int, int, void * );
     430                 :     
     431                 :     virtual void   GetFileList(char*** ppapszFileList, int *pnSize,
     432                 :                                int *pnMaxSize, CPLHashSet* hSetFiles);
     433                 : 
     434                 :     virtual int         CloseDependentDatasets();
     435                 : 
     436            1814 :     virtual int         IsSourcedRasterBand() { return TRUE; }
     437                 : };
     438                 : 
     439                 : /************************************************************************/
     440                 : /*                         VRTWarpedRasterBand                          */
     441                 : /************************************************************************/
     442                 : 
     443                 : class CPL_DLL VRTWarpedRasterBand : public VRTRasterBand
     444                 : {
     445                 :   public:
     446                 :                    VRTWarpedRasterBand( GDALDataset *poDS, int nBand,
     447                 :                                      GDALDataType eType = GDT_Unknown );
     448                 :     virtual        ~VRTWarpedRasterBand();
     449                 : 
     450                 :     virtual CPLErr         XMLInit( CPLXMLNode *, const char * );
     451                 :     virtual CPLXMLNode *   SerializeToXML( const char *pszVRTPath );
     452                 : 
     453                 :     virtual CPLErr IReadBlock( int, int, void * );
     454                 :     virtual CPLErr IWriteBlock( int, int, void * );
     455                 : 
     456                 :     virtual int GetOverviewCount();
     457                 :     virtual GDALRasterBand *GetOverview(int);
     458                 : };
     459                 : 
     460                 : /************************************************************************/
     461                 : /*                         VRTDerivedRasterBand                         */
     462                 : /************************************************************************/
     463                 : 
     464                 : class CPL_DLL VRTDerivedRasterBand : public VRTSourcedRasterBand
     465                 : {
     466                 : 
     467                 :  public:
     468                 :     char *pszFuncName;
     469                 :     GDALDataType eSourceTransferType;
     470                 : 
     471                 :     VRTDerivedRasterBand(GDALDataset *poDS, int nBand);
     472                 :     VRTDerivedRasterBand(GDALDataset *poDS, int nBand, 
     473                 :                          GDALDataType eType, int nXSize, int nYSize);
     474                 :     virtual        ~VRTDerivedRasterBand();
     475                 : 
     476                 :     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
     477                 :                               void *, int, int, GDALDataType,
     478                 :                               int, int );
     479                 : 
     480                 :     static CPLErr AddPixelFunction
     481                 :         (const char *pszFuncName, GDALDerivedPixelFunc pfnPixelFunc);
     482                 :     static GDALDerivedPixelFunc GetPixelFunction(const char *pszFuncName);
     483                 : 
     484                 :     void SetPixelFunctionName(const char *pszFuncName);
     485                 :     void SetSourceTransferType(GDALDataType eDataType);
     486                 : 
     487                 :     virtual CPLErr         XMLInit( CPLXMLNode *, const char * );
     488                 :     virtual CPLXMLNode *   SerializeToXML( const char *pszVRTPath );
     489                 : 
     490                 : };
     491                 : 
     492                 : /************************************************************************/
     493                 : /*                           VRTRawRasterBand                           */
     494                 : /************************************************************************/
     495                 : 
     496                 : class RawRasterBand;
     497                 : 
     498                 : class CPL_DLL VRTRawRasterBand : public VRTRasterBand
     499                 : {
     500                 :     RawRasterBand  *poRawRaster;
     501                 : 
     502                 :     char           *pszSourceFilename;
     503                 :     int            bRelativeToVRT;
     504                 : 
     505                 :   public:
     506                 :                    VRTRawRasterBand( GDALDataset *poDS, int nBand,
     507                 :                                      GDALDataType eType = GDT_Unknown );
     508                 :     virtual        ~VRTRawRasterBand();
     509                 : 
     510                 :     virtual CPLErr         XMLInit( CPLXMLNode *, const char * );
     511                 :     virtual CPLXMLNode *   SerializeToXML( const char *pszVRTPath );
     512                 : 
     513                 :     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
     514                 :                               void *, int, int, GDALDataType,
     515                 :                               int, int );
     516                 : 
     517                 :     virtual CPLErr IReadBlock( int, int, void * );
     518                 :     virtual CPLErr IWriteBlock( int, int, void * );
     519                 : 
     520                 :     CPLErr         SetRawLink( const char *pszFilename, 
     521                 :                                const char *pszVRTPath,
     522                 :                                int bRelativeToVRT, 
     523                 :                                vsi_l_offset nImageOffset, 
     524                 :                                int nPixelOffset, int nLineOffset, 
     525                 :                                const char *pszByteOrder );
     526                 : 
     527                 :     void           ClearRawLink();
     528                 : 
     529                 :     virtual void   GetFileList(char*** ppapszFileList, int *pnSize,
     530                 :                                int *pnMaxSize, CPLHashSet* hSetFiles);
     531                 : };
     532                 : 
     533                 : /************************************************************************/
     534                 : /*                              VRTDriver                               */
     535                 : /************************************************************************/
     536                 : 
     537                 : class VRTDriver : public GDALDriver
     538                 : {
     539                 :     void        *pDeserializerData;
     540                 : 
     541                 :   public:
     542                 :                  VRTDriver();
     543                 :                  ~VRTDriver();
     544                 : 
     545                 :     char         **papszSourceParsers;
     546                 : 
     547                 :     virtual char      **GetMetadata( const char * pszDomain = "" );
     548                 :     virtual CPLErr      SetMetadata( char ** papszMetadata,
     549                 :                                      const char * pszDomain = "" );
     550                 : 
     551                 :     VRTSource   *ParseSource( CPLXMLNode *psSrc, const char *pszVRTPath );
     552                 :     void         AddSourceParser( const char *pszElementName, 
     553                 :                                   VRTSourceParser pfnParser );
     554                 : };
     555                 : 
     556                 : /************************************************************************/
     557                 : /*                           VRTSimpleSource                            */
     558                 : /************************************************************************/
     559                 : 
     560                 : class VRTSimpleSource : public VRTSource
     561                 : {
     562                 : protected:
     563                 :     GDALRasterBand      *poRasterBand;
     564                 : 
     565                 :     /* when poRasterBand is a mask band, poMaskBandMainBand is the band */
     566                 :     /* from which the mask band is taken */
     567                 :     GDALRasterBand      *poMaskBandMainBand; 
     568                 : 
     569                 :     int                 nSrcXOff;
     570                 :     int                 nSrcYOff;
     571                 :     int                 nSrcXSize;
     572                 :     int                 nSrcYSize;
     573                 : 
     574                 :     int                 nDstXOff;
     575                 :     int                 nDstYOff;
     576                 :     int                 nDstXSize;
     577                 :     int                 nDstYSize;
     578                 : 
     579                 :     int                 bNoDataSet;
     580                 :     double              dfNoDataValue;
     581                 : 
     582                 : public:
     583                 :             VRTSimpleSource();
     584                 :     virtual ~VRTSimpleSource();
     585                 : 
     586                 :     virtual CPLErr  XMLInit( CPLXMLNode *psTree, const char * );
     587                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     588                 : 
     589                 :     void           SetSrcBand( GDALRasterBand * );
     590                 :     void           SetSrcMaskBand( GDALRasterBand * );
     591                 :     void           SetSrcWindow( int, int, int, int );
     592                 :     void           SetDstWindow( int, int, int, int );
     593                 :     void           SetNoDataValue( double dfNoDataValue );
     594                 : 
     595                 :     int            GetSrcDstWindow( int, int, int, int, int, int, 
     596                 :                                     int *, int *, int *, int *,
     597                 :                                     int *, int *, int *, int * );
     598                 : 
     599                 :     virtual CPLErr  RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 
     600                 :                               void *pData, int nBufXSize, int nBufYSize, 
     601                 :                               GDALDataType eBufType, 
     602                 :                               int nPixelSpace, int nLineSpace );
     603                 : 
     604                 :     virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
     605                 :     virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
     606                 :     virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
     607                 :     virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
     608                 :                                       int bApproxOK, 
     609                 :                                       double *pdfMin, double *pdfMax, 
     610                 :                                       double *pdfMean, double *pdfStdDev,
     611                 :                                       GDALProgressFunc pfnProgress, void *pProgressData );
     612                 :     virtual CPLErr  GetHistogram( int nXSize, int nYSize,
     613                 :                                   double dfMin, double dfMax,
     614                 :                                   int nBuckets, int * panHistogram,
     615                 :                                   int bIncludeOutOfRange, int bApproxOK,
     616                 :                                   GDALProgressFunc pfnProgress, void *pProgressData );
     617                 : 
     618                 :     void            DstToSrc( double dfX, double dfY,
     619                 :                               double &dfXOut, double &dfYOut );
     620                 :     void            SrcToDst( double dfX, double dfY,
     621                 :                               double &dfXOut, double &dfYOut );
     622                 :     
     623                 :     virtual void   GetFileList(char*** ppapszFileList, int *pnSize,
     624                 :                                int *pnMaxSize, CPLHashSet* hSetFiles);
     625                 : 
     626            1363 :     virtual int    IsSimpleSource() { return TRUE; }
     627            5061 :     virtual const char* GetType() { return "SimpleSource"; }
     628                 : 
     629                 :     GDALRasterBand* GetBand();
     630                 :     int             IsSameExceptBandNumber(VRTSimpleSource* poOtherSource);
     631                 :     CPLErr          DatasetRasterIO(
     632                 :                                int nXOff, int nYOff, int nXSize, int nYSize,
     633                 :                                void * pData, int nBufXSize, int nBufYSize,
     634                 :                                GDALDataType eBufType,
     635                 :                                int nBandCount, int *panBandMap,
     636                 :                                int nPixelSpace, int nLineSpace, int nBandSpace);
     637                 : };
     638                 : 
     639                 : /************************************************************************/
     640                 : /*                          VRTAveragedSource                           */
     641                 : /************************************************************************/
     642                 : 
     643                 : class VRTAveragedSource : public VRTSimpleSource
     644               2 : {
     645                 : public:
     646                 :                     VRTAveragedSource();
     647                 :     virtual CPLErr  RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 
     648                 :                               void *pData, int nBufXSize, int nBufYSize, 
     649                 :                               GDALDataType eBufType, 
     650                 :                               int nPixelSpace, int nLineSpace );
     651                 : 
     652                 :     virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
     653                 :     virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
     654                 :     virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
     655                 :     virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
     656                 :                                       int bApproxOK, 
     657                 :                                       double *pdfMin, double *pdfMax, 
     658                 :                                       double *pdfMean, double *pdfStdDev,
     659                 :                                       GDALProgressFunc pfnProgress, void *pProgressData );
     660                 :     virtual CPLErr  GetHistogram( int nXSize, int nYSize,
     661                 :                                   double dfMin, double dfMax,
     662                 :                                   int nBuckets, int * panHistogram,
     663                 :                                   int bIncludeOutOfRange, int bApproxOK,
     664                 :                                   GDALProgressFunc pfnProgress, void *pProgressData );
     665                 : 
     666                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     667               0 :     virtual const char* GetType() { return "AveragedSource"; }
     668                 : };
     669                 : 
     670                 : /************************************************************************/
     671                 : /*                           VRTComplexSource                           */
     672                 : /************************************************************************/
     673                 : 
     674                 : class VRTComplexSource : public VRTSimpleSource
     675                 : {
     676                 : protected:
     677                 :     CPLErr          RasterIOInternal( int nReqXOff, int nReqYOff,
     678                 :                                       int nReqXSize, int nReqYSize,
     679                 :                                       void *pData, int nOutXSize, int nOutYSize,
     680                 :                                       GDALDataType eBufType,
     681                 :                                       int nPixelSpace, int nLineSpace );
     682                 : 
     683                 : public:
     684                 :                    VRTComplexSource();
     685                 :     virtual        ~VRTComplexSource();
     686                 : 
     687                 :     virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 
     688                 :                              void *pData, int nBufXSize, int nBufYSize, 
     689                 :                              GDALDataType eBufType, 
     690                 :                              int nPixelSpace, int nLineSpace );
     691                 : 
     692                 :     virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
     693                 :     virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
     694                 :     virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
     695                 :     virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
     696                 :                                       int bApproxOK, 
     697                 :                                       double *pdfMin, double *pdfMax, 
     698                 :                                       double *pdfMean, double *pdfStdDev,
     699                 :                                       GDALProgressFunc pfnProgress, void *pProgressData );
     700                 :     virtual CPLErr  GetHistogram( int nXSize, int nYSize,
     701                 :                                   double dfMin, double dfMax,
     702                 :                                   int nBuckets, int * panHistogram,
     703                 :                                   int bIncludeOutOfRange, int bApproxOK,
     704                 :                                   GDALProgressFunc pfnProgress, void *pProgressData );
     705                 : 
     706                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     707                 :     virtual CPLErr XMLInit( CPLXMLNode *, const char * );
     708               9 :     virtual const char* GetType() { return "ComplexSource"; }
     709                 : 
     710                 :     double  LookupValue( double dfInput );
     711                 : 
     712                 :     int            bDoScaling;
     713                 :     double         dfScaleOff;
     714                 :     double         dfScaleRatio;
     715                 :     double         *padfLUTInputs;
     716                 :     double         *padfLUTOutputs;
     717                 :     int            nLUTItemCount;
     718                 :     int            nColorTableComponent;
     719                 : };
     720                 : 
     721                 : /************************************************************************/
     722                 : /*                           VRTFilteredSource                          */
     723                 : /************************************************************************/
     724                 : 
     725                 : class VRTFilteredSource : public VRTComplexSource
     726                 : {
     727                 : private:
     728                 :     int          IsTypeSupported( GDALDataType eType );
     729                 : 
     730                 : protected:
     731                 :     int          nSupportedTypesCount;
     732                 :     GDALDataType aeSupportedTypes[20];
     733                 : 
     734                 :     int          nExtraEdgePixels;
     735                 : 
     736                 : public:
     737                 :             VRTFilteredSource();
     738                 :     virtual ~VRTFilteredSource();
     739                 : 
     740                 :     void    SetExtraEdgePixels( int );
     741                 :     void    SetFilteringDataTypesSupported( int, GDALDataType * );
     742                 : 
     743                 :     virtual CPLErr  FilterData( int nXSize, int nYSize, GDALDataType eType, 
     744                 :                                 GByte *pabySrcData, GByte *pabyDstData ) = 0;
     745                 : 
     746                 :     virtual CPLErr  RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 
     747                 :                               void *pData, int nBufXSize, int nBufYSize, 
     748                 :                               GDALDataType eBufType, 
     749                 :                               int nPixelSpace, int nLineSpace );
     750                 : };
     751                 : 
     752                 : /************************************************************************/
     753                 : /*                       VRTKernelFilteredSource                        */
     754                 : /************************************************************************/
     755                 : 
     756                 : class VRTKernelFilteredSource : public VRTFilteredSource
     757                 : {
     758                 : protected:
     759                 :     int     nKernelSize;
     760                 : 
     761                 :     double  *padfKernelCoefs;
     762                 : 
     763                 :     int     bNormalized;
     764                 : 
     765                 : public:
     766                 :             VRTKernelFilteredSource();
     767                 :     virtual ~VRTKernelFilteredSource();
     768                 : 
     769                 :     virtual CPLErr  XMLInit( CPLXMLNode *psTree, const char * );
     770                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     771                 : 
     772                 :     virtual CPLErr  FilterData( int nXSize, int nYSize, GDALDataType eType, 
     773                 :                                 GByte *pabySrcData, GByte *pabyDstData );
     774                 : 
     775                 :     CPLErr          SetKernel( int nKernelSize, double *padfCoefs );
     776                 :     void            SetNormalized( int );
     777                 : };
     778                 : 
     779                 : /************************************************************************/
     780                 : /*                       VRTAverageFilteredSource                       */
     781                 : /************************************************************************/
     782                 : 
     783                 : class VRTAverageFilteredSource : public VRTKernelFilteredSource
     784                 : {
     785                 : public:
     786                 :             VRTAverageFilteredSource( int nKernelSize );
     787                 :     virtual ~VRTAverageFilteredSource();
     788                 : 
     789                 :     virtual CPLErr  XMLInit( CPLXMLNode *psTree, const char * );
     790                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     791                 : };
     792                 : 
     793                 : /************************************************************************/
     794                 : /*                            VRTFuncSource                             */
     795                 : /************************************************************************/
     796                 : class VRTFuncSource : public VRTSource
     797                 : {
     798                 : public:
     799                 :             VRTFuncSource();
     800                 :     virtual ~VRTFuncSource();
     801                 : 
     802               0 :     virtual CPLErr  XMLInit( CPLXMLNode *, const char *) { return CE_Failure; }
     803                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     804                 : 
     805                 :     virtual CPLErr  RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 
     806                 :                               void *pData, int nBufXSize, int nBufYSize, 
     807                 :                               GDALDataType eBufType, 
     808                 :                               int nPixelSpace, int nLineSpace );
     809                 : 
     810                 :     virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
     811                 :     virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
     812                 :     virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax );
     813                 :     virtual CPLErr ComputeStatistics( int nXSize, int nYSize,
     814                 :                                       int bApproxOK, 
     815                 :                                       double *pdfMin, double *pdfMax, 
     816                 :                                       double *pdfMean, double *pdfStdDev,
     817                 :                                       GDALProgressFunc pfnProgress, void *pProgressData );
     818                 :     virtual CPLErr  GetHistogram( int nXSize, int nYSize,
     819                 :                                   double dfMin, double dfMax,
     820                 :                                   int nBuckets, int * panHistogram,
     821                 :                                   int bIncludeOutOfRange, int bApproxOK,
     822                 :                                   GDALProgressFunc pfnProgress, void *pProgressData );
     823                 : 
     824                 :     VRTImageReadFunc    pfnReadFunc;
     825                 :     void               *pCBData;
     826                 :     GDALDataType        eType;
     827                 :     
     828                 :     float               fNoDataValue;
     829                 : };
     830                 : 
     831                 : #endif /* ndef VIRTUALDATASET_H_INCLUDED */

Generated by: LCOV version 1.7