GDAL
gdalwarper.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: gdalwarper.h 25884 2013-04-09 17:04:16Z etourigny $
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 
56 
57 typedef int
58 (*GDALMaskFunc)( void *pMaskFuncArg,
59  int nBandCount, GDALDataType eType,
60  int nXOff, int nYOff,
61  int nXSize, int nYSize,
62  GByte **papabyImageData,
63  int bMaskIsFloat, void *pMask );
64 
65 CPLErr CPL_DLL
66 GDALWarpNoDataMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
67  int nXOff, int nYOff, int nXSize, int nYSize,
68  GByte **papabyImageData, int bMaskIsFloat,
69  void *pValidityMask );
70 
71 CPLErr CPL_DLL
72 GDALWarpDstAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
73  int nXOff, int nYOff, int nXSize, int nYSize,
74  GByte ** /*ppImageData */,
75  int bMaskIsFloat, void *pValidityMask );
76 CPLErr CPL_DLL
77 GDALWarpSrcAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
78  int nXOff, int nYOff, int nXSize, int nYSize,
79  GByte ** /*ppImageData */,
80  int bMaskIsFloat, void *pValidityMask );
81 
82 CPLErr CPL_DLL
83 GDALWarpSrcMaskMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
84  int nXOff, int nYOff, int nXSize, int nYSize,
85  GByte ** /*ppImageData */,
86  int bMaskIsFloat, void *pValidityMask );
87 
88 CPLErr CPL_DLL
89 GDALWarpCutlineMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
90  int nXOff, int nYOff, int nXSize, int nYSize,
91  GByte ** /* ppImageData */,
92  int bMaskIsFloat, void *pValidityMask );
93 
94 /************************************************************************/
95 /* GDALWarpOptions */
96 /************************************************************************/
97 
99 typedef struct {
100 
102 
105 
108 
112 
115 
118 
121 
124 
127 
130 
133 
139 
145 
148  GDALProgressFunc pfnProgress;
149 
152 
155 
158 
159  GDALMaskFunc *papfnSrcPerBandValidityMaskFunc;
160  void **papSrcPerBandValidityMaskFuncArg;
161 
162  GDALMaskFunc pfnSrcValidityMaskFunc;
163  void *pSrcValidityMaskFuncArg;
164 
165  GDALMaskFunc pfnSrcDensityMaskFunc;
166  void *pSrcDensityMaskFuncArg;
167 
168  GDALMaskFunc pfnDstDensityMaskFunc;
169  void *pDstDensityMaskFuncArg;
170 
171  GDALMaskFunc pfnDstValidityMaskFunc;
172  void *pDstValidityMaskFuncArg;
173 
174  CPLErr (*pfnPreWarpChunkProcessor)( void *pKern, void *pArg );
175  void *pPreWarpProcessorArg;
176 
177  CPLErr (*pfnPostWarpChunkProcessor)( void *pKern, void *pArg);
178  void *pPostWarpProcessorArg;
179 
181  void *hCutline;
182 
185 
187 
188 GDALWarpOptions CPL_DLL * CPL_STDCALL GDALCreateWarpOptions(void);
189 void CPL_DLL CPL_STDCALL GDALDestroyWarpOptions( GDALWarpOptions * );
190 GDALWarpOptions CPL_DLL * CPL_STDCALL
191 GDALCloneWarpOptions( const GDALWarpOptions * );
192 
193 CPLXMLNode CPL_DLL * CPL_STDCALL
194  GDALSerializeWarpOptions( const GDALWarpOptions * );
195 GDALWarpOptions CPL_DLL * CPL_STDCALL
196  GDALDeserializeWarpOptions( CPLXMLNode * );
197 
198 /************************************************************************/
199 /* GDALReprojectImage() */
200 /************************************************************************/
201 
202 CPLErr CPL_DLL CPL_STDCALL
203 GDALReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
204  GDALDatasetH hDstDS, const char *pszDstWKT,
205  GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit,
206  double dfMaxError,
207  GDALProgressFunc pfnProgress, void *pProgressArg,
208  GDALWarpOptions *psOptions );
209 
210 CPLErr CPL_DLL CPL_STDCALL
211 GDALCreateAndReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
212  const char *pszDstFilename, const char *pszDstWKT,
213  GDALDriverH hDstDriver, char **papszCreateOptions,
214  GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit,
215  double dfMaxError,
216  GDALProgressFunc pfnProgress, void *pProgressArg,
217  GDALWarpOptions *psOptions );
218 
219 /************************************************************************/
220 /* VRTWarpedDataset */
221 /************************************************************************/
222 
223 GDALDatasetH CPL_DLL CPL_STDCALL
225  const char *pszSrcWKT, const char *pszDstWKT,
226  GDALResampleAlg eResampleAlg,
227  double dfMaxError, const GDALWarpOptions *psOptions );
228 
229 GDALDatasetH CPL_DLL CPL_STDCALL
231  int nPixels, int nLines, double *padfGeoTransform,
232  GDALWarpOptions *psOptions );
233 
234 CPLErr CPL_DLL CPL_STDCALL
236  GDALWarpOptions *psWO );
237 
238 CPL_C_END
239 
240 #ifdef __cplusplus
241 
242 /************************************************************************/
243 /* GDALWarpKernel */
244 /* */
245 /* This class represents the lowest level of abstraction. It */
246 /* is holds the imagery for one "chunk" of a warp, and the */
247 /* pre-prepared masks. All IO is done before and after it's */
248 /* operation. This class is not normally used by the */
249 /* application. */
250 /************************************************************************/
251 
252 // This is the number of dummy pixels that must be reserved in source arrays
253 // in order to satisfy assumptions made in GWKResample(), and more specifically
254 // by GWKGetPixelRow() that always read a even number of pixels. So if we are
255 // in the situation to read the last pixel of the source array, we need 1 extra
256 // dummy pixel to avoid reading out of bounds.
257 #define WARP_EXTRA_ELTS 1
258 
259 class CPL_DLL GDALWarpKernel
260 {
261 public:
262  char **papszWarpOptions;
263 
266  int nBands;
267 
270  GByte **papabySrcImage; /* each subarray must have WARP_EXTRA_ELTS at the end */
271 
272  GUInt32 **papanBandSrcValid; /* each subarray must have WARP_EXTRA_ELTS at the end */
273  GUInt32 *panUnifiedSrcValid; /* must have WARP_EXTRA_ELTS at the end */
274  float *pafUnifiedSrcDensity; /* must have WARP_EXTRA_ELTS at the end */
275 
278  GByte **papabyDstImage;
279  GUInt32 *panDstValid;
281 
282  double dfXScale; // Resampling scale, i.e.
283  double dfYScale; // nDstSize/nSrcSize.
284  double dfXFilter; // Size of filter kernel.
285  double dfYFilter;
286  int nXRadius; // Size of window to filter.
287  int nYRadius;
288  int nFiltInitX; // Filtering offset
289  int nFiltInitY;
290 
291  int nSrcXOff;
292  int nSrcYOff;
293 
294  int nDstXOff;
295  int nDstYOff;
296 
299 
300  GDALProgressFunc pfnProgress;
301  void *pProgress;
302 
303  double dfProgressBase;
304  double dfProgressScale;
305 
306  double *padfDstNoDataReal;
307 
308  GDALWarpKernel();
309  virtual ~GDALWarpKernel();
310 
311  CPLErr Validate();
312  CPLErr PerformWarp();
313 };
314 
315 /************************************************************************/
316 /* GDALWarpOperation() */
317 /* */
318 /* This object is application created, or created by a higher */
319 /* level convenience function. It is responsible for */
320 /* subdividing the operation into chunks, loading and saving */
321 /* imagery, and establishing the varios validity and density */
322 /* masks. Actual resampling is done by the GDALWarpKernel. */
323 /************************************************************************/
324 
325 class CPL_DLL GDALWarpOperation {
326 private:
327  GDALWarpOptions *psOptions;
328 
329  void WipeOptions();
330  int ValidateOptions();
331 
332  CPLErr ComputeSourceWindow( int nDstXOff, int nDstYOff,
333  int nDstXSize, int nDstYSize,
334  int *pnSrcXOff, int *pnSrcYOff,
335  int *pnSrcXSize, int *pnSrcYSize );
336 
337  CPLErr CreateKernelMask( GDALWarpKernel *, int iBand,
338  const char *pszType );
339 
340  void *unused1;
341  void *unused2;
342  void *hIOMutex;
343  void *hWarpMutex;
344 
345  int nChunkListCount;
346  int nChunkListMax;
347  int *panChunkList;
348 
349  int bReportTimings;
350  unsigned long nLastTimeReported;
351 
352  void WipeChunkList();
353  CPLErr CollectChunkList( int nDstXOff, int nDstYOff,
354  int nDstXSize, int nDstYSize );
355  void ReportTiming( const char * );
356 
357 public:
359  virtual ~GDALWarpOperation();
360 
361  CPLErr Initialize( const GDALWarpOptions *psNewOptions );
362 
363  const GDALWarpOptions *GetOptions();
364 
365  CPLErr ChunkAndWarpImage( int nDstXOff, int nDstYOff,
366  int nDstXSize, int nDstYSize );
367  CPLErr ChunkAndWarpMulti( int nDstXOff, int nDstYOff,
368  int nDstXSize, int nDstYSize );
369  CPLErr WarpRegion( int nDstXOff, int nDstYOff,
370  int nDstXSize, int nDstYSize,
371  int nSrcXOff=0, int nSrcYOff=0,
372  int nSrcXSize=0, int nSrcYSize=0,
373  double dfProgressBase=0.0, double dfProgressScale=1.0);
374 
375  CPLErr WarpRegionToBuffer( int nDstXOff, int nDstYOff,
376  int nDstXSize, int nDstYSize,
377  void *pDataBuf,
378  GDALDataType eBufDataType,
379  int nSrcXOff=0, int nSrcYOff=0,
380  int nSrcXSize=0, int nSrcYSize=0,
381  double dfProgressBase=0.0, double dfProgressScale=1.0);
382 };
383 
384 #endif /* def __cplusplus */
385 
386 CPL_C_START
387 
388 typedef void * GDALWarpOperationH;
389 
390 GDALWarpOperationH CPL_DLL GDALCreateWarpOperation(const GDALWarpOptions* );
391 void CPL_DLL GDALDestroyWarpOperation( GDALWarpOperationH );
392 CPLErr CPL_DLL GDALChunkAndWarpImage( GDALWarpOperationH, int, int, int, int );
393 CPLErr CPL_DLL GDALChunkAndWarpMulti( GDALWarpOperationH, int, int, int, int );
394 CPLErr CPL_DLL GDALWarpRegion( GDALWarpOperationH,
395  int, int, int, int, int, int, int, int );
396 CPLErr CPL_DLL GDALWarpRegionToBuffer( GDALWarpOperationH, int, int, int, int,
397  void *, GDALDataType,
398  int, int, int, int );
399 
400 CPL_C_END
401 
402 #endif /* ndef GDAL_ALG_H_INCLUDED */
int nSrcXOff
X offset to source pixel coordinates for transformation.
Definition: gdalwarper.h:291
GDALDataType
Definition: gdal.h:53
Document node structure.
Definition: cpl_minixml.h:65
Low level image warping class.
Definition: gdalwarper.h:259
Definitions for CPL mini XML Parser/Serializer.
Definition: gdalwarper.h:51
GByte ** papabySrcImage
Array of source image band data.
Definition: gdalwarper.h:270
CPLErr GDALInitializeWarpedVRT(GDALDatasetH hDS, GDALWarpOptions *psWO)
Set warp info on virtual warped dataset.
Definition: vrtwarped.cpp:795
GUInt32 * panUnifiedSrcValid
Per pixel validity mask for source pixels.
Definition: gdalwarper.h:273
int nDstXSize
Width of destination image in pixels.
Definition: gdalwarper.h:276
int * panDstBands
Definition: gdalwarper.h:126
void * pProgressArg
Definition: gdalwarper.h:151
int nDstXOff
X offset to destination pixel coordinates for transformation.
Definition: gdalwarper.h:294
double dfWarpMemoryLimit
Definition: gdalwarper.h:104
int nSrcAlphaBand
Definition: gdalwarper.h:129
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition: gdal.h:160
CPLErr GDALWarpRegionToBuffer(GDALWarpOperationH, int, int, int, int, void *, GDALDataType, int, int, int, int)
Definition: gdalwarpoperation.cpp:1862
Definition: gdalwarper.h:52
Definition: gdalwarper.h:53
GUInt32 * panDstValid
Per pixel validity mask for destination pixels.
Definition: gdalwarper.h:279
double * padfDstNoDataReal
Definition: gdalwarper.h:141
GDALDataType eWorkingDataType
Working pixel data type.
Definition: gdalwarper.h:265
float * pafUnifiedSrcDensity
Per pixel density mask for source pixels.
Definition: gdalwarper.h:274
double * padfSrcNoDataImag
Definition: gdalwarper.h:138
GDALResampleAlg eResampleAlg
Definition: gdalwarper.h:107
CPLErr GDALChunkAndWarpMulti(GDALWarpOperationH, int, int, int, int)
Definition: gdalwarpoperation.cpp:960
CPLErr GDALWarpRegion(GDALWarpOperationH, int, int, int, int, int, int, int, int)
Definition: gdalwarpoperation.cpp:1377
GDALDatasetH GDALCreateWarpedVRT(GDALDatasetH hSrcDS, int nPixels, int nLines, double *padfGeoTransform, GDALWarpOptions *psOptions)
Create virtual warped dataset.
Definition: vrtwarped.cpp:223
GDALTransformerFunc pfnTransformer
Definition: gdalwarper.h:154
void GDALDestroyWarpOperation(GDALWarpOperationH)
Definition: gdalwarpoperation.cpp:605
CPLErr GDALReprojectImage(GDALDatasetH hSrcDS, const char *pszSrcWKT, GDALDatasetH hDstDS, const char *pszDstWKT, GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit, double dfMaxError, GDALProgressFunc pfnProgress, void *pProgressArg, GDALWarpOptions *psOptions)
Reproject image.
Definition: gdalwarper.cpp:76
double * padfDstNoDataImag
Definition: gdalwarper.h:144
int nDstYOff
Y offset to destination pixel coordinates for transformation.
Definition: gdalwarper.h:295
GDALResampleAlg eResample
Resampling algorithm.
Definition: gdalwarper.h:264
GDALResampleAlg
Definition: gdalwarper.h:47
Warp control options for use with GDALWarpOperation::Initialize()
Definition: gdalwarper.h:99
GDALProgressFunc pfnProgress
Definition: gdalwarper.h:148
Definition: gdalwarper.h:50
High level image warping class.
Definition: gdalwarper.h:325
void * pTransformerArg
Definition: gdalwarper.h:157
int nSrcYSize
Source image height in pixels.
Definition: gdalwarper.h:269
GDALProgressFunc pfnProgress
The function to call to report progress of the algorithm, and to check for a requested termination of...
Definition: gdalwarper.h:300
Definition: gdalwarper.h:49
int * panSrcBands
Definition: gdalwarper.h:123
int(* GDALTransformerFunc)(void *pTransformerArg, int bDstToSrc, int nPointCount, double *x, double *y, double *z, int *panSuccess)
Definition: gdal_alg.h:113
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition: gdal.h:166
char ** papszWarpOptions
A string list of additional options controlling the warp operation in name=value format.
Definition: gdalwarper.h:101
int nDstYSize
Height of destination image in pixels.
Definition: gdalwarper.h:277
int nBands
Number of bands.
Definition: gdalwarper.h:266
CPLErr GDALChunkAndWarpImage(GDALWarpOperationH, int, int, int, int)
Definition: gdalwarpoperation.cpp:728
Definition: gdalwarper.h:48
Public (C callable) GDAL algorithm entry points, and definitions.
void * pTransformerArg
Callback data for pfnTransformer.
Definition: gdalwarper.h:298
int nSrcXSize
Source image width in pixels.
Definition: gdalwarper.h:268
GDALDatasetH hSrcDS
Definition: gdalwarper.h:114
int nBandCount
Definition: gdalwarper.h:120
float * pafDstDensity
Per pixel density mask for destination pixels.
Definition: gdalwarper.h:280
GDALDataType eWorkingDataType
Definition: gdalwarper.h:111
GDALTransformerFunc pfnTransformer
Source/destination location transformer.
Definition: gdalwarper.h:297
GDALDatasetH hDstDS
Definition: gdalwarper.h:117
Definition: gdalwarper.h:54
void * hCutline
Definition: gdalwarper.h:181
double dfCutlineBlendDist
Definition: gdalwarper.h:184
GDALDatasetH GDALAutoCreateWarpedVRT(GDALDatasetH hSrcDS, const char *pszSrcWKT, const char *pszDstWKT, GDALResampleAlg eResampleAlg, double dfMaxError, const GDALWarpOptions *psOptions)
Create virtual warped dataset automatically.
Definition: vrtwarped.cpp:86
double * padfSrcNoDataReal
Definition: gdalwarper.h:135
void * pProgress
Callback data for pfnProgress.
Definition: gdalwarper.h:301
int nSrcYOff
Y offset to source pixel coordinates for transformation.
Definition: gdalwarper.h:292
GDALWarpOperationH GDALCreateWarpOperation(const GDALWarpOptions *)
Definition: gdalwarpoperation.cpp:582
GByte ** papabyDstImage
Array of destination image band data.
Definition: gdalwarper.h:278
int nDstAlphaBand
Definition: gdalwarper.h:132
GUInt32 ** papanBandSrcValid
Per band validity mask for source pixels.
Definition: gdalwarper.h:272

Generated for GDAL by doxygen 1.8.5.