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: 2011-12-18 Functions: 16 11 68.8 %

       1                 : /******************************************************************************
       2                 :  * $Id: vrtdataset.h 23574 2011-12-14 19:29:48Z 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               6 : {
      52                 : public:
      53                 :     CPLString       osFilename;
      54                 :     int             nBand;
      55                 :     GDALRasterBand *poBand;
      56                 :     int             bTriedToOpen;
      57                 :     
      58               6 :     VRTOverviewInfo() : poBand(NULL), bTriedToOpen(FALSE) {}
      59              12 :     ~VRTOverviewInfo() {
      60              12 :         if( poBand == NULL ) 
      61                 :             /* do nothing */;
      62               4 :         else if( poBand->GetDataset()->GetShared() )
      63               4 :             GDALClose( (GDALDatasetH) poBand->GetDataset() );
      64                 :         else
      65               0 :             poBand->GetDataset()->Dereference();
      66              12 :     }
      67                 : };
      68                 : 
      69                 : 
      70                 : /************************************************************************/
      71                 : /*                              VRTSource                               */
      72                 : /************************************************************************/
      73                 : 
      74                 : class VRTSource 
      75             631 : {
      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                 : 
      87                 :     virtual CPLErr  XMLInit( CPLXMLNode *psTree, const char * ) = 0;
      88                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) = 0;
      89                 :     
      90                 :     virtual void   GetFileList(char*** ppapszFileList, int *pnSize,
      91                 :                                int *pnMaxSize, CPLHashSet* hSetFiles);
      92                 : 
      93               0 :     virtual int    IsSimpleSource() { return FALSE; }
      94                 : };
      95                 : 
      96                 : typedef VRTSource *(*VRTSourceParser)(CPLXMLNode *, const char *);
      97                 : 
      98                 : VRTSource *VRTParseCoreSources( CPLXMLNode *psTree, const char * );
      99                 : VRTSource *VRTParseFilterSources( CPLXMLNode *psTree, const char * );
     100                 : 
     101                 : /************************************************************************/
     102                 : /*                              VRTDataset                              */
     103                 : /************************************************************************/
     104                 : 
     105                 : class VRTRasterBand;
     106                 : 
     107                 : class CPL_DLL VRTDataset : public GDALDataset
     108                 : {
     109                 :     friend class VRTRasterBand;
     110                 : 
     111                 :     char           *pszProjection;
     112                 : 
     113                 :     int            bGeoTransformSet;
     114                 :     double         adfGeoTransform[6];
     115                 : 
     116                 :     int           nGCPCount;
     117                 :     GDAL_GCP      *pasGCPList;
     118                 :     char          *pszGCPProjection;
     119                 : 
     120                 :     int            bNeedsFlush;
     121                 :     int            bWritable;
     122                 :     
     123                 :     char          *pszVRTPath;
     124                 : 
     125                 :     VRTRasterBand *poMaskBand;
     126                 : 
     127                 :     int            bCompatibleForDatasetIO;
     128                 :     int            CheckCompatibleForDatasetIO();
     129                 : 
     130                 :   protected:
     131                 :     virtual int         CloseDependentDatasets();
     132                 : 
     133                 :   public:
     134                 :                  VRTDataset(int nXSize, int nYSize);
     135                 :                 ~VRTDataset();
     136                 : 
     137            4100 :     void          SetNeedsFlush() { bNeedsFlush = TRUE; }
     138                 :     virtual void  FlushCache();
     139                 :     
     140                 :     void SetWritable(int bWritable) { this->bWritable = bWritable; }
     141                 : 
     142                 :     virtual CPLErr          CreateMaskBand( int nFlags );
     143                 :     void SetMaskBand(VRTRasterBand* poMaskBand);
     144                 : 
     145                 :     virtual const char *GetProjectionRef(void);
     146                 :     virtual CPLErr SetProjection( const char * );
     147                 :     virtual CPLErr GetGeoTransform( double * );
     148                 :     virtual CPLErr SetGeoTransform( double * );
     149                 : 
     150                 :     virtual CPLErr SetMetadata( char **papszMD, const char *pszDomain = "" );
     151                 :     virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue,
     152                 :                                     const char *pszDomain = "" );
     153                 : 
     154                 :     virtual int    GetGCPCount();
     155                 :     virtual const char *GetGCPProjection();
     156                 :     virtual const GDAL_GCP *GetGCPs();
     157                 :     virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList,
     158                 :                             const char *pszGCPProjection );
     159                 : 
     160                 :     virtual CPLErr AddBand( GDALDataType eType, 
     161                 :                             char **papszOptions=NULL );
     162                 :                             
     163                 :     virtual char      **GetFileList();
     164                 : 
     165                 :     virtual CPLErr  IRasterIO( GDALRWFlag eRWFlag,
     166                 :                                int nXOff, int nYOff, int nXSize, int nYSize,
     167                 :                                void * pData, int nBufXSize, int nBufYSize,
     168                 :                                GDALDataType eBufType,
     169                 :                                int nBandCount, int *panBandMap,
     170                 :                                int nPixelSpace, int nLineSpace, int nBandSpace);
     171                 : 
     172                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath);
     173                 :     virtual CPLErr      XMLInit( CPLXMLNode *, const char * );
     174                 :  
     175                 :     static int          Identify( GDALOpenInfo * );
     176                 :     static GDALDataset *Open( GDALOpenInfo * );
     177                 :     static GDALDataset *OpenXML( const char *, const char * = NULL, GDALAccess eAccess = GA_ReadOnly );
     178                 :     static GDALDataset *Create( const char * pszName,
     179                 :                                 int nXSize, int nYSize, int nBands,
     180                 :                                 GDALDataType eType, char ** papszOptions );
     181                 :     static CPLErr       Delete( const char * pszFilename );
     182                 : };
     183                 : 
     184                 : /************************************************************************/
     185                 : /*                           VRTWarpedDataset                           */
     186                 : /************************************************************************/
     187                 : 
     188                 : class GDALWarpOperation;
     189                 : class VRTWarpedRasterBand;
     190                 : 
     191                 : class CPL_DLL VRTWarpedDataset : public VRTDataset
     192                 : {
     193                 :     int               nBlockXSize;
     194                 :     int               nBlockYSize;
     195                 :     GDALWarpOperation *poWarper;
     196                 : 
     197                 :     friend class VRTWarpedRasterBand;
     198                 : 
     199                 :   protected:
     200                 :     virtual int         CloseDependentDatasets();
     201                 : 
     202                 : public:
     203                 :     int               nOverviewCount;
     204                 :     VRTWarpedDataset  **papoOverviews;
     205                 : 
     206                 : public:
     207                 :                       VRTWarpedDataset( int nXSize, int nYSize );
     208                 :                      ~VRTWarpedDataset();
     209                 : 
     210                 :     CPLErr            Initialize( /* GDALWarpOptions */ void * );
     211                 : 
     212                 :     virtual CPLErr IBuildOverviews( const char *, int, int *,
     213                 :                                     int, int *, GDALProgressFunc, void * );
     214                 :     
     215                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     216                 :     virtual CPLErr    XMLInit( CPLXMLNode *, const char * );
     217                 : 
     218                 :     virtual CPLErr AddBand( GDALDataType eType, 
     219                 :                             char **papszOptions=NULL );
     220                 :                             
     221                 :     virtual char      **GetFileList();
     222                 :     
     223                 :     CPLErr            ProcessBlock( int iBlockX, int iBlockY );
     224                 : 
     225                 :     void              GetBlockSize( int *, int * );
     226                 : };
     227                 : 
     228                 : /************************************************************************/
     229                 : /*                            VRTRasterBand                             */
     230                 : /*                                                                      */
     231                 : /*      Provides support for all the various kinds of metadata but      */
     232                 : /*      no raster access.  That is handled by derived classes.          */
     233                 : /************************************************************************/
     234                 : 
     235                 : class CPL_DLL VRTRasterBand : public GDALRasterBand
     236                 : {
     237                 :   protected:
     238                 :     int            bIsMaskBand;
     239                 : 
     240                 :     int            bNoDataValueSet;
     241                 :     int            bHideNoDataValue; // If set to true, will not report the existance of nodata
     242                 :     double         dfNoDataValue;
     243                 : 
     244                 :     GDALColorTable *poColorTable;
     245                 : 
     246                 :     GDALColorInterp eColorInterp;
     247                 : 
     248                 :     char           *pszUnitType;
     249                 :     char           **papszCategoryNames;
     250                 :     
     251                 :     double         dfOffset;
     252                 :     double         dfScale;
     253                 : 
     254                 :     CPLXMLNode    *psSavedHistograms;
     255                 : 
     256                 :     void           Initialize( int nXSize, int nYSize );
     257                 : 
     258                 :     std::vector<VRTOverviewInfo> apoOverviews;
     259                 : 
     260                 :     VRTRasterBand *poMaskBand;
     261                 : 
     262                 :   public:
     263                 : 
     264                 :                     VRTRasterBand();
     265                 :     virtual        ~VRTRasterBand();
     266                 : 
     267                 :     virtual CPLErr         XMLInit( CPLXMLNode *, const char * );
     268                 :     virtual CPLXMLNode *   SerializeToXML( const char *pszVRTPath );
     269                 : 
     270                 :     virtual CPLErr SetNoDataValue( double );
     271                 :     virtual double GetNoDataValue( int *pbSuccess = NULL );
     272                 : 
     273                 :     virtual CPLErr SetColorTable( GDALColorTable * ); 
     274                 :     virtual GDALColorTable *GetColorTable();
     275                 : 
     276                 :     virtual CPLErr SetColorInterpretation( GDALColorInterp );
     277                 :     virtual GDALColorInterp GetColorInterpretation();
     278                 : 
     279                 :     virtual const char *GetUnitType();
     280                 :     CPLErr SetUnitType( const char * ); 
     281                 : 
     282                 :     virtual char **GetCategoryNames();
     283                 :     virtual CPLErr SetCategoryNames( char ** );
     284                 : 
     285                 :     virtual CPLErr SetMetadata( char **papszMD, const char *pszDomain = "" );
     286                 :     virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue,
     287                 :                                     const char *pszDomain = "" );
     288                 : 
     289                 :     virtual double GetOffset( int *pbSuccess = NULL );
     290                 :     CPLErr SetOffset( double );
     291                 :     virtual double GetScale( int *pbSuccess = NULL );
     292                 :     CPLErr SetScale( double );
     293                 : 
     294                 :     virtual int GetOverviewCount();
     295                 :     virtual GDALRasterBand *GetOverview(int);
     296                 :     
     297                 :     virtual CPLErr  GetHistogram( double dfMin, double dfMax,
     298                 :                           int nBuckets, int * panHistogram,
     299                 :                           int bIncludeOutOfRange, int bApproxOK,
     300                 :                           GDALProgressFunc, void *pProgressData );
     301                 : 
     302                 :     virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax,
     303                 :                                         int *pnBuckets, int ** ppanHistogram,
     304                 :                                         int bForce,
     305                 :                                         GDALProgressFunc, void *pProgressData);
     306                 : 
     307                 :     virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax,
     308                 :                                         int nBuckets, int *panHistogram );
     309                 : 
     310                 :     CPLErr         CopyCommonInfoFrom( GDALRasterBand * );
     311                 :     
     312                 :     virtual void   GetFileList(char*** ppapszFileList, int *pnSize,
     313                 :                                int *pnMaxSize, CPLHashSet* hSetFiles);
     314                 :     
     315                 :     virtual void   SetDescription( const char * );
     316                 : 
     317                 :     virtual GDALRasterBand *GetMaskBand();
     318                 :     virtual int             GetMaskFlags();
     319                 : 
     320                 :     virtual CPLErr          CreateMaskBand( int nFlags );
     321                 :     
     322                 :     void SetMaskBand(VRTRasterBand* poMaskBand);
     323                 : 
     324                 :     void SetIsMaskBand();
     325                 : 
     326                 :     CPLErr UnsetNoDataValue();
     327                 : 
     328                 :     virtual int         CloseDependentDatasets();
     329                 : 
     330              15 :     virtual int         IsSourcedRasterBand() { return FALSE; }
     331                 : };
     332                 : 
     333                 : /************************************************************************/
     334                 : /*                         VRTSourcedRasterBand                         */
     335                 : /************************************************************************/
     336                 : 
     337                 : class CPL_DLL VRTSourcedRasterBand : public VRTRasterBand
     338                 : {
     339                 :   private:
     340                 :     int            bAntiRecursionFlag;
     341                 :     CPLString      osLastLocationInfo;
     342                 : 
     343                 :     void           Initialize( int nXSize, int nYSize );
     344                 : 
     345                 :   public:
     346                 :     int            nSources;
     347                 :     VRTSource    **papoSources;
     348                 :     int            bEqualAreas;
     349                 : 
     350                 :                    VRTSourcedRasterBand( GDALDataset *poDS, int nBand );
     351                 :                    VRTSourcedRasterBand( GDALDataType eType, 
     352                 :                                          int nXSize, int nYSize );
     353                 :                    VRTSourcedRasterBand( GDALDataset *poDS, int nBand, 
     354                 :                                          GDALDataType eType, 
     355                 :                                          int nXSize, int nYSize );
     356                 :     virtual        ~VRTSourcedRasterBand();
     357                 : 
     358                 :     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
     359                 :                               void *, int, int, GDALDataType,
     360                 :                               int, int );
     361                 : 
     362                 :     virtual const char *GetMetadataItem( const char * pszName,
     363                 :                                          const char * pszDomain = "" );
     364                 :     virtual char      **GetMetadata( const char * pszDomain = "" );
     365                 :     virtual CPLErr      SetMetadata( char ** papszMetadata,
     366                 :                                      const char * pszDomain = "" );
     367                 :     virtual CPLErr      SetMetadataItem( const char * pszName,
     368                 :                                          const char * pszValue,
     369                 :                                          const char * pszDomain = "" );
     370                 : 
     371                 :     virtual CPLErr         XMLInit( CPLXMLNode *, const char * );
     372                 :     virtual CPLXMLNode *   SerializeToXML( const char *pszVRTPath );
     373                 : 
     374                 :     virtual double GetMinimum( int *pbSuccess = NULL );
     375                 :     virtual double GetMaximum(int *pbSuccess = NULL );
     376                 : 
     377                 :     CPLErr         AddSource( VRTSource * );
     378                 :     CPLErr         AddSimpleSource( GDALRasterBand *poSrcBand, 
     379                 :                                     int nSrcXOff=-1, int nSrcYOff=-1, 
     380                 :                                     int nSrcXSize=-1, int nSrcYSize=-1, 
     381                 :                                     int nDstXOff=-1, int nDstYOff=-1, 
     382                 :                                     int nDstXSize=-1, int nDstYSize=-1,
     383                 :                                     const char *pszResampling = "near",
     384                 :                                     double dfNoDataValue = VRT_NODATA_UNSET);
     385                 :     CPLErr         AddComplexSource( GDALRasterBand *poSrcBand, 
     386                 :                                      int nSrcXOff=-1, int nSrcYOff=-1, 
     387                 :                                      int nSrcXSize=-1, int nSrcYSize=-1, 
     388                 :                                      int nDstXOff=-1, int nDstYOff=-1, 
     389                 :                                      int nDstXSize=-1, int nDstYSize=-1,
     390                 :                                      double dfScaleOff=0.0, 
     391                 :                                      double dfScaleRatio=1.0,
     392                 :                                      double dfNoDataValue = VRT_NODATA_UNSET,
     393                 :                                      int nColorTableComponent = 0);
     394                 : 
     395                 :     CPLErr         AddMaskBandSource( GDALRasterBand *poSrcBand,
     396                 :                                       int nSrcXOff=-1, int nSrcYOff=-1,
     397                 :                                       int nSrcXSize=-1, int nSrcYSize=-1,
     398                 :                                       int nDstXOff=-1, int nDstYOff=-1,
     399                 :                                       int nDstXSize=-1, int nDstYSize=-1 );
     400                 : 
     401                 :     CPLErr         AddFuncSource( VRTImageReadFunc pfnReadFunc, void *hCBData,
     402                 :                                   double dfNoDataValue = VRT_NODATA_UNSET );
     403                 : 
     404                 : 
     405                 :     virtual CPLErr IReadBlock( int, int, void * );
     406                 :     
     407                 :     virtual void   GetFileList(char*** ppapszFileList, int *pnSize,
     408                 :                                int *pnMaxSize, CPLHashSet* hSetFiles);
     409                 : 
     410                 :     virtual int         CloseDependentDatasets();
     411                 : 
     412             112 :     virtual int         IsSourcedRasterBand() { return TRUE; }
     413                 : };
     414                 : 
     415                 : /************************************************************************/
     416                 : /*                         VRTWarpedRasterBand                          */
     417                 : /************************************************************************/
     418                 : 
     419                 : class CPL_DLL VRTWarpedRasterBand : public VRTRasterBand
     420                 : {
     421                 :   public:
     422                 :                    VRTWarpedRasterBand( GDALDataset *poDS, int nBand,
     423                 :                                      GDALDataType eType = GDT_Unknown );
     424                 :     virtual        ~VRTWarpedRasterBand();
     425                 : 
     426                 :     virtual CPLErr         XMLInit( CPLXMLNode *, const char * );
     427                 :     virtual CPLXMLNode *   SerializeToXML( const char *pszVRTPath );
     428                 : 
     429                 :     virtual CPLErr IReadBlock( int, int, void * );
     430                 :     virtual CPLErr IWriteBlock( int, int, void * );
     431                 : 
     432                 :     virtual int GetOverviewCount();
     433                 :     virtual GDALRasterBand *GetOverview(int);
     434                 : };
     435                 : 
     436                 : /************************************************************************/
     437                 : /*                         VRTDerivedRasterBand                         */
     438                 : /************************************************************************/
     439                 : 
     440                 : class CPL_DLL VRTDerivedRasterBand : public VRTSourcedRasterBand
     441                 : {
     442                 : 
     443                 :  public:
     444                 :     char *pszFuncName;
     445                 :     GDALDataType eSourceTransferType;
     446                 : 
     447                 :     VRTDerivedRasterBand(GDALDataset *poDS, int nBand);
     448                 :     VRTDerivedRasterBand(GDALDataset *poDS, int nBand, 
     449                 :                          GDALDataType eType, int nXSize, int nYSize);
     450                 :     virtual        ~VRTDerivedRasterBand();
     451                 : 
     452                 :     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
     453                 :                               void *, int, int, GDALDataType,
     454                 :                               int, int );
     455                 : 
     456                 :     static CPLErr AddPixelFunction
     457                 :         (const char *pszFuncName, GDALDerivedPixelFunc pfnPixelFunc);
     458                 :     static GDALDerivedPixelFunc GetPixelFunction(const char *pszFuncName);
     459                 : 
     460                 :     void SetPixelFunctionName(const char *pszFuncName);
     461                 :     void SetSourceTransferType(GDALDataType eDataType);
     462                 : 
     463                 :     virtual CPLErr         XMLInit( CPLXMLNode *, const char * );
     464                 :     virtual CPLXMLNode *   SerializeToXML( const char *pszVRTPath );
     465                 : 
     466                 : };
     467                 : 
     468                 : /************************************************************************/
     469                 : /*                           VRTRawRasterBand                           */
     470                 : /************************************************************************/
     471                 : 
     472                 : class RawRasterBand;
     473                 : 
     474                 : class CPL_DLL VRTRawRasterBand : public VRTRasterBand
     475                 : {
     476                 :     RawRasterBand  *poRawRaster;
     477                 : 
     478                 :     char           *pszSourceFilename;
     479                 :     int            bRelativeToVRT;
     480                 : 
     481                 :   public:
     482                 :                    VRTRawRasterBand( GDALDataset *poDS, int nBand,
     483                 :                                      GDALDataType eType = GDT_Unknown );
     484                 :     virtual        ~VRTRawRasterBand();
     485                 : 
     486                 :     virtual CPLErr         XMLInit( CPLXMLNode *, const char * );
     487                 :     virtual CPLXMLNode *   SerializeToXML( const char *pszVRTPath );
     488                 : 
     489                 :     virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int,
     490                 :                               void *, int, int, GDALDataType,
     491                 :                               int, int );
     492                 : 
     493                 :     virtual CPLErr IReadBlock( int, int, void * );
     494                 :     virtual CPLErr IWriteBlock( int, int, void * );
     495                 : 
     496                 :     CPLErr         SetRawLink( const char *pszFilename, 
     497                 :                                const char *pszVRTPath,
     498                 :                                int bRelativeToVRT, 
     499                 :                                vsi_l_offset nImageOffset, 
     500                 :                                int nPixelOffset, int nLineOffset, 
     501                 :                                const char *pszByteOrder );
     502                 : 
     503                 :     void           ClearRawLink();
     504                 : 
     505                 :     virtual void   GetFileList(char*** ppapszFileList, int *pnSize,
     506                 :                                int *pnMaxSize, CPLHashSet* hSetFiles);
     507                 : };
     508                 : 
     509                 : /************************************************************************/
     510                 : /*                              VRTDriver                               */
     511                 : /************************************************************************/
     512                 : 
     513                 : class VRTDriver : public GDALDriver
     514                 : {
     515                 :     void        *pDeserializerData;
     516                 : 
     517                 :   public:
     518                 :                  VRTDriver();
     519                 :                  ~VRTDriver();
     520                 : 
     521                 :     char         **papszSourceParsers;
     522                 : 
     523                 :     virtual char      **GetMetadata( const char * pszDomain = "" );
     524                 :     virtual CPLErr      SetMetadata( char ** papszMetadata,
     525                 :                                      const char * pszDomain = "" );
     526                 : 
     527                 :     VRTSource   *ParseSource( CPLXMLNode *psSrc, const char *pszVRTPath );
     528                 :     void         AddSourceParser( const char *pszElementName, 
     529                 :                                   VRTSourceParser pfnParser );
     530                 : };
     531                 : 
     532                 : /************************************************************************/
     533                 : /*                           VRTSimpleSource                            */
     534                 : /************************************************************************/
     535                 : 
     536                 : class VRTSimpleSource : public VRTSource
     537                 : {
     538                 : protected:
     539                 :     GDALRasterBand      *poRasterBand;
     540                 : 
     541                 :     /* when poRasterBand is a mask band, poMaskBandMainBand is the band */
     542                 :     /* from which the mask band is taken */
     543                 :     GDALRasterBand      *poMaskBandMainBand; 
     544                 : 
     545                 :     int                 nSrcXOff;
     546                 :     int                 nSrcYOff;
     547                 :     int                 nSrcXSize;
     548                 :     int                 nSrcYSize;
     549                 : 
     550                 :     int                 nDstXOff;
     551                 :     int                 nDstYOff;
     552                 :     int                 nDstXSize;
     553                 :     int                 nDstYSize;
     554                 : 
     555                 :     int                 bNoDataSet;
     556                 :     double              dfNoDataValue;
     557                 : 
     558                 : public:
     559                 :             VRTSimpleSource();
     560                 :     virtual ~VRTSimpleSource();
     561                 : 
     562                 :     virtual CPLErr  XMLInit( CPLXMLNode *psTree, const char * );
     563                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     564                 : 
     565                 :     void           SetSrcBand( GDALRasterBand * );
     566                 :     void           SetSrcMaskBand( GDALRasterBand * );
     567                 :     void           SetSrcWindow( int, int, int, int );
     568                 :     void           SetDstWindow( int, int, int, int );
     569                 :     void           SetNoDataValue( double dfNoDataValue );
     570                 : 
     571                 :     int            GetSrcDstWindow( int, int, int, int, int, int, 
     572                 :                                     int *, int *, int *, int *,
     573                 :                                     int *, int *, int *, int * );
     574                 : 
     575                 :     virtual CPLErr  RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 
     576                 :                               void *pData, int nBufXSize, int nBufYSize, 
     577                 :                               GDALDataType eBufType, 
     578                 :                               int nPixelSpace, int nLineSpace );
     579                 : 
     580                 :     virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
     581                 :     virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
     582                 : 
     583                 :     void            DstToSrc( double dfX, double dfY,
     584                 :                               double &dfXOut, double &dfYOut );
     585                 :     void            SrcToDst( double dfX, double dfY,
     586                 :                               double &dfXOut, double &dfYOut );
     587                 :     
     588                 :     virtual void   GetFileList(char*** ppapszFileList, int *pnSize,
     589                 :                                int *pnMaxSize, CPLHashSet* hSetFiles);
     590                 : 
     591              82 :     virtual int    IsSimpleSource() { return TRUE; }
     592             163 :     virtual const char* GetType() { return "SimpleSource"; }
     593                 : 
     594                 :     GDALRasterBand* GetBand();
     595                 :     int             IsSameExceptBandNumber(VRTSimpleSource* poOtherSource);
     596                 :     CPLErr          DatasetRasterIO(
     597                 :                                int nXOff, int nYOff, int nXSize, int nYSize,
     598                 :                                void * pData, int nBufXSize, int nBufYSize,
     599                 :                                GDALDataType eBufType,
     600                 :                                int nBandCount, int *panBandMap,
     601                 :                                int nPixelSpace, int nLineSpace, int nBandSpace);
     602                 : };
     603                 : 
     604                 : /************************************************************************/
     605                 : /*                          VRTAveragedSource                           */
     606                 : /************************************************************************/
     607                 : 
     608                 : class VRTAveragedSource : public VRTSimpleSource
     609               2 : {
     610                 : public:
     611                 :                     VRTAveragedSource();
     612                 :     virtual CPLErr  RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 
     613                 :                               void *pData, int nBufXSize, int nBufYSize, 
     614                 :                               GDALDataType eBufType, 
     615                 :                               int nPixelSpace, int nLineSpace );
     616                 : 
     617                 :     virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
     618                 :     virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
     619                 : 
     620                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     621               0 :     virtual const char* GetType() { return "AveragedSource"; }
     622                 : };
     623                 : 
     624                 : /************************************************************************/
     625                 : /*                           VRTComplexSource                           */
     626                 : /************************************************************************/
     627                 : 
     628                 : class VRTComplexSource : public VRTSimpleSource
     629                 : {
     630                 : public:
     631                 :                    VRTComplexSource();
     632                 :     virtual        ~VRTComplexSource();
     633                 : 
     634                 :     virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 
     635                 :                              void *pData, int nBufXSize, int nBufYSize, 
     636                 :                              GDALDataType eBufType, 
     637                 :                              int nPixelSpace, int nLineSpace );
     638                 : 
     639                 :     virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
     640                 :     virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
     641                 : 
     642                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     643                 :     virtual CPLErr XMLInit( CPLXMLNode *, const char * );
     644               5 :     virtual const char* GetType() { return "ComplexSource"; }
     645                 : 
     646                 :     double  LookupValue( double dfInput );
     647                 : 
     648                 :     int            bDoScaling;
     649                 :     double         dfScaleOff;
     650                 :     double         dfScaleRatio;
     651                 :     double         *padfLUTInputs;
     652                 :     double         *padfLUTOutputs;
     653                 :     int            nLUTItemCount;
     654                 :     int            nColorTableComponent;
     655                 : };
     656                 : 
     657                 : /************************************************************************/
     658                 : /*                           VRTFilteredSource                          */
     659                 : /************************************************************************/
     660                 : 
     661                 : class VRTFilteredSource : public VRTComplexSource
     662                 : {
     663                 : private:
     664                 :     int          IsTypeSupported( GDALDataType eType );
     665                 : 
     666                 : protected:
     667                 :     int          nSupportedTypesCount;
     668                 :     GDALDataType aeSupportedTypes[20];
     669                 : 
     670                 :     int          nExtraEdgePixels;
     671                 : 
     672                 : public:
     673                 :             VRTFilteredSource();
     674                 :     virtual ~VRTFilteredSource();
     675                 : 
     676                 :     void    SetExtraEdgePixels( int );
     677                 :     void    SetFilteringDataTypesSupported( int, GDALDataType * );
     678                 : 
     679                 :     virtual CPLErr  FilterData( int nXSize, int nYSize, GDALDataType eType, 
     680                 :                                 GByte *pabySrcData, GByte *pabyDstData ) = 0;
     681                 : 
     682                 :     virtual CPLErr  RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 
     683                 :                               void *pData, int nBufXSize, int nBufYSize, 
     684                 :                               GDALDataType eBufType, 
     685                 :                               int nPixelSpace, int nLineSpace );
     686                 : };
     687                 : 
     688                 : /************************************************************************/
     689                 : /*                       VRTKernelFilteredSource                        */
     690                 : /************************************************************************/
     691                 : 
     692                 : class VRTKernelFilteredSource : public VRTFilteredSource
     693                 : {
     694                 : protected:
     695                 :     int     nKernelSize;
     696                 : 
     697                 :     double  *padfKernelCoefs;
     698                 : 
     699                 :     int     bNormalized;
     700                 : 
     701                 : public:
     702                 :             VRTKernelFilteredSource();
     703                 :     virtual ~VRTKernelFilteredSource();
     704                 : 
     705                 :     virtual CPLErr  XMLInit( CPLXMLNode *psTree, const char * );
     706                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     707                 : 
     708                 :     virtual CPLErr  FilterData( int nXSize, int nYSize, GDALDataType eType, 
     709                 :                                 GByte *pabySrcData, GByte *pabyDstData );
     710                 : 
     711                 :     CPLErr          SetKernel( int nKernelSize, double *padfCoefs );
     712                 :     void            SetNormalized( int );
     713                 : };
     714                 : 
     715                 : /************************************************************************/
     716                 : /*                       VRTAverageFilteredSource                       */
     717                 : /************************************************************************/
     718                 : 
     719                 : class VRTAverageFilteredSource : public VRTKernelFilteredSource
     720                 : {
     721                 : public:
     722                 :             VRTAverageFilteredSource( int nKernelSize );
     723                 :     virtual ~VRTAverageFilteredSource();
     724                 : 
     725                 :     virtual CPLErr  XMLInit( CPLXMLNode *psTree, const char * );
     726                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     727                 : };
     728                 : 
     729                 : /************************************************************************/
     730                 : /*                            VRTFuncSource                             */
     731                 : /************************************************************************/
     732                 : class VRTFuncSource : public VRTSource
     733                 : {
     734                 : public:
     735                 :             VRTFuncSource();
     736                 :     virtual ~VRTFuncSource();
     737                 : 
     738               0 :     virtual CPLErr  XMLInit( CPLXMLNode *, const char *) { return CE_Failure; }
     739                 :     virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath );
     740                 : 
     741                 :     virtual CPLErr  RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 
     742                 :                               void *pData, int nBufXSize, int nBufYSize, 
     743                 :                               GDALDataType eBufType, 
     744                 :                               int nPixelSpace, int nLineSpace );
     745                 : 
     746                 :     virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess );
     747                 :     virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess );
     748                 : 
     749                 :     VRTImageReadFunc    pfnReadFunc;
     750                 :     void               *pCBData;
     751                 :     GDALDataType        eType;
     752                 :     
     753                 :     float               fNoDataValue;
     754                 : };
     755                 : 
     756                 : #endif /* ndef VIRTUALDATASET_H_INCLUDED */

Generated by: LCOV version 1.7