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