GDAL
gdalwarper.h
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: gdalwarper.h 27739 2014-09-25 18:49:52Z goatbar $
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  * Copyright (c) 2009-2012, Even Rouault <even dot rouault at mines-paris dot org>
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included
20  * in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28  * DEALINGS IN THE SOFTWARE.
29  ****************************************************************************/
30 
31 #ifndef GDALWARPER_H_INCLUDED
32 #define GDALWARPER_H_INCLUDED
33 
42 #include "gdal_alg.h"
43 #include "cpl_minixml.h"
44 
45 CPL_C_START
46 
57 
58 typedef int
59 (*GDALMaskFunc)( void *pMaskFuncArg,
60  int nBandCount, GDALDataType eType,
61  int nXOff, int nYOff,
62  int nXSize, int nYSize,
63  GByte **papabyImageData,
64  int bMaskIsFloat, void *pMask );
65 
66 CPLErr CPL_DLL
67 GDALWarpNoDataMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
68  int nXOff, int nYOff, int nXSize, int nYSize,
69  GByte **papabyImageData, int bMaskIsFloat,
70  void *pValidityMask );
71 
72 CPLErr CPL_DLL
73 GDALWarpDstAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
74  int nXOff, int nYOff, int nXSize, int nYSize,
75  GByte ** /*ppImageData */,
76  int bMaskIsFloat, void *pValidityMask );
77 CPLErr CPL_DLL
78 GDALWarpSrcAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
79  int nXOff, int nYOff, int nXSize, int nYSize,
80  GByte ** /*ppImageData */,
81  int bMaskIsFloat, void *pValidityMask );
82 
83 CPLErr CPL_DLL
84 GDALWarpSrcMaskMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
85  int nXOff, int nYOff, int nXSize, int nYSize,
86  GByte ** /*ppImageData */,
87  int bMaskIsFloat, void *pValidityMask );
88 
89 CPLErr CPL_DLL
90 GDALWarpCutlineMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
91  int nXOff, int nYOff, int nXSize, int nYSize,
92  GByte ** /* ppImageData */,
93  int bMaskIsFloat, void *pValidityMask );
94 
95 /************************************************************************/
96 /* GDALWarpOptions */
97 /************************************************************************/
98 
100 typedef struct {
101 
103 
106 
109 
113 
116 
119 
122 
125 
128 
131 
134 
140 
146 
149  GDALProgressFunc pfnProgress;
150 
153 
156 
159 
160  GDALMaskFunc *papfnSrcPerBandValidityMaskFunc;
161  void **papSrcPerBandValidityMaskFuncArg;
162 
163  GDALMaskFunc pfnSrcValidityMaskFunc;
164  void *pSrcValidityMaskFuncArg;
165 
166  GDALMaskFunc pfnSrcDensityMaskFunc;
167  void *pSrcDensityMaskFuncArg;
168 
169  GDALMaskFunc pfnDstDensityMaskFunc;
170  void *pDstDensityMaskFuncArg;
171 
172  GDALMaskFunc pfnDstValidityMaskFunc;
173  void *pDstValidityMaskFuncArg;
174 
175  CPLErr (*pfnPreWarpChunkProcessor)( void *pKern, void *pArg );
176  void *pPreWarpProcessorArg;
177 
178  CPLErr (*pfnPostWarpChunkProcessor)( void *pKern, void *pArg);
179  void *pPostWarpProcessorArg;
180 
182  void *hCutline;
183 
186 
188 
189 GDALWarpOptions CPL_DLL * CPL_STDCALL GDALCreateWarpOptions(void);
190 void CPL_DLL CPL_STDCALL GDALDestroyWarpOptions( GDALWarpOptions * );
191 GDALWarpOptions CPL_DLL * CPL_STDCALL
192 GDALCloneWarpOptions( const GDALWarpOptions * );
193 
194 CPLXMLNode CPL_DLL * CPL_STDCALL
195  GDALSerializeWarpOptions( const GDALWarpOptions * );
196 GDALWarpOptions CPL_DLL * CPL_STDCALL
197  GDALDeserializeWarpOptions( CPLXMLNode * );
198 
199 /************************************************************************/
200 /* GDALReprojectImage() */
201 /************************************************************************/
202 
203 CPLErr CPL_DLL CPL_STDCALL
204 GDALReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
205  GDALDatasetH hDstDS, const char *pszDstWKT,
206  GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit,
207  double dfMaxError,
208  GDALProgressFunc pfnProgress, void *pProgressArg,
209  GDALWarpOptions *psOptions );
210 
211 CPLErr CPL_DLL CPL_STDCALL
212 GDALCreateAndReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
213  const char *pszDstFilename, const char *pszDstWKT,
214  GDALDriverH hDstDriver, char **papszCreateOptions,
215  GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit,
216  double dfMaxError,
217  GDALProgressFunc pfnProgress, void *pProgressArg,
218  GDALWarpOptions *psOptions );
219 
220 /************************************************************************/
221 /* VRTWarpedDataset */
222 /************************************************************************/
223 
224 GDALDatasetH CPL_DLL CPL_STDCALL
226  const char *pszSrcWKT, const char *pszDstWKT,
227  GDALResampleAlg eResampleAlg,
228  double dfMaxError, const GDALWarpOptions *psOptions );
229 
230 GDALDatasetH CPL_DLL CPL_STDCALL
232  int nPixels, int nLines, double *padfGeoTransform,
233  GDALWarpOptions *psOptions );
234 
235 CPLErr CPL_DLL CPL_STDCALL
237  GDALWarpOptions *psWO );
238 
239 CPL_C_END
240 
241 #ifdef __cplusplus
242 
243 /************************************************************************/
244 /* GDALWarpKernel */
245 /* */
246 /* This class represents the lowest level of abstraction. It */
247 /* is holds the imagery for one "chunk" of a warp, and the */
248 /* pre-prepared masks. All IO is done before and after it's */
249 /* operation. This class is not normally used by the */
250 /* application. */
251 /************************************************************************/
252 
253 // This is the number of dummy pixels that must be reserved in source arrays
254 // in order to satisfy assumptions made in GWKResample(), and more specifically
255 // by GWKGetPixelRow() that always read a even number of pixels. So if we are
256 // in the situation to read the last pixel of the source array, we need 1 extra
257 // dummy pixel to avoid reading out of bounds.
258 #define WARP_EXTRA_ELTS 1
259 
260 class CPL_DLL GDALWarpKernel
261 {
262 public:
263  char **papszWarpOptions;
264 
267  int nBands;
268 
271  GByte **papabySrcImage; /* each subarray must have WARP_EXTRA_ELTS at the end */
272 
273  GUInt32 **papanBandSrcValid; /* each subarray must have WARP_EXTRA_ELTS at the end */
274  GUInt32 *panUnifiedSrcValid; /* must have WARP_EXTRA_ELTS at the end */
275  float *pafUnifiedSrcDensity; /* must have WARP_EXTRA_ELTS at the end */
276 
279  GByte **papabyDstImage;
280  GUInt32 *panDstValid;
282 
283  double dfXScale; // Resampling scale, i.e.
284  double dfYScale; // nDstSize/nSrcSize.
285  double dfXFilter; // Size of filter kernel.
286  double dfYFilter;
287  int nXRadius; // Size of window to filter.
288  int nYRadius;
289  int nFiltInitX; // Filtering offset
290  int nFiltInitY;
291 
292  int nSrcXOff;
293  int nSrcYOff;
294 
295  int nDstXOff;
296  int nDstYOff;
297 
300 
301  GDALProgressFunc pfnProgress;
302  void *pProgress;
303 
304  double dfProgressBase;
305  double dfProgressScale;
306 
307  double *padfDstNoDataReal;
308 
309  GDALWarpKernel();
310  virtual ~GDALWarpKernel();
311 
312  CPLErr Validate();
313  CPLErr PerformWarp();
314 };
315 
316 /************************************************************************/
317 /* GDALWarpOperation() */
318 /* */
319 /* This object is application created, or created by a higher */
320 /* level convenience function. It is responsible for */
321 /* subdividing the operation into chunks, loading and saving */
322 /* imagery, and establishing the varios validity and density */
323 /* masks. Actual resampling is done by the GDALWarpKernel. */
324 /************************************************************************/
325 
326 class CPL_DLL GDALWarpOperation {
327 private:
328  GDALWarpOptions *psOptions;
329 
330  void WipeOptions();
331  int ValidateOptions();
332 
333  CPLErr ComputeSourceWindow( int nDstXOff, int nDstYOff,
334  int nDstXSize, int nDstYSize,
335  int *pnSrcXOff, int *pnSrcYOff,
336  int *pnSrcXSize, int *pnSrcYSize );
337 
338  CPLErr CreateKernelMask( GDALWarpKernel *, int iBand,
339  const char *pszType );
340 
341  /* Unused kept to preserve binary ABI */
342  /* CPL_UNUSED */ void *unused1;
343  /* CPL_UNUSED */ void *unused2;
344  void *hIOMutex;
345  void *hWarpMutex;
346 
347  int nChunkListCount;
348  int nChunkListMax;
349  int *panChunkList;
350 
351  int bReportTimings;
352  unsigned long nLastTimeReported;
353 
354  void WipeChunkList();
355  CPLErr CollectChunkList( int nDstXOff, int nDstYOff,
356  int nDstXSize, int nDstYSize );
357  void ReportTiming( const char * );
358 
359 public:
361  virtual ~GDALWarpOperation();
362 
363  CPLErr Initialize( const GDALWarpOptions *psNewOptions );
364 
365  const GDALWarpOptions *GetOptions();
366 
367  CPLErr ChunkAndWarpImage( int nDstXOff, int nDstYOff,
368  int nDstXSize, int nDstYSize );
369  CPLErr ChunkAndWarpMulti( int nDstXOff, int nDstYOff,
370  int nDstXSize, int nDstYSize );
371  CPLErr WarpRegion( int nDstXOff, int nDstYOff,
372  int nDstXSize, int nDstYSize,
373  int nSrcXOff=0, int nSrcYOff=0,
374  int nSrcXSize=0, int nSrcYSize=0,
375  double dfProgressBase=0.0, double dfProgressScale=1.0);
376 
377  CPLErr WarpRegionToBuffer( int nDstXOff, int nDstYOff,
378  int nDstXSize, int nDstYSize,
379  void *pDataBuf,
380  GDALDataType eBufDataType,
381  int nSrcXOff=0, int nSrcYOff=0,
382  int nSrcXSize=0, int nSrcYSize=0,
383  double dfProgressBase=0.0, double dfProgressScale=1.0);
384 };
385 
386 #endif /* def __cplusplus */
387 
388 CPL_C_START
389 
390 typedef void * GDALWarpOperationH;
391 
392 GDALWarpOperationH CPL_DLL GDALCreateWarpOperation(const GDALWarpOptions* );
393 void CPL_DLL GDALDestroyWarpOperation( GDALWarpOperationH );
394 CPLErr CPL_DLL GDALChunkAndWarpImage( GDALWarpOperationH, int, int, int, int );
395 CPLErr CPL_DLL GDALChunkAndWarpMulti( GDALWarpOperationH, int, int, int, int );
396 CPLErr CPL_DLL GDALWarpRegion( GDALWarpOperationH,
397  int, int, int, int, int, int, int, int );
398 CPLErr CPL_DLL GDALWarpRegionToBuffer( GDALWarpOperationH, int, int, int, int,
399  void *, GDALDataType,
400  int, int, int, int );
401 
402 CPL_C_END
403 
404 #endif /* ndef GDAL_ALG_H_INCLUDED */
int nSrcXOff
X offset to source pixel coordinates for transformation.
Definition: gdalwarper.h:292
GDALDataType
Definition: gdal.h:55
Document node structure.
Definition: cpl_minixml.h:65
Low level image warping class.
Definition: gdalwarper.h:260
Definitions for CPL mini XML Parser/Serializer.
Definition: gdalwarper.h:52
GByte ** papabySrcImage
Array of source image band data.
Definition: gdalwarper.h:271
CPLErr GDALInitializeWarpedVRT(GDALDatasetH hDS, GDALWarpOptions *psWO)
Set warp info on virtual warped dataset.
Definition: vrtwarped.cpp:802
GUInt32 * panUnifiedSrcValid
Per pixel validity mask for source pixels.
Definition: gdalwarper.h:274
int nDstXSize
Width of destination image in pixels.
Definition: gdalwarper.h:277
int * panDstBands
Definition: gdalwarper.h:127
void * pProgressArg
Definition: gdalwarper.h:152
int nDstXOff
X offset to destination pixel coordinates for transformation.
Definition: gdalwarper.h:295
double dfWarpMemoryLimit
Definition: gdalwarper.h:105
int nSrcAlphaBand
Definition: gdalwarper.h:130
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition: gdal.h:162
CPLErr GDALWarpRegionToBuffer(GDALWarpOperationH, int, int, int, int, void *, GDALDataType, int, int, int, int)
Definition: gdalwarpoperation.cpp:1863
Definition: gdalwarper.h:53
Definition: gdalwarper.h:54
GUInt32 * panDstValid
Per pixel validity mask for destination pixels.
Definition: gdalwarper.h:280
double * padfDstNoDataReal
Definition: gdalwarper.h:142
GDALDataType eWorkingDataType
Working pixel data type.
Definition: gdalwarper.h:266
float * pafUnifiedSrcDensity
Per pixel density mask for source pixels.
Definition: gdalwarper.h:275
double * padfSrcNoDataImag
Definition: gdalwarper.h:139
GDALResampleAlg eResampleAlg
Definition: gdalwarper.h:108
CPLErr GDALChunkAndWarpMulti(GDALWarpOperationH, int, int, int, int)
Definition: gdalwarpoperation.cpp:961
CPLErr GDALWarpRegion(GDALWarpOperationH, int, int, int, int, int, int, int, int)
Definition: gdalwarpoperation.cpp:1378
GDALDatasetH GDALCreateWarpedVRT(GDALDatasetH hSrcDS, int nPixels, int nLines, double *padfGeoTransform, GDALWarpOptions *psOptions)
Create virtual warped dataset.
Definition: vrtwarped.cpp:230
GDALTransformerFunc pfnTransformer
Definition: gdalwarper.h:155
void GDALDestroyWarpOperation(GDALWarpOperationH)
Definition: gdalwarpoperation.cpp:606
double * padfDstNoDataImag
Definition: gdalwarper.h:145
int nDstYOff
Y offset to destination pixel coordinates for transformation.
Definition: gdalwarper.h:296
GDALResampleAlg eResample
Resampling algorithm.
Definition: gdalwarper.h:265
GDALResampleAlg
Definition: gdalwarper.h:48
Warp control options for use with GDALWarpOperation::Initialize()
Definition: gdalwarper.h:100
GDALProgressFunc pfnProgress
Definition: gdalwarper.h:149
Definition: gdalwarper.h:51
High level image warping class.
Definition: gdalwarper.h:326
void * pTransformerArg
Definition: gdalwarper.h:158
int nSrcYSize
Source image height in pixels.
Definition: gdalwarper.h:270
GDALProgressFunc pfnProgress
The function to call to report progress of the algorithm, and to check for a requested termination of...
Definition: gdalwarper.h:301
Definition: gdalwarper.h:50
int * panSrcBands
Definition: gdalwarper.h:124
int(* GDALTransformerFunc)(void *pTransformerArg, int bDstToSrc, int nPointCount, double *x, double *y, double *z, int *panSuccess)
Definition: gdal_alg.h:114
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition: gdal.h:168
char ** papszWarpOptions
A string list of additional options controlling the warp operation in name=value format.
Definition: gdalwarper.h:102
int nDstYSize
Height of destination image in pixels.
Definition: gdalwarper.h:278
int nBands
Number of bands.
Definition: gdalwarper.h:267
CPLErr GDALChunkAndWarpImage(GDALWarpOperationH, int, int, int, int)
Definition: gdalwarpoperation.cpp:729
Definition: gdalwarper.h:49
Public (C callable) GDAL algorithm entry points, and definitions.
void * pTransformerArg
Callback data for pfnTransformer.
Definition: gdalwarper.h:299
int nSrcXSize
Source image width in pixels.
Definition: gdalwarper.h:269
GDALDatasetH hSrcDS
Definition: gdalwarper.h:115
int nBandCount
Definition: gdalwarper.h:121
float * pafDstDensity
Per pixel density mask for destination pixels.
Definition: gdalwarper.h:281
GDALDataType eWorkingDataType
Definition: gdalwarper.h:112
GDALTransformerFunc pfnTransformer
Source/destination location transformer.
Definition: gdalwarper.h:298
GDALDatasetH hDstDS
Definition: gdalwarper.h:118
Definition: gdalwarper.h:55
void * hCutline
Definition: gdalwarper.h:182
double dfCutlineBlendDist
Definition: gdalwarper.h:185
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:87
double * padfSrcNoDataReal
Definition: gdalwarper.h:136
void * pProgress
Callback data for pfnProgress.
Definition: gdalwarper.h:302
int nSrcYOff
Y offset to source pixel coordinates for transformation.
Definition: gdalwarper.h:293
GDALWarpOperationH GDALCreateWarpOperation(const GDALWarpOptions *)
Definition: gdalwarpoperation.cpp:583
GByte ** papabyDstImage
Array of destination image band data.
Definition: gdalwarper.h:279
int nDstAlphaBand
Definition: gdalwarper.h:133
GUInt32 ** papanBandSrcValid
Per band validity mask for source pixels.
Definition: gdalwarper.h:273

Generated for GDAL by doxygen 1.8.11.