GDAL
gdalwarper.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: gdalwarper.h 20819 2010-10-13 15:59:44Z warmerdam $
3  *
4  * Project: GDAL High Performance Warper
5  * Purpose: Prototypes, and definitions for warping related work.
6  * Author: Frank Warmerdam, warmerdam@pobox.com
7  *
8  ******************************************************************************
9  * Copyright (c) 2003, Frank Warmerdam
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included
19  * in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  ****************************************************************************/
29 
30 #ifndef GDALWARPER_H_INCLUDED
31 #define GDALWARPER_H_INCLUDED
32 
41 #include "gdal_alg.h"
42 #include "cpl_minixml.h"
43 
44 CPL_C_START
45 
54 
55 typedef int
56 (*GDALMaskFunc)( void *pMaskFuncArg,
57  int nBandCount, GDALDataType eType,
58  int nXOff, int nYOff,
59  int nXSize, int nYSize,
60  GByte **papabyImageData,
61  int bMaskIsFloat, void *pMask );
62 
63 CPLErr CPL_DLL
64 GDALWarpNoDataMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
65  int nXOff, int nYOff, int nXSize, int nYSize,
66  GByte **papabyImageData, int bMaskIsFloat,
67  void *pValidityMask );
68 
69 CPLErr CPL_DLL
70 GDALWarpDstAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
71  int nXOff, int nYOff, int nXSize, int nYSize,
72  GByte ** /*ppImageData */,
73  int bMaskIsFloat, void *pValidityMask );
74 CPLErr CPL_DLL
75 GDALWarpSrcAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
76  int nXOff, int nYOff, int nXSize, int nYSize,
77  GByte ** /*ppImageData */,
78  int bMaskIsFloat, void *pValidityMask );
79 
80 CPLErr CPL_DLL
81 GDALWarpSrcMaskMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
82  int nXOff, int nYOff, int nXSize, int nYSize,
83  GByte ** /*ppImageData */,
84  int bMaskIsFloat, void *pValidityMask );
85 
86 CPLErr CPL_DLL
87 GDALWarpCutlineMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
88  int nXOff, int nYOff, int nXSize, int nYSize,
89  GByte ** /* ppImageData */,
90  int bMaskIsFloat, void *pValidityMask );
91 
92 /************************************************************************/
93 /* GDALWarpOptions */
94 /************************************************************************/
95 
97 typedef struct {
98 
100 
103 
106 
110 
113 
116 
119 
122 
125 
128 
131 
137 
143 
147 
150 
153 
156 
157  GDALMaskFunc *papfnSrcPerBandValidityMaskFunc;
158  void **papSrcPerBandValidityMaskFuncArg;
159 
160  GDALMaskFunc pfnSrcValidityMaskFunc;
161  void *pSrcValidityMaskFuncArg;
162 
163  GDALMaskFunc pfnSrcDensityMaskFunc;
164  void *pSrcDensityMaskFuncArg;
165 
166  GDALMaskFunc pfnDstDensityMaskFunc;
167  void *pDstDensityMaskFuncArg;
168 
169  GDALMaskFunc pfnDstValidityMaskFunc;
170  void *pDstValidityMaskFuncArg;
171 
172  CPLErr (*pfnPreWarpChunkProcessor)( void *pKern, void *pArg );
173  void *pPreWarpProcessorArg;
174 
175  CPLErr (*pfnPostWarpChunkProcessor)( void *pKern, void *pArg);
176  void *pPostWarpProcessorArg;
177 
179  void *hCutline;
180 
183 
185 
186 GDALWarpOptions CPL_DLL * CPL_STDCALL GDALCreateWarpOptions(void);
187 void CPL_DLL CPL_STDCALL GDALDestroyWarpOptions( GDALWarpOptions * );
188 GDALWarpOptions CPL_DLL * CPL_STDCALL
189 GDALCloneWarpOptions( const GDALWarpOptions * );
190 
191 CPLXMLNode CPL_DLL * CPL_STDCALL
192  GDALSerializeWarpOptions( const GDALWarpOptions * );
193 GDALWarpOptions CPL_DLL * CPL_STDCALL
194  GDALDeserializeWarpOptions( CPLXMLNode * );
195 
196 /************************************************************************/
197 /* GDALReprojectImage() */
198 /************************************************************************/
199 
200 CPLErr CPL_DLL CPL_STDCALL
201 GDALReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
202  GDALDatasetH hDstDS, const char *pszDstWKT,
203  GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit,
204  double dfMaxError,
205  GDALProgressFunc pfnProgress, void *pProgressArg,
206  GDALWarpOptions *psOptions );
207 
208 CPLErr CPL_DLL CPL_STDCALL
209 GDALCreateAndReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
210  const char *pszDstFilename, const char *pszDstWKT,
211  GDALDriverH hDstDriver, char **papszCreateOptions,
212  GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit,
213  double dfMaxError,
214  GDALProgressFunc pfnProgress, void *pProgressArg,
215  GDALWarpOptions *psOptions );
216 
217 /************************************************************************/
218 /* VRTWarpedDataset */
219 /************************************************************************/
220 
221 GDALDatasetH CPL_DLL CPL_STDCALL
223  const char *pszSrcWKT, const char *pszDstWKT,
224  GDALResampleAlg eResampleAlg,
225  double dfMaxError, const GDALWarpOptions *psOptions );
226 
227 GDALDatasetH CPL_DLL CPL_STDCALL
229  int nPixels, int nLines, double *padfGeoTransform,
230  GDALWarpOptions *psOptions );
231 
232 CPLErr CPL_DLL CPL_STDCALL
234  GDALWarpOptions *psWO );
235 
236 CPL_C_END
237 
238 #ifdef __cplusplus
239 
240 /************************************************************************/
241 /* GDALWarpKernel */
242 /* */
243 /* This class represents the lowest level of abstraction. It */
244 /* is holds the imagery for one "chunk" of a warp, and the */
245 /* pre-prepared masks. All IO is done before and after it's */
246 /* operation. This class is not normally used by the */
247 /* application. */
248 /************************************************************************/
249 
250 class CPL_DLL GDALWarpKernel
251 {
252 public:
253  char **papszWarpOptions;
254 
257  int nBands;
258 
261  GByte **papabySrcImage;
262 
263  GUInt32 **papanBandSrcValid;
266 
269  GByte **papabyDstImage;
270  GUInt32 *panDstValid;
272 
273  double dfXScale; // Resampling scale, i.e.
274  double dfYScale; // nDstSize/nSrcSize.
275  double dfXFilter; // Size of filter kernel.
276  double dfYFilter;
277  int nXRadius; // Size of window to filter.
278  int nYRadius;
279  int nFiltInitX; // Filtering offset
280  int nFiltInitY;
281 
282  int nSrcXOff;
283  int nSrcYOff;
284 
285  int nDstXOff;
286  int nDstYOff;
287 
290 
292  void *pProgress;
293 
294  double dfProgressBase;
295  double dfProgressScale;
296 
297  double *padfDstNoDataReal;
298 
299  GDALWarpKernel();
300  virtual ~GDALWarpKernel();
301 
302  CPLErr Validate();
303  CPLErr PerformWarp();
304 };
305 
306 /************************************************************************/
307 /* GDALWarpOperation() */
308 /* */
309 /* This object is application created, or created by a higher */
310 /* level convenience function. It is responsible for */
311 /* subdividing the operation into chunks, loading and saving */
312 /* imagery, and establishing the varios validity and density */
313 /* masks. Actual resampling is done by the GDALWarpKernel. */
314 /************************************************************************/
315 
316 class CPL_DLL GDALWarpOperation {
317 private:
318  GDALWarpOptions *psOptions;
319 
320  void WipeOptions();
321  int ValidateOptions();
322 
323  CPLErr ComputeSourceWindow( int nDstXOff, int nDstYOff,
324  int nDstXSize, int nDstYSize,
325  int *pnSrcXOff, int *pnSrcYOff,
326  int *pnSrcXSize, int *pnSrcYSize );
327 
328  CPLErr CreateKernelMask( GDALWarpKernel *, int iBand,
329  const char *pszType );
330 
331  void *hThread1Mutex;
332  void *hThread2Mutex;
333  void *hIOMutex;
334  void *hWarpMutex;
335 
336  int nChunkListCount;
337  int nChunkListMax;
338  int *panChunkList;
339 
340  int bReportTimings;
341  unsigned long nLastTimeReported;
342 
343  void WipeChunkList();
344  CPLErr CollectChunkList( int nDstXOff, int nDstYOff,
345  int nDstXSize, int nDstYSize );
346  void ReportTiming( const char * );
347 
348 public:
350  virtual ~GDALWarpOperation();
351 
352  CPLErr Initialize( const GDALWarpOptions *psNewOptions );
353 
354  const GDALWarpOptions *GetOptions();
355 
356  CPLErr ChunkAndWarpImage( int nDstXOff, int nDstYOff,
357  int nDstXSize, int nDstYSize );
358  CPLErr ChunkAndWarpMulti( int nDstXOff, int nDstYOff,
359  int nDstXSize, int nDstYSize );
360  CPLErr WarpRegion( int nDstXOff, int nDstYOff,
361  int nDstXSize, int nDstYSize,
362  int nSrcXOff=0, int nSrcYOff=0,
363  int nSrcXSize=0, int nSrcYSize=0,
364  double dfProgressBase=0.0, double dfProgressScale=1.0);
365 
366  CPLErr WarpRegionToBuffer( int nDstXOff, int nDstYOff,
367  int nDstXSize, int nDstYSize,
368  void *pDataBuf,
369  GDALDataType eBufDataType,
370  int nSrcXOff=0, int nSrcYOff=0,
371  int nSrcXSize=0, int nSrcYSize=0,
372  double dfProgressBase=0.0, double dfProgressScale=1.0);
373 };
374 
375 #endif /* def __cplusplus */
376 
377 CPL_C_START
378 
379 typedef void * GDALWarpOperationH;
380 
381 GDALWarpOperationH CPL_DLL GDALCreateWarpOperation(const GDALWarpOptions* );
382 void CPL_DLL GDALDestroyWarpOperation( GDALWarpOperationH );
383 CPLErr CPL_DLL GDALChunkAndWarpImage( GDALWarpOperationH, int, int, int, int );
384 CPLErr CPL_DLL GDALChunkAndWarpMulti( GDALWarpOperationH, int, int, int, int );
385 CPLErr CPL_DLL GDALWarpRegion( GDALWarpOperationH,
386  int, int, int, int, int, int, int, int );
387 CPLErr CPL_DLL GDALWarpRegionToBuffer( GDALWarpOperationH, int, int, int, int,
388  void *, GDALDataType,
389  int, int, int, int );
390 
391 CPL_C_END
392 
393 #endif /* ndef GDAL_ALG_H_INCLUDED */

Generated for GDAL by doxygen 1.8.2.