31#ifndef GDALWARPER_H_INCLUDED
32#define GDALWARPER_H_INCLUDED
44#include "cpl_multiproc.h"
101typedef int (*GDALMaskFunc)(
void *pMaskFuncArg,
int nBandCount,
103 int nXSize,
int nYSize,
GByte **papabyImageData,
104 int bMaskIsFloat,
void *pMask);
106CPLErr CPL_DLL GDALWarpNoDataMasker(
void *pMaskFuncArg,
int nBandCount,
108 int nXSize,
int nYSize,
109 GByte **papabyImageData,
int bMaskIsFloat,
110 void *pValidityMask,
int *pbOutAllValid);
112CPLErr CPL_DLL GDALWarpDstAlphaMasker(
void *pMaskFuncArg,
int nBandCount,
114 int nXSize,
int nYSize,
116 int bMaskIsFloat,
void *pValidityMask);
117CPLErr CPL_DLL GDALWarpSrcAlphaMasker(
void *pMaskFuncArg,
int nBandCount,
119 int nXSize,
int nYSize,
121 int bMaskIsFloat,
void *pValidityMask,
122 int *pbOutAllOpaque);
124CPLErr CPL_DLL GDALWarpSrcMaskMasker(
void *pMaskFuncArg,
int nBandCount,
126 int nXSize,
int nYSize,
128 int bMaskIsFloat,
void *pValidityMask);
130CPLErr 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
140CPLErr CPL_DLL GDALWarpCutlineMaskerEx(
void *pMaskFuncArg,
int nBandCount,
142 int nXSize,
int nYSize,
144 int bMaskIsFloat,
void *pValidityMask,
145 int *pnValidityFlag);
246 CPLErr (*pfnPreWarpChunkProcessor)(
void *pKern,
void *pArg);
251 CPLErr (*pfnPostWarpChunkProcessor)(
void *pKern,
void *pArg);
302 double dfWarpMemoryLimit,
double dfMaxError, GDALProgressFunc pfnProgress,
306 GDALDatasetH hSrcDS,
const char *pszSrcWKT,
const char *pszDstFilename,
307 const char *pszDstWKT,
GDALDriverH hDstDriver,
char **papszCreateOptions,
308 GDALResampleAlg eResampleAlg,
double dfWarpMemoryLimit,
double dfMaxError,
309 GDALProgressFunc pfnProgress,
void *pProgressArg,
322 GDALDatasetH hSrcDS,
const char *pszSrcWKT,
const char *pszDstWKT,
335#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
349#define WARP_EXTRA_ELTS 1
461 bool bApplyVerticalShift =
false;
463 double dfMultFactorVerticalShift = 1.0;
468 std::vector<std::vector<double>> m_aadfExcludedValues{};
480void *GWKThreadsCreate(
char **papszWarpOptions,
482 void *pTransformerArg);
483void GWKThreadsEnd(
void *psThreadDataIn);
497typedef struct _GDALWarpChunk GDALWarpChunk;
510 int ValidateOptions();
512 bool ComputeSourceWindowTransformPoints(
513 int nDstXOff,
int nDstYOff,
int nDstXSize,
int nDstYSize,
bool bUseGrid,
514 bool bAll,
int nStepCount,
bool bTryWithCheckWithInvertProj,
515 double &dfMinXOut,
double &dfMinYOut,
double &dfMaxXOut,
516 double &dfMaxYOut,
int &nSamplePoints,
int &nFailedCount);
518 void ComputeSourceWindowStartingFromSource(
int nDstXOff,
int nDstYOff,
519 int nDstXSize,
int nDstYSize,
523 double *padfSrcMaxY);
526 const char *pszType);
529 CPLMutex *hWarpMutex;
533 GDALWarpChunk *pasChunkList;
536 unsigned long nLastTimeReported;
542 std::vector<std::pair<double, double>> aDstXYSpecialPoints{};
544 bool m_bIsTranslationOnPixelBoundaries =
false;
546 void WipeChunkList();
547 CPLErr CollectChunkListInternal(
int nDstXOff,
int nDstYOff,
int nDstXSize,
549 void CollectChunkList(
int nDstXOff,
int nDstYOff,
int nDstXSize,
551 void ReportTiming(
const char *);
558 void *CreateDestinationBuffer(
int nDstXSize,
int nDstYSize,
559 int *pbWasInitialized =
nullptr);
560 static void DestroyDestinationBuffer(
void *pDstBuffer);
564 CPLErr ChunkAndWarpImage(
int nDstXOff,
int nDstYOff,
int nDstXSize,
566 CPLErr ChunkAndWarpMulti(
int nDstXOff,
int nDstYOff,
int nDstXSize,
568 CPLErr WarpRegion(
int nDstXOff,
int nDstYOff,
int nDstXSize,
int nDstYSize,
569 int nSrcXOff = 0,
int nSrcYOff = 0,
int nSrcXSize = 0,
570 int nSrcYSize = 0,
double dfProgressBase = 0.0,
571 double dfProgressScale = 1.0);
572 CPLErr WarpRegion(
int nDstXOff,
int nDstYOff,
int nDstXSize,
int nDstYSize,
573 int nSrcXOff,
int nSrcYOff,
int nSrcXSize,
int nSrcYSize,
574 double dfSrcXExtraSize,
double dfSrcYExtraSize,
575 double dfProgressBase,
double dfProgressScale);
576 CPLErr WarpRegionToBuffer(
int nDstXOff,
int nDstYOff,
int nDstXSize,
577 int nDstYSize,
void *pDataBuf,
579 int nSrcYOff = 0,
int nSrcXSize = 0,
580 int nSrcYSize = 0,
double dfProgressBase = 0.0,
581 double dfProgressScale = 1.0);
582 CPLErr WarpRegionToBuffer(
int nDstXOff,
int nDstYOff,
int nDstXSize,
583 int nDstYSize,
void *pDataBuf,
585 int nSrcYOff,
int nSrcXSize,
int nSrcYSize,
586 double dfSrcXExtraSize,
double dfSrcYExtraSize,
587 double dfProgressBase,
double dfProgressScale);
590 friend class VRTWarpedDataset;
591 CPLErr ComputeSourceWindow(
int nDstXOff,
int nDstYOff,
int nDstXSize,
592 int nDstYSize,
int *pnSrcXOff,
int *pnSrcYOff,
593 int *pnSrcXSize,
int *pnSrcYSize,
594 double *pdfSrcXExtraSize,
595 double *pdfSrcYExtraSize,
596 double *pdfSrcFillRatio);
598 double GetWorkingMemoryForWindow(
int nSrcXSize,
int nSrcYSize,
599 int nDstXSize,
int nDstYSize)
const;
625typedef double (*FilterFuncType)(
double dfX);
629typedef double (*FilterFunc4ValuesType)(
double *padfVals);
630FilterFunc4ValuesType GWKGetFilterFunc4Values(
GDALResampleAlg eResampleAlg);
This class represents the lowest level of abstraction of warping.
Definition gdalwarper.h:359
int nXRadius
X size of window to filter.
Definition gdalwarper.h:417
int nSrcYSize
Height of the source image.
Definition gdalwarper.h:376
char ** papszWarpOptions
Warp options.
Definition gdalwarper.h:364
int nFiltInitX
X filtering offset.
Definition gdalwarper.h:421
double dfXScale
X resampling scale, i.e.
Definition gdalwarper.h:409
double dfYFilter
Y size of filter kernel.
Definition gdalwarper.h:415
int nDstXSize
Width of the destination image.
Definition gdalwarper.h:398
double dfSrcXExtraSize
Extra pixels (included in nSrcXSize) reserved for filter window.
Definition gdalwarper.h:379
double * padfDstNoDataReal
Array of nBands value for destination nodata.
Definition gdalwarper.h:455
int nDstXOff
X offset of the destination buffer regarding the top-left corner of the image.
Definition gdalwarper.h:434
GDALResampleAlg eResample
Resample algorithm.
Definition gdalwarper.h:367
GDALTransformerFunc pfnTransformer
Pixel transformation function.
Definition gdalwarper.h:440
GUInt32 * panUnifiedSrcValid
Unified validity mask of size (nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS) / 8.
Definition gdalwarper.h:392
int nDstYSize
Height of the destination image.
Definition gdalwarper.h:400
int nBands
Number of input and output bands (excluding alpha bands)
Definition gdalwarper.h:371
double dfProgressBase
Base/offset value for progress computation.
Definition gdalwarper.h:450
GDALDataType eWorkingDataType
Working data type.
Definition gdalwarper.h:369
double dfSrcYExtraSize
Extra pixels (included in nSrcYSize) reserved for filter window.
Definition gdalwarper.h:382
int nSrcXOff
X offset of the source buffer regarding the top-left corner of the image.
Definition gdalwarper.h:427
int nSrcYOff
Y offset of the source buffer regarding the top-left corner of the image.
Definition gdalwarper.h:430
int nDstYOff
Y offset of the destination buffer regarding the top-left corner of the image.
Definition gdalwarper.h:437
int nFiltInitY
Y filtering offset.
Definition gdalwarper.h:423
GDALProgressFunc pfnProgress
Progress function.
Definition gdalwarper.h:445
GUInt32 ** papanBandSrcValid
Array of nBands validity mask of size (nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS) / 8.
Definition gdalwarper.h:389
void * pProgress
User data provided to pfnProgress.
Definition gdalwarper.h:447
float * pafUnifiedSrcDensity
Unified source density of size nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS.
Definition gdalwarper.h:395
int nYRadius
Y size of window to filter.
Definition gdalwarper.h:419
float * pafDstDensity
Destination density of size nDstXSize * nDstYSize.
Definition gdalwarper.h:406
double dfXFilter
X size of filter kernel.
Definition gdalwarper.h:413
double dfYScale
Y resampling scale, i.e.
Definition gdalwarper.h:411
GByte ** papabyDstImage
Array of nBands destination images of size nDstXSize * nDstYSize.
Definition gdalwarper.h:402
double dfProgressScale
Scale value for progress computation.
Definition gdalwarper.h:452
int nSrcXSize
Width of the source image.
Definition gdalwarper.h:374
void * pTransformerArg
User data provided to pfnTransformer.
Definition gdalwarper.h:442
GByte ** papabySrcImage
Array of nBands source images of size nSrcXSize * nSrcYSize.
Definition gdalwarper.h:385
GUInt32 * panDstValid
Validify mask of size (nDstXSize * nDstYSize) / 8.
Definition gdalwarper.h:404
High level image warping class.
Definition gdalwarper.h:502
CPLErr
Error category.
Definition cpl_error.h:53
Definitions for CPL mini XML Parser/Serializer.
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:299
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:295
unsigned int GUInt32
Unsigned int32 type.
Definition cpl_port.h:177
#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
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1191
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:185
GDALDataType
Definition gdal.h:64
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition gdal.h:291
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition gdal.h:297
Public (C callable) GDAL algorithm entry points, and definitions.
int(* GDALTransformerFunc)(void *pTransformerArg, int bDstToSrc, int nPointCount, double *x, double *y, double *z, int *panSuccess)
Definition gdal_alg.h:95
CPLErr GDALWarpRegion(GDALWarpOperationH, int, int, int, int, int, int, int, int)
Definition gdalwarpoperation.cpp:1702
void GDALDestroyWarpOperation(GDALWarpOperationH)
Definition gdalwarpoperation.cpp:825
GDALWarpOperationH GDALCreateWarpOperation(const GDALWarpOptions *)
Definition gdalwarpoperation.cpp:805
GWKAverageOrModeAlg
Definition gdalwarper.h:89
@ GWKAOM_Fmode
Definition gdalwarper.h:91
@ GWKAOM_Min
Definition gdalwarper.h:94
@ GWKAOM_RMS
Definition gdalwarper.h:97
@ GWKAOM_Quant
Definition gdalwarper.h:95
@ GWKAOM_Sum
Definition gdalwarper.h:96
@ GWKAOM_Imode
Definition gdalwarper.h:92
@ GWKAOM_Average
Definition gdalwarper.h:90
@ GWKAOM_Max
Definition gdalwarper.h:93
void GDALWarpInitDstNoDataImag(GDALWarpOptions *, double dNoDataImag)
Initialize padfDstNoDataImag with specified value.
Definition gdalwarper.cpp:1478
GDALResampleAlg
Definition gdalwarper.h:52
@ GRA_CubicSpline
Definition gdalwarper.h:57
@ GRA_Q1
Definition gdalwarper.h:73
@ GRA_Sum
Definition gdalwarper.h:78
@ GRA_Max
Definition gdalwarper.h:66
@ GRA_Cubic
Definition gdalwarper.h:56
@ GRA_Min
Definition gdalwarper.h:68
@ GRA_RMS
Definition gdalwarper.h:81
@ GRA_Lanczos
Definition gdalwarper.h:58
@ GRA_Mode
Definition gdalwarper.h:64
@ GRA_NearestNeighbour
Definition gdalwarper.h:53
@ GRA_Q3
Definition gdalwarper.h:75
@ GRA_Med
Definition gdalwarper.h:70
@ GRA_Average
Definition gdalwarper.h:61
@ GRA_Bilinear
Definition gdalwarper.h:55
GDALDatasetH GDALCreateWarpedVRT(GDALDatasetH hSrcDS, int nPixels, int nLines, double *padfGeoTransform, GDALWarpOptions *psOptions)
Create virtual warped dataset.
Definition vrtwarped.cpp:365
void GDALDestroyWarpOptions(GDALWarpOptions *)
Destroy a warp options structure.
Definition gdalwarper.cpp:1312
void * GDALWarpOperationH
Opaque type representing a GDALWarpOperation object.
Definition gdalwarper.h:607
CPLErr GDALWarpRegionToBuffer(GDALWarpOperationH, int, int, int, int, void *, GDALDataType, int, int, int, int)
Definition gdalwarpoperation.cpp:2331
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
CPLErr GDALChunkAndWarpImage(GDALWarpOperationH, int, int, int, int)
Definition gdalwarpoperation.cpp:999
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:155
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:1623
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:134
void GDALWarpInitSrcNoDataImag(GDALWarpOptions *, double dNoDataImag)
Initialize padfSrcNoDataImag with specified value.
Definition gdalwarper.cpp:1497
CPLErr GDALInitializeWarpedVRT(GDALDatasetH hDS, GDALWarpOptions *psWO)
Set warp info on virtual warped dataset.
Definition vrtwarped.cpp:1271
void GDALWarpInitSrcNoDataReal(GDALWarpOptions *, double dNoDataReal)
Initialize padfSrcNoDataReal with specified value.
Definition gdalwarper.cpp:1440
void GDALWarpInitDstNoDataReal(GDALWarpOptions *, double dNoDataReal)
Initialize padfDstNoDataReal with specified value.
Definition gdalwarper.cpp:1421
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
CPLErr GDALChunkAndWarpMulti(GDALWarpOperationH, int, int, int, int)
Definition gdalwarpoperation.cpp:1241
GDALWarpOptions * GDALCreateWarpOptions(void)
Create a warp options structure.
Definition gdalwarper.cpp:1293
void GDALWarpInitNoDataReal(GDALWarpOptions *, double dNoDataReal)
Initialize padfSrcNoDataReal and padfDstNoDataReal with specified value.
Definition gdalwarper.cpp:1460
GDALWarpOptions * GDALCloneWarpOptions(const GDALWarpOptions *)
Clone a warp options structure.
Definition gdalwarper.cpp:1357
void GDALWarpResolveWorkingDataType(GDALWarpOptions *)
If the working data type is unknown, this method will determine a valid working data type to support ...
Definition gdalwarper.cpp:1517
Document node structure.
Definition cpl_minixml.h:71
Warp control options for use with GDALWarpOperation::Initialize()
Definition gdalwarper.h:155
int nSrcAlphaBand
Definition gdalwarper.h:186
GDALDatasetH hDstDS
Definition gdalwarper.h:174
char ** papszWarpOptions
A string list of additional options controlling the warp operation in name=value format.
Definition gdalwarper.h:157
double * padfDstNoDataImag
Definition gdalwarper.h:205
GDALMaskFunc pfnDstValidityMaskFunc
Unused.
Definition gdalwarper.h:241
double * padfSrcNoDataReal
Definition gdalwarper.h:193
void * pTransformerArg
Definition gdalwarper.h:218
GDALDataType eWorkingDataType
Definition gdalwarper.h:167
void * pSrcValidityMaskFuncArg
Unused.
Definition gdalwarper.h:228
void * pDstDensityMaskFuncArg
Unused.
Definition gdalwarper.h:238
int * panDstBands
Definition gdalwarper.h:183
double dfCutlineBlendDist
Definition gdalwarper.h:260
GDALProgressFunc pfnProgress
Definition gdalwarper.h:209
GDALMaskFunc pfnSrcDensityMaskFunc
Unused.
Definition gdalwarper.h:231
GDALDatasetH hSrcDS
Definition gdalwarper.h:170
GDALMaskFunc pfnDstDensityMaskFunc
Unused.
Definition gdalwarper.h:236
void * pPreWarpProcessorArg
Unused.
Definition gdalwarper.h:248
void * pProgressArg
Definition gdalwarper.h:212
int nDstAlphaBand
Definition gdalwarper.h:189
int * panSrcBands
Definition gdalwarper.h:180
GDALTransformerFunc pfnTransformer
Definition gdalwarper.h:215
int nBandCount
Definition gdalwarper.h:177
double dfWarpMemoryLimit
Definition gdalwarper.h:160
void * pSrcDensityMaskFuncArg
Unused.
Definition gdalwarper.h:233
GDALMaskFunc * papfnSrcPerBandValidityMaskFunc
Unused.
Definition gdalwarper.h:221
GDALResampleAlg eResampleAlg
Definition gdalwarper.h:163
GDALMaskFunc pfnSrcValidityMaskFunc
Unused.
Definition gdalwarper.h:226
void * hCutline
Definition gdalwarper.h:256
void * pDstValidityMaskFuncArg
Unused.
Definition gdalwarper.h:243
void ** papSrcPerBandValidityMaskFuncArg
Unused.
Definition gdalwarper.h:223
double * padfDstNoDataReal
Definition gdalwarper.h:201
double * padfSrcNoDataImag
Definition gdalwarper.h:197
void * pPostWarpProcessorArg
Unused.
Definition gdalwarper.h:253