GDAL
|
00001 /****************************************************************************** 00002 * $Id: vrtdataset.h 25569 2013-01-26 22:32:26Z rouault $ 00003 * 00004 * Project: Virtual GDAL Datasets 00005 * Purpose: Declaration of virtual gdal dataset classes. 00006 * Author: Frank Warmerdam, warmerdam@pobox.com 00007 * 00008 ****************************************************************************** 00009 * Copyright (c) 2001, Frank Warmerdam <warmerdam@pobox.com> 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining a 00012 * copy of this software and associated documentation files (the "Software"), 00013 * to deal in the Software without restriction, including without limitation 00014 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00015 * and/or sell copies of the Software, and to permit persons to whom the 00016 * Software is furnished to do so, subject to the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be included 00019 * in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00022 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00023 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00024 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00025 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00026 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00027 * DEALINGS IN THE SOFTWARE. 00028 ****************************************************************************/ 00029 00030 #ifndef VIRTUALDATASET_H_INCLUDED 00031 #define VIRTUALDATASET_H_INCLUDED 00032 00033 #include "gdal_priv.h" 00034 #include "gdal_pam.h" 00035 #include "gdal_vrt.h" 00036 #include "cpl_hash_set.h" 00037 00038 int VRTApplyMetadata( CPLXMLNode *, GDALMajorObject * ); 00039 CPLXMLNode *VRTSerializeMetadata( GDALMajorObject * ); 00040 00041 int VRTWarpedOverviewTransform( void *pTransformArg, int bDstToSrc, 00042 int nPointCount, 00043 double *padfX, double *padfY, double *padfZ, 00044 int *panSuccess ); 00045 void* VRTDeserializeWarpedOverviewTransformer( CPLXMLNode *psTree ); 00046 00047 /************************************************************************/ 00048 /* VRTOverviewInfo() */ 00049 /************************************************************************/ 00050 class VRTOverviewInfo 00051 { 00052 public: 00053 CPLString osFilename; 00054 int nBand; 00055 GDALRasterBand *poBand; 00056 int bTriedToOpen; 00057 00058 VRTOverviewInfo() : poBand(NULL), bTriedToOpen(FALSE) {} 00059 ~VRTOverviewInfo() { 00060 if( poBand == NULL ) 00061 /* do nothing */; 00062 else if( poBand->GetDataset()->GetShared() ) 00063 GDALClose( (GDALDatasetH) poBand->GetDataset() ); 00064 else 00065 poBand->GetDataset()->Dereference(); 00066 } 00067 }; 00068 00069 00070 /************************************************************************/ 00071 /* VRTSource */ 00072 /************************************************************************/ 00073 00074 class VRTSource 00075 { 00076 public: 00077 virtual ~VRTSource(); 00078 00079 virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 00080 void *pData, int nBufXSize, int nBufYSize, 00081 GDALDataType eBufType, 00082 int nPixelSpace, int nLineSpace ) = 0; 00083 00084 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ) = 0; 00085 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ) = 0; 00086 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax ) = 0; 00087 virtual CPLErr ComputeStatistics( int nXSize, int nYSize, 00088 int bApproxOK, 00089 double *pdfMin, double *pdfMax, 00090 double *pdfMean, double *pdfStdDev, 00091 GDALProgressFunc pfnProgress, void *pProgressData ) = 0; 00092 virtual CPLErr GetHistogram( int nXSize, int nYSize, 00093 double dfMin, double dfMax, 00094 int nBuckets, int * panHistogram, 00095 int bIncludeOutOfRange, int bApproxOK, 00096 GDALProgressFunc pfnProgress, void *pProgressData ) = 0; 00097 00098 virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * ) = 0; 00099 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ) = 0; 00100 00101 virtual void GetFileList(char*** ppapszFileList, int *pnSize, 00102 int *pnMaxSize, CPLHashSet* hSetFiles); 00103 00104 virtual int IsSimpleSource() { return FALSE; } 00105 }; 00106 00107 typedef VRTSource *(*VRTSourceParser)(CPLXMLNode *, const char *); 00108 00109 VRTSource *VRTParseCoreSources( CPLXMLNode *psTree, const char * ); 00110 VRTSource *VRTParseFilterSources( CPLXMLNode *psTree, const char * ); 00111 00112 /************************************************************************/ 00113 /* VRTDataset */ 00114 /************************************************************************/ 00115 00116 class VRTRasterBand; 00117 00118 class CPL_DLL VRTDataset : public GDALDataset 00119 { 00120 friend class VRTRasterBand; 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 int bWritable; 00133 00134 char *pszVRTPath; 00135 00136 VRTRasterBand *poMaskBand; 00137 00138 int bCompatibleForDatasetIO; 00139 int CheckCompatibleForDatasetIO(); 00140 00141 protected: 00142 virtual int CloseDependentDatasets(); 00143 00144 public: 00145 VRTDataset(int nXSize, int nYSize); 00146 ~VRTDataset(); 00147 00148 void SetNeedsFlush() { bNeedsFlush = TRUE; } 00149 virtual void FlushCache(); 00150 00151 void SetWritable(int bWritable) { this->bWritable = bWritable; } 00152 00153 virtual CPLErr CreateMaskBand( int nFlags ); 00154 void SetMaskBand(VRTRasterBand* poMaskBand); 00155 00156 virtual const char *GetProjectionRef(void); 00157 virtual CPLErr SetProjection( const char * ); 00158 virtual CPLErr GetGeoTransform( double * ); 00159 virtual CPLErr SetGeoTransform( double * ); 00160 00161 virtual CPLErr SetMetadata( char **papszMD, const char *pszDomain = "" ); 00162 virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue, 00163 const char *pszDomain = "" ); 00164 00165 virtual int GetGCPCount(); 00166 virtual const char *GetGCPProjection(); 00167 virtual const GDAL_GCP *GetGCPs(); 00168 virtual CPLErr SetGCPs( int nGCPCount, const GDAL_GCP *pasGCPList, 00169 const char *pszGCPProjection ); 00170 00171 virtual CPLErr AddBand( GDALDataType eType, 00172 char **papszOptions=NULL ); 00173 00174 virtual char **GetFileList(); 00175 00176 virtual CPLErr IRasterIO( GDALRWFlag eRWFlag, 00177 int nXOff, int nYOff, int nXSize, int nYSize, 00178 void * pData, int nBufXSize, int nBufYSize, 00179 GDALDataType eBufType, 00180 int nBandCount, int *panBandMap, 00181 int nPixelSpace, int nLineSpace, int nBandSpace); 00182 00183 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath); 00184 virtual CPLErr XMLInit( CPLXMLNode *, const char * ); 00185 00186 /* Used by PDF driver for example */ 00187 GDALDataset* GetSingleSimpleSource(); 00188 00189 static int Identify( GDALOpenInfo * ); 00190 static GDALDataset *Open( GDALOpenInfo * ); 00191 static GDALDataset *OpenXML( const char *, const char * = NULL, GDALAccess eAccess = GA_ReadOnly ); 00192 static GDALDataset *Create( const char * pszName, 00193 int nXSize, int nYSize, int nBands, 00194 GDALDataType eType, char ** papszOptions ); 00195 static CPLErr Delete( const char * pszFilename ); 00196 }; 00197 00198 /************************************************************************/ 00199 /* VRTWarpedDataset */ 00200 /************************************************************************/ 00201 00202 class GDALWarpOperation; 00203 class VRTWarpedRasterBand; 00204 00205 class CPL_DLL VRTWarpedDataset : public VRTDataset 00206 { 00207 int nBlockXSize; 00208 int nBlockYSize; 00209 GDALWarpOperation *poWarper; 00210 00211 friend class VRTWarpedRasterBand; 00212 00213 protected: 00214 virtual int CloseDependentDatasets(); 00215 00216 public: 00217 int nOverviewCount; 00218 VRTWarpedDataset **papoOverviews; 00219 00220 public: 00221 VRTWarpedDataset( int nXSize, int nYSize ); 00222 ~VRTWarpedDataset(); 00223 00224 CPLErr Initialize( /* GDALWarpOptions */ void * ); 00225 00226 virtual CPLErr IBuildOverviews( const char *, int, int *, 00227 int, int *, GDALProgressFunc, void * ); 00228 00229 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); 00230 virtual CPLErr XMLInit( CPLXMLNode *, const char * ); 00231 00232 virtual CPLErr AddBand( GDALDataType eType, 00233 char **papszOptions=NULL ); 00234 00235 virtual char **GetFileList(); 00236 00237 CPLErr ProcessBlock( int iBlockX, int iBlockY ); 00238 00239 void GetBlockSize( int *, int * ); 00240 }; 00241 00242 /************************************************************************/ 00243 /* VRTRasterBand */ 00244 /* */ 00245 /* Provides support for all the various kinds of metadata but */ 00246 /* no raster access. That is handled by derived classes. */ 00247 /************************************************************************/ 00248 00249 class CPL_DLL VRTRasterBand : public GDALRasterBand 00250 { 00251 protected: 00252 int bIsMaskBand; 00253 00254 int bNoDataValueSet; 00255 int bHideNoDataValue; // If set to true, will not report the existance of nodata 00256 double dfNoDataValue; 00257 00258 GDALColorTable *poColorTable; 00259 00260 GDALColorInterp eColorInterp; 00261 00262 char *pszUnitType; 00263 char **papszCategoryNames; 00264 00265 double dfOffset; 00266 double dfScale; 00267 00268 CPLXMLNode *psSavedHistograms; 00269 00270 void Initialize( int nXSize, int nYSize ); 00271 00272 std::vector<VRTOverviewInfo> apoOverviews; 00273 00274 VRTRasterBand *poMaskBand; 00275 00276 public: 00277 00278 VRTRasterBand(); 00279 virtual ~VRTRasterBand(); 00280 00281 virtual CPLErr XMLInit( CPLXMLNode *, const char * ); 00282 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ); 00283 00284 virtual CPLErr SetNoDataValue( double ); 00285 virtual double GetNoDataValue( int *pbSuccess = NULL ); 00286 00287 virtual CPLErr SetColorTable( GDALColorTable * ); 00288 virtual GDALColorTable *GetColorTable(); 00289 00290 virtual CPLErr SetColorInterpretation( GDALColorInterp ); 00291 virtual GDALColorInterp GetColorInterpretation(); 00292 00293 virtual const char *GetUnitType(); 00294 CPLErr SetUnitType( const char * ); 00295 00296 virtual char **GetCategoryNames(); 00297 virtual CPLErr SetCategoryNames( char ** ); 00298 00299 virtual CPLErr SetMetadata( char **papszMD, const char *pszDomain = "" ); 00300 virtual CPLErr SetMetadataItem( const char *pszName, const char *pszValue, 00301 const char *pszDomain = "" ); 00302 00303 virtual double GetOffset( int *pbSuccess = NULL ); 00304 CPLErr SetOffset( double ); 00305 virtual double GetScale( int *pbSuccess = NULL ); 00306 CPLErr SetScale( double ); 00307 00308 virtual int GetOverviewCount(); 00309 virtual GDALRasterBand *GetOverview(int); 00310 00311 virtual CPLErr GetHistogram( double dfMin, double dfMax, 00312 int nBuckets, int * panHistogram, 00313 int bIncludeOutOfRange, int bApproxOK, 00314 GDALProgressFunc, void *pProgressData ); 00315 00316 virtual CPLErr GetDefaultHistogram( double *pdfMin, double *pdfMax, 00317 int *pnBuckets, int ** ppanHistogram, 00318 int bForce, 00319 GDALProgressFunc, void *pProgressData); 00320 00321 virtual CPLErr SetDefaultHistogram( double dfMin, double dfMax, 00322 int nBuckets, int *panHistogram ); 00323 00324 CPLErr CopyCommonInfoFrom( GDALRasterBand * ); 00325 00326 virtual void GetFileList(char*** ppapszFileList, int *pnSize, 00327 int *pnMaxSize, CPLHashSet* hSetFiles); 00328 00329 virtual void SetDescription( const char * ); 00330 00331 virtual GDALRasterBand *GetMaskBand(); 00332 virtual int GetMaskFlags(); 00333 00334 virtual CPLErr CreateMaskBand( int nFlags ); 00335 00336 void SetMaskBand(VRTRasterBand* poMaskBand); 00337 00338 void SetIsMaskBand(); 00339 00340 CPLErr UnsetNoDataValue(); 00341 00342 virtual int CloseDependentDatasets(); 00343 00344 virtual int IsSourcedRasterBand() { return FALSE; } 00345 }; 00346 00347 /************************************************************************/ 00348 /* VRTSourcedRasterBand */ 00349 /************************************************************************/ 00350 00351 class CPL_DLL VRTSourcedRasterBand : public VRTRasterBand 00352 { 00353 private: 00354 int bAntiRecursionFlag; 00355 CPLString osLastLocationInfo; 00356 char **papszSourceList; 00357 00358 void Initialize( int nXSize, int nYSize ); 00359 00360 public: 00361 int nSources; 00362 VRTSource **papoSources; 00363 int bEqualAreas; 00364 00365 VRTSourcedRasterBand( GDALDataset *poDS, int nBand ); 00366 VRTSourcedRasterBand( GDALDataType eType, 00367 int nXSize, int nYSize ); 00368 VRTSourcedRasterBand( GDALDataset *poDS, int nBand, 00369 GDALDataType eType, 00370 int nXSize, int nYSize ); 00371 virtual ~VRTSourcedRasterBand(); 00372 00373 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, 00374 void *, int, int, GDALDataType, 00375 int, int ); 00376 00377 virtual const char *GetMetadataItem( const char * pszName, 00378 const char * pszDomain = "" ); 00379 virtual char **GetMetadata( const char * pszDomain = "" ); 00380 virtual CPLErr SetMetadata( char ** papszMetadata, 00381 const char * pszDomain = "" ); 00382 virtual CPLErr SetMetadataItem( const char * pszName, 00383 const char * pszValue, 00384 const char * pszDomain = "" ); 00385 00386 virtual CPLErr XMLInit( CPLXMLNode *, const char * ); 00387 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ); 00388 00389 virtual double GetMinimum( int *pbSuccess = NULL ); 00390 virtual double GetMaximum(int *pbSuccess = NULL ); 00391 virtual CPLErr ComputeRasterMinMax( int bApproxOK, double* adfMinMax ); 00392 virtual CPLErr ComputeStatistics( int bApproxOK, 00393 double *pdfMin, double *pdfMax, 00394 double *pdfMean, double *pdfStdDev, 00395 GDALProgressFunc pfnProgress, void *pProgressData ); 00396 virtual CPLErr GetHistogram( double dfMin, double dfMax, 00397 int nBuckets, int * panHistogram, 00398 int bIncludeOutOfRange, int bApproxOK, 00399 GDALProgressFunc pfnProgress, void *pProgressData ); 00400 00401 CPLErr AddSource( VRTSource * ); 00402 CPLErr AddSimpleSource( GDALRasterBand *poSrcBand, 00403 int nSrcXOff=-1, int nSrcYOff=-1, 00404 int nSrcXSize=-1, int nSrcYSize=-1, 00405 int nDstXOff=-1, int nDstYOff=-1, 00406 int nDstXSize=-1, int nDstYSize=-1, 00407 const char *pszResampling = "near", 00408 double dfNoDataValue = VRT_NODATA_UNSET); 00409 CPLErr AddComplexSource( GDALRasterBand *poSrcBand, 00410 int nSrcXOff=-1, int nSrcYOff=-1, 00411 int nSrcXSize=-1, int nSrcYSize=-1, 00412 int nDstXOff=-1, int nDstYOff=-1, 00413 int nDstXSize=-1, int nDstYSize=-1, 00414 double dfScaleOff=0.0, 00415 double dfScaleRatio=1.0, 00416 double dfNoDataValue = VRT_NODATA_UNSET, 00417 int nColorTableComponent = 0); 00418 00419 CPLErr AddMaskBandSource( GDALRasterBand *poSrcBand, 00420 int nSrcXOff=-1, int nSrcYOff=-1, 00421 int nSrcXSize=-1, int nSrcYSize=-1, 00422 int nDstXOff=-1, int nDstYOff=-1, 00423 int nDstXSize=-1, int nDstYSize=-1 ); 00424 00425 CPLErr AddFuncSource( VRTImageReadFunc pfnReadFunc, void *hCBData, 00426 double dfNoDataValue = VRT_NODATA_UNSET ); 00427 00428 00429 virtual CPLErr IReadBlock( int, int, void * ); 00430 00431 virtual void GetFileList(char*** ppapszFileList, int *pnSize, 00432 int *pnMaxSize, CPLHashSet* hSetFiles); 00433 00434 virtual int CloseDependentDatasets(); 00435 00436 virtual int IsSourcedRasterBand() { return TRUE; } 00437 }; 00438 00439 /************************************************************************/ 00440 /* VRTWarpedRasterBand */ 00441 /************************************************************************/ 00442 00443 class CPL_DLL VRTWarpedRasterBand : public VRTRasterBand 00444 { 00445 public: 00446 VRTWarpedRasterBand( GDALDataset *poDS, int nBand, 00447 GDALDataType eType = GDT_Unknown ); 00448 virtual ~VRTWarpedRasterBand(); 00449 00450 virtual CPLErr XMLInit( CPLXMLNode *, const char * ); 00451 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ); 00452 00453 virtual CPLErr IReadBlock( int, int, void * ); 00454 virtual CPLErr IWriteBlock( int, int, void * ); 00455 00456 virtual int GetOverviewCount(); 00457 virtual GDALRasterBand *GetOverview(int); 00458 }; 00459 00460 /************************************************************************/ 00461 /* VRTDerivedRasterBand */ 00462 /************************************************************************/ 00463 00464 class CPL_DLL VRTDerivedRasterBand : public VRTSourcedRasterBand 00465 { 00466 00467 public: 00468 char *pszFuncName; 00469 GDALDataType eSourceTransferType; 00470 00471 VRTDerivedRasterBand(GDALDataset *poDS, int nBand); 00472 VRTDerivedRasterBand(GDALDataset *poDS, int nBand, 00473 GDALDataType eType, int nXSize, int nYSize); 00474 virtual ~VRTDerivedRasterBand(); 00475 00476 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, 00477 void *, int, int, GDALDataType, 00478 int, int ); 00479 00480 static CPLErr AddPixelFunction 00481 (const char *pszFuncName, GDALDerivedPixelFunc pfnPixelFunc); 00482 static GDALDerivedPixelFunc GetPixelFunction(const char *pszFuncName); 00483 00484 void SetPixelFunctionName(const char *pszFuncName); 00485 void SetSourceTransferType(GDALDataType eDataType); 00486 00487 virtual CPLErr XMLInit( CPLXMLNode *, const char * ); 00488 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ); 00489 00490 }; 00491 00492 /************************************************************************/ 00493 /* VRTRawRasterBand */ 00494 /************************************************************************/ 00495 00496 class RawRasterBand; 00497 00498 class CPL_DLL VRTRawRasterBand : public VRTRasterBand 00499 { 00500 RawRasterBand *poRawRaster; 00501 00502 char *pszSourceFilename; 00503 int bRelativeToVRT; 00504 00505 public: 00506 VRTRawRasterBand( GDALDataset *poDS, int nBand, 00507 GDALDataType eType = GDT_Unknown ); 00508 virtual ~VRTRawRasterBand(); 00509 00510 virtual CPLErr XMLInit( CPLXMLNode *, const char * ); 00511 virtual CPLXMLNode * SerializeToXML( const char *pszVRTPath ); 00512 00513 virtual CPLErr IRasterIO( GDALRWFlag, int, int, int, int, 00514 void *, int, int, GDALDataType, 00515 int, int ); 00516 00517 virtual CPLErr IReadBlock( int, int, void * ); 00518 virtual CPLErr IWriteBlock( int, int, void * ); 00519 00520 CPLErr SetRawLink( const char *pszFilename, 00521 const char *pszVRTPath, 00522 int bRelativeToVRT, 00523 vsi_l_offset nImageOffset, 00524 int nPixelOffset, int nLineOffset, 00525 const char *pszByteOrder ); 00526 00527 void ClearRawLink(); 00528 00529 virtual void GetFileList(char*** ppapszFileList, int *pnSize, 00530 int *pnMaxSize, CPLHashSet* hSetFiles); 00531 }; 00532 00533 /************************************************************************/ 00534 /* VRTDriver */ 00535 /************************************************************************/ 00536 00537 class VRTDriver : public GDALDriver 00538 { 00539 void *pDeserializerData; 00540 00541 public: 00542 VRTDriver(); 00543 ~VRTDriver(); 00544 00545 char **papszSourceParsers; 00546 00547 virtual char **GetMetadata( const char * pszDomain = "" ); 00548 virtual CPLErr SetMetadata( char ** papszMetadata, 00549 const char * pszDomain = "" ); 00550 00551 VRTSource *ParseSource( CPLXMLNode *psSrc, const char *pszVRTPath ); 00552 void AddSourceParser( const char *pszElementName, 00553 VRTSourceParser pfnParser ); 00554 }; 00555 00556 /************************************************************************/ 00557 /* VRTSimpleSource */ 00558 /************************************************************************/ 00559 00560 class VRTSimpleSource : public VRTSource 00561 { 00562 protected: 00563 GDALRasterBand *poRasterBand; 00564 00565 /* when poRasterBand is a mask band, poMaskBandMainBand is the band */ 00566 /* from which the mask band is taken */ 00567 GDALRasterBand *poMaskBandMainBand; 00568 00569 int nSrcXOff; 00570 int nSrcYOff; 00571 int nSrcXSize; 00572 int nSrcYSize; 00573 00574 int nDstXOff; 00575 int nDstYOff; 00576 int nDstXSize; 00577 int nDstYSize; 00578 00579 int bNoDataSet; 00580 double dfNoDataValue; 00581 00582 public: 00583 VRTSimpleSource(); 00584 virtual ~VRTSimpleSource(); 00585 00586 virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * ); 00587 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); 00588 00589 void SetSrcBand( GDALRasterBand * ); 00590 void SetSrcMaskBand( GDALRasterBand * ); 00591 void SetSrcWindow( int, int, int, int ); 00592 void SetDstWindow( int, int, int, int ); 00593 void SetNoDataValue( double dfNoDataValue ); 00594 00595 int GetSrcDstWindow( int, int, int, int, int, int, 00596 int *, int *, int *, int *, 00597 int *, int *, int *, int * ); 00598 00599 virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 00600 void *pData, int nBufXSize, int nBufYSize, 00601 GDALDataType eBufType, 00602 int nPixelSpace, int nLineSpace ); 00603 00604 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ); 00605 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ); 00606 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax ); 00607 virtual CPLErr ComputeStatistics( int nXSize, int nYSize, 00608 int bApproxOK, 00609 double *pdfMin, double *pdfMax, 00610 double *pdfMean, double *pdfStdDev, 00611 GDALProgressFunc pfnProgress, void *pProgressData ); 00612 virtual CPLErr GetHistogram( int nXSize, int nYSize, 00613 double dfMin, double dfMax, 00614 int nBuckets, int * panHistogram, 00615 int bIncludeOutOfRange, int bApproxOK, 00616 GDALProgressFunc pfnProgress, void *pProgressData ); 00617 00618 void DstToSrc( double dfX, double dfY, 00619 double &dfXOut, double &dfYOut ); 00620 void SrcToDst( double dfX, double dfY, 00621 double &dfXOut, double &dfYOut ); 00622 00623 virtual void GetFileList(char*** ppapszFileList, int *pnSize, 00624 int *pnMaxSize, CPLHashSet* hSetFiles); 00625 00626 virtual int IsSimpleSource() { return TRUE; } 00627 virtual const char* GetType() { return "SimpleSource"; } 00628 00629 GDALRasterBand* GetBand(); 00630 int IsSameExceptBandNumber(VRTSimpleSource* poOtherSource); 00631 CPLErr DatasetRasterIO( 00632 int nXOff, int nYOff, int nXSize, int nYSize, 00633 void * pData, int nBufXSize, int nBufYSize, 00634 GDALDataType eBufType, 00635 int nBandCount, int *panBandMap, 00636 int nPixelSpace, int nLineSpace, int nBandSpace); 00637 }; 00638 00639 /************************************************************************/ 00640 /* VRTAveragedSource */ 00641 /************************************************************************/ 00642 00643 class VRTAveragedSource : public VRTSimpleSource 00644 { 00645 public: 00646 VRTAveragedSource(); 00647 virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 00648 void *pData, int nBufXSize, int nBufYSize, 00649 GDALDataType eBufType, 00650 int nPixelSpace, int nLineSpace ); 00651 00652 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ); 00653 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ); 00654 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax ); 00655 virtual CPLErr ComputeStatistics( int nXSize, int nYSize, 00656 int bApproxOK, 00657 double *pdfMin, double *pdfMax, 00658 double *pdfMean, double *pdfStdDev, 00659 GDALProgressFunc pfnProgress, void *pProgressData ); 00660 virtual CPLErr GetHistogram( int nXSize, int nYSize, 00661 double dfMin, double dfMax, 00662 int nBuckets, int * panHistogram, 00663 int bIncludeOutOfRange, int bApproxOK, 00664 GDALProgressFunc pfnProgress, void *pProgressData ); 00665 00666 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); 00667 virtual const char* GetType() { return "AveragedSource"; } 00668 }; 00669 00670 /************************************************************************/ 00671 /* VRTComplexSource */ 00672 /************************************************************************/ 00673 00674 class VRTComplexSource : public VRTSimpleSource 00675 { 00676 protected: 00677 CPLErr RasterIOInternal( int nReqXOff, int nReqYOff, 00678 int nReqXSize, int nReqYSize, 00679 void *pData, int nOutXSize, int nOutYSize, 00680 GDALDataType eBufType, 00681 int nPixelSpace, int nLineSpace ); 00682 00683 public: 00684 VRTComplexSource(); 00685 virtual ~VRTComplexSource(); 00686 00687 virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 00688 void *pData, int nBufXSize, int nBufYSize, 00689 GDALDataType eBufType, 00690 int nPixelSpace, int nLineSpace ); 00691 00692 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ); 00693 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ); 00694 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax ); 00695 virtual CPLErr ComputeStatistics( int nXSize, int nYSize, 00696 int bApproxOK, 00697 double *pdfMin, double *pdfMax, 00698 double *pdfMean, double *pdfStdDev, 00699 GDALProgressFunc pfnProgress, void *pProgressData ); 00700 virtual CPLErr GetHistogram( int nXSize, int nYSize, 00701 double dfMin, double dfMax, 00702 int nBuckets, int * panHistogram, 00703 int bIncludeOutOfRange, int bApproxOK, 00704 GDALProgressFunc pfnProgress, void *pProgressData ); 00705 00706 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); 00707 virtual CPLErr XMLInit( CPLXMLNode *, const char * ); 00708 virtual const char* GetType() { return "ComplexSource"; } 00709 00710 double LookupValue( double dfInput ); 00711 00712 int bDoScaling; 00713 double dfScaleOff; 00714 double dfScaleRatio; 00715 double *padfLUTInputs; 00716 double *padfLUTOutputs; 00717 int nLUTItemCount; 00718 int nColorTableComponent; 00719 }; 00720 00721 /************************************************************************/ 00722 /* VRTFilteredSource */ 00723 /************************************************************************/ 00724 00725 class VRTFilteredSource : public VRTComplexSource 00726 { 00727 private: 00728 int IsTypeSupported( GDALDataType eType ); 00729 00730 protected: 00731 int nSupportedTypesCount; 00732 GDALDataType aeSupportedTypes[20]; 00733 00734 int nExtraEdgePixels; 00735 00736 public: 00737 VRTFilteredSource(); 00738 virtual ~VRTFilteredSource(); 00739 00740 void SetExtraEdgePixels( int ); 00741 void SetFilteringDataTypesSupported( int, GDALDataType * ); 00742 00743 virtual CPLErr FilterData( int nXSize, int nYSize, GDALDataType eType, 00744 GByte *pabySrcData, GByte *pabyDstData ) = 0; 00745 00746 virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 00747 void *pData, int nBufXSize, int nBufYSize, 00748 GDALDataType eBufType, 00749 int nPixelSpace, int nLineSpace ); 00750 }; 00751 00752 /************************************************************************/ 00753 /* VRTKernelFilteredSource */ 00754 /************************************************************************/ 00755 00756 class VRTKernelFilteredSource : public VRTFilteredSource 00757 { 00758 protected: 00759 int nKernelSize; 00760 00761 double *padfKernelCoefs; 00762 00763 int bNormalized; 00764 00765 public: 00766 VRTKernelFilteredSource(); 00767 virtual ~VRTKernelFilteredSource(); 00768 00769 virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * ); 00770 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); 00771 00772 virtual CPLErr FilterData( int nXSize, int nYSize, GDALDataType eType, 00773 GByte *pabySrcData, GByte *pabyDstData ); 00774 00775 CPLErr SetKernel( int nKernelSize, double *padfCoefs ); 00776 void SetNormalized( int ); 00777 }; 00778 00779 /************************************************************************/ 00780 /* VRTAverageFilteredSource */ 00781 /************************************************************************/ 00782 00783 class VRTAverageFilteredSource : public VRTKernelFilteredSource 00784 { 00785 public: 00786 VRTAverageFilteredSource( int nKernelSize ); 00787 virtual ~VRTAverageFilteredSource(); 00788 00789 virtual CPLErr XMLInit( CPLXMLNode *psTree, const char * ); 00790 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); 00791 }; 00792 00793 /************************************************************************/ 00794 /* VRTFuncSource */ 00795 /************************************************************************/ 00796 class VRTFuncSource : public VRTSource 00797 { 00798 public: 00799 VRTFuncSource(); 00800 virtual ~VRTFuncSource(); 00801 00802 virtual CPLErr XMLInit( CPLXMLNode *, const char *) { return CE_Failure; } 00803 virtual CPLXMLNode *SerializeToXML( const char *pszVRTPath ); 00804 00805 virtual CPLErr RasterIO( int nXOff, int nYOff, int nXSize, int nYSize, 00806 void *pData, int nBufXSize, int nBufYSize, 00807 GDALDataType eBufType, 00808 int nPixelSpace, int nLineSpace ); 00809 00810 virtual double GetMinimum( int nXSize, int nYSize, int *pbSuccess ); 00811 virtual double GetMaximum( int nXSize, int nYSize, int *pbSuccess ); 00812 virtual CPLErr ComputeRasterMinMax( int nXSize, int nYSize, int bApproxOK, double* adfMinMax ); 00813 virtual CPLErr ComputeStatistics( int nXSize, int nYSize, 00814 int bApproxOK, 00815 double *pdfMin, double *pdfMax, 00816 double *pdfMean, double *pdfStdDev, 00817 GDALProgressFunc pfnProgress, void *pProgressData ); 00818 virtual CPLErr GetHistogram( int nXSize, int nYSize, 00819 double dfMin, double dfMax, 00820 int nBuckets, int * panHistogram, 00821 int bIncludeOutOfRange, int bApproxOK, 00822 GDALProgressFunc pfnProgress, void *pProgressData ); 00823 00824 VRTImageReadFunc pfnReadFunc; 00825 void *pCBData; 00826 GDALDataType eType; 00827 00828 float fNoDataValue; 00829 }; 00830 00831 #endif /* ndef VIRTUALDATASET_H_INCLUDED */