Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

vrtdataset.h

00001 /****************************************************************************** 00002 * $Id: vrtdataset.h,v 1.11 2003/09/11 23:00:04 aamici Exp $ 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 * $Log: vrtdataset.h,v $ 00031 * Revision 1.11 2003/09/11 23:00:04 aamici 00032 * add class constructors and destructors where needed in order to 00033 * let the mingw/cygwin binutils produce sensible partially linked objet files 00034 * with 'ld -r'. 00035 * 00036 * Revision 1.10 2003/08/07 17:11:21 warmerda 00037 * added normalized flag for kernel based filters 00038 * 00039 * Revision 1.9 2003/07/17 20:30:24 warmerda 00040 * Added custom VRTDriver and moved all the sources class declarations in here. 00041 * 00042 * Revision 1.8 2003/06/10 19:59:33 warmerda 00043 * added new Func based source type for passthrough to a callback 00044 * 00045 * Revision 1.7 2003/03/13 20:38:30 dron 00046 * bNoDataValueSet added to VRTRasterBand class. 00047 * 00048 * Revision 1.6 2002/11/30 16:55:49 warmerda 00049 * added OpenXML method 00050 * 00051 * Revision 1.5 2002/11/24 04:29:02 warmerda 00052 * Substantially rewrote VRTSimpleSource. Now VRTSource is base class, and 00053 * sources do their own SerializeToXML(), and XMLInit(). New VRTComplexSource 00054 * supports scaling and nodata values. 00055 * 00056 * Revision 1.4 2002/05/29 18:13:44 warmerda 00057 * added nodata handling for averager 00058 * 00059 * Revision 1.3 2002/05/29 16:06:05 warmerda 00060 * complete detailed band metadata 00061 * 00062 * Revision 1.2 2001/11/18 15:46:45 warmerda 00063 * added SRS and GeoTransform 00064 * 00065 * Revision 1.1 2001/11/16 21:14:31 warmerda 00066 * New 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 /* VRTSource */ 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 /* VRTDataset */ 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 /* VRTRasterBand */ 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 /* VRTDriver */ 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 /* VRTSimpleSource */ 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 /* VRTAveragedSource */ 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 /* VRTComplexSource */ 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 /* VRTFilteredSource */ 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 /* VRTKernelFilteredSource */ 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 /* VRTAverageFilteredSource */ 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 /* VRTFuncSource */ 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 /* ndef VIRTUALDATASET_H_INCLUDED */

Generated on Thu Jul 29 19:47:52 2004 for GDAL by doxygen 1.3.7