00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
#ifndef VIRTUALDATASET_H_INCLUDED
00071
#define VIRTUALDATASET_H_INCLUDED
00072
00073
#include "gdal_priv.h"
00074
#include "cpl_minixml.h"
00075
00076 CPL_C_START
00077
void GDALRegister_VRT(
void);
00078
typedef CPLErr
00079 (*VRTImageReadFunc)(
void *hCBData,
00080
int nXOff,
int nYOff,
int nXSize,
int nYSize,
00081
void *pData );
00082 CPL_C_END
00083
00084
int VRTApplyMetadata(
CPLXMLNode *, GDALMajorObject * );
00085
CPLXMLNode *VRTSerializeMetadata( GDALMajorObject * );
00086
00087
00088
00089
00090
00091
class VRTSource
00092 {
00093
public:
00094
virtual ~VRTSource();
00095
00096
virtual CPLErr RasterIO(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
00097
void *pData,
int nBufXSize,
int nBufYSize,
00098 GDALDataType eBufType,
00099
int nPixelSpace,
int nLineSpace ) = 0;
00100
00101
virtual CPLErr XMLInit(
CPLXMLNode *psTree ) = 0;
00102
virtual CPLXMLNode *SerializeToXML() = 0;
00103 };
00104
00105
typedef VRTSource *(*VRTSourceParser)(
CPLXMLNode *);
00106
00107 VRTSource *VRTParseCoreSources(
CPLXMLNode *psTree );
00108 VRTSource *VRTParseFilterSources(
CPLXMLNode *psTree );
00109
00110
00111
00112
00113
00114
class CPL_DLL VRTDataset :
public GDALDataset
00115 {
00116
char *pszProjection;
00117
00118
int bGeoTransformSet;
00119
double adfGeoTransform[6];
00120
00121
int nGCPCount;
00122
GDAL_GCP *pasGCPList;
00123
char *pszGCPProjection;
00124
00125
int bNeedsFlush;
00126
00127
public:
00128 VRTDataset(
int nXSize,
int nYSize);
00129 ~VRTDataset();
00130
00131
void SetNeedsFlush() { bNeedsFlush = TRUE; }
00132
virtual void FlushCache();
00133
00134
virtual const char *
GetProjectionRef(
void);
00135
virtual CPLErr SetProjection(
const char * );
00136
virtual CPLErr GetGeoTransform(
double * );
00137
virtual CPLErr SetGeoTransform(
double * );
00138
00139
virtual int GetGCPCount();
00140
virtual const char *
GetGCPProjection();
00141
virtual const GDAL_GCP *
GetGCPs();
00142
virtual CPLErr SetGCPs(
int nGCPCount,
const GDAL_GCP *pasGCPList,
00143
const char *pszGCPProjection );
00144
00145
virtual CPLErr AddBand( GDALDataType eType,
00146
char **papszOptions=NULL );
00147
00148
CPLXMLNode * SerializeToXML(
void);
00149
00150
static GDALDataset *Open( GDALOpenInfo * );
00151
static GDALDataset *OpenXML(
const char * );
00152
static GDALDataset *Create(
const char * pszName,
00153
int nXSize,
int nYSize,
int nBands,
00154 GDALDataType eType,
char ** papszOptions );
00155 };
00156
00157
00158
00159
00160
00161
class CPL_DLL VRTRasterBand :
public GDALRasterBand
00162 {
00163
int nSources;
00164 VRTSource **papoSources;
00165
00166
int bEqualAreas;
00167
00168
int bNoDataValueSet;
00169
double dfNoDataValue;
00170
00171 GDALColorTable *poColorTable;
00172
00173
GDALColorInterp eColorInterp;
00174
00175
void Initialize(
int nXSize,
int nYSize );
00176
00177
virtual CPLErr IRasterIO( GDALRWFlag,
int,
int,
int,
int,
00178
void *,
int,
int, GDALDataType,
00179
int,
int );
00180
public:
00181
00182 VRTRasterBand(
GDALDataset *poDS,
int nBand );
00183 VRTRasterBand( GDALDataType eType,
00184
int nXSize,
int nYSize );
00185 VRTRasterBand(
GDALDataset *poDS,
int nBand,
00186 GDALDataType eType,
00187
int nXSize,
int nYSize );
00188
virtual ~VRTRasterBand();
00189
00190 CPLErr XMLInit(
CPLXMLNode * );
00191
CPLXMLNode * SerializeToXML(
void);
00192
00193
#define VRT_NODATA_UNSET -1234.56
00194
00195 CPLErr AddSource( VRTSource * );
00196 CPLErr AddSimpleSource(
GDALRasterBand *poSrcBand,
00197
int nSrcXOff=-1,
int nSrcYOff=-1,
00198
int nSrcXSize=-1,
int nSrcYSize=-1,
00199
int nDstXOff=-1,
int nDstYOff=-1,
00200
int nDstXSize=-1,
int nDstYSize=-1,
00201
const char *pszResampling =
"near",
00202
double dfNoDataValue = VRT_NODATA_UNSET);
00203 CPLErr AddComplexSource(
GDALRasterBand *poSrcBand,
00204
int nSrcXOff=-1,
int nSrcYOff=-1,
00205
int nSrcXSize=-1,
int nSrcYSize=-1,
00206
int nDstXOff=-1,
int nDstYOff=-1,
00207
int nDstXSize=-1,
int nDstYSize=-1,
00208
double dfScaleOff=0.0,
00209
double dfScaleRatio=1.0,
00210
double dfNoDataValue = VRT_NODATA_UNSET);
00211
00212 CPLErr AddFuncSource( VRTImageReadFunc pfnReadFunc,
void *hCBData,
00213
double dfNoDataValue = VRT_NODATA_UNSET );
00214
00215
00216
virtual CPLErr IReadBlock(
int,
int,
void * );
00217
00218
virtual char **GetMetadata(
const char * pszDomain =
"" );
00219
virtual CPLErr SetMetadata(
char ** papszMetadata,
00220
const char * pszDomain =
"" );
00221
00222
virtual CPLErr SetNoDataValue(
double );
00223
virtual double GetNoDataValue(
int *pbSuccess = NULL );
00224
00225
virtual CPLErr SetColorTable( GDALColorTable * );
00226
virtual GDALColorTable *
GetColorTable();
00227
00228
virtual CPLErr SetColorInterpretation( GDALColorInterp );
00229
virtual GDALColorInterp GetColorInterpretation();
00230 };
00231
00232
00233
00234
00235
00236
class VRTDriver :
public GDALDriver
00237 {
00238
public:
00239 VRTDriver();
00240 ~VRTDriver();
00241
00242
char **papszSourceParsers;
00243
00244
virtual char **GetMetadata(
const char * pszDomain =
"" );
00245
virtual CPLErr SetMetadata(
char ** papszMetadata,
00246
const char * pszDomain =
"" );
00247
00248 VRTSource *ParseSource(
CPLXMLNode *psSrc );
00249
void AddSourceParser(
const char *pszElementName,
00250 VRTSourceParser pfnParser );
00251 };
00252
00253
00254
00255
00256
00257
class VRTSimpleSource :
public VRTSource
00258 {
00259
protected:
00260
GDALRasterBand *poRasterBand;
00261
00262
int nSrcXOff;
00263
int nSrcYOff;
00264
int nSrcXSize;
00265
int nSrcYSize;
00266
00267
int nDstXOff;
00268
int nDstYOff;
00269
int nDstXSize;
00270
int nDstYSize;
00271
00272
int bNoDataSet;
00273
double dfNoDataValue;
00274
00275
public:
00276 VRTSimpleSource();
00277
virtual ~VRTSimpleSource();
00278
00279
virtual CPLErr XMLInit(
CPLXMLNode *psTree );
00280
virtual CPLXMLNode *SerializeToXML();
00281
00282
void SetSrcBand(
GDALRasterBand * );
00283
void SetSrcWindow(
int,
int,
int,
int );
00284
void SetDstWindow(
int,
int,
int,
int );
00285
void SetNoDataValue(
double dfNoDataValue );
00286
00287
int GetSrcDstWindow(
int,
int,
int,
int,
int,
int,
00288
int *,
int *,
int *,
int *,
00289
int *,
int *,
int *,
int * );
00290
00291
virtual CPLErr RasterIO(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
00292
void *pData,
int nBufXSize,
int nBufYSize,
00293 GDALDataType eBufType,
00294
int nPixelSpace,
int nLineSpace );
00295
00296
void DstToSrc(
double dfX,
double dfY,
00297
double &dfXOut,
double &dfYOut );
00298
void SrcToDst(
double dfX,
double dfY,
00299
double &dfXOut,
double &dfYOut );
00300
00301 };
00302
00303
00304
00305
00306
00307
class VRTAveragedSource :
public VRTSimpleSource
00308 {
00309
public:
00310 VRTAveragedSource();
00311
virtual CPLErr RasterIO(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
00312
void *pData,
int nBufXSize,
int nBufYSize,
00313 GDALDataType eBufType,
00314
int nPixelSpace,
int nLineSpace );
00315
virtual CPLXMLNode *SerializeToXML();
00316 };
00317
00318
00319
00320
00321
00322
class VRTComplexSource :
public VRTSimpleSource
00323 {
00324
public:
00325 VRTComplexSource();
00326
virtual ~VRTComplexSource();
00327
00328
virtual CPLErr RasterIO(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
00329
void *pData,
int nBufXSize,
int nBufYSize,
00330 GDALDataType eBufType,
00331
int nPixelSpace,
int nLineSpace );
00332
virtual CPLXMLNode *SerializeToXML();
00333
virtual CPLErr XMLInit(
CPLXMLNode * );
00334
00335
int bDoScaling;
00336
double dfScaleOff;
00337
double dfScaleRatio;
00338
00339 };
00340
00341
00342
00343
00344
00345
class VRTFilteredSource :
public VRTComplexSource
00346 {
00347
private:
00348
int IsTypeSupported( GDALDataType eType );
00349
00350
protected:
00351
int nSupportedTypesCount;
00352
GDALDataType aeSupportedTypes[20];
00353
00354
int nExtraEdgePixels;
00355
00356
public:
00357 VRTFilteredSource();
00358
virtual ~VRTFilteredSource();
00359
00360
void SetExtraEdgePixels(
int );
00361
void SetFilteringDataTypesSupported(
int, GDALDataType * );
00362
00363
virtual CPLErr FilterData(
int nXSize,
int nYSize, GDALDataType eType,
00364 GByte *pabySrcData, GByte *pabyDstData ) = 0;
00365
00366
virtual CPLErr RasterIO(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
00367
void *pData,
int nBufXSize,
int nBufYSize,
00368 GDALDataType eBufType,
00369
int nPixelSpace,
int nLineSpace );
00370 };
00371
00372
00373
00374
00375
00376
class VRTKernelFilteredSource :
public VRTFilteredSource
00377 {
00378
protected:
00379
int nKernelSize;
00380
00381
double *padfKernelCoefs;
00382
00383
int bNormalized;
00384
00385
public:
00386 VRTKernelFilteredSource();
00387
virtual ~VRTKernelFilteredSource();
00388
00389
virtual CPLErr XMLInit(
CPLXMLNode *psTree );
00390
virtual CPLXMLNode *SerializeToXML();
00391
00392
virtual CPLErr FilterData(
int nXSize,
int nYSize, GDALDataType eType,
00393 GByte *pabySrcData, GByte *pabyDstData );
00394
00395 CPLErr SetKernel(
int nKernelSize,
double *padfCoefs );
00396
void SetNormalized(
int );
00397 };
00398
00399
00400
00401
00402
00403
class VRTAverageFilteredSource :
public VRTKernelFilteredSource
00404 {
00405
public:
00406 VRTAverageFilteredSource(
int nKernelSize );
00407
virtual ~VRTAverageFilteredSource();
00408
00409
virtual CPLErr XMLInit(
CPLXMLNode *psTree );
00410
virtual CPLXMLNode *SerializeToXML();
00411 };
00412
00413
00414
00415
00416
class VRTFuncSource :
public VRTSource
00417 {
00418
public:
00419 VRTFuncSource();
00420
virtual ~VRTFuncSource();
00421
00422
virtual CPLErr XMLInit(
CPLXMLNode * ) {
return CE_Failure; }
00423
virtual CPLXMLNode *SerializeToXML();
00424
00425
virtual CPLErr RasterIO(
int nXOff,
int nYOff,
int nXSize,
int nYSize,
00426
void *pData,
int nBufXSize,
int nBufYSize,
00427 GDALDataType eBufType,
00428
int nPixelSpace,
int nLineSpace );
00429
00430 VRTImageReadFunc pfnReadFunc;
00431
void *pCBData;
00432
GDALDataType eType;
00433
00434
float fNoDataValue;
00435 };
00436
00437
#endif