15#ifndef GDALWARPER_H_INCLUDED
16#define GDALWARPER_H_INCLUDED
28#include "cpl_multiproc.h"
85typedef int (*GDALMaskFunc)(
void *pMaskFuncArg,
int nBandCount,
87 int nXSize,
int nYSize,
GByte **papabyImageData,
88 int bMaskIsFloat,
void *pMask);
90CPLErr CPL_DLL GDALWarpNoDataMasker(
void *pMaskFuncArg,
int nBandCount,
92 int nXSize,
int nYSize,
93 GByte **papabyImageData,
int bMaskIsFloat,
94 void *pValidityMask,
int *pbOutAllValid);
96CPLErr CPL_DLL GDALWarpDstAlphaMasker(
void *pMaskFuncArg,
int nBandCount,
98 int nXSize,
int nYSize,
100 int bMaskIsFloat,
void *pValidityMask);
101CPLErr CPL_DLL GDALWarpSrcAlphaMasker(
void *pMaskFuncArg,
int nBandCount,
103 int nXSize,
int nYSize,
105 int bMaskIsFloat,
void *pValidityMask,
106 int *pbOutAllOpaque);
108CPLErr CPL_DLL GDALWarpSrcMaskMasker(
void *pMaskFuncArg,
int nBandCount,
110 int nXSize,
int nYSize,
112 int bMaskIsFloat,
void *pValidityMask);
114CPLErr CPL_DLL GDALWarpCutlineMasker(
void *pMaskFuncArg,
int nBandCount,
116 int nXSize,
int nYSize,
118 int bMaskIsFloat,
void *pValidityMask);
121#define GCMVF_PARTIAL_INTERSECTION 0
122#define GCMVF_NO_INTERSECTION 1
123#define GCMVF_CHUNK_FULLY_WITHIN_CUTLINE 2
124CPLErr CPL_DLL GDALWarpCutlineMaskerEx(
void *pMaskFuncArg,
int nBandCount,
126 int nXSize,
int nYSize,
128 int bMaskIsFloat,
void *pValidityMask,
129 int *pnValidityFlag);
230 CPLErr (*pfnPreWarpChunkProcessor)(
void *pKern,
void *pArg);
235 CPLErr (*pfnPostWarpChunkProcessor)(
void *pKern,
void *pArg);
286 double dfWarpMemoryLimit,
double dfMaxError, GDALProgressFunc pfnProgress,
290 GDALDatasetH hSrcDS,
const char *pszSrcWKT,
const char *pszDstFilename,
291 const char *pszDstWKT,
GDALDriverH hDstDriver,
char **papszCreateOptions,
292 GDALResampleAlg eResampleAlg,
double dfWarpMemoryLimit,
double dfMaxError,
293 GDALProgressFunc pfnProgress,
void *pProgressArg,
306 GDALDatasetH hSrcDS,
const char *pszSrcWKT,
const char *pszDstWKT,
319#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
333#define WARP_EXTRA_ELTS 1
445 bool bApplyVerticalShift =
false;
447 double dfMultFactorVerticalShift = 1.0;
452 std::vector<std::vector<double>> m_aadfExcludedValues{};
464void *GWKThreadsCreate(
char **papszWarpOptions,
466 void *pTransformerArg);
467void GWKThreadsEnd(
void *psThreadDataIn);
481typedef struct _GDALWarpChunk GDALWarpChunk;
494 int ValidateOptions();
496 bool ComputeSourceWindowTransformPoints(
497 int nDstXOff,
int nDstYOff,
int nDstXSize,
int nDstYSize,
bool bUseGrid,
498 bool bAll,
int nStepCount,
bool bTryWithCheckWithInvertProj,
499 double &dfMinXOut,
double &dfMinYOut,
double &dfMaxXOut,
500 double &dfMaxYOut,
int &nSamplePoints,
int &nFailedCount);
502 void ComputeSourceWindowStartingFromSource(
int nDstXOff,
int nDstYOff,
503 int nDstXSize,
int nDstYSize,
507 double *padfSrcMaxY);
510 const char *pszType);
513 CPLMutex *hWarpMutex;
517 GDALWarpChunk *pasChunkList;
520 unsigned long nLastTimeReported;
526 std::vector<std::pair<double, double>> aDstXYSpecialPoints{};
528 bool m_bIsTranslationOnPixelBoundaries =
false;
530 void WipeChunkList();
531 CPLErr CollectChunkListInternal(
int nDstXOff,
int nDstYOff,
int nDstXSize,
533 void CollectChunkList(
int nDstXOff,
int nDstYOff,
int nDstXSize,
535 void ReportTiming(
const char *);
542 void *CreateDestinationBuffer(
int nDstXSize,
int nDstYSize,
543 int *pbWasInitialized =
nullptr);
544 void InitializeDestinationBuffer(
void *pDstBuffer,
int nDstXSize,
546 int *pbWasInitialized =
nullptr);
547 static void DestroyDestinationBuffer(
void *pDstBuffer);
551 CPLErr ChunkAndWarpImage(
int nDstXOff,
int nDstYOff,
int nDstXSize,
553 CPLErr ChunkAndWarpMulti(
int nDstXOff,
int nDstYOff,
int nDstXSize,
555 CPLErr WarpRegion(
int nDstXOff,
int nDstYOff,
int nDstXSize,
int nDstYSize,
556 int nSrcXOff = 0,
int nSrcYOff = 0,
int nSrcXSize = 0,
557 int nSrcYSize = 0,
double dfProgressBase = 0.0,
558 double dfProgressScale = 1.0);
559 CPLErr WarpRegion(
int nDstXOff,
int nDstYOff,
int nDstXSize,
int nDstYSize,
560 int nSrcXOff,
int nSrcYOff,
int nSrcXSize,
int nSrcYSize,
561 double dfSrcXExtraSize,
double dfSrcYExtraSize,
562 double dfProgressBase,
double dfProgressScale);
563 CPLErr WarpRegionToBuffer(
int nDstXOff,
int nDstYOff,
int nDstXSize,
564 int nDstYSize,
void *pDataBuf,
566 int nSrcYOff = 0,
int nSrcXSize = 0,
567 int nSrcYSize = 0,
double dfProgressBase = 0.0,
568 double dfProgressScale = 1.0);
569 CPLErr WarpRegionToBuffer(
int nDstXOff,
int nDstYOff,
int nDstXSize,
570 int nDstYSize,
void *pDataBuf,
572 int nSrcYOff,
int nSrcXSize,
int nSrcYSize,
573 double dfSrcXExtraSize,
double dfSrcYExtraSize,
574 double dfProgressBase,
double dfProgressScale);
577 friend class VRTWarpedDataset;
578 CPLErr ComputeSourceWindow(
int nDstXOff,
int nDstYOff,
int nDstXSize,
579 int nDstYSize,
int *pnSrcXOff,
int *pnSrcYOff,
580 int *pnSrcXSize,
int *pnSrcYSize,
581 double *pdfSrcXExtraSize,
582 double *pdfSrcYExtraSize,
583 double *pdfSrcFillRatio);
585 double GetWorkingMemoryForWindow(
int nSrcXSize,
int nSrcYSize,
586 int nDstXSize,
int nDstYSize)
const;
612typedef double (*FilterFuncType)(
double dfX);
616typedef double (*FilterFunc4ValuesType)(
double *padfVals);
617FilterFunc4ValuesType GWKGetFilterFunc4Values(
GDALResampleAlg eResampleAlg);
This class represents the lowest level of abstraction of warping.
Definition gdalwarper.h:343
int nXRadius
X size of window to filter.
Definition gdalwarper.h:401
int nSrcYSize
Height of the source image.
Definition gdalwarper.h:360
char ** papszWarpOptions
Warp options.
Definition gdalwarper.h:348
int nFiltInitX
X filtering offset.
Definition gdalwarper.h:405
double dfXScale
X resampling scale, i.e.
Definition gdalwarper.h:393
double dfYFilter
Y size of filter kernel.
Definition gdalwarper.h:399
int nDstXSize
Width of the destination image.
Definition gdalwarper.h:382
double dfSrcXExtraSize
Extra pixels (included in nSrcXSize) reserved for filter window.
Definition gdalwarper.h:363
double * padfDstNoDataReal
Array of nBands value for destination nodata.
Definition gdalwarper.h:439
int nDstXOff
X offset of the destination buffer regarding the top-left corner of the image.
Definition gdalwarper.h:418
GDALResampleAlg eResample
Resample algorithm.
Definition gdalwarper.h:351
GDALTransformerFunc pfnTransformer
Pixel transformation function.
Definition gdalwarper.h:424
GUInt32 * panUnifiedSrcValid
Unified validity mask of size (nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS) / 8.
Definition gdalwarper.h:376
int nDstYSize
Height of the destination image.
Definition gdalwarper.h:384
int nBands
Number of input and output bands (excluding alpha bands)
Definition gdalwarper.h:355
double dfProgressBase
Base/offset value for progress computation.
Definition gdalwarper.h:434
GDALDataType eWorkingDataType
Working data type.
Definition gdalwarper.h:353
double dfSrcYExtraSize
Extra pixels (included in nSrcYSize) reserved for filter window.
Definition gdalwarper.h:366
int nSrcXOff
X offset of the source buffer regarding the top-left corner of the image.
Definition gdalwarper.h:411
int nSrcYOff
Y offset of the source buffer regarding the top-left corner of the image.
Definition gdalwarper.h:414
int nDstYOff
Y offset of the destination buffer regarding the top-left corner of the image.
Definition gdalwarper.h:421
int nFiltInitY
Y filtering offset.
Definition gdalwarper.h:407
GDALProgressFunc pfnProgress
Progress function.
Definition gdalwarper.h:429
GUInt32 ** papanBandSrcValid
Array of nBands validity mask of size (nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS) / 8.
Definition gdalwarper.h:373
void * pProgress
User data provided to pfnProgress.
Definition gdalwarper.h:431
float * pafUnifiedSrcDensity
Unified source density of size nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS.
Definition gdalwarper.h:379
int nYRadius
Y size of window to filter.
Definition gdalwarper.h:403
float * pafDstDensity
Destination density of size nDstXSize * nDstYSize.
Definition gdalwarper.h:390
double dfXFilter
X size of filter kernel.
Definition gdalwarper.h:397
double dfYScale
Y resampling scale, i.e.
Definition gdalwarper.h:395
GByte ** papabyDstImage
Array of nBands destination images of size nDstXSize * nDstYSize.
Definition gdalwarper.h:386
double dfProgressScale
Scale value for progress computation.
Definition gdalwarper.h:436
int nSrcXSize
Width of the source image.
Definition gdalwarper.h:358
void * pTransformerArg
User data provided to pfnTransformer.
Definition gdalwarper.h:426
GByte ** papabySrcImage
Array of nBands source images of size nSrcXSize * nSrcYSize.
Definition gdalwarper.h:369
GUInt32 * panDstValid
Validify mask of size (nDstXSize * nDstYSize) / 8.
Definition gdalwarper.h:388
High level image warping class.
Definition gdalwarper.h:486
CPLErr
Error category.
Definition cpl_error.h:37
Definitions for CPL mini XML Parser/Serializer.
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:283
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:279
unsigned int GUInt32
Unsigned int32 type.
Definition cpl_port.h:161
#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:1030
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1179
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:169
GDALDataType
Definition gdal.h:48
void * GDALDatasetH
Opaque type used for the C bindings of the C++ GDALDataset class.
Definition gdal.h:376
void * GDALDriverH
Opaque type used for the C bindings of the C++ GDALDriver class.
Definition gdal.h:382
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:79
CPLErr GDALWarpRegion(GDALWarpOperationH, int, int, int, int, int, int, int, int)
Definition gdalwarpoperation.cpp:1705
void GDALDestroyWarpOperation(GDALWarpOperationH)
Definition gdalwarpoperation.cpp:836
GDALWarpOperationH GDALCreateWarpOperation(const GDALWarpOptions *)
Definition gdalwarpoperation.cpp:816
GWKAverageOrModeAlg
Definition gdalwarper.h:73
@ GWKAOM_Fmode
Definition gdalwarper.h:75
@ GWKAOM_Min
Definition gdalwarper.h:78
@ GWKAOM_RMS
Definition gdalwarper.h:81
@ GWKAOM_Quant
Definition gdalwarper.h:79
@ GWKAOM_Sum
Definition gdalwarper.h:80
@ GWKAOM_Imode
Definition gdalwarper.h:76
@ GWKAOM_Average
Definition gdalwarper.h:74
@ GWKAOM_Max
Definition gdalwarper.h:77
void GDALWarpInitDstNoDataImag(GDALWarpOptions *, double dNoDataImag)
Initialize padfDstNoDataImag with specified value.
Definition gdalwarper.cpp:1483
GDALResampleAlg
Definition gdalwarper.h:36
@ GRA_CubicSpline
Definition gdalwarper.h:41
@ GRA_Q1
Definition gdalwarper.h:57
@ GRA_Sum
Definition gdalwarper.h:62
@ GRA_Max
Definition gdalwarper.h:50
@ GRA_Cubic
Definition gdalwarper.h:40
@ GRA_Min
Definition gdalwarper.h:52
@ GRA_RMS
Definition gdalwarper.h:65
@ GRA_Lanczos
Definition gdalwarper.h:42
@ GRA_Mode
Definition gdalwarper.h:48
@ GRA_NearestNeighbour
Definition gdalwarper.h:37
@ GRA_Q3
Definition gdalwarper.h:59
@ GRA_Med
Definition gdalwarper.h:54
@ GRA_Average
Definition gdalwarper.h:45
@ GRA_Bilinear
Definition gdalwarper.h:39
GDALDatasetH GDALCreateWarpedVRT(GDALDatasetH hSrcDS, int nPixels, int nLines, double *padfGeoTransform, GDALWarpOptions *psOptions)
Create virtual warped dataset.
Definition vrtwarped.cpp:372
void GDALDestroyWarpOptions(GDALWarpOptions *)
Destroy a warp options structure.
Definition gdalwarper.cpp:1317
void * GDALWarpOperationH
Opaque type representing a GDALWarpOperation object.
Definition gdalwarper.h:594
CPLErr GDALWarpRegionToBuffer(GDALWarpOperationH, int, int, int, int, void *, GDALDataType, int, int, int, int)
Definition gdalwarpoperation.cpp:2334
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:220
CPLErr GDALChunkAndWarpImage(GDALWarpOperationH, int, int, int, int)
Definition gdalwarpoperation.cpp:1002
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:139
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:1654
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:118
void GDALWarpInitSrcNoDataImag(GDALWarpOptions *, double dNoDataImag)
Initialize padfSrcNoDataImag with specified value.
Definition gdalwarper.cpp:1502
CPLErr GDALInitializeWarpedVRT(GDALDatasetH hDS, GDALWarpOptions *psWO)
Set warp info on virtual warped dataset.
Definition vrtwarped.cpp:1334
void GDALWarpInitSrcNoDataReal(GDALWarpOptions *, double dNoDataReal)
Initialize padfSrcNoDataReal with specified value.
Definition gdalwarper.cpp:1445
void GDALWarpInitDstNoDataReal(GDALWarpOptions *, double dNoDataReal)
Initialize padfDstNoDataReal with specified value.
Definition gdalwarper.cpp:1426
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:83
CPLErr GDALChunkAndWarpMulti(GDALWarpOperationH, int, int, int, int)
Definition gdalwarpoperation.cpp:1244
GDALWarpOptions * GDALCreateWarpOptions(void)
Create a warp options structure.
Definition gdalwarper.cpp:1298
void GDALWarpInitNoDataReal(GDALWarpOptions *, double dNoDataReal)
Initialize padfSrcNoDataReal and padfDstNoDataReal with specified value.
Definition gdalwarper.cpp:1465
GDALWarpOptions * GDALCloneWarpOptions(const GDALWarpOptions *)
Clone a warp options structure.
Definition gdalwarper.cpp:1362
void GDALWarpResolveWorkingDataType(GDALWarpOptions *)
If the working data type is unknown, this method will determine a valid working data type to support ...
Definition gdalwarper.cpp:1522
Document node structure.
Definition cpl_minixml.h:55
Warp control options for use with GDALWarpOperation::Initialize()
Definition gdalwarper.h:139
int nSrcAlphaBand
Definition gdalwarper.h:170
GDALDatasetH hDstDS
Definition gdalwarper.h:158
char ** papszWarpOptions
A string list of additional options controlling the warp operation in name=value format.
Definition gdalwarper.h:141
double * padfDstNoDataImag
Definition gdalwarper.h:189
GDALMaskFunc pfnDstValidityMaskFunc
Unused.
Definition gdalwarper.h:225
double * padfSrcNoDataReal
Definition gdalwarper.h:177
void * pTransformerArg
Definition gdalwarper.h:202
GDALDataType eWorkingDataType
Definition gdalwarper.h:151
void * pSrcValidityMaskFuncArg
Unused.
Definition gdalwarper.h:212
void * pDstDensityMaskFuncArg
Unused.
Definition gdalwarper.h:222
int * panDstBands
Definition gdalwarper.h:167
double dfCutlineBlendDist
Definition gdalwarper.h:244
GDALProgressFunc pfnProgress
Definition gdalwarper.h:193
GDALMaskFunc pfnSrcDensityMaskFunc
Unused.
Definition gdalwarper.h:215
GDALDatasetH hSrcDS
Definition gdalwarper.h:154
GDALMaskFunc pfnDstDensityMaskFunc
Unused.
Definition gdalwarper.h:220
void * pPreWarpProcessorArg
Unused.
Definition gdalwarper.h:232
void * pProgressArg
Definition gdalwarper.h:196
int nDstAlphaBand
Definition gdalwarper.h:173
int * panSrcBands
Definition gdalwarper.h:164
GDALTransformerFunc pfnTransformer
Definition gdalwarper.h:199
int nBandCount
Definition gdalwarper.h:161
double dfWarpMemoryLimit
Definition gdalwarper.h:144
void * pSrcDensityMaskFuncArg
Unused.
Definition gdalwarper.h:217
GDALMaskFunc * papfnSrcPerBandValidityMaskFunc
Unused.
Definition gdalwarper.h:205
GDALResampleAlg eResampleAlg
Definition gdalwarper.h:147
GDALMaskFunc pfnSrcValidityMaskFunc
Unused.
Definition gdalwarper.h:210
void * hCutline
Definition gdalwarper.h:240
void * pDstValidityMaskFuncArg
Unused.
Definition gdalwarper.h:227
void ** papSrcPerBandValidityMaskFuncArg
Unused.
Definition gdalwarper.h:207
double * padfDstNoDataReal
Definition gdalwarper.h:185
double * padfSrcNoDataImag
Definition gdalwarper.h:181
void * pPostWarpProcessorArg
Unused.
Definition gdalwarper.h:237