Go to the documentation of this file.
31 #ifndef GDALWARPER_H_INCLUDED
32 #define GDALWARPER_H_INCLUDED
44 #include "cpl_multiproc.h"
101 typedef int (*GDALMaskFunc)(
void *pMaskFuncArg,
int nBandCount,
103 int nXSize,
int nYSize,
GByte **papabyImageData,
104 int bMaskIsFloat,
void *pMask);
106 CPLErr CPL_DLL GDALWarpNoDataMasker(
void *pMaskFuncArg,
int nBandCount,
108 int nXSize,
int nYSize,
109 GByte **papabyImageData,
int bMaskIsFloat,
110 void *pValidityMask,
int *pbOutAllValid);
112 CPLErr CPL_DLL GDALWarpDstAlphaMasker(
void *pMaskFuncArg,
int nBandCount,
114 int nXSize,
int nYSize,
116 int bMaskIsFloat,
void *pValidityMask);
117 CPLErr CPL_DLL GDALWarpSrcAlphaMasker(
void *pMaskFuncArg,
int nBandCount,
119 int nXSize,
int nYSize,
121 int bMaskIsFloat,
void *pValidityMask,
122 int *pbOutAllOpaque);
124 CPLErr CPL_DLL GDALWarpSrcMaskMasker(
void *pMaskFuncArg,
int nBandCount,
126 int nXSize,
int nYSize,
128 int bMaskIsFloat,
void *pValidityMask);
130 CPLErr CPL_DLL GDALWarpCutlineMasker(
void *pMaskFuncArg,
int nBandCount,
132 int nXSize,
int nYSize,
134 int bMaskIsFloat,
void *pValidityMask);
137 #define GCMVF_PARTIAL_INTERSECTION 0
138 #define GCMVF_NO_INTERSECTION 1
139 #define GCMVF_CHUNK_FULLY_WITHIN_CUTLINE 2
140 CPLErr CPL_DLL GDALWarpCutlineMaskerEx(
void *pMaskFuncArg,
int nBandCount,
142 int nXSize,
int nYSize,
144 int bMaskIsFloat,
void *pValidityMask,
145 int *pnValidityFlag);
245 CPLErr (*pfnPreWarpChunkProcessor)(
void *pKern,
void *pArg);
250 CPLErr (*pfnPostWarpChunkProcessor)(
void *pKern,
void *pArg);
301 double dfWarpMemoryLimit,
double dfMaxError, GDALProgressFunc pfnProgress,
305 GDALDatasetH hSrcDS,
const char *pszSrcWKT,
const char *pszDstFilename,
306 const char *pszDstWKT,
GDALDriverH hDstDriver,
char **papszCreateOptions,
307 GDALResampleAlg eResampleAlg,
double dfWarpMemoryLimit,
double dfMaxError,
308 GDALProgressFunc pfnProgress,
void *pProgressArg,
321 GDALDatasetH hSrcDS,
const char *pszSrcWKT,
const char *pszDstWKT,
334 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
348 #define WARP_EXTRA_ELTS 1
460 bool bApplyVerticalShift =
false;
462 double dfMultFactorVerticalShift = 1.0;
473 void *GWKThreadsCreate(
char **papszWarpOptions,
475 void *pTransformerArg);
476 void GWKThreadsEnd(
void *psThreadDataIn);
490 typedef struct _GDALWarpChunk GDALWarpChunk;
502 int ValidateOptions();
504 CPLErr ComputeSourceWindow(
int nDstXOff,
int nDstYOff,
int nDstXSize,
505 int nDstYSize,
int *pnSrcXOff,
int *pnSrcYOff,
506 int *pnSrcXSize,
int *pnSrcYSize,
507 double *pdfSrcXExtraSize,
508 double *pdfSrcYExtraSize,
509 double *pdfSrcFillRatio);
511 void ComputeSourceWindowStartingFromSource(
int nDstXOff,
int nDstYOff,
512 int nDstXSize,
int nDstYSize,
516 double *padfSrcMaxY);
519 const char *pszType);
522 CPLMutex *hWarpMutex;
526 GDALWarpChunk *pasChunkList;
529 unsigned long nLastTimeReported;
535 std::vector<std::pair<double, double>> aDstXYSpecialPoints{};
537 bool m_bIsTranslationOnPixelBoundaries =
false;
539 void WipeChunkList();
540 CPLErr CollectChunkListInternal(
int nDstXOff,
int nDstYOff,
int nDstXSize,
542 void CollectChunkList(
int nDstXOff,
int nDstYOff,
int nDstXSize,
544 void ReportTiming(
const char *);
551 void *CreateDestinationBuffer(
int nDstXSize,
int nDstYSize,
552 int *pbWasInitialized =
nullptr);
553 static void DestroyDestinationBuffer(
void *pDstBuffer);
557 CPLErr ChunkAndWarpImage(
int nDstXOff,
int nDstYOff,
int nDstXSize,
559 CPLErr ChunkAndWarpMulti(
int nDstXOff,
int nDstYOff,
int nDstXSize,
561 CPLErr WarpRegion(
int nDstXOff,
int nDstYOff,
int nDstXSize,
int nDstYSize,
562 int nSrcXOff = 0,
int nSrcYOff = 0,
int nSrcXSize = 0,
563 int nSrcYSize = 0,
double dfProgressBase = 0.0,
564 double dfProgressScale = 1.0);
565 CPLErr WarpRegion(
int nDstXOff,
int nDstYOff,
int nDstXSize,
int nDstYSize,
566 int nSrcXOff,
int nSrcYOff,
int nSrcXSize,
int nSrcYSize,
567 double dfSrcXExtraSize,
double dfSrcYExtraSize,
568 double dfProgressBase,
double dfProgressScale);
569 CPLErr WarpRegionToBuffer(
int nDstXOff,
int nDstYOff,
int nDstXSize,
570 int nDstYSize,
void *pDataBuf,
572 int nSrcYOff = 0,
int nSrcXSize = 0,
573 int nSrcYSize = 0,
double dfProgressBase = 0.0,
574 double dfProgressScale = 1.0);
575 CPLErr WarpRegionToBuffer(
int nDstXOff,
int nDstYOff,
int nDstXSize,
576 int nDstYSize,
void *pDataBuf,
578 int nSrcYOff,
int nSrcXSize,
int nSrcYSize,
579 double dfSrcXExtraSize,
double dfSrcYExtraSize,
580 double dfProgressBase,
double dfProgressScale);
606 typedef double (*FilterFuncType)(
double dfX);
610 typedef double (*FilterFunc4ValuesType)(
double *padfVals);
611 FilterFunc4ValuesType GWKGetFilterFunc4Values(
GDALResampleAlg eResampleAlg);
int nSrcYSize
Height of the source image.
Definition: gdalwarper.h:375
int nXRadius
X size of window to filter.
Definition: gdalwarper.h:416
float * pafUnifiedSrcDensity
Unified source density of size nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS.
Definition: gdalwarper.h:394
@ GRA_Med
Definition: gdalwarper.h:70
CPLErr GDALCreateAndReprojectImage(GDALDatasetH hSrcDS, const char *pszSrcWKT, const char *pszDstFilename, const char *pszDstWKT, GDALDriverH hDstDriver, char **papszCreateOptions, GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit, double dfMaxError, GDALProgressFunc pfnProgress, void *pProgressArg, GDALWarpOptions *psOptions)
Reproject an image and create the target reprojected image.
Definition: gdalwarper.cpp:235
double dfXFilter
X size of filter kernel.
Definition: gdalwarper.h:412
double * padfSrcNoDataImag
Definition: gdalwarper.h:196
double dfProgressScale
Scale value for progress computation.
Definition: gdalwarper.h:451
GDALProgressFunc pfnProgress
Definition: gdalwarper.h:208
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:196
int nFiltInitX
X filtering offset.
Definition: gdalwarper.h:420
GDALDatasetH GDALAutoCreateWarpedVRTEx(GDALDatasetH hSrcDS, const char *pszSrcWKT, const char *pszDstWKT, GDALResampleAlg eResampleAlg, double dfMaxError, const GDALWarpOptions *psOptions, CSLConstList papszTransformerOptions)
Create virtual warped dataset automatically.
Definition: vrtwarped.cpp:152
void * pTransformerArg
Definition: gdalwarper.h:217
void * pPostWarpProcessorArg
Unused.
Definition: gdalwarper.h:252
double dfYFilter
Y size of filter kernel.
Definition: gdalwarper.h:414
double * padfDstNoDataImag
Definition: gdalwarper.h:204
GByte ** papabySrcImage
Array of nBands source images of size nSrcXSize * nSrcYSize.
Definition: gdalwarper.h:384
GDALResampleAlg eResample
Resample algorithm.
Definition: gdalwarper.h:366
char ** papszWarpOptions
Warp options.
Definition: gdalwarper.h:363
GDALMaskFunc pfnDstDensityMaskFunc
Unused.
Definition: gdalwarper.h:235
int nDstYOff
Y offset of the destination buffer regarding the top-left corner of the image.
Definition: gdalwarper.h:436
double dfYScale
Y resampling scale, i.e.
Definition: gdalwarper.h:410
@ GRA_CubicSpline
Definition: gdalwarper.h:57
void * pDstDensityMaskFuncArg
Unused.
Definition: gdalwarper.h:237
int(* GDALTransformerFunc)(void *pTransformerArg, int bDstToSrc, int nPointCount, double *x, double *y, double *z, int *panSuccess)
Definition: gdal_alg.h:95
CPLErr GDALWarpRegionToBuffer(GDALWarpOperationH, int, int, int, int, void *, GDALDataType, int, int, int, int)
Definition: gdalwarpoperation.cpp:2312
void GDALWarpInitSrcNoDataReal(GDALWarpOptions *, double dNoDataReal)
Initialize padfSrcNoDataReal with specified value.
Definition: gdalwarper.cpp:1413
void * pSrcDensityMaskFuncArg
Unused.
Definition: gdalwarper.h:232
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:131
@ GWKAOM_Min
Definition: gdalwarper.h:94
void GDALDestroyWarpOptions(GDALWarpOptions *)
Destroy a warp options structure.
Definition: gdalwarper.cpp:1284
@ GRA_Sum
Definition: gdalwarper.h:78
int nBandCount
Definition: gdalwarper.h:176
int nSrcYOff
Y offset of the source buffer regarding the top-left corner of the image.
Definition: gdalwarper.h:429
GDALDatasetH GDALCreateWarpedVRT(GDALDatasetH hSrcDS, int nPixels, int nLines, double *padfGeoTransform, GDALWarpOptions *psOptions)
Create virtual warped dataset.
Definition: vrtwarped.cpp:362
This class represents the lowest level of abstraction of warping.
Definition: gdalwarper.h:357
@ GWKAOM_Average
Definition: gdalwarper.h:90
GWKAverageOrModeAlg
Definition: gdalwarper.h:88
GDALDataType
Definition: gdal.h:63
@ GRA_Q1
Definition: gdalwarper.h:73
int nYRadius
Y size of window to filter.
Definition: gdalwarper.h:418
Document node structure.
Definition: cpl_minixml.h:69
Definition: gdalwarper.h:493
double dfXScale
X resampling scale, i.e.
Definition: gdalwarper.h:408
double dfSrcXExtraSize
Extra pixels (included in nSrcXSize) reserved for filter window.
Definition: gdalwarper.h:378
void GDALWarpInitDstNoDataReal(GDALWarpOptions *, double dNoDataReal)
Initialize padfDstNoDataReal with specified value.
Definition: gdalwarper.cpp:1394
char ** papszWarpOptions
Definition: gdalwarper.h:156
float * pafDstDensity
Destination density of size nDstXSize * nDstYSize.
Definition: gdalwarper.h:405
void GDALWarpInitDstNoDataImag(GDALWarpOptions *, double dNoDataImag)
Initialize padfDstNoDataImag with specified value.
Definition: gdalwarper.cpp:1451
GDALMaskFunc pfnSrcValidityMaskFunc
Unused.
Definition: gdalwarper.h:225
void * pProgressArg
Definition: gdalwarper.h:211
@ GRA_Lanczos
Definition: gdalwarper.h:58
int nFiltInitY
Y filtering offset.
Definition: gdalwarper.h:422
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:306
@ GRA_Average
Definition: gdalwarper.h:61
Warp control options for use with GDALWarpOperation::Initialize()
Definition: gdalwarper.h:153
@ GWKAOM_Max
Definition: gdalwarper.h:93
int nSrcAlphaBand
Definition: gdalwarper.h:185
void GDALDestroyWarpOperation(GDALWarpOperationH)
Definition: gdalwarpoperation.cpp:824
void * pProgress
User data provided to pfnProgress.
Definition: gdalwarper.h:446
int * panSrcBands
Definition: gdalwarper.h:179
double dfSrcYExtraSize
Extra pixels (included in nSrcYSize) reserved for filter window.
Definition: gdalwarper.h:381
GDALTransformerFunc pfnTransformer
Pixel transformation function.
Definition: gdalwarper.h:439
GDALDatasetH hSrcDS
Definition: gdalwarper.h:169
@ GWKAOM_RMS
Definition: gdalwarper.h:97
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1178
@ GRA_Cubic
Definition: gdalwarper.h:56
@ GWKAOM_Sum
Definition: gdalwarper.h:96
GDALWarpOptions * GDALCloneWarpOptions(const GDALWarpOptions *)
Clone a warp options structure.
Definition: gdalwarper.cpp:1330
void ** papSrcPerBandValidityMaskFuncArg
Unused.
Definition: gdalwarper.h:222
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:98
void * pTransformerArg
User data provided to pfnTransformer.
Definition: gdalwarper.h:441
@ GRA_Min
Definition: gdalwarper.h:68
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:310
double * padfDstNoDataReal
Definition: gdalwarper.h:200
int nBands
Number of input and output bands (excluding alpha bands)
Definition: gdalwarper.h:370
int * panDstBands
Definition: gdalwarper.h:182
@ GRA_RMS
Definition: gdalwarper.h:81
GUInt32 * panUnifiedSrcValid
Unified validity mask of size (nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS) / 8.
Definition: gdalwarper.h:391
void * GDALWarpOperationH
Opaque type representing a GDALWarpOperation object.
Definition: gdalwarper.h:588
CPLErr GDALWarpRegion(GDALWarpOperationH, int, int, int, int, int, int, int, int)
Definition: gdalwarpoperation.cpp:1683
@ GWKAOM_Fmode
Definition: gdalwarper.h:91
GDALMaskFunc * papfnSrcPerBandValidityMaskFunc
Unused.
Definition: gdalwarper.h:220
GDALResampleAlg
Definition: gdalwarper.h:51
@ GRA_Bilinear
Definition: gdalwarper.h:55
@ GRA_Max
Definition: gdalwarper.h:66
GDALDatasetH hDstDS
Definition: gdalwarper.h:173
void GDALWarpInitSrcNoDataImag(GDALWarpOptions *, double dNoDataImag)
Initialize padfSrcNoDataImag with specified value.
Definition: gdalwarper.cpp:1470
void * pDstValidityMaskFuncArg
Unused.
Definition: gdalwarper.h:242
void GDALWarpInitDefaultBandMapping(GDALWarpOptions *, int nBandCount)
Init src and dst band mappings such that Bands[i] = i+1 for nBandCount Does nothing if psOptionsIn->n...
Definition: gdalwarper.cpp:1596
double * padfDstNoDataReal
Array of nBands value for destination nodata.
Definition: gdalwarper.h:454
CPLErr GDALChunkAndWarpImage(GDALWarpOperationH, int, int, int, int)
Definition: gdalwarpoperation.cpp:998
GDALMaskFunc pfnSrcDensityMaskFunc
Unused.
Definition: gdalwarper.h:230
void * pPreWarpProcessorArg
Unused.
Definition: gdalwarper.h:247
GByte ** papabyDstImage
Array of nBands destination images of size nDstXSize * nDstYSize.
Definition: gdalwarper.h:401
double dfCutlineBlendDist
Definition: gdalwarper.h:259
void * hCutline
Definition: gdalwarper.h:255
GDALDataType eWorkingDataType
Working data type.
Definition: gdalwarper.h:368
@ GRA_Mode
Definition: gdalwarper.h:64
double * padfSrcNoDataReal
Definition: gdalwarper.h:192
GDALResampleAlg eResampleAlg
Definition: gdalwarper.h:162
CPLErr GDALChunkAndWarpMulti(GDALWarpOperationH, int, int, int, int)
Definition: gdalwarpoperation.cpp:1240
CPLErr
Error category.
Definition: cpl_error.h:52
int nDstAlphaBand
Definition: gdalwarper.h:188
GDALTransformerFunc pfnTransformer
Definition: gdalwarper.h:214
int nSrcXOff
X offset of the source buffer regarding the top-left corner of the image.
Definition: gdalwarper.h:426
@ GWKAOM_Quant
Definition: gdalwarper.h:95
int nDstXOff
X offset of the destination buffer regarding the top-left corner of the image.
Definition: gdalwarper.h:433
int nDstYSize
Height of the destination image.
Definition: gdalwarper.h:399
void GDALWarpInitNoDataReal(GDALWarpOptions *, double dNoDataReal)
Initialize padfSrcNoDataReal and padfDstNoDataReal with specified value.
Definition: gdalwarper.cpp:1433
GDALMaskFunc pfnDstValidityMaskFunc
Unused.
Definition: gdalwarper.h:240
GDALWarpOperationH GDALCreateWarpOperation(const GDALWarpOptions *)
Definition: gdalwarpoperation.cpp:804
@ GRA_NearestNeighbour
Definition: gdalwarper.h:53
int nDstXSize
Width of the destination image.
Definition: gdalwarper.h:397
@ GWKAOM_Imode
Definition: gdalwarper.h:92
void GDALWarpResolveWorkingDataType(GDALWarpOptions *)
If the working data type is unknown, this method will determine a valid working data type to support ...
Definition: gdalwarper.cpp:1490
GUInt32 * panDstValid
Validify mask of size (nDstXSize * nDstYSize) / 8.
Definition: gdalwarper.h:403
CPLErr GDALInitializeWarpedVRT(GDALDatasetH hDS, GDALWarpOptions *psWO)
Set warp info on virtual warped dataset.
Definition: vrtwarped.cpp:1268
void * pSrcValidityMaskFuncArg
Unused.
Definition: gdalwarper.h:227
double dfWarpMemoryLimit
Definition: gdalwarper.h:159
int nSrcXSize
Width of the source image.
Definition: gdalwarper.h:373
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:1042
GDALProgressFunc pfnProgress
Progress function.
Definition: gdalwarper.h:444
GDALWarpOptions * GDALCreateWarpOptions(void)
Create a warp options structure.
Definition: gdalwarper.cpp:1265
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition: gdal.h:291
GDALDataType eWorkingDataType
Definition: gdalwarper.h:166
@ GRA_Q3
Definition: gdalwarper.h:75
GUInt32 ** papanBandSrcValid
Array of nBands validity mask of size (nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS) / 8.
Definition: gdalwarper.h:388
double dfProgressBase
Base/offset value for progress computation.
Definition: gdalwarper.h:449
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition: gdal.h:297
unsigned int GUInt32
Unsigned int32 type.
Definition: cpl_port.h:188