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

gdalwarper.h

Go to the documentation of this file.
00001 /****************************************************************************** 00002 * $Id: gdalwarper.h,v 1.11 2003/11/22 19:13:31 dron Exp $ 00003 * 00004 * Project: GDAL High Performance Warper 00005 * Purpose: Prototypes, and definitions for warping related work. 00006 * Author: Frank Warmerdam, warmerdam@pobox.com 00007 * 00008 ****************************************************************************** 00009 * Copyright (c) 2003, Frank Warmerdam 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: gdalwarper.h,v $ 00031 * Revision 1.11 2003/11/22 19:13:31 dron 00032 * Added C bindings for GDALWarpOperation functions. 00033 * 00034 * Revision 1.10 2003/07/04 11:50:57 dron 00035 * GRA_CubicSpline added to the list of resampling algorithms. 00036 * 00037 * Revision 1.9 2003/06/12 11:21:33 dron 00038 * Few additional comments. 00039 * 00040 * Revision 1.8 2003/05/27 20:49:25 warmerda 00041 * added REPORT_TIMINGS support 00042 * 00043 * Revision 1.7 2003/05/07 19:13:06 warmerda 00044 * added pre and post warp chunk processor 00045 * 00046 * Revision 1.6 2003/04/23 05:18:57 warmerda 00047 * added multithread support 00048 * 00049 * Revision 1.5 2003/03/02 05:25:59 warmerda 00050 * added some source nodata support 00051 * 00052 * Revision 1.4 2003/02/22 02:04:11 warmerda 00053 * added dfMaxError to reproject function 00054 * 00055 * Revision 1.3 2003/02/21 15:41:37 warmerda 00056 * added progressbase/scale for operation 00057 * 00058 * Revision 1.2 2003/02/20 21:53:06 warmerda 00059 * partial implementation 00060 * 00061 * Revision 1.1 2003/02/18 17:25:50 warmerda 00062 * New 00063 * 00064 */ 00065 00066 #ifndef GDALWARPER_H_INCLUDED 00067 #define GDALWARPER_H_INCLUDED 00068 00077 #include "gdal_alg.h" 00078 00079 CPL_C_START 00080 00082 typedef enum { GRA_NearestNeighbour=0, GRA_Bilinear=1, GRA_Cubic=2, GRA_CubicSpline=3, 00087 } GDALResampleAlg; 00088 00089 typedef int 00090 (*GDALMaskFunc)( void *pMaskFuncArg, 00091 int nBandCount, GDALDataType eType, 00092 int nXOff, int nYOff, 00093 int nXSize, int nYSize, 00094 GByte **papabyImageData, 00095 int bMaskIsFloat, void *pMask ); 00096 00097 CPLErr GDALWarpNoDataMasker( void *pMaskFuncArg, int nBandCount, 00098 GDALDataType eType, 00099 int nXOff, int nYOff, int nXSize, int nYSize, 00100 GByte **papabyImageData, int bMaskIsFloat, 00101 void *pValidityMask ); 00102 00103 /************************************************************************/ 00104 /* GDALWarpOptions */ 00105 /************************************************************************/ 00106 00108 typedef struct { 00109 00110 char **papszWarpOptions; 00111 00113 double dfWarpMemoryLimit; 00114 00116 GDALResampleAlg eResampleAlg; 00117 00120 GDALDataType eWorkingDataType; 00121 00123 GDALDatasetH hSrcDS; 00124 00126 GDALDatasetH hDstDS; 00127 00129 int nBandCount; 00130 00132 int *panSrcBands; 00133 00135 int *panDstBands; 00136 00138 double *padfSrcNoDataReal; 00141 double *padfSrcNoDataImag; 00142 00144 double *padfDstNoDataReal; 00147 double *padfDstNoDataImag; 00148 00151 GDALProgressFunc pfnProgress; 00152 00154 void *pProgressArg; 00155 00157 GDALTransformerFunc pfnTransformer; 00158 00160 void *pTransformerArg; 00161 00162 GDALMaskFunc *papfnSrcPerBandValidityMaskFunc; 00163 void **papSrcPerBandValidityMaskFuncArg; 00164 00165 GDALMaskFunc pfnSrcValidityMaskFunc; 00166 void *pSrcValidityMaskFuncArg; 00167 00168 GDALMaskFunc pfnSrcDensityMaskFunc; 00169 void *pSrcDensityMaskFuncArg; 00170 00171 GDALMaskFunc pfnDstDensityMaskFunc; 00172 void *pDstDensityMaskFuncArg; 00173 00174 GDALMaskFunc pfnDstValidityMaskFunc; 00175 void *pDstValidityMaskFuncArg; 00176 00177 CPLErr (*pfnPreWarpChunkProcessor)( void *pKern, void *pArg ); 00178 void *pPreWarpProcessorArg; 00179 00180 CPLErr (*pfnPostWarpChunkProcessor)( void *pKern, void *pArg); 00181 void *pPostWarpProcessorArg; 00182 00183 } GDALWarpOptions; 00184 00185 GDALWarpOptions CPL_DLL *GDALCreateWarpOptions(); 00186 void CPL_DLL GDALDestroyWarpOptions( GDALWarpOptions * ); 00187 GDALWarpOptions CPL_DLL *GDALCloneWarpOptions( const GDALWarpOptions * ); 00188 00189 /************************************************************************/ 00190 /* GDALReprojectImage() */ 00191 /************************************************************************/ 00192 00193 CPLErr CPL_DLL 00194 GDALReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT, 00195 GDALDatasetH hDstDS, const char *pszDstWKT, 00196 GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit, 00197 double dfMaxError, 00198 GDALProgressFunc pfnProgress, void *pProgressArg, 00199 GDALWarpOptions *psOptions ); 00200 00201 CPLErr CPL_DLL 00202 GDALCreateAndReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT, 00203 const char *pszDstFilename, const char *pszDstWKT, 00204 GDALDriverH hDstDriver, char **papszCreateOptions, 00205 GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit, 00206 double dfMaxError, 00207 GDALProgressFunc pfnProgress, void *pProgressArg, 00208 GDALWarpOptions *psOptions ); 00209 00210 CPL_C_END 00211 00212 #ifdef __cplusplus 00213 00214 /************************************************************************/ 00215 /* GDALWarpKernel */ 00216 /* */ 00217 /* This class represents the lowest level of abstraction. It */ 00218 /* is holds the imagery for one "chunk" of a warp, and the */ 00219 /* pre-prepared masks. All IO is done before and after it's */ 00220 /* operation. This class is not normally used by the */ 00221 /* application. */ 00222 /************************************************************************/ 00223 00224 class CPL_DLL GDALWarpKernel 00225 { 00226 public: 00227 GDALWarpKernel(); 00228 virtual ~GDALWarpKernel(); 00229 00230 char **papszWarpOptions; 00231 00232 GDALResampleAlg eResample; 00233 GDALDataType eWorkingDataType; 00234 int nBands; 00235 00236 int nSrcXSize; 00237 int nSrcYSize; 00238 GByte **papabySrcImage; 00239 00240 GUInt32 **papanBandSrcValid; 00241 GUInt32 *panUnifiedSrcValid; 00242 float *pafUnifiedSrcDensity; 00243 00244 int nDstXSize; 00245 int nDstYSize; 00246 GByte **papabyDstImage; 00247 GUInt32 *panDstValid; 00248 float *pafDstDensity; 00249 00250 int nSrcXOff; 00251 int nSrcYOff; 00252 00253 int nDstXOff; 00254 int nDstYOff; 00255 00256 GDALTransformerFunc pfnTransformer; 00257 void *pTransformerArg; 00258 00259 GDALProgressFunc pfnProgress; 00260 void *pProgress; 00261 00262 double dfProgressBase; 00263 double dfProgressScale; 00264 00265 CPLErr Validate(); 00266 CPLErr PerformWarp(); 00267 }; 00268 00269 /************************************************************************/ 00270 /* GDALWarpOperation() */ 00271 /* */ 00272 /* This object is application created, or created by a higher */ 00273 /* level convenience function. It is responsible for */ 00274 /* subdividing the operation into chunks, loading and saving */ 00275 /* imagery, and establishing the varios validity and density */ 00276 /* masks. Actual resampling is done by the GDALWarpKernel. */ 00277 /************************************************************************/ 00278 00279 class CPL_DLL GDALWarpOperation { 00280 private: 00281 GDALWarpOptions *psOptions; 00282 00283 double dfProgressBase; 00284 double dfProgressScale; 00285 00286 void WipeOptions(); 00287 int ValidateOptions(); 00288 00289 CPLErr ComputeSourceWindow( int nDstXOff, int nDstYOff, 00290 int nDstXSize, int nDstYSize, 00291 int *pnSrcXOff, int *pnSrcYOff, 00292 int *pnSrcXSize, int *pnSrcYSize ); 00293 00294 CPLErr CreateKernelMask( GDALWarpKernel *, int iBand, 00295 const char *pszType ); 00296 00297 void *hThread1Mutex; 00298 void *hThread2Mutex; 00299 void *hIOMutex; 00300 void *hWarpMutex; 00301 00302 int nChunkListCount; 00303 int nChunkListMax; 00304 int *panChunkList; 00305 00306 int bReportTimings; 00307 unsigned long nLastTimeReported; 00308 00309 void WipeChunkList(); 00310 CPLErr CollectChunkList( int nDstXOff, int nDstYOff, 00311 int nDstXSize, int nDstYSize ); 00312 void ReportTiming( const char * ); 00313 00314 public: 00315 GDALWarpOperation(); 00316 virtual ~GDALWarpOperation(); 00317 00318 CPLErr Initialize( const GDALWarpOptions *psNewOptions ); 00319 00320 const GDALWarpOptions *GetOptions(); 00321 00322 CPLErr ChunkAndWarpImage( int nDstXOff, int nDstYOff, 00323 int nDstXSize, int nDstYSize ); 00324 CPLErr ChunkAndWarpMulti( int nDstXOff, int nDstYOff, 00325 int nDstXSize, int nDstYSize ); 00326 CPLErr WarpRegion( int nDstXOff, int nDstYOff, 00327 int nDstXSize, int nDstYSize, 00328 int nSrcXOff=0, int nSrcYOff=0, 00329 int nSrcXSize=0, int nSrcYSize=0 ); 00330 00331 CPLErr WarpRegionToBuffer( int nDstXOff, int nDstYOff, 00332 int nDstXSize, int nDstYSize, 00333 void *pDataBuf, 00334 GDALDataType eBufDataType, 00335 int nSrcXOff=0, int nSrcYOff=0, 00336 int nSrcXSize=0, int nSrcYSize=0 ); 00337 }; 00338 00339 #endif /* def __cplusplus */ 00340 00341 CPL_C_START 00342 00343 typedef void * GDALWarpOperationH; 00344 00345 GDALWarpOperationH CPL_DLL GDALCreateWarpOperation(const GDALWarpOptions* ); 00346 void CPL_DLL GDALDestroyWarpOperation( GDALWarpOperationH ); 00347 CPLErr CPL_DLL GDALChunkAndWarpImage( GDALWarpOperationH, int, int, int, int ); 00348 CPLErr CPL_DLL GDALChunkAndWarpMulti( GDALWarpOperationH, int, int, int, int ); 00349 CPLErr CPL_DLL GDALWarpRegion( GDALWarpOperationH, 00350 int, int, int, int, int, int, int, int ); 00351 CPLErr CPL_DLL GDALWarpRegionToBuffer( GDALWarpOperationH, int, int, int, int, 00352 void *, GDALDataType, 00353 int, int, int, int ); 00354 00355 CPL_C_END 00356 00357 #endif /* ndef GDAL_ALG_H_INCLUDED */

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