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

vrtdataset.h

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

Generated on Mon Aug 9 12:09:04 2004 for GDAL by doxygen 1.3.8